|
@@ -1,6 +1,7 @@
|
|
|
package com.usky.fire.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.usky.common.core.bean.CommonPage;
|
|
|
import com.usky.common.core.exception.BusinessException;
|
|
@@ -204,6 +205,9 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
|
if (patrolInspectionPlanVo.getPlanType() == 1) {//普通计划
|
|
|
//计算两时间天数
|
|
|
int day = OnlineMethod.fun(patrolInspectionPlanVo.getStartDate(), patrolInspectionPlanVo.getEndDate())+1;
|
|
|
+ if(day > 7){
|
|
|
+ day = 7;
|
|
|
+ }
|
|
|
// if (patrolInspectionPlanVo.getStartDate().equals(patrolInspectionPlanVo.getEndDate())){
|
|
|
// day = 1;
|
|
|
// }else {
|
|
@@ -398,7 +402,11 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
|
if (patrolInspectionPlanVo.getPlanType() == 1) {//普通计划
|
|
|
//计算两时间天数
|
|
|
int day = OnlineMethod.fun(patrolInspectionPlanVo.getStartDate(), patrolInspectionPlanVo.getEndDate())+1;
|
|
|
- String timeStr1 = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ if(day > 7){
|
|
|
+ day = 7;
|
|
|
+ }
|
|
|
+
|
|
|
+ String timeStr1 = patrolInspectionPlanVo.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
for (int i = 0; i < day; i++) {
|
|
|
for (int j = 0; j < patrolInspectionPlanVo.getPlanScheduleList().size(); j++) {
|
|
|
LocalDate s = OnlineMethod.getDate(timeStr1, "yyyy-MM-dd", true, i );
|
|
@@ -469,6 +477,85 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void addPatrolInspectionPlanSon(){
|
|
|
+ LambdaQueryWrapper<PatrolInspectionPlan> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.le(PatrolInspectionPlan::getStartDate,LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
|
|
|
+ .ge(PatrolInspectionPlan::getEndDate,OnlineMethod.getDate(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), "yyyy-MM-dd", true, 7))
|
|
|
+ .eq(PatrolInspectionPlan::getEnable,1);
|
|
|
+ List<PatrolInspectionPlan> list = this.list(queryWrapper);
|
|
|
+ if(CollectionUtils.isNotEmpty(list)){
|
|
|
+ List<Integer> planIdList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ planIdList.add(list.get(i).getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ //巡检日程关联信息
|
|
|
+ LambdaQueryWrapper<PatrolInspectionPlanSchedule> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.in(PatrolInspectionPlanSchedule::getPlanId,planIdList);
|
|
|
+ List<PatrolInspectionPlanSchedule> scheduleList = planScheduleService.list(queryWrapper1);
|
|
|
+ if(CollectionUtils.isEmpty(scheduleList)){
|
|
|
+ throw new BusinessException("无巡检日程关联信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ //主计划地点关联
|
|
|
+ LambdaQueryWrapper<PatrolInspectionPlanSite> queryWrapper2 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper2.in(PatrolInspectionPlanSite::getPlanId,planIdList);
|
|
|
+ List<PatrolInspectionPlanSite> siteList = planSiteService.list(queryWrapper2);
|
|
|
+ if(CollectionUtils.isEmpty(siteList)){
|
|
|
+ throw new BusinessException("无主计划地点关联信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int m = 0; m < list.size(); m++) {
|
|
|
+ //子表数据添加
|
|
|
+ if (list.get(m).getPlanType() == 1) {//普通计划 当前日期+7天在巡检计划时间范围内,就创建一条当前日期+7天日期对应的巡检记录
|
|
|
+ for (int j = 0; j < scheduleList.size(); j++) {
|
|
|
+ if(list.get(m).getId().equals(scheduleList.get(j).getPlanId())){
|
|
|
+ LocalDate s = OnlineMethod.getDate(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), "yyyy-MM-dd", true, 7);
|
|
|
+ Date date = Date.from(s.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
|
|
|
+ String week = OnlineMethod.getWeekOfDate(date);
|
|
|
+ if (!list.get(m).getRestDay().contains(week)) {
|
|
|
+ PatrolInspectionPlanSon patrolInspectionPlanSon = new PatrolInspectionPlanSon();
|
|
|
+ patrolInspectionPlanSon.setPlanId(list.get(m).getId());
|
|
|
+ patrolInspectionPlanSon.setInspectionDate(s);
|
|
|
+ patrolInspectionPlanSon.setStartTime(scheduleList.get(j).getStartTime());
|
|
|
+ patrolInspectionPlanSon.setEndTime(scheduleList.get(j).getEndTime());
|
|
|
+ patrolInspectionPlanSon.setPersonnelId(scheduleList.get(j).getPersonnelId());
|
|
|
+ patrolInspectionPlanSon.setAreaId(list.get(m).getAreaId());
|
|
|
+ patrolInspectionPlanSon.setPlanType(list.get(m).getPlanType());
|
|
|
+ patrolInspectionPlanSon.setPlanCycle(list.get(m).getPlanCycle());
|
|
|
+ patrolInspectionPlanSon.setPlanFrequency(list.get(m).getPlanFrequency());
|
|
|
+ patrolInspectionPlanSon.setLapTime(list.get(m).getLapTime());
|
|
|
+ patrolInspectionPlanSon.setIntervalTime(list.get(m).getIntervalTime());
|
|
|
+ patrolInspectionPlanSon.setPlanDescribe(list.get(m).getPlanDescribe());
|
|
|
+ patrolInspectionPlanSon.setCompletion(0);
|
|
|
+ patrolInspectionPlanSon.setCreateTime(LocalDateTime.now());
|
|
|
+ patrolInspectionPlanSon.setCreator(SecurityUtils.getUsername());
|
|
|
+ patrolInspectionPlanSon.setAlternateField("0");
|
|
|
+ patrolInspectionPlanSon.setTenantId(SecurityUtils.getTenantId());
|
|
|
+ patrolInspectionPlanSon.setCompanyId(list.get(m).getCompanyId());
|
|
|
+ patrolInspectionPlanSonService.save(patrolInspectionPlanSon);
|
|
|
+ Integer zfid = patrolInspectionPlanSon.getId();
|
|
|
+ for (int k = 0; k < siteList.size(); k++) {
|
|
|
+ if(list.get(m).getId().equals(siteList.get(k).getPlanId())){
|
|
|
+ PatrolInspectionPlanSiteSon planSiteSon = new PatrolInspectionPlanSiteSon();
|
|
|
+ planSiteSon.setPlanId(zfid);
|
|
|
+ planSiteSon.setSiteId(siteList.get(k).getSiteId());
|
|
|
+ planSiteSon.setInspectionStatus(1);
|
|
|
+ planSiteSonService.save(planSiteSon);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|