浏览代码

修复巡检相关BUG

hanzhengyi 1 周之前
父节点
当前提交
6b29637ae3

+ 4 - 1
service-fire/service-fire-biz/src/main/java/com/usky/fire/mapper/PatrolInspectionSiteMapper.java

@@ -2,8 +2,11 @@ package com.usky.fire.mapper;
 
 
 import com.usky.common.mybatis.core.CrudMapper;
 import com.usky.common.mybatis.core.CrudMapper;
 import com.usky.fire.domain.PatrolInspectionSite;
 import com.usky.fire.domain.PatrolInspectionSite;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 import org.springframework.stereotype.Repository;
 
 
+import java.util.List;
+
 /**
 /**
  * <p>
  * <p>
  * Mapper 接口
  * Mapper 接口
@@ -14,5 +17,5 @@ import org.springframework.stereotype.Repository;
  */
  */
 @Repository
 @Repository
 public interface PatrolInspectionSiteMapper extends CrudMapper<PatrolInspectionSite> {
 public interface PatrolInspectionSiteMapper extends CrudMapper<PatrolInspectionSite> {
-
+    int selectSiteCount(@Param("ids") List<Integer> ids);
 }
 }

+ 2 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionSiteService.java

@@ -46,4 +46,6 @@ public interface PatrolInspectionSiteService extends CrudService<PatrolInspectio
 
 
     void patrolInspectionSiteImport(MultipartFile multipartFile);
     void patrolInspectionSiteImport(MultipartFile multipartFile);
 
 
+    int siteCount(List<Integer> ids);
+
 }
 }

+ 20 - 4
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionAreaServiceImpl.java

@@ -9,7 +9,9 @@ import com.usky.common.core.exception.BusinessException;
 import com.usky.common.mybatis.core.AbstractCrudService;
 import com.usky.common.mybatis.core.AbstractCrudService;
 import com.usky.common.security.utils.SecurityUtils;
 import com.usky.common.security.utils.SecurityUtils;
 import com.usky.fire.domain.PatrolInspectionArea;
 import com.usky.fire.domain.PatrolInspectionArea;
+import com.usky.fire.domain.PatrolInspectionSite;
 import com.usky.fire.mapper.PatrolInspectionAreaMapper;
 import com.usky.fire.mapper.PatrolInspectionAreaMapper;
+import com.usky.fire.mapper.PatrolInspectionSiteMapper;
 import com.usky.fire.service.BaseCompanyService;
 import com.usky.fire.service.BaseCompanyService;
 import com.usky.fire.service.PatrolInspectionAreaService;
 import com.usky.fire.service.PatrolInspectionAreaService;
 import com.usky.fire.service.vo.PatrolInspectionAreaVo;
 import com.usky.fire.service.vo.PatrolInspectionAreaVo;
@@ -42,6 +44,9 @@ public class PatrolInspectionAreaServiceImpl extends AbstractCrudService<PatrolI
     @Autowired
     @Autowired
     private RemoteDeptService remoteDeptService;
     private RemoteDeptService remoteDeptService;
 
 
