|
@@ -3,6 +3,7 @@ package com.usky.fire.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.usky.common.core.bean.CommonPage;
|
|
import com.usky.common.core.bean.CommonPage;
|
|
|
|
+import com.usky.common.core.exception.BusinessException;
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
import com.usky.common.security.utils.SecurityUtils;
|
|
import com.usky.common.security.utils.SecurityUtils;
|
|
import com.usky.fire.domain.*;
|
|
import com.usky.fire.domain.*;
|
|
@@ -56,6 +57,9 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
@Autowired
|
|
@Autowired
|
|
private PatrolInspectionSiteService patrolInspectionSiteService;
|
|
private PatrolInspectionSiteService patrolInspectionSiteService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private PatrolInspectionRecordService patrolInspectionRecordService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<PatrolInspectionAreaVo> planLeftList() {
|
|
public List<PatrolInspectionAreaVo> planLeftList() {
|
|
LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
|
|
@@ -107,6 +111,19 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
public void addPatrolInspectionPlan(PatrolInspectionPlanVo patrolInspectionPlanVo) {
|
|
public void addPatrolInspectionPlan(PatrolInspectionPlanVo patrolInspectionPlanVo) {
|
|
|
|
+ Integer planCycle = patrolInspectionPlanVo.getPlanCycle();
|
|
|
|
+ String timeStr = patrolInspectionPlanVo.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
|
+ Date startDate = OnlineMethod.getDate(timeStr);
|
|
|
|
+ LocalDate ss = null;
|
|
|
|
+ if (planCycle == 1) {
|
|
|
|
+ ss = OnlineMethod.getDate(timeStr, "yyyy-MM-dd", true, 1 * patrolInspectionPlanVo.getWeekCount() - 1);
|
|
|
|
+ } else if (planCycle == 2) {
|
|
|
|
+ ss = OnlineMethod.getDate(timeStr, "yyyy-MM-dd", true, 7 * patrolInspectionPlanVo.getWeekCount() - 1);
|
|
|
|
+ } else if (planCycle == 3) {
|
|
|
|
+ ss = OnlineMethod.getMonthDate(startDate, 1 * patrolInspectionPlanVo.getWeekCount());
|
|
|
|
+ } else if (planCycle == 4) {
|
|
|
|
+ ss = OnlineMethod.getMonthDate(startDate, 12 * patrolInspectionPlanVo.getWeekCount());
|
|
|
|
+ }
|
|
//主表数据添加
|
|
//主表数据添加
|
|
PatrolInspectionPlan patrolInspectionPlan = new PatrolInspectionPlan();
|
|
PatrolInspectionPlan patrolInspectionPlan = new PatrolInspectionPlan();
|
|
patrolInspectionPlan.setPlanName(patrolInspectionPlanVo.getPlanName());
|
|
patrolInspectionPlan.setPlanName(patrolInspectionPlanVo.getPlanName());
|
|
@@ -114,8 +131,6 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
if (patrolInspectionPlanVo.getPlanType() == 1) {
|
|
if (patrolInspectionPlanVo.getPlanType() == 1) {
|
|
patrolInspectionPlan.setEndDate(patrolInspectionPlanVo.getEndDate());
|
|
patrolInspectionPlan.setEndDate(patrolInspectionPlanVo.getEndDate());
|
|
} else {
|
|
} else {
|
|
- String timeStr = patrolInspectionPlanVo.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
|
- LocalDate ss = OnlineMethod.getDate(timeStr, "yyyy-MM-dd", true, 7 * patrolInspectionPlanVo.getWeekCount());
|
|
|
|
patrolInspectionPlan.setEndDate(ss);
|
|
patrolInspectionPlan.setEndDate(ss);
|
|
}
|
|
}
|
|
patrolInspectionPlan.setAreaId(patrolInspectionPlanVo.getAreaId());
|
|
patrolInspectionPlan.setAreaId(patrolInspectionPlanVo.getAreaId());
|
|
@@ -157,7 +172,7 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
days = OnlineMethod.fun(patrolInspectionPlanVo.getStartDate(), date);
|
|
days = OnlineMethod.fun(patrolInspectionPlanVo.getStartDate(), date);
|
|
}
|
|
}
|
|
for (int i = 0; i < days; i++) {
|
|
for (int i = 0; i < days; i++) {
|
|
- LocalDate date1 = OnlineMethod.getDate(timeStr3, "yyyy-MM-dd", true, i+1);
|
|
|
|
|
|
+ LocalDate date1 = OnlineMethod.getDate(timeStr3, "yyyy-MM-dd", true, i + 1);
|
|
Date date = Date.from(date1.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
|
|
Date date = Date.from(date1.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
|
|
String week1 = OnlineMethod.getWeekOfDate(date);
|
|
String week1 = OnlineMethod.getWeekOfDate(date);
|
|
if (patrolInspectionPlanVo.getRestDay().contains(week1)) {
|
|
if (patrolInspectionPlanVo.getRestDay().contains(week1)) {
|
|
@@ -174,7 +189,7 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
String timeStr1 = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
String timeStr1 = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
for (int i = 0; i < day; i++) {
|
|
for (int i = 0; i < day; i++) {
|
|
for (int j = 0; j < patrolInspectionPlanVo.getPlanScheduleList().size(); j++) {
|
|
for (int j = 0; j < patrolInspectionPlanVo.getPlanScheduleList().size(); j++) {
|
|
- LocalDate s = OnlineMethod.getDate(timeStr1, "yyyy-MM-dd", true, i+1);
|
|
|
|
|
|
+ LocalDate s = OnlineMethod.getDate(timeStr1, "yyyy-MM-dd", true, i + 1);
|
|
Date date = Date.from(s.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
|
|
Date date = Date.from(s.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
|
|
String week = OnlineMethod.getWeekOfDate(date);
|
|
String week = OnlineMethod.getWeekOfDate(date);
|
|
if (!patrolInspectionPlanVo.getRestDay().contains(week)) {
|
|
if (!patrolInspectionPlanVo.getRestDay().contains(week)) {
|
|
@@ -210,18 +225,11 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {//按次计划
|
|
} else {//按次计划
|
|
- for (int i = 0; i < patrolInspectionPlanVo.getWeekCount(); i++) {
|
|
|
|
- String timeStr2 = patrolInspectionPlanVo.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
|
- LocalDate sss = OnlineMethod.getDate(timeStr2, "yyyy-MM-dd", true, 7 * (i + 1));
|
|
|
|
|
|
+ for (int i = 0; i < patrolInspectionPlanVo.getPlanFrequency(); i++) {
|
|
PatrolInspectionPlanSon patrolInspectionPlanSon = new PatrolInspectionPlanSon();
|
|
PatrolInspectionPlanSon patrolInspectionPlanSon = new PatrolInspectionPlanSon();
|
|
patrolInspectionPlanSon.setPlanId(fid);
|
|
patrolInspectionPlanSon.setPlanId(fid);
|
|
- if (i == 0) {
|
|
|
|
- patrolInspectionPlanSon.setStartDate(patrolInspectionPlanVo.getStartDate());
|
|
|
|
- } else {
|
|
|
|
- LocalDate ssss = OnlineMethod.getDate(timeStr2, "yyyy-MM-dd", true, 7 * i + 1);
|
|
|
|
- patrolInspectionPlanSon.setStartDate(ssss);
|
|
|
|
- }
|
|
|
|
- patrolInspectionPlanSon.setEndDate(sss);
|
|
|
|
|
|
+ patrolInspectionPlanSon.setStartDate(patrolInspectionPlanVo.getStartDate());
|
|
|
|
+ patrolInspectionPlanSon.setEndDate(ss);
|
|
patrolInspectionPlanSon.setPersonnelId(patrolInspectionPlanVo.getPlanScheduleList().get(0).getPersonnelId());
|
|
patrolInspectionPlanSon.setPersonnelId(patrolInspectionPlanVo.getPlanScheduleList().get(0).getPersonnelId());
|
|
patrolInspectionPlanSon.setAreaId(patrolInspectionPlanVo.getAreaId());
|
|
patrolInspectionPlanSon.setAreaId(patrolInspectionPlanVo.getAreaId());
|
|
patrolInspectionPlanSon.setPlanType(patrolInspectionPlanVo.getPlanType());
|
|
patrolInspectionPlanSon.setPlanType(patrolInspectionPlanVo.getPlanType());
|
|
@@ -254,6 +262,26 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
public void updatePatrolInspectionPlan(PatrolInspectionPlanVo patrolInspectionPlanVo) {
|
|
public void updatePatrolInspectionPlan(PatrolInspectionPlanVo patrolInspectionPlanVo) {
|
|
|
|
+ LambdaQueryWrapper<PatrolInspectionRecord> queryWrapperSix = Wrappers.lambdaQuery();
|
|
|
|
+ queryWrapperSix.eq(PatrolInspectionRecord::getPlanId, patrolInspectionPlanVo.getId());
|
|
|
|
+ List<PatrolInspectionRecord> patrolInspectionRecordList = patrolInspectionRecordService.list(queryWrapperSix);
|
|
|
|
+ if (patrolInspectionRecordList.size() <= 0) {
|
|
|
|
+ throw new BusinessException("巡检计划已执行中不可修改");
|
|
|
|
+ }
|
|
|
|
+ Integer planCycle = patrolInspectionPlanVo.getPlanCycle();
|
|
|
|
+ String timeStr = patrolInspectionPlanVo.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
|
+ Date startDate = OnlineMethod.getDate(timeStr);
|
|
|
|
+ LocalDate ss = null;
|
|
|
|
+ if (planCycle == 1) {
|
|
|
|
+ ss = OnlineMethod.getDate(timeStr, "yyyy-MM-dd", true, 1 * patrolInspectionPlanVo.getWeekCount() - 1);
|
|
|
|
+ } else if (planCycle == 2) {
|
|
|
|
+ ss = OnlineMethod.getDate(timeStr, "yyyy-MM-dd", true, 7 * patrolInspectionPlanVo.getWeekCount() - 1);
|
|
|
|
+ } else if (planCycle == 3) {
|
|
|
|
+ ss = OnlineMethod.getMonthDate(startDate, 1 * patrolInspectionPlanVo.getWeekCount());
|
|
|
|
+ } else if (planCycle == 4) {
|
|
|
|
+ ss = OnlineMethod.getMonthDate(startDate, 12 * patrolInspectionPlanVo.getWeekCount());
|
|
|
|
+ }
|
|
|
|
+
|
|
//主表数据修改
|
|
//主表数据修改
|
|
PatrolInspectionPlan patrolInspectionPlan = new PatrolInspectionPlan();
|
|
PatrolInspectionPlan patrolInspectionPlan = new PatrolInspectionPlan();
|
|
patrolInspectionPlan.setId(patrolInspectionPlanVo.getId());
|
|
patrolInspectionPlan.setId(patrolInspectionPlanVo.getId());
|
|
@@ -262,8 +290,6 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
if (patrolInspectionPlanVo.getPlanType() == 1) {
|
|
if (patrolInspectionPlanVo.getPlanType() == 1) {
|
|
patrolInspectionPlan.setEndDate(patrolInspectionPlanVo.getEndDate());
|
|
patrolInspectionPlan.setEndDate(patrolInspectionPlanVo.getEndDate());
|
|
} else {
|
|
} else {
|
|
- String timeStr = patrolInspectionPlanVo.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
|
- LocalDate ss = OnlineMethod.getDate(timeStr, "yyyy-MM-dd", true, 7 * patrolInspectionPlanVo.getWeekCount());
|
|
|
|
patrolInspectionPlan.setEndDate(ss);
|
|
patrolInspectionPlan.setEndDate(ss);
|
|
}
|
|
}
|
|
patrolInspectionPlan.setAreaId(patrolInspectionPlanVo.getAreaId());
|
|
patrolInspectionPlan.setAreaId(patrolInspectionPlanVo.getAreaId());
|
|
@@ -318,7 +344,7 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
days = OnlineMethod.fun(patrolInspectionPlanVo.getStartDate(), date);
|
|
days = OnlineMethod.fun(patrolInspectionPlanVo.getStartDate(), date);
|
|
}
|
|
}
|
|
for (int i = 0; i < days; i++) {
|
|
for (int i = 0; i < days; i++) {
|
|
- LocalDate date1 = OnlineMethod.getDate(timeStr3, "yyyy-MM-dd", true, i+1);
|
|
|
|
|
|
+ LocalDate date1 = OnlineMethod.getDate(timeStr3, "yyyy-MM-dd", true, i + 1);
|
|
Date date = Date.from(date1.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
|
|
Date date = Date.from(date1.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
|
|
String week1 = OnlineMethod.getWeekOfDate(date);
|
|
String week1 = OnlineMethod.getWeekOfDate(date);
|
|
if (patrolInspectionPlanVo.getRestDay().contains(week1)) {
|
|
if (patrolInspectionPlanVo.getRestDay().contains(week1)) {
|
|
@@ -348,7 +374,7 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
String timeStr1 = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
String timeStr1 = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
for (int i = 0; i < day; i++) {
|
|
for (int i = 0; i < day; i++) {
|
|
for (int j = 0; j < patrolInspectionPlanVo.getPlanScheduleList().size(); j++) {
|
|
for (int j = 0; j < patrolInspectionPlanVo.getPlanScheduleList().size(); j++) {
|
|
- LocalDate s = OnlineMethod.getDate(timeStr1, "yyyy-MM-dd", true, i+1);
|
|
|
|
|
|
+ LocalDate s = OnlineMethod.getDate(timeStr1, "yyyy-MM-dd", true, i + 1);
|
|
Date date = Date.from(s.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
|
|
Date date = Date.from(s.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
|
|
String week = OnlineMethod.getWeekOfDate(date);
|
|
String week = OnlineMethod.getWeekOfDate(date);
|
|
if (!patrolInspectionPlanVo.getRestDay().contains(week)) {
|
|
if (!patrolInspectionPlanVo.getRestDay().contains(week)) {
|
|
@@ -384,18 +410,11 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {//按次计划
|
|
} else {//按次计划
|
|
- for (int i = 0; i < patrolInspectionPlanVo.getWeekCount(); i++) {
|
|
|
|
- String timeStr2 = patrolInspectionPlanVo.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
|
- LocalDate sss = OnlineMethod.getDate(timeStr2, "yyyy-MM-dd", true, 7 * (i + 1));
|
|
|
|
|
|
+ for (int i = 0; i < patrolInspectionPlanVo.getPlanFrequency(); i++) {
|
|
PatrolInspectionPlanSon patrolInspectionPlanSon = new PatrolInspectionPlanSon();
|
|
PatrolInspectionPlanSon patrolInspectionPlanSon = new PatrolInspectionPlanSon();
|
|
patrolInspectionPlanSon.setPlanId(patrolInspectionPlanVo.getId());
|
|
patrolInspectionPlanSon.setPlanId(patrolInspectionPlanVo.getId());
|
|
- if (i == 0) {
|
|
|
|
- patrolInspectionPlanSon.setStartDate(patrolInspectionPlanVo.getStartDate());
|
|
|
|
- } else {
|
|
|
|
- LocalDate ssss = OnlineMethod.getDate(timeStr2, "yyyy-MM-dd", true, 7 * i + 1);
|
|
|
|
- patrolInspectionPlanSon.setStartDate(ssss);
|
|
|
|
- }
|
|
|
|
- patrolInspectionPlanSon.setEndDate(sss);
|
|
|
|
|
|
+ patrolInspectionPlanSon.setStartDate(patrolInspectionPlanVo.getStartDate());
|
|
|
|
+ patrolInspectionPlanSon.setEndDate(ss);
|
|
patrolInspectionPlanSon.setPersonnelId(patrolInspectionPlanVo.getPlanScheduleList().get(0).getPersonnelId());
|
|
patrolInspectionPlanSon.setPersonnelId(patrolInspectionPlanVo.getPlanScheduleList().get(0).getPersonnelId());
|
|
patrolInspectionPlanSon.setAreaId(patrolInspectionPlanVo.getAreaId());
|
|
patrolInspectionPlanSon.setAreaId(patrolInspectionPlanVo.getAreaId());
|
|
patrolInspectionPlanSon.setPlanType(patrolInspectionPlanVo.getPlanType());
|
|
patrolInspectionPlanSon.setPlanType(patrolInspectionPlanVo.getPlanType());
|
|
@@ -427,6 +446,12 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
public void delPatrolInspectionPlan(Integer id) {
|
|
public void delPatrolInspectionPlan(Integer id) {
|
|
|
|
+ LambdaQueryWrapper<PatrolInspectionRecord> queryWrapperSix = Wrappers.lambdaQuery();
|
|
|
|
+ queryWrapperSix.eq(PatrolInspectionRecord::getPlanId, id);
|
|
|
|
+ List<PatrolInspectionRecord> patrolInspectionRecordList = patrolInspectionRecordService.list(queryWrapperSix);
|
|
|
|
+ if (patrolInspectionRecordList.size() <= 0) {
|
|
|
|
+ throw new BusinessException("巡检计划已执行中不可删除");
|
|
|
|
+ }
|
|
PatrolInspectionPlan patrolInspectionPlan = new PatrolInspectionPlan();
|
|
PatrolInspectionPlan patrolInspectionPlan = new PatrolInspectionPlan();
|
|
patrolInspectionPlan.setId(id);
|
|
patrolInspectionPlan.setId(id);
|
|
patrolInspectionPlan.setEnable(0);
|
|
patrolInspectionPlan.setEnable(0);
|
|
@@ -535,7 +560,7 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
|
|
list1.add(patrolInspectionPlanDataVo);
|
|
list1.add(patrolInspectionPlanDataVo);
|
|
}
|
|
}
|
|
List<PatrolInspectionPlanDataVo> list3 = list1.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
|
|
List<PatrolInspectionPlanDataVo> list3 = list1.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
|
|
- return new CommonPage<>(list3, list1.size(), pageSize,pageNum);
|
|
|
|
|
|
+ return new CommonPage<>(list3, list1.size(), pageSize, pageNum);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|