Browse Source

手机端-巡检自检-巡检扫码地点详情

jichaobo 2 years ago
parent
commit
3b5cb7680d

+ 17 - 3
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/AppPatrolInspectionController.java

@@ -61,9 +61,23 @@ public class AppPatrolInspectionController {
      * @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));
+    }
+
+
+    /**
+     * 手机端-巡检自检-巡检扫码地点详情
+     *
+     * @param siteId      地点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));
+    public ApiResult<Map<String, Object>> siteDetails(@RequestParam(value = "siteId") Integer siteId,
+                                                      @RequestParam(value = "siteNubmber") String siteNubmber) {
+        return ApiResult.success(patrolInspectionPlanSonService.siteDetails(siteId, siteNubmber));
     }
 }

+ 23 - 1
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionPlanSonService.java

@@ -3,6 +3,7 @@ package com.usky.fire.service;
 import com.usky.common.mybatis.core.CrudService;
 import com.usky.fire.domain.PatrolInspectionPlanSon;
 import com.usky.fire.service.vo.DataCountVo;
+import com.usky.fire.service.vo.PatrolInspectionContentVo;
 import com.usky.fire.service.vo.PatrolInspectionPlanSonVo;
 
 import java.util.List;
@@ -28,6 +29,7 @@ public interface PatrolInspectionPlanSonService extends CrudService<PatrolInspec
 
     /**
      * 手机端-巡检自检-巡检计划
+     *
      * @param personnelId
      * @param currentDate
      * @param sort
@@ -38,15 +40,35 @@ public interface PatrolInspectionPlanSonService extends CrudService<PatrolInspec
 
     /**
      * 手机端-巡检自检-巡检计划-扫码查询计划
+     *
      * @param siteNubmber 地点号码
      * @param personnelId 人员ID
      * @return
      */
