jichaobo 2 лет назад
Родитель
Сommit
27fd525963

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

@@ -70,6 +70,12 @@ public class PatrolInspectionContentServiceImpl extends AbstractCrudService<Patr
     @Override
     @Transactional
     public void updatePatrolInspectionContent(PatrolInspectionContentVo patrolInspectionContentVo) {
+        LambdaQueryWrapper<SiteContent> queryWrapperOne = Wrappers.lambdaQuery();
+        queryWrapperOne.eq(SiteContent::getContentId,patrolInspectionContentVo.getId());
+        List<SiteContent> siteContentList = siteContentService.list(queryWrapperOne);
+        if (siteContentList.size()<=0){
+            throw new BusinessException("巡检内容已绑定站点不可修改");
+        }
         PatrolInspectionContent patrolInspectionContent = new PatrolInspectionContent();
         patrolInspectionContent.setId(patrolInspectionContentVo.getId());
         patrolInspectionContent.setContentTitle(patrolInspectionContentVo.getContentTitle());
@@ -114,7 +120,7 @@ public class PatrolInspectionContentServiceImpl extends AbstractCrudService<Patr
         LambdaQueryWrapper<SiteContent> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(SiteContent::getContentId, id);
         List<SiteContent> siteContentList = siteContentService.list(queryWrapper);
-        if (siteContentList.size() > 0) {
+        if (siteContentList.size() <= 0) {
             throw new BusinessException("巡检内容正在使用中不可删除");
         }
         PatrolInspectionContent patrolInspectionContent = new PatrolInspectionContent();

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

@@ -3,15 +3,17 @@ 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.bean.CommonPage;
+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.PatrolInspectionArea;
-import com.usky.fire.domain.PatrolInspectionContent;
 import com.usky.fire.domain.PatrolInspectionSite;
+import com.usky.fire.domain.PlanSite;
 import com.usky.fire.domain.SiteContent;
 import com.usky.fire.mapper.PatrolInspectionSiteMapper;
 import com.usky.fire.service.PatrolInspectionAreaService;
 import com.usky.fire.service.PatrolInspectionSiteService;
+import com.usky.fire.service.PlanSiteService;
 import com.usky.fire.service.SiteContentService;
 import com.usky.fire.service.util.OnlineMethod;
 import com.usky.fire.service.vo.DataCountVo;
@@ -42,6 +44,9 @@ public class PatrolInspectionSiteServiceImpl extends AbstractCrudService<PatrolI
     @Autowired
     private SiteContentService siteContentService;
 
+    @Autowired
+    private PlanSiteService planSiteService;
+
     @Override
     public List<PatrolInspectionAreaVo> areaLeftList() {
         LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
@@ -125,11 +130,23 @@ public class PatrolInspectionSiteServiceImpl extends AbstractCrudService<PatrolI
 
     @Override
     public void updatePatrolInspectionSite(PatrolInspectionSite patrolInspectionSite) {
+        LambdaQueryWrapper<PlanSite> queryWrapperOne = Wrappers.lambdaQuery();
+        queryWrapperOne.eq(PlanSite::getSiteId, patrolInspectionSite.getId());
+        List<PlanSite> planSiteList = planSiteService.list(queryWrapperOne);
+        if (planSiteList.size() <= 0) {
+            throw new BusinessException("巡检地点已绑定计划不可修改");
+        }
         this.updateById(patrolInspectionSite);
     }
 
     @Override
     public void delPatrolInspectionSite(Integer id) {
+        LambdaQueryWrapper<PlanSite> queryWrapperOne = Wrappers.lambdaQuery();
+        queryWrapperOne.eq(PlanSite::getSiteId, id);
+        List<PlanSite> planSiteList = planSiteService.list(queryWrapperOne);
+        if (planSiteList.size() <= 0) {
+            throw new BusinessException("巡检地点已绑定计划不可删除");
+        }
         PatrolInspectionSite patrolInspectionSite = new PatrolInspectionSite();
         patrolInspectionSite.setId(id);
         patrolInspectionSite.setEnable(0);