|
@@ -507,11 +507,24 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
|
throw new BusinessException("无主计划地点关联信息");
|
|
|
}
|
|
|
|
|
|
+ //分配创建巡检计划之前先判断数据库中是否已经存在这条计划记录
|
|
|
+ LocalDate inspectionDate = OnlineMethod.getDate(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), "yyyy-MM-dd", true, 7);
|
|
|
+ LambdaQueryWrapper<PatrolInspectionPlanSon> queryWrapper3 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper3.select(PatrolInspectionPlanSon::getPlanId)
|
|
|
+ .eq(PatrolInspectionPlanSon::getInspectionDate,inspectionDate);
|
|
|
+ List<PatrolInspectionPlanSon> planSonList = patrolInspectionPlanSonService.list(queryWrapper3);
|
|
|
+ List<Integer> planSonPlanIdList = new ArrayList<>();
|
|
|
+ if(CollectionUtils.isNotEmpty(planSonList)){
|
|
|
+ for (int i = 0; i < planSonList.size(); i++) {
|
|
|
+ planSonPlanIdList.add(planSonList.get(i).getPlanId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
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())){
|
|
|
+ if((list.get(m).getId().equals(scheduleList.get(j).getPlanId())) && (!planSonPlanIdList.contains(list.get(m).getId()))){
|
|
|
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);
|
|
@@ -531,9 +544,9 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
|
patrolInspectionPlanSon.setPlanDescribe(list.get(m).getPlanDescribe());
|
|
|
patrolInspectionPlanSon.setCompletion(0);
|
|
|
patrolInspectionPlanSon.setCreateTime(LocalDateTime.now());
|
|
|
- patrolInspectionPlanSon.setCreator(SecurityUtils.getUsername());
|
|
|
+ patrolInspectionPlanSon.setCreator(list.get(m).getCreator());
|
|
|
patrolInspectionPlanSon.setAlternateField("0");
|
|
|
- patrolInspectionPlanSon.setTenantId(SecurityUtils.getTenantId());
|
|
|
+ patrolInspectionPlanSon.setTenantId(list.get(m).getTenantId());
|
|
|
patrolInspectionPlanSon.setCompanyId(list.get(m).getCompanyId());
|
|
|
patrolInspectionPlanSonService.save(patrolInspectionPlanSon);
|
|
|
Integer zfid = patrolInspectionPlanSon.getId();
|