Browse Source

App巡检-首页相关接口开发

jichaobo 2 years ago
parent
commit
273261b3c5

+ 37 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/AppPatrolInspectionController.java

@@ -0,0 +1,37 @@
+package com.usky.fire.controller.web;
+
+
+import com.usky.common.core.bean.ApiResult;
+import com.usky.fire.service.PatrolInspectionPlanSonService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+/**
+ * APP-巡检
+ *
+ * @author JCB
+ * @since 2022-07-12
+ */
+@RestController
+@RequestMapping("/appPatrolInspection")
+public class AppPatrolInspectionController {
+
+    @Autowired
+    private PatrolInspectionPlanSonService patrolInspectionPlanSonService;
+
+    /**
+     * App-巡检自查-首页
+     *
+     * @param personnelId 人员ID
+     * @return
+     */
+    @GetMapping("appPlanStatistics")
+    public ApiResult<Map<String, Object>> appPlanStatistics(@RequestParam(value = "personnelId") Integer personnelId) {
+        return ApiResult.success(patrolInspectionPlanSonService.appPlanStatistics(personnelId));
+    }
+}

+ 21 - 2
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionPlanSonService.java

@@ -1,11 +1,14 @@
 package com.usky.fire.service;
 
-import com.usky.fire.domain.PatrolInspectionPlanSon;
 import com.usky.common.mybatis.core.CrudService;
+import com.usky.fire.domain.PatrolInspectionPlanSon;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
- *  服务类
+ * 服务类
  * </p>
  *
  * @author JCB
@@ -13,4 +16,20 @@ import com.usky.common.mybatis.core.CrudService;
  */
 public interface PatrolInspectionPlanSonService extends CrudService<PatrolInspectionPlanSon> {
 
+    /**
+     * 手机端-巡检自检-首页
+     *
+     * @param personnelId 人员ID
+     * @return
+     */
+    Map<String, Object> appPlanStatistics(Integer personnelId);
+
+    /**
+     * 手机端-巡检子计划数量查询
+     *
+     * @param planIdList 主计划ID
+     * @param completion 完成百分比
+     * @return
+     */
+    Integer planSonCount(List<Integer> planIdList, Integer completion);
 }

+ 18 - 7
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/AlarmFireServiceImpl.java

@@ -16,10 +16,7 @@ import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * <p>
@@ -246,7 +243,14 @@ public class AlarmFireServiceImpl extends AbstractCrudService<AlarmFireMapper, A
             queryWrapper.eq(AlarmFire::getHandlingStatus, handlingStatus);
         }
         if (alarmTypeList.size() > 0) {
-            queryWrapper.in(AlarmFire::getAlarmType, alarmTypeList);
+            if (alarmTypeList.contains(100)){
+                List<Integer> alarmTypeList1 = new ArrayList<>();
+                alarmTypeList1.add(2);
+                alarmTypeList1.add(4);
+                queryWrapper.notIn(AlarmFire::getAlarmType, alarmTypeList1);
+            }else {
+                queryWrapper.in(AlarmFire::getAlarmType, alarmTypeList);
+            }
         }
         int total = this.count(queryWrapper);
         return total;
@@ -261,7 +265,7 @@ public class AlarmFireServiceImpl extends AbstractCrudService<AlarmFireMapper, A
      * @param endDate        结束时间 格式:yyyy-MM-dd HH:mm:ss
      * @param pageNum        当前页
      * @param pageSize       每页条数
-     * @param alarmTypeList  告警类型(2 火警、4 故障、16 监管等)
+     * @param alarmTypeList  告警类型(2 火警、4 故障、16 监管等、100隐患
      * @return
      */
     @Override
@@ -276,7 +280,14 @@ public class AlarmFireServiceImpl extends AbstractCrudService<AlarmFireMapper, A
         }
 
         if (alarmTypeList.size() > 0) {
-            queryWrapper.in(AlarmFire::getAlarmType, alarmTypeList);
+            if (alarmTypeList.contains(100)){
+                List<Integer> alarmTypeList1 = new ArrayList<>();
+                alarmTypeList1.add(2);
+                alarmTypeList1.add(4);
+                queryWrapper.notIn(AlarmFire::getAlarmType, alarmTypeList1);
+            }else {
+                queryWrapper.in(AlarmFire::getAlarmType, alarmTypeList);
+            }
         }
 
         if (startDate != null && !"".equals(startDate) && endDate != null && !"".equals(endDate)) {

+ 59 - 2
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionPlanSonServiceImpl.java

@@ -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;
+    }
 }