Browse Source

巡检记录ID

jichaobo 2 years ago
parent
commit
cdfaa1c56f

+ 26 - 15
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/AppPatrolInspectionController.java

@@ -5,6 +5,7 @@ import com.usky.common.core.bean.ApiResult;
 import com.usky.fire.domain.PatrolInspectionSite;
 import com.usky.fire.service.PatrolInspectionPlanSonService;
 import com.usky.fire.service.vo.PatrolInspectionPlanSonVo;
+import com.usky.fire.service.vo.PatrolInspectionRecordVo;
 import com.usky.fire.service.vo.PatrolInspectionSiteVo;
 import com.usky.fire.service.vo.PlanRecordVo;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -27,44 +28,38 @@ public class AppPatrolInspectionController {
     private PatrolInspectionPlanSonService patrolInspectionPlanSonService;
 
     /**
-     * App-巡检自查-首页
+     * App-巡检自查-/首页/巡检计划-统计
      *
-     * @param personnelId 人员ID
+     * @param currentDate 时间 格式:yyyy-MM-dd
      * @return
      */
     @GetMapping("appPlanStatistics")
-    public ApiResult<Map<String, Object>> appPlanStatistics(@RequestParam(value = "personnelId") Integer personnelId,
-                                                            @RequestParam(value = "currentDate", required = false) String currentDate) {
-        return ApiResult.success(patrolInspectionPlanSonService.appPlanStatistics(personnelId, currentDate));
+    public ApiResult<Map<String, Object>> appPlanStatistics(@RequestParam(value = "currentDate", required = false) String currentDate) {
+        return ApiResult.success(patrolInspectionPlanSonService.appPlanStatistics(currentDate));
     }
 
-
     /**
      * App-巡检自查-巡检计划
      *
-     * @param personnelId 人员ID
      * @param currentDate 日期 格式:yyyy-MM-dd
      * @param sort        排序 (正序:ASC 倒序:DESC)
      * @return
      */
     @GetMapping("patrolInspectionPlan")
-    public ApiResult<Map<String, Object>> patrolInspectionPlan(@RequestParam(value = "personnelId") Integer personnelId,
-                                                               @RequestParam(value = "currentDate", required = false) String currentDate,
-                                                               @RequestParam(value = "sort", required = false, defaultValue = "DESC") String sort) {
-        return ApiResult.success(patrolInspectionPlanSonService.patrolInspectionPlan(personnelId, currentDate, sort));
+    public ApiResult<List<PatrolInspectionPlanSonVo>> patrolInspectionPlan(@RequestParam(value = "currentDate", required = false) String currentDate,
+                                                                           @RequestParam(value = "sort", required = false, defaultValue = "DESC") String sort) {
+        return ApiResult.success(patrolInspectionPlanSonService.patrolInspectionPlan(currentDate, sort));
     }
 
     /**
      * 手机端-巡检自检-巡检计划-扫码查询计划
      *
-     * @param personnelId 人员ID
      * @param siteNubmber 地点号码
      * @return
      */
     @GetMapping("planList")
-    public ApiResult<List<PatrolInspectionPlanSonVo>> planList(@RequestParam(value = "personnelId") Integer personnelId,
-                                                               @RequestParam(value = "siteNubmber") String siteNubmber) {
-        return ApiResult.success(patrolInspectionPlanSonService.planList(siteNubmber, personnelId));
+    public ApiResult<List<PatrolInspectionPlanSonVo>> planList(@RequestParam(value = "siteNubmber") String siteNubmber) {
+        return ApiResult.success(patrolInspectionPlanSonService.planList(siteNubmber));
     }
 
 
@@ -131,4 +126,20 @@ public class AppPatrolInspectionController {
                                                           @RequestParam(value = "endTime", required = false) String endTime) {
         return ApiResult.success(patrolInspectionPlanSonService.siteList(startTime, endTime));
     }
+
+    /**
+     * 手机端-巡检自检-巡检记录
+     *
+     * @param currentDate 时间 格式:yyyy-MM-dd
+     * @param sort        排序 (正序:ASC 倒序:DESC)
+     * @param id          记录ID
+     * @return
+     */
+    @GetMapping("recordList")
+    public ApiResult<List<PatrolInspectionRecordVo>> recordList(@RequestParam(value = "currentDate", required = false) String currentDate,
+                                                                @RequestParam(value = "sort", required = false, defaultValue = "DESC") String sort,
+                                                                @RequestParam(value = "id", required = false, defaultValue = "0") Integer id) {
+        return ApiResult.success(patrolInspectionPlanSonService.recordList(currentDate, sort, id));
+    }
+
 }

+ 4 - 1
service-fire/service-fire-biz/src/main/java/com/usky/fire/domain/PatrolInspectionRecord.java

@@ -124,6 +124,9 @@ public class PatrolInspectionRecord implements Serializable {
      */
     private String creator;
 
-
+    /**
+     * 备注
+     */
+    private String remarks;
 
 }

+ 25 - 9
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionPlanSonService.java

@@ -21,30 +21,28 @@ public interface PatrolInspectionPlanSonService extends CrudService<PatrolInspec
     /**
      * 手机端-巡检自检-首页
      *
-     * @param personnelId 人员ID
+     * @param currentDate 时间 格式:yyyy-MM-dd
      * @return
      */
-    Map<String, Object> appPlanStatistics(Integer personnelId, String currentDate);
+    Map<String, Object> appPlanStatistics(String currentDate);
 
     /**
      * 手机端-巡检自检-巡检计划
      *
-     * @param personnelId
-     * @param currentDate
-     * @param sort
+     * @param currentDate 时间 格式:yyyy-MM-dd
+     * @param sort        排序 (正序:ASC 倒序:DESC)
      * @return
      */
-    Map<String, Object> patrolInspectionPlan(Integer personnelId, String currentDate, String sort);
+    List<PatrolInspectionPlanSonVo> patrolInspectionPlan(String currentDate, String sort);
 
 
     /**
      * 手机端-巡检自检-巡检计划-扫码查询计划
      *
      * @param siteNubmber 地点号码
-     * @param personnelId 人员ID
      * @return
      */
-    List<PatrolInspectionPlanSonVo> planList(String siteNubmber, Integer personnelId);
+    List<PatrolInspectionPlanSonVo> planList(String siteNubmber);
 
 
     /**
@@ -83,12 +81,30 @@ public interface PatrolInspectionPlanSonService extends CrudService<PatrolInspec
 
     /**
      * 手机端-巡检自检-点位采集-采集记录
+     *
      * @param startTime 开始时间 格式:yyyy-MM-dd HH:mm:ss
-     * @param endTime 结束时间 格式:yyyy-MM-dd HH:mm:ss
+     * @param endTime   结束时间 格式:yyyy-MM-dd HH:mm:ss
      * @return
      */
     List<PatrolInspectionSite> siteList(String startTime, String endTime);
 
+    /**
+     * 手机端-巡检自检-巡检记录
+     *
+     * @param currentDate 时间 格式:yyyy-MM-dd
+     * @param sort        排序 (正序:ASC 倒序:DESC)
+     * @return
+     */
+    List<PatrolInspectionRecordVo> recordList(String currentDate, String sort,Integer id);
+
+
+    /**
+     * 手机端-根据用户获取巡检人员ID
+     *
+     * @return
+     */
+    List<Integer> getpersonId();
+
     /**
      * 手机端-巡检自检-子计划巡检点位统计
      *

+ 113 - 22
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionPlanSonServiceImpl.java

@@ -67,11 +67,15 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
     @Autowired
     private PatrolInspectionRecordPictureService patrolInspectionRecordPictureService;
 
+    @Autowired
+    private PatrolInspectionPersonnelService patrolInspectionPersonnelService;
+
     @Override
-    public Map<String, Object> appPlanStatistics(Integer personnelId, String currentDate) {
+    public Map<String, Object> appPlanStatistics(String currentDate) {
+        List<Integer> personnelIdList = this.getpersonId();
         LambdaQueryWrapper<PatrolInspectionPlanSchedule> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.select(PatrolInspectionPlanSchedule::getPlanId)
-                .eq(PatrolInspectionPlanSchedule::getPersonnelId, personnelId)
+                .in(PatrolInspectionPlanSchedule::getPersonnelId, personnelIdList)
                 .groupBy(PatrolInspectionPlanSchedule::getPlanId);
         List<PatrolInspectionPlanSchedule> planScheduleList = patrolInspectionPlanScheduleService.list(queryWrapper);
         Integer planSonCount = 0;
@@ -93,17 +97,14 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
         return map;
     }
 
-
     @Override
-    public Map<String, Object> patrolInspectionPlan(Integer personnelId, String currentDate, String sort) {
+    public List<PatrolInspectionPlanSonVo> patrolInspectionPlan(String currentDate, String sort) {
+        List<Integer> personnelIdList = this.getpersonId();
         LambdaQueryWrapper<PatrolInspectionPlanSchedule> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.select(PatrolInspectionPlanSchedule::getPlanId)
-                .eq(PatrolInspectionPlanSchedule::getPersonnelId, personnelId)
+                .in(PatrolInspectionPlanSchedule::getPersonnelId, personnelIdList)
                 .groupBy(PatrolInspectionPlanSchedule::getPlanId);
         List<PatrolInspectionPlanSchedule> planScheduleList = patrolInspectionPlanScheduleService.list(queryWrapper);
-        Integer planSonCount = 0;
-        Integer patrolledCount = 0;
-        Integer undetectedCount = 0;
         List<PatrolInspectionPlanSonVo> planList = new ArrayList<>();
         if (planScheduleList.size() > 0) {
             List<Integer> planIdList = new ArrayList<>();
@@ -111,22 +112,14 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
                 planIdList.add(planScheduleList.get(i).getPlanId());
             }
             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;
+        return planList;
     }
 
     @Override
-    public List<PatrolInspectionPlanSonVo> planList(String siteNubmber, Integer personnelId) {
+    public List<PatrolInspectionPlanSonVo> planList(String siteNubmber) {
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        List<Integer> personnelIdList = this.getpersonId();
         LambdaQueryWrapper<PatrolInspectionSite> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(PatrolInspectionSite::getEnable, 1);
         queryWrapper
@@ -139,7 +132,7 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
 
         LambdaQueryWrapper<PatrolInspectionPlanSchedule> queryWrapperOne = Wrappers.lambdaQuery();
         queryWrapperOne.select(PatrolInspectionPlanSchedule::getPlanId)
-                .eq(PatrolInspectionPlanSchedule::getPersonnelId, personnelId)
+                .in(PatrolInspectionPlanSchedule::getPersonnelId, personnelIdList)
                 .groupBy(PatrolInspectionPlanSchedule::getPlanId);
         List<PatrolInspectionPlanSchedule> planScheduleList = patrolInspectionPlanScheduleService.list(queryWrapperOne);
         List<PatrolInspectionPlanSonVo> list = new ArrayList<>();
@@ -175,7 +168,7 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
     @Override
     public Map<String, Object> siteDetails(Integer siteId, String siteNubmber) {
         LambdaQueryWrapper<PatrolInspectionSite> queryWrapper = Wrappers.lambdaQuery();
-//        queryWrapper.eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId());
+        queryWrapper.eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId());
         queryWrapper.eq(PatrolInspectionSite::getEnable, 1);
         if (siteId != 0 && siteId != null) {
             queryWrapper.eq(PatrolInspectionSite::getId, siteId);
@@ -348,6 +341,104 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
         return list;
     }
 
+    public List<PatrolInspectionRecordVo> recordList(String currentDate, String sort,Integer id) {
+        List<Integer> personnelIdList = this.getpersonId();
+        LambdaQueryWrapper<PatrolInspectionPlanSchedule> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.select(PatrolInspectionPlanSchedule::getPlanId)
+                .in(PatrolInspectionPlanSchedule::getPersonnelId, personnelIdList)
+                .groupBy(PatrolInspectionPlanSchedule::getPlanId);
+        List<PatrolInspectionPlanSchedule> planScheduleList = patrolInspectionPlanScheduleService.list(queryWrapper);
+        List<PatrolInspectionRecordVo> list = 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());
+            }
+            LambdaQueryWrapper<PatrolInspectionRecord> queryWrapperOne = Wrappers.lambdaQuery();
+            queryWrapperOne.in(PatrolInspectionRecord::getPlanId, planIdList)
+                    .between(PatrolInspectionRecord::getCreateTime, currentDate + " 00:00:00", currentDate + " 23:59:59");
+            if (id != null && id != 0) {
+                queryWrapperOne.eq(PatrolInspectionRecord::getId,id);
+            }
+            if (sort.equals("ASC")) {
+                queryWrapperOne.orderByAsc(PatrolInspectionRecord::getId);
+            } else {
+                queryWrapperOne.orderByDesc(PatrolInspectionRecord::getId);
+            }
+            List<PatrolInspectionRecord> recordList = patrolInspectionRecordMapper.selectList(queryWrapperOne);
+            if (recordList.size() > 0) {
+                List<Integer> siteIdList = new ArrayList<>();
+                for (int i = 0; i < recordList.size(); i++) {
+                    siteIdList.add(recordList.get(i).getSiteId());
+                }
+                LambdaQueryWrapper<PatrolInspectionSiteContent> queryWrapperTwo = Wrappers.lambdaQuery();
+                queryWrapperTwo.in(PatrolInspectionSiteContent::getSiteId, siteIdList);
+                List<PatrolInspectionSiteContent> siteContentLsit = patrolInspectionSiteContentService.list(queryWrapperTwo);
+
+                Map<Integer, List<PatrolInspectionSiteContent>> grouypByAreaId = siteContentLsit.stream().collect(
+                        Collectors.groupingBy(o -> o.getSiteId())
+                );
+                List<DataCountVo> dataCountVoList = new ArrayList<>();
+                grouypByAreaId.forEach((k, v) -> {
+                    DataCountVo dataCountVo = new DataCountVo();
+                    dataCountVo.setListCount(v.size());
+                    dataCountVo.setId(k);
+                    dataCountVoList.add(dataCountVo);
+                });
+                for (int i = 0; i < recordList.size(); i++) {
+                    PatrolInspectionRecordVo record = new PatrolInspectionRecordVo();
+                    record.setId(recordList.get(i).getId());
+                    record.setSiteNubmber(recordList.get(i).getSiteNubmber());
+                    record.setSiteType(recordList.get(i).getSiteType());
+                    record.setAreaName(recordList.get(i).getAreaName());
+                    record.setSiteName(recordList.get(i).getSiteName());
+                    record.setName(recordList.get(i).getName());
+                    record.setPhone(recordList.get(i).getPhone());
+                    record.setPlanType(recordList.get(i).getPlanType());
+                    record.setSiteStatus(recordList.get(i).getSiteStatus());
+                    record.setLongitude(recordList.get(i).getLongitude());
+                    record.setLatitude(recordList.get(i).getLatitude());
+                    record.setStartDate(recordList.get(i).getStartDate());
+                    record.setEndDate(recordList.get(i).getEndDate());
+                    record.setCreateTime(recordList.get(i).getCreateTime());
+                    record.setPlanId(recordList.get(i).getPlanId());
+                    record.setPlanSonId(recordList.get(i).getPlanSonId());
+                    record.setSiteId(recordList.get(i).getSiteId());
+                    record.setTenantId(recordList.get(i).getTenantId());
+                    record.setCompanyId(recordList.get(i).getCompanyId());
+                    record.setCreator(recordList.get(i).getCreator());
+                    record.setRemarks(recordList.get(i).getRemarks());
+                    record.setContentCount(0);
+                    for (int j = 0; j < dataCountVoList.size(); j++) {
+                        if (recordList.get(i).getSiteId() == dataCountVoList.get(i).getId()) {
+                            record.setContentCount(dataCountVoList.get(i).getListCount());
+                        }
+                    }
+                    list.add(record);
+                }
+            }
+        }
+        return list;
+    }
+
+
+    @Override
+    public List<Integer> getpersonId() {
+        LambdaQueryWrapper<PatrolInspectionPersonnel> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolInspectionPersonnel::getEnable, 1)
+                .eq(PatrolInspectionPersonnel::getTenantId, SecurityUtils.getTenantId())
+                .eq(PatrolInspectionPersonnel::getUserId, SecurityUtils.getUserId());
+        List<PatrolInspectionPersonnel> personnelList = patrolInspectionPersonnelService.list(queryWrapper);
+        if (personnelList.size() <= 0) {
+            throw new BusinessException("该用户不是巡检人员,请联系管理员");
+        }
+        List<Integer> list = new ArrayList<>();
+        for (int i = 0; i < personnelList.size(); i++) {
+            list.add(personnelList.get(i).getId());
+        }
+        return list;
+    }
+
 
     @Override
     public Integer planSiteSonCount(Integer planSonId, Integer inspectionStatus) {
@@ -377,7 +468,7 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
         LambdaQueryWrapper<PatrolInspectionContent> queryWrapperOne = Wrappers.lambdaQuery();
         queryWrapperOne.eq(PatrolInspectionContent::getEnable, 1)
                 .in(PatrolInspectionContent::getId, contentIdList);
-//        queryWrapperOne.eq(PatrolInspectionContent::getTenantId, SecurityUtils.getTenantId());
+        queryWrapperOne.eq(PatrolInspectionContent::getTenantId, SecurityUtils.getTenantId());
         List<PatrolInspectionContent> patrolInspectionContentList = patrolInspectionContentService.list(queryWrapperOne);
         List<PatrolInspectionContentVo> patrolInspectionContentVoList = new ArrayList<>();
         if (patrolInspectionContentList.size() > 0) {

+ 10 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/PatrolInspectionRecordVo.java

@@ -127,6 +127,11 @@ public class PatrolInspectionRecordVo implements Serializable {
      */
     private String creator;
 
+    /**
+     * 备注
+     */
+    private String remarks;
+
     /**
      * 图片路径
      */
@@ -137,4 +142,9 @@ public class PatrolInspectionRecordVo implements Serializable {
      */
     private List<PatrolInspectionContentVo> contentVoList;
 
+    /**
+     * 检查项数量
+     */
+    private Integer contentCount;
+
 }

+ 1 - 0
service-fire/service-fire-biz/src/main/resources/mapper/fire/PatrolInspectionRecordMapper.xml

@@ -23,6 +23,7 @@
         <result column="site_id" property="siteId" />
         <result column="tenant_id" property="tenantId" />
         <result column="company_id" property="companyId" />
+        <result column="remarks" property="remarks" />
     </resultMap>
 
 </mapper>