Browse Source

手机端-巡检自检-巡检计划-扫码查询计划

jichaobo 2 years ago
parent
commit
a948c33710

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

@@ -3,12 +3,14 @@ package com.usky.fire.controller.web;
 
 import com.usky.common.core.bean.ApiResult;
 import com.usky.fire.service.PatrolInspectionPlanSonService;
+import com.usky.fire.service.vo.PatrolInspectionPlanSonVo;
 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.List;
 import java.util.Map;
 
 /**
@@ -51,4 +53,17 @@ public class AppPatrolInspectionController {
                                                                @RequestParam(value = "sort", required = false, defaultValue = "DESC") String sort) {
         return ApiResult.success(patrolInspectionPlanSonService.patrolInspectionPlan(personnelId, currentDate, sort));
     }
+
+    /**
+     * 手机端-巡检自检-巡检计划-扫码查询计划
+     *
+     * @param personnelId 人员ID
+     * @param siteNubmber 地点号码
+     * @return
+     */
+    @GetMapping("siteDetails")
+    public ApiResult<List<PatrolInspectionPlanSonVo>> siteDetails(@RequestParam(value = "personnelId") Integer personnelId,
+                                                                  @RequestParam(value = "siteNubmber") String siteNubmber) {
+        return ApiResult.success(patrolInspectionPlanSonService.siteDetails(siteNubmber, personnelId));
+    }
 }

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

@@ -36,6 +36,15 @@ public interface PatrolInspectionPlanSonService extends CrudService<PatrolInspec
     Map<String, Object> patrolInspectionPlan(Integer personnelId, String currentDate, String sort);
 
 