-    List<PatrolInspectionPlanSonVo> siteDetails(String siteNubmber, Integer personnelId);
+    List<PatrolInspectionPlanSonVo> planList(String siteNubmber, Integer personnelId);
 
 
+    /**
+     * 手机端-巡检自检-巡检扫码地点详情
+     *
+     * @param siteId      地点ID
+     * @param siteNubmber 地点号码
+     * @return
+     */
+    Map<String, Object> siteDetails(Integer siteId, String siteNubmber);
+
+
+    /**
+     * 手机端-巡检自检-根据巡检地点ID查巡检内容
+     *
+     * @param siteId 地点ID
+     * @return
+     */
+    List<PatrolInspectionContentVo> contentList(Integer siteId);
+
     /**
      * 手机端-巡检自检-巡检计划列表查询
+     *
      * @param planIdList
      * @param currentDate
      * @param sort

+ 109 - 15
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionPlanSonServiceImpl.java

@@ -2,16 +2,15 @@ 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.core.exception.BusinessException;
 import com.usky.common.mybatis.core.AbstractCrudService;
 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.*;
 import com.usky.fire.service.vo.DataCountVo;
+import com.usky.fire.service.vo.PatrolInspectionContentVo;
 import com.usky.fire.service.vo.PatrolInspectionPlanSonVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -45,6 +44,15 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
     @Autowired
     private PatrolInspectionSiteService patrolInspectionSiteService;
 
+    @Autowired
+    private PatrolInspectionSiteContentService patrolInspectionSiteContentService;
+
+    @Autowired
+    private PatrolInspectionContentService patrolInspectionContentService;
+
+    @Autowired
+    private PatrolInspectionContentOptionService patrolInspectionContentOptionService;
+
     @Override
     public Map<String, Object> appPlanStatistics(Integer personnelId, String currentDate) {
         LambdaQueryWrapper<PatrolInspectionPlanSchedule> queryWrapper = Wrappers.lambdaQuery();
@@ -103,8 +111,18 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
     }
 
     @Override
-    public List<PatrolInspectionPlanSonVo> siteDetails(String siteNubmber, Integer personnelId) {
+    public List<PatrolInspectionPlanSonVo> planList(String siteNubmber, Integer personnelId) {
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        LambdaQueryWrapper<PatrolInspectionSite> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolInspectionSite::getEnable, 1);
+        queryWrapper
+                .eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId())
+                .eq(PatrolInspectionSite::getSiteNubmber, siteNubmber);
+        List<PatrolInspectionSite> siteList = patrolInspectionSiteService.list(queryWrapper);
+        if (siteList.size() <= 0) {
+            throw new BusinessException("无效地点,请联系管理人员添加点位");
+        }
+
         LambdaQueryWrapper<PatrolInspectionPlanSchedule> queryWrapperOne = Wrappers.lambdaQuery();
         queryWrapperOne.select(PatrolInspectionPlanSchedule::getPlanId)
                 .eq(PatrolInspectionPlanSchedule::getPersonnelId, personnelId)
@@ -116,17 +134,7 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
             for (int i = 0; i < planScheduleList.size(); i++) {
                 planIdList.add(planScheduleList.get(i).getPlanId());
             }
-//            ;
             List<PatrolInspectionPlanSonVo> planSonList = this.patrolInspectionPlanSon(planIdList, formatter.format(new Date()), "DESC");
-            LambdaQueryWrapper<PatrolInspectionSite> queryWrapper = Wrappers.lambdaQuery();
-            queryWrapper
-                    .eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId())
-                    .eq(PatrolInspectionSite::getSiteNubmber, siteNubmber);
-            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());
@@ -150,6 +158,91 @@ 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::getEnable, 1);
+        if (siteId != 0 && siteId != null) {
+            queryWrapper.eq(PatrolInspectionSite::getId, siteId);
+        }
+        if (siteNubmber != null && !"".equals(siteNubmber)) {
+            queryWrapper.eq(PatrolInspectionSite::getSiteNubmber, siteNubmber);
+        }
+        List<PatrolInspectionSite> siteList = patrolInspectionSiteService.list(queryWrapper);
+        if (siteList.size() <= 0) {
+            throw new BusinessException("无效地点,请联系管理人员添加点位");
+        }
+        List<PatrolInspectionContentVo> contentList = this.contentList(siteList.get(0).getId());
+        Map<String, Object> map = new HashMap<>();
+        map.put("siteList", siteList);
+        map.put("contentList", contentList);
+        map.put("contentCount", contentList.size());
+        return map;
+    }
+
+    public void updatePlan(){
+
+    }
+
+
+    @Override
+    public List<PatrolInspectionContentVo> contentList(Integer siteId) {
+        LambdaQueryWrapper<PatrolInspectionSiteContent> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.select(PatrolInspectionSiteContent::getContentId)
+                .eq(PatrolInspectionSiteContent::getSiteId, siteId);
+        List<PatrolInspectionSiteContent> contentId = patrolInspectionSiteContentService.list(queryWrapper);
+        if (contentId.size() <= 0) {
+            throw new BusinessException("地点尚未分配内容,请联系管理人员");
+        }
+        List<Integer> contentIdList = new ArrayList<>();
+        for (int i = 0; i < contentId.size(); i++) {
+            contentIdList.add(contentId.get(i).getContentId());
+        }
+
+
+        LambdaQueryWrapper<PatrolInspectionContent> queryWrapperOne = Wrappers.lambdaQuery();
+        queryWrapperOne.eq(PatrolInspectionContent::getEnable, 1)
+                .in(PatrolInspectionContent::getId, contentIdList);
+//        queryWrapperOne.eq(PatrolInspectionContent::getTenantId, SecurityUtils.getTenantId());
+        List<PatrolInspectionContent> patrolInspectionContentList = patrolInspectionContentService.list(queryWrapperOne);
+        List<PatrolInspectionContentVo> patrolInspectionContentVoList = new ArrayList<>();
+        if (patrolInspectionContentList.size() > 0) {
+            List<Integer> idList = new ArrayList<>();
+            for (int i = 0; i < patrolInspectionContentList.size(); i++) {
+                idList.add(patrolInspectionContentList.get(i).getId());
+            }
+            LambdaQueryWrapper<PatrolInspectionContentOption> queryWrapperTwo = Wrappers.lambdaQuery();
+            queryWrapperTwo.eq(PatrolInspectionContentOption::getEnable, 1)
+                    .in(PatrolInspectionContentOption::getContentId, idList);
+            List<PatrolInspectionContentOption> contentOptionList = patrolInspectionContentOptionService.list(queryWrapperTwo);
+            for (int i = 0; i < patrolInspectionContentList.size(); i++) {
+                PatrolInspectionContentVo patrolInspectionContentVo = new PatrolInspectionContentVo();
+                patrolInspectionContentVo.setXh(i + 1);
+                patrolInspectionContentVo.setId(patrolInspectionContentList.get(i).getId());
+                patrolInspectionContentVo.setContentTitle(patrolInspectionContentList.get(i).getContentTitle());
+                patrolInspectionContentVo.setContentDescribe(patrolInspectionContentList.get(i).getContentDescribe());
+                patrolInspectionContentVo.setSubmissionMethod(patrolInspectionContentList.get(i).getSubmissionMethod());
+                patrolInspectionContentVo.setTenantId(patrolInspectionContentList.get(i).getTenantId());
+                patrolInspectionContentVo.setCompanyId(patrolInspectionContentList.get(i).getCompanyId());
+                patrolInspectionContentVo.setCreator(patrolInspectionContentList.get(i).getCreator());
+                patrolInspectionContentVo.setCreateTime(patrolInspectionContentList.get(i).getCreateTime());
+                patrolInspectionContentVo.setEnable(patrolInspectionContentList.get(i).getEnable());
+                List<PatrolInspectionContentOption> contentOptionListOne = new ArrayList<>();
+                for (int j = 0; j < contentOptionList.size(); j++) {
+                    if (patrolInspectionContentList.get(i).getId() == contentOptionList.get(j).getContentId()) {
+                        contentOptionListOne.add(contentOptionList.get(j));
+                    }
+                }
+                patrolInspectionContentVo.setContentOptionList(contentOptionListOne);
+                patrolInspectionContentVoList.add(patrolInspectionContentVo);
+            }
+
+        }
+        return patrolInspectionContentVoList;
+    }
+
+
     @Override
     public List<PatrolInspectionPlanSonVo> patrolInspectionPlanSon(List<Integer> planIdList, String currentDate, String sort) {
 //        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@@ -181,6 +274,7 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
             //巡检计划名称查询
             LambdaQueryWrapper<PatrolInspectionPlan> queryWrapperOne = Wrappers.lambdaQuery();
             queryWrapperOne.eq(PatrolInspectionPlan::getTenantId, SecurityUtils.getTenantId());
+            queryWrapperOne.eq(PatrolInspectionPlan::getEnable, 1);
             queryWrapperOne.select(PatrolInspectionPlan::getId, PatrolInspectionPlan::getPlanName);
             if (planIdList != null && planIdList.size() > 0) {
                 queryWrapperOne.in(PatrolInspectionPlan::getId, planIdList);

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

@@ -163,7 +163,7 @@ public class PatrolInspectionSiteServiceImpl extends AbstractCrudService<PatrolI
         LambdaQueryWrapper<PatrolInspectionPlanSite> queryWrapperOne = Wrappers.lambdaQuery();
         queryWrapperOne.eq(PatrolInspectionPlanSite::getSiteId, patrolInspectionSite.getId());
         List<PatrolInspectionPlanSite> planSiteList = planSiteService.list(queryWrapperOne);
-        if (planSiteList.size() <= 0) {
+        if (planSiteList.size() > 0) {
             throw new BusinessException("巡检地点已绑定计划不可修改");
         }
         this.updateById(patrolInspectionSite);
@@ -174,7 +174,7 @@ public class PatrolInspectionSiteServiceImpl extends AbstractCrudService<PatrolI
         LambdaQueryWrapper<PatrolInspectionPlanSite> queryWrapperOne = Wrappers.lambdaQuery();
         queryWrapperOne.eq(PatrolInspectionPlanSite::getSiteId, id);
         List<PatrolInspectionPlanSite> planSiteList = planSiteService.list(queryWrapperOne);
-        if (planSiteList.size() <= 0) {
+        if (planSiteList.size() > 0) {
             throw new BusinessException("巡检地点已绑定计划不可删除");
         }
         PatrolInspectionSite patrolInspectionSite = new PatrolInspectionSite();