+    @Autowired
+    private PatrolInspectionSiteMapper patrolInspectionSiteMapper;
+
     /**
     /**
      * 巡查自检-巡检区域-新增
      * 巡查自检-巡检区域-新增
      *
      *
@@ -161,18 +166,29 @@ public class PatrolInspectionAreaServiceImpl extends AbstractCrudService<PatrolI
         LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
         LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(PatrolInspectionArea::getEnable, 1).eq(PatrolInspectionArea::getAreaFid, id);
         queryWrapper.eq(PatrolInspectionArea::getEnable, 1).eq(PatrolInspectionArea::getAreaFid, id);
         List<PatrolInspectionArea> patrolInspectionArealist = this.list(queryWrapper);
         List<PatrolInspectionArea> patrolInspectionArealist = this.list(queryWrapper);
+        List<Integer> areaIdList = new ArrayList<>();
+        int siteNum = 0;
         if (null != patrolInspectionArealist && !patrolInspectionArealist.isEmpty()) {
         if (null != patrolInspectionArealist && !patrolInspectionArealist.isEmpty()) {
+            for (int j = 0; j < patrolInspectionArealist.size(); j++) {
+                areaIdList.add(patrolInspectionArealist.get(j).getId());
+            }
+            areaIdList.add(id);
+            siteNum = patrolInspectionSiteMapper.selectSiteCount(areaIdList);
+        }
+        if (siteNum>0){
             for (int i = 0; i < patrolInspectionArealist.size(); i++) {
             for (int i = 0; i < patrolInspectionArealist.size(); i++) {
                 PatrolInspectionArea patrolInspectionAreaz = new PatrolInspectionArea();
                 PatrolInspectionArea patrolInspectionAreaz = new PatrolInspectionArea();
                 patrolInspectionAreaz.setId(patrolInspectionArealist.get(i).getId());
                 patrolInspectionAreaz.setId(patrolInspectionArealist.get(i).getId());
                 patrolInspectionAreaz.setEnable(0);
                 patrolInspectionAreaz.setEnable(0);
                 this.updateById(patrolInspectionAreaz);
                 this.updateById(patrolInspectionAreaz);
             }
             }
+            PatrolInspectionArea patrolInspectionArea = new PatrolInspectionArea();
+            patrolInspectionArea.setId(id);
+            patrolInspectionArea.setEnable(0);
+            this.updateById(patrolInspectionArea);
+        }else {
+            throw new BusinessException("区域下有绑定的点位,请解绑后再删除!");
         }
         }
-        PatrolInspectionArea patrolInspectionArea = new PatrolInspectionArea();
-        patrolInspectionArea.setId(id);
-        patrolInspectionArea.setEnable(0);
-        this.updateById(patrolInspectionArea);
     }
     }
 
 
     /**
     /**

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

@@ -276,7 +276,7 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
         }
         }
         List<Integer> planSonidListTwo = this.getPlanSon(null, null);
         List<Integer> planSonidListTwo = this.getPlanSon(null, null);
         if (planSonidListTwo.size() > 0) {
         if (planSonidListTwo.size() > 0) {
-            siteCount = this.getPlanSiteSonCount(planSonidListTwo, 0);
+            siteCount = this.getPlanSiteSonCount(planSonidListTwo, 2);
             siteCountLeak = this.getPlanSiteSonCount(planSonidListTwo, 1);
             siteCountLeak = this.getPlanSiteSonCount(planSonidListTwo, 1);
         }
         }
         RecordStatisticsVo recordStatisticsVo = new RecordStatisticsVo();
         RecordStatisticsVo recordStatisticsVo = new RecordStatisticsVo();
@@ -300,7 +300,7 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
     public Integer getPlanSiteSonCount(List<Integer> planSonidList, Integer inspectionStatus) {
     public Integer getPlanSiteSonCount(List<Integer> planSonidList, Integer inspectionStatus) {
         LambdaQueryWrapper<PatrolInspectionPlanSiteSon> queryWrapper = Wrappers.lambdaQuery();
         LambdaQueryWrapper<PatrolInspectionPlanSiteSon> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.in(PatrolInspectionPlanSiteSon::getPlanId, planSonidList);
         queryWrapper.in(PatrolInspectionPlanSiteSon::getPlanId, planSonidList);
-        if (inspectionStatus != 0 && inspectionStatus != null) {
+        if (inspectionStatus.equals(1)||inspectionStatus.equals(2)){
             queryWrapper.eq(PatrolInspectionPlanSiteSon::getInspectionStatus, inspectionStatus);
             queryWrapper.eq(PatrolInspectionPlanSiteSon::getInspectionStatus, inspectionStatus);
         }
         }
         Integer taskCount = planSiteSonService.count(queryWrapper);
         Integer taskCount = planSiteSonService.count(queryWrapper);

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

@@ -338,4 +338,14 @@ public class PatrolInspectionSiteServiceImpl extends AbstractCrudService<PatrolI
         Set<T> set = new HashSet<>(list);
         Set<T> set = new HashSet<>(list);
         return new ArrayList<>(set);
         return new ArrayList<>(set);
     }
     }
+
+    @Override
+    public int siteCount(List<Integer> ids){
+        LambdaQueryWrapper<PatrolInspectionSite> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolInspectionSite::getEnable, 1)
+                .in(PatrolInspectionSite::getAreaId, ids);
+        int siteCounts = this.count(queryWrapper);
+        List<Integer> siteIdList = new ArrayList<>();
+        return siteCounts;
+    }
 }
 }

+ 10 - 0
service-fire/service-fire-biz/src/main/resources/mapper/fire/PatrolInspectionSiteMapper.xml

@@ -23,4 +23,14 @@
         <result column="company_id" property="companyId" />
         <result column="company_id" property="companyId" />
     </resultMap>
     </resultMap>
 
 
+    <select id="selectSiteCount" resultType="java.lang.Integer">
+        select count(*)
+        from patrol_inspection_site AS a
+        <where>
+            <if test="ids != null">
+                and a.area_id in #{ids}
+            </if>
+        </where>
+    </select>
+
 </mapper>
 </mapper>