|
@@ -3,18 +3,25 @@ package com.usky.fire.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
+import com.usky.fire.domain.PatrolInspectionPlan;
|
|
|
import com.usky.fire.domain.PatrolInspectionPlanSchedule;
|
|
|
+import com.usky.fire.domain.PatrolInspectionPlanSiteSon;
|
|
|
import com.usky.fire.domain.PatrolInspectionPlanSon;
|
|
|
+import com.usky.fire.mapper.PatrolInspectionPlanMapper;
|
|
|
import com.usky.fire.mapper.PatrolInspectionPlanSonMapper;
|
|
|
import com.usky.fire.service.PatrolInspectionPlanScheduleService;
|
|
|
+import com.usky.fire.service.PatrolInspectionPlanSiteSonService;
|
|
|
import com.usky.fire.service.PatrolInspectionPlanSonService;
|
|
|
+import com.usky.fire.service.vo.DataCountVo;
|
|
|
+import com.usky.fire.service.vo.PatrolInspectionPlanSonVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -30,7 +37,40 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
|
|
|
@Autowired
|
|
|
private PatrolInspectionPlanScheduleService patrolInspectionPlanScheduleService;
|
|
|
|
|
|
- public Map<String, Object> appPlanStatistics(Integer personnelId) {
|
|
|
+ @Autowired
|
|
|
+ private PatrolInspectionPlanMapper patrolInspectionPlanMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PatrolInspectionPlanSiteSonService patrolInspectionPlanSiteSonService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> appPlanStatistics(Integer personnelId, String currentDate) {
|
|
|
+ LambdaQueryWrapper<PatrolInspectionPlanSchedule> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.select(PatrolInspectionPlanSchedule::getPlanId)
|
|
|
+ .eq(PatrolInspectionPlanSchedule::getPersonnelId, personnelId)
|
|
|
+ .groupBy(PatrolInspectionPlanSchedule::getPlanId);
|
|
|
+ List<PatrolInspectionPlanSchedule> planScheduleList = patrolInspectionPlanScheduleService.list(queryWrapper);
|
|
|
+ Integer planSonCount = 0;
|
|
|
+ Integer patrolledCount = 0;
|
|
|
+ Integer undetectedCount = 0;
|
|
|
+ if (planScheduleList.size() > 0) {
|
|
|
+ List<Integer> planIdList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < planScheduleList.size(); i++) {
|
|
|
+ planIdList.add(planScheduleList.get(i).getPlanId());
|
|
|
+ }
|
|
|
+ planSonCount = this.planSonCount(planIdList, null, currentDate);
|
|
|
+ patrolledCount = this.planSonCount(planIdList, 100, currentDate);
|
|
|
+ undetectedCount = planSonCount - patrolledCount;
|
|
|
+ }
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("planSonCount", planSonCount);//巡检任务总数
|
|
|
+ map.put("patrolledCount", patrolledCount);//已巡检任务
|
|
|
+ map.put("undetectedCount", undetectedCount);//漏检任务
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public Map<String, Object> patrolInspectionPlan(Integer personnelId, String currentDate, String sort) {
|
|
|
LambdaQueryWrapper<PatrolInspectionPlanSchedule> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.select(PatrolInspectionPlanSchedule::getPlanId)
|
|
|
.eq(PatrolInspectionPlanSchedule::getPersonnelId, personnelId)
|
|
@@ -39,23 +79,171 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
|
|
|
Integer planSonCount = 0;
|
|
|
Integer patrolledCount = 0;
|
|
|
Integer undetectedCount = 0;
|
|
|
+ List<PatrolInspectionPlanSonVo> planList = new ArrayList<>();
|
|
|
if (planScheduleList.size() > 0) {
|
|
|
List<Integer> planIdList = new ArrayList<>();
|
|
|
for (int i = 0; i < planScheduleList.size(); i++) {
|
|
|
planIdList.add(planScheduleList.get(i).getPlanId());
|
|
|
}
|
|
|
- planSonCount = this.planSonCount(planIdList, null);
|
|
|
- patrolledCount = this.planSonCount(planIdList, 100);
|
|
|
+ planList = this.patrolInspectionPlanSon(planIdList, currentDate, sort);
|
|
|
+ planSonCount = this.planSonCount(planIdList, null, currentDate);
|
|
|
+ patrolledCount = this.planSonCount(planIdList, 100, currentDate);
|
|
|
undetectedCount = planSonCount - patrolledCount;
|
|
|
+
|
|
|
}
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("planSonCount", planSonCount);//巡检任务总数
|
|
|
map.put("patrolledCount", patrolledCount);//已巡检任务
|
|
|
map.put("undetectedCount", undetectedCount);//漏检任务
|
|
|
+ map.put("planList", planList);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- public Integer planSonCount(List<Integer> planIdList, Integer completion) {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PatrolInspectionPlanSonVo> patrolInspectionPlanSon(List<Integer> planIdList, String currentDate, String sort) {
|
|
|
+// DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ DateTimeFormatter df1 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ LambdaQueryWrapper<PatrolInspectionPlanSon> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ if (planIdList != null && planIdList.size() > 0) {
|
|
|
+ queryWrapper.in(PatrolInspectionPlanSon::getPlanId, planIdList);
|
|
|
+ }
|
|
|
+ queryWrapper.and((wrapper) -> {
|
|
|
+ wrapper.eq(PatrolInspectionPlanSon::getInspectionDate, currentDate)
|
|
|
+ .or()
|
|
|
+ .le(PatrolInspectionPlanSon::getStartDate, currentDate)
|
|
|
+ .ge(PatrolInspectionPlanSon::getEndDate, currentDate);
|
|
|
+ });
|
|
|
+ if (sort.equals("ASC")) {
|
|
|
+ queryWrapper.orderByAsc(PatrolInspectionPlanSon::getId);
|
|
|
+ } else {
|
|
|
+ queryWrapper.orderByDesc(PatrolInspectionPlanSon::getId);
|
|
|
+ }
|
|
|
+ List<PatrolInspectionPlanSon> planSonList = this.list(queryWrapper);
|
|
|
+ List<PatrolInspectionPlanSonVo> list = new ArrayList<>();
|
|
|
+ if (planSonList.size() > 0) {
|
|
|
+ List<Integer> planSonidList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < planSonList.size(); i++) {
|
|
|
+ planSonidList.add(planSonList.get(i).getId());
|
|
|
+ }
|
|
|
+ //巡检计划名称查询
|
|
|
+ LambdaQueryWrapper<PatrolInspectionPlan> queryWrapperOne = Wrappers.lambdaQuery();
|
|
|
+ queryWrapperOne.select(PatrolInspectionPlan::getId, PatrolInspectionPlan::getPlanName);
|
|
|
+ if (planIdList != null && planIdList.size() > 0) {
|
|
|
+ queryWrapperOne.in(PatrolInspectionPlan::getId, planIdList);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<PatrolInspectionPlan> planList = patrolInspectionPlanMapper.selectList(queryWrapperOne);
|
|
|
+ List<DataCountVo> patrolledSiteCountList = this.planSiteSonCount(planSonidList, 2);//已巡检地点数量
|
|
|
+ List<DataCountVo> undetectedSiteCountList = this.planSiteSonCount(planSonidList, 1);//漏检地点数量
|
|
|
+ for (int i = 0; i < planSonList.size(); i++) {
|
|
|
+ PatrolInspectionPlanSonVo patrolInspectionPlanSonVo = new PatrolInspectionPlanSonVo();
|
|
|
+ patrolInspectionPlanSonVo.setId(planSonList.get(i).getId());
|
|
|
+ patrolInspectionPlanSonVo.setStartTime(planSonList.get(i).getStartTime());
|
|
|
+ patrolInspectionPlanSonVo.setEndTime(planSonList.get(i).getEndTime());
|
|
|
+ patrolInspectionPlanSonVo.setCompletion(planSonList.get(i).getCompletion());
|
|
|
+ patrolInspectionPlanSonVo.setPlanType(planSonList.get(i).getPlanType());
|
|
|
+ patrolInspectionPlanSonVo.setPlanCycle(planSonList.get(i).getPlanCycle());
|
|
|
+ patrolInspectionPlanSonVo.setStartDate(planSonList.get(i).getStartDate());
|
|
|
+ patrolInspectionPlanSonVo.setEndDate(planSonList.get(i).getEndDate());
|
|
|
+ patrolInspectionPlanSonVo.setInspectionDate(planSonList.get(i).getInspectionDate());
|
|
|
+ patrolInspectionPlanSonVo.setPatrolledSiteCount(0);
|
|
|
+ patrolInspectionPlanSonVo.setUndetectedSiteCount(0);
|
|
|
+ //计划名称
|
|
|
+ for (int j = 0; j < planList.size(); j++) {
|
|
|
+ if (planSonList.get(i).getPlanId() == planList.get(j).getId()) {
|
|
|
+ patrolInspectionPlanSonVo.setPlanName(planList.get(j).getPlanName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Integer planStatus = 1;
|
|
|
+ Date currentTime = new Date();
|
|
|
+ Date endTime = null;
|
|
|
+ if (planSonList.get(i).getPlanType() == 1) {
|
|
|
+ //获取结束日期时间
|
|
|
+ LocalDate inspectionDate = planSonList.get(i).getInspectionDate();
|
|
|
+ String inspectionDateOne = df1.format(inspectionDate);
|
|
|
+ String inspectionDateTwo = inspectionDateOne + " " + planSonList.get(i).getEndTime();
|
|
|
+ try {
|
|
|
+ endTime = formatter.parse(inspectionDateTwo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //获取结束日期时间
|
|
|
+ LocalDate endDate = planSonList.get(i).getEndDate();
|
|
|
+ String endDateOne = df1.format(endDate) + " 23:59:59";
|
|
|
+ try {
|
|
|
+ endTime = formatter.parse(endDateOne);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ //计划类型描述
|
|
|
+ String planCycleName = null;
|
|
|
+ if (planSonList.get(i).getPlanCycle() == 1) {
|
|
|
+ planCycleName = "(日)";
|
|
|
+ } else if (planSonList.get(i).getPlanCycle() == 2) {
|
|
|
+ planCycleName = "(周)";
|
|
|
+ } else if (planSonList.get(i).getPlanCycle() == 3) {
|
|
|
+ planCycleName = "(月)";
|
|
|
+ } else if (planSonList.get(i).getPlanCycle() == 4) {
|
|
|
+ planCycleName = "(年)";
|
|
|
+ }
|
|
|
+ patrolInspectionPlanSonVo.setPlanTypeDescribe("按次计划" + planCycleName);
|
|
|
+ }
|
|
|
+ //判断计划状态
|
|
|
+ int status = endTime.compareTo(currentTime);
|
|
|
+ if (status == -1) {
|
|
|
+ if (planSonList.get(i).getCompletion() == 100) {
|
|
|
+ planStatus = 2;
|
|
|
+ } else {
|
|
|
+ planStatus = 3;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ patrolInspectionPlanSonVo.setPlanStatus(planStatus);
|
|
|
+ for (int j = 0; j < patrolledSiteCountList.size(); j++) {
|
|
|
+ if (planSonList.get(i).getId() == patrolledSiteCountList.get(j).getId()) {
|
|
|
+ patrolInspectionPlanSonVo.setPatrolledSiteCount(patrolledSiteCountList.get(j).getListCount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (int j = 0; j < undetectedSiteCountList.size(); j++) {
|
|
|
+ if (planSonList.get(i).getId() == undetectedSiteCountList.get(j).getId()) {
|
|
|
+ patrolInspectionPlanSonVo.setUndetectedSiteCount(undetectedSiteCountList.get(j).getListCount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list.add(patrolInspectionPlanSonVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<DataCountVo> planSiteSonCount(List<Integer> planSonidList, Integer inspectionStatus) {
|
|
|
+
|
|
|
+ LambdaQueryWrapper<PatrolInspectionPlanSiteSon> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ if (planSonidList != null && planSonidList.size() > 0) {
|
|
|
+ queryWrapper.in(PatrolInspectionPlanSiteSon::getPlanId, planSonidList);
|
|
|
+ }
|
|
|
+ if (inspectionStatus != null) {
|
|
|
+ queryWrapper.eq(PatrolInspectionPlanSiteSon::getInspectionStatus, inspectionStatus);
|
|
|
+ }
|
|
|
+ List<PatrolInspectionPlanSiteSon> planSiteSonList = patrolInspectionPlanSiteSonService.list(queryWrapper);
|
|
|
+
|
|
|
+ Map<Integer, List<PatrolInspectionPlanSiteSon>> grouypByAreaPlanId = planSiteSonList.stream().collect(
|
|
|
+ Collectors.groupingBy(o -> o.getPlanId())
|
|
|
+ );
|
|
|
+ List<DataCountVo> dataCountVoList = new ArrayList<>();
|
|
|
+ grouypByAreaPlanId.forEach((k, v) -> {
|
|
|
+ DataCountVo dataCountVo = new DataCountVo();
|
|
|
+ dataCountVo.setListCount(v.size());
|
|
|
+ dataCountVo.setId(k);
|
|
|
+ dataCountVoList.add(dataCountVo);
|
|
|
+ });
|
|
|
+ return dataCountVoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Integer planSonCount(List<Integer> planIdList, Integer completion, String currentDate) {
|
|
|
+ DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
LambdaQueryWrapper<PatrolInspectionPlanSon> queryWrapper = Wrappers.lambdaQuery();
|
|
|
if (planIdList != null && planIdList.size() > 0) {
|
|
|
queryWrapper.in(PatrolInspectionPlanSon::getPlanId, planIdList);
|
|
@@ -63,12 +251,16 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
|
|
|
if (completion != null) {
|
|
|
queryWrapper.eq(PatrolInspectionPlanSon::getCompletion, completion);
|
|
|
}
|
|
|
-
|
|
|
+ LocalDate currentDate1 = LocalDate.now();
|
|
|
+ if (currentDate != null && !"".equals(currentDate)) {
|
|
|
+ currentDate1 = LocalDate.parse(currentDate);
|
|
|
+ }
|
|
|
+ LocalDate finalCurrentDate = currentDate1;
|
|
|
queryWrapper.and((wrapper) -> {
|
|
|
- wrapper.eq(PatrolInspectionPlanSon::getInspectionDate, "2022-07-31")
|
|
|
+ wrapper.eq(PatrolInspectionPlanSon::getInspectionDate, finalCurrentDate)
|
|
|
.or()
|
|
|
- .ge(PatrolInspectionPlanSon::getStartDate, "2022-07-31")
|
|
|
- .le(PatrolInspectionPlanSon::getEndDate, "2022-08-07");
|
|
|
+ .le(PatrolInspectionPlanSon::getStartDate, finalCurrentDate)
|
|
|
+ .ge(PatrolInspectionPlanSon::getEndDate, finalCurrentDate);
|
|
|
});
|
|
|
|
|
|
Integer planSonCount = this.count(queryWrapper);
|