|
@@ -1,14 +1,24 @@
|
|
|
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.PatrolInspectionPlanSchedule;
|
|
|
import com.usky.fire.domain.PatrolInspectionPlanSon;
|
|
|
import com.usky.fire.mapper.PatrolInspectionPlanSonMapper;
|
|
|
+import com.usky.fire.service.PatrolInspectionPlanScheduleService;
|
|
|
import com.usky.fire.service.PatrolInspectionPlanSonService;
|
|
|
-import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
+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;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 服务实现类
|
|
|
+ * 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
* @author JCB
|
|
@@ -17,4 +27,51 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<PatrolInspectionPlanSonMapper, PatrolInspectionPlanSon> implements PatrolInspectionPlanSonService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PatrolInspectionPlanScheduleService patrolInspectionPlanScheduleService;
|
|
|
+
|
|
|
+ public Map<String, Object> appPlanStatistics(Integer personnelId) {
|
|
|
+ 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);
|
|
|
+ patrolledCount = this.planSonCount(planIdList, 100);
|
|
|
+ undetectedCount = planSonCount - patrolledCount;
|
|
|
+ }
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("planSonCount", planSonCount);//巡检任务总数
|
|
|
+ map.put("patrolledCount", patrolledCount);//已巡检任务
|
|
|
+ map.put("undetectedCount", undetectedCount);//漏检任务
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Integer planSonCount(List<Integer> planIdList, Integer completion) {
|
|
|
+ LambdaQueryWrapper<PatrolInspectionPlanSon> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ if (planIdList != null && planIdList.size() > 0) {
|
|
|
+ queryWrapper.in(PatrolInspectionPlanSon::getPlanId, planIdList);
|
|
|
+ }
|
|
|
+ if (completion != null) {
|
|
|
+ queryWrapper.eq(PatrolInspectionPlanSon::getCompletion, completion);
|
|
|
+ }
|
|
|
+
|
|
|
+ queryWrapper.and((wrapper) -> {
|
|
|
+ wrapper.eq(PatrolInspectionPlanSon::getInspectionDate, "2022-07-31")
|
|
|
+ .or()
|
|
|
+ .ge(PatrolInspectionPlanSon::getStartDate, "2022-07-31")
|
|
|
+ .le(PatrolInspectionPlanSon::getEndDate, "2022-08-07");
|
|
|
+ });
|
|
|
+
|
|
|
+ Integer planSonCount = this.count(queryWrapper);
|
|
|
+ return planSonCount;
|
|
|
+ }
|
|
|
}
|