+    /**
+     * 手机端-巡检自检-巡检计划-扫码查询计划
+     * @param siteNubmber 地点号码
+     * @param personnelId 人员ID
+     * @return
+     */
+    List<PatrolInspectionPlanSonVo> siteDetails(String siteNubmber, Integer personnelId);
+
+
     /**
      * 手机端-巡检自检-巡检计划列表查询
      * @param planIdList

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

@@ -76,7 +76,7 @@ public class PatrolInspectionContentServiceImpl extends AbstractCrudService<Patr
         LambdaQueryWrapper<PatrolInspectionSiteContent> queryWrapperOne = Wrappers.lambdaQuery();
         queryWrapperOne.eq(PatrolInspectionSiteContent::getContentId, patrolInspectionContentVo.getId());
         List<PatrolInspectionSiteContent> siteContentList = siteContentService.list(queryWrapperOne);
-        if (siteContentList.size() <= 0) {
+        if (siteContentList.size() > 0) {
             throw new BusinessException("巡检内容已绑定站点不可修改");
         }
         PatrolInspectionContent patrolInspectionContent = new PatrolInspectionContent();
@@ -123,7 +123,7 @@ public class PatrolInspectionContentServiceImpl extends AbstractCrudService<Patr
         LambdaQueryWrapper<PatrolInspectionSiteContent> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(PatrolInspectionSiteContent::getContentId, id);
         List<PatrolInspectionSiteContent> siteContentList = siteContentService.list(queryWrapper);
-        if (siteContentList.size() <= 0) {
+        if (siteContentList.size() > 0) {
             throw new BusinessException("巡检内容正在使用中不可删除");
         }
         PatrolInspectionContent patrolInspectionContent = new PatrolInspectionContent();

+ 56 - 5
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionPlanSonServiceImpl.java

@@ -3,15 +3,14 @@ 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.common.security.utils.SecurityUtils;
+import com.usky.fire.domain.*;
 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.PatrolInspectionSiteService;
 import com.usky.fire.service.vo.DataCountVo;
 import com.usky.fire.service.vo.PatrolInspectionPlanSonVo;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -43,6 +42,9 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
     @Autowired
     private PatrolInspectionPlanSiteSonService patrolInspectionPlanSiteSonService;
 
+    @Autowired
+    private PatrolInspectionSiteService patrolInspectionSiteService;
+
     @Override
     public Map<String, Object> appPlanStatistics(Integer personnelId, String currentDate) {
         LambdaQueryWrapper<PatrolInspectionPlanSchedule> queryWrapper = Wrappers.lambdaQuery();
@@ -70,6 +72,7 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
     }
 
 
+    @Override
     public Map<String, Object> patrolInspectionPlan(Integer personnelId, String currentDate, String sort) {
         LambdaQueryWrapper<PatrolInspectionPlanSchedule> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.select(PatrolInspectionPlanSchedule::getPlanId)
@@ -99,6 +102,52 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
         return map;
     }
 
+    @Override
+    public List<PatrolInspectionPlanSonVo> siteDetails(String siteNubmber, Integer personnelId) {
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        LambdaQueryWrapper<PatrolInspectionPlanSchedule> queryWrapperOne = Wrappers.lambdaQuery();
+        queryWrapperOne.select(PatrolInspectionPlanSchedule::getPlanId)
+                .eq(PatrolInspectionPlanSchedule::getPersonnelId, personnelId)
+                .groupBy(PatrolInspectionPlanSchedule::getPlanId);
+        List<PatrolInspectionPlanSchedule> planScheduleList = patrolInspectionPlanScheduleService.list(queryWrapperOne);
+        List<PatrolInspectionPlanSonVo> 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());
+            }
+//            formatter.format(new Date());
+            List<PatrolInspectionPlanSonVo> planSonList = this.patrolInspectionPlanSon(planIdList, "2022-09-01", "DESC");
+            LambdaQueryWrapper<PatrolInspectionSite> queryWrapper = Wrappers.lambdaQuery();
+            queryWrapper.eq(PatrolInspectionSite::getSiteNubmber, siteNubmber)
+                    .eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId());
+            List<PatrolInspectionSite> siteList = patrolInspectionSiteService.list(queryWrapper);
+//            List<Integer> siteIdList = new ArrayList<>();
+//            for (int i = 0; i < siteList.size(); i++) {
+//                siteIdList.add(siteList.get(i).getId());
+//            }
+            List<Integer> planSonIdList = new ArrayList<>();
+            for (int i = 0; i < planSonList.size(); i++) {
+                planSonIdList.add(planSonList.get(i).getId());
+            }
+            LambdaQueryWrapper<PatrolInspectionPlanSiteSon> queryWrapperTwo = Wrappers.lambdaQuery();
+            queryWrapperTwo.select(PatrolInspectionPlanSiteSon::getPlanId)
+                    .eq(PatrolInspectionPlanSiteSon::getSiteId, siteList.get(0).getId())
+                    .in(PatrolInspectionPlanSiteSon::getPlanId, planSonIdList)
+                    .eq(PatrolInspectionPlanSiteSon::getInspectionStatus, 1);
+            List<PatrolInspectionPlanSiteSon> planSiteSonList = patrolInspectionPlanSiteSonService.list(queryWrapperTwo);
+            for (int i = 0; i < planSonList.size(); i++) {
+                for (int j = 0; j < planSiteSonList.size(); j++) {
+                    if (planSonList.get(i).getId() == planSiteSonList.get(j).getPlanId()) {
+                        planSonList.get(i).setSiteId(siteList.get(i).getId());
+                        list.add(planSonList.get(i));
+                    }
+                }
+            }
+        }
+        return list;
+    }
+
 
     @Override
     public List<PatrolInspectionPlanSonVo> patrolInspectionPlanSon(List<Integer> planIdList, String currentDate, String sort) {
@@ -106,6 +155,7 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
         DateTimeFormatter df1 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         LambdaQueryWrapper<PatrolInspectionPlanSon> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolInspectionPlanSon::getTenantId, SecurityUtils.getTenantId());
         if (planIdList != null && planIdList.size() > 0) {
             queryWrapper.in(PatrolInspectionPlanSon::getPlanId, planIdList);
         }
@@ -129,6 +179,7 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
             }
             //巡检计划名称查询
             LambdaQueryWrapper<PatrolInspectionPlan> queryWrapperOne = Wrappers.lambdaQuery();
+            queryWrapperOne.eq(PatrolInspectionPlan::getTenantId, SecurityUtils.getTenantId());
             queryWrapperOne.select(PatrolInspectionPlan::getId, PatrolInspectionPlan::getPlanName);
             if (planIdList != null && planIdList.size() > 0) {
                 queryWrapperOne.in(PatrolInspectionPlan::getId, planIdList);
@@ -218,7 +269,6 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
 
     @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);
@@ -245,6 +295,7 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
     public Integer planSonCount(List<Integer> planIdList, Integer completion, String currentDate) {
         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         LambdaQueryWrapper<PatrolInspectionPlanSon> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolInspectionPlanSon::getTenantId, SecurityUtils.getTenantId());
         if (planIdList != null && planIdList.size() > 0) {
             queryWrapper.in(PatrolInspectionPlanSon::getPlanId, planIdList);
         }

+ 5 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/PatrolInspectionPlanSonVo.java

@@ -156,4 +156,9 @@ public class PatrolInspectionPlanSonVo implements Serializable {
      */
     private String planTypeDescribe;
 
+    /**
+     * 点位ID
+     */
+    private Integer siteId;
+
 }