Browse Source

增加来源

shiyue 1 year ago
parent
commit
054cb8400f

+ 6 - 3
energy-manage-service/src/main/java/com/energy/manage/service/controller/company/WindCompanyController.java

@@ -13,6 +13,7 @@ import com.energy.manage.service.domain.vo.windfield.WindFieldVo;
 import com.energy.manage.service.service.company.WindCompanyService;
 import com.energy.manage.service.service.system.SysOrganizationAuthService;
 import com.energy.manage.service.service.windfield.WindFieldService;
+import com.energy.manage.service.service.windrelation.WindRelationService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -38,7 +39,7 @@ public class WindCompanyController extends BaseServiceController {
     private WindFieldService windFieldService;
 
     @Autowired
-    private SysOrganizationAuthService sysOrganizationAuthService;
+    private WindRelationService windRelationService;
 
 
     @UserLoginToken
@@ -68,9 +69,11 @@ public class WindCompanyController extends BaseServiceController {
         if (list.size() > 0) {
             return ResultResp.FAIL("项目公司有绑定风场不可删除!");
         }
-        if(!sysOrganizationAuthService.verifySysOrganizationAuthByType(dto.getCompanyCode(), TypeRelationEnum.COMPANY_NUMBER.getCode())){
-            return ResultResp.FAIL("企业有绑定数据权限不可删除!");
+        int number = windRelationService.getCountParentCode(dto.getCompanyCode());
+        if(number>0){
+            return ResultResp.FAIL("该项目公司下有子公司不可删除!");
         }
+
         boolean flg = windCompanyService.delCompany(dto);
         return flg ? ResultResp.SUCCESS() : ResultResp.FAIL();
     }

+ 10 - 2
energy-manage-service/src/main/java/com/energy/manage/service/controller/windfield/WindFieldController.java

@@ -9,11 +9,13 @@ import com.energy.manage.common.reponse.ResultResp;
 import com.energy.manage.service.config.annotations.UserLoginToken;
 import com.energy.manage.service.controller.base.BaseServiceController;
 import com.energy.manage.service.domain.dto.windfield.*;
+import com.energy.manage.service.domain.vo.anemometertower.AnemometerTowerByFieldVo;
 import com.energy.manage.service.domain.vo.company.WindCompanyPageVo;
 import com.energy.manage.service.domain.vo.windfield.WindFieldNameVo;
 import com.energy.manage.service.domain.vo.windfield.WindFieldPageVo;
 import com.energy.manage.service.domain.vo.windfield.WindFieldVo;
 import com.energy.manage.service.domain.vo.windrelation.WindRelationVo;
+import com.energy.manage.service.service.anemometertower.AnemometerTowerService;
 import com.energy.manage.service.service.system.SysOrganizationAuthService;
 import com.energy.manage.service.service.windenginegroup.WindEngineGroupService;
 import com.energy.manage.service.service.windfield.WindFieldResourceService;
@@ -22,6 +24,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -48,6 +51,10 @@ public class WindFieldController extends BaseServiceController {
     @Autowired
     private SysOrganizationAuthService sysOrganizationAuthService;
 
+    @Autowired
+    private AnemometerTowerService anemometerTowerService;
+
+
 
     @UserLoginToken
     @PostMapping(value = "/createWindField")
@@ -104,8 +111,9 @@ public class WindFieldController extends BaseServiceController {
         if (windEngineGroupService.getWindEngineGroupCountByField(windFieldCodeDto.getFieldCode()) > 0) {
             return ResultResp.FAIL("风场下有绑定风机,不可删除!");
         }
-        if(!sysOrganizationAuthService.verifySysOrganizationAuthByType(windFieldCodeDto.getFieldCode(), TypeRelationEnum.WIND_FIELD_NUMBER.getCode())){
-            return ResultResp.FAIL("风场有绑定数据权限不可删除!");
+        List<AnemometerTowerByFieldVo>  list = anemometerTowerService.getAnemometerTowerByField(windFieldCodeDto.getFieldCode());
+        if(!CollectionUtils.isEmpty(list)){
+            return ResultResp.FAIL("风场有绑定测风塔不可删除!");
         }
         boolean flg = windFieldService.delWindFieldById(windFieldCodeDto.getFieldCode());
         return flg ? ResultResp.SUCCESS() : ResultResp.FAIL();

+ 9 - 0
energy-manage-service/src/main/java/com/energy/manage/service/service/company/impl/WindCompanyServiceImpl.java

@@ -24,6 +24,7 @@ import com.energy.manage.service.mappers.system.SysPermissionMapper;
 import com.energy.manage.service.mappers.system.SysRolePermissionMapper;
 import com.energy.manage.service.service.cache.CacheService;
 import com.energy.manage.service.service.company.WindCompanyService;
+import com.energy.manage.service.service.system.SysOrganizationAuthService;
 import com.energy.manage.service.service.system.SysPermissionService;
 import com.energy.manage.service.service.windrelation.WindRelationService;
 import com.energy.manage.service.util.BeanMapUtils;
@@ -54,6 +55,9 @@ public class WindCompanyServiceImpl extends BaseServiceImpl<WindCompanyPO> imple
     @Autowired
     private WindCompanyMapper windCompanyMapper;
 
+    @Autowired
+    private SysOrganizationAuthService sysOrganizationAuthService;
+
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -83,6 +87,11 @@ public class WindCompanyServiceImpl extends BaseServiceImpl<WindCompanyPO> imple
         if (windCompanyMapper.updateByExampleSelective(po, queryExample) <= 0) {
             return false;
         }
+
+        // 删除数据权限
+        sysOrganizationAuthService.delSysOrganizationAuth(dto.getCompanyCode(),TypeRelationEnum.COMPANY_NUMBER.getCode());
+
+        // 删除树形结构
         WindRelationDelDto windRelationDelDto = new WindRelationDelDto();
         windRelationDelDto.setCodeNumber(dto.getCompanyCode());
         windRelationDelDto.setType(TypeRelationEnum.COMPANY_NUMBER.getCode());

+ 6 - 0
energy-manage-service/src/main/java/com/energy/manage/service/service/system/SysOrganizationAuthService.java

@@ -57,5 +57,11 @@ public interface SysOrganizationAuthService {
     CompanyFieldNumberVo getCompanyFieldNumberVo(Integer roleId);
 
 
+    /**
+     * 删除数据权限对应codee
+     * @param codeNumber
+     * @return
+     */
+    int delSysOrganizationAuth(String codeNumber,String type);
 
 }

+ 9 - 0
energy-manage-service/src/main/java/com/energy/manage/service/service/system/impl/SysOrganizationAuthServiceImpl.java

@@ -132,5 +132,14 @@ public class SysOrganizationAuthServiceImpl implements SysOrganizationAuthServic
         return companyFieldNumberVo;
     }
 
+    @Override
+    public int delSysOrganizationAuth(String codeNumber,String type) {
+        Example queryExample = new Example(SysOrganizationAuthPO.class);
+        Example.Criteria criteria = queryExample.createCriteria();
+        criteria.andEqualTo("codeNumber", codeNumber);
+        criteria.andEqualTo("codeType", type);
+        return sysOrganizationAuthMapper.deleteByExample(queryExample);
+    }
+
 
 }

+ 9 - 0
energy-manage-service/src/main/java/com/energy/manage/service/service/windfield/impl/WindFieldServiceImpl.java

@@ -39,6 +39,7 @@ import com.energy.manage.service.service.anemometertower.AnemometerTowerService;
 import com.energy.manage.service.service.area.AreaApiService;
 import com.energy.manage.service.service.cache.CacheService;
 import com.energy.manage.service.service.company.WindCompanyService;
+import com.energy.manage.service.service.system.SysOrganizationAuthService;
 import com.energy.manage.service.service.windfield.WindFieldResourceService;
 import com.energy.manage.service.service.windfield.WindFieldService;
 import com.energy.manage.service.service.windrelation.WindRelationService;
@@ -90,6 +91,10 @@ public class WindFieldServiceImpl extends BaseServiceImpl<WindFieldPO> implement
     private WindRelationService windRelationService;
 
 
+    @Autowired
+    private SysOrganizationAuthService sysOrganizationAuthService;
+
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean createWindField(WindFieldDto windFieldDto) {
@@ -287,6 +292,10 @@ public class WindFieldServiceImpl extends BaseServiceImpl<WindFieldPO> implement
         if (windFieldMapper.updateByExampleSelective(windFieldPO, queryExample) <= 0) {
             return false;
         }
+
+        // 删除数据权限
+        sysOrganizationAuthService.delSysOrganizationAuth(fieldCode,TypeRelationEnum.WIND_FIELD_NUMBER.getCode());
+
         WindRelationDelDto windRelationDelDto = new WindRelationDelDto();
         windRelationDelDto.setCodeNumber(fieldCode);
         windRelationDelDto.setType(TypeRelationEnum.WIND_FIELD_NUMBER.getCode());

+ 7 - 0
energy-manage-service/src/main/java/com/energy/manage/service/service/windrelation/WindRelationService.java

@@ -60,4 +60,11 @@ public interface WindRelationService {
      */
     List<Map<String, Object>> getWindRelationTree();
 
+    /**
+     * 通过企业code查询下级单位
+     * @param fieldCode
+     * @return
+     */
+    int getCountParentCode(String fieldCode);
+
 }

+ 10 - 0
energy-manage-service/src/main/java/com/energy/manage/service/service/windrelation/impl/WindRelationServiceImpl.java

@@ -122,4 +122,14 @@ public class WindRelationServiceImpl extends BaseServiceImpl<WindRelationPO> imp
     }
 
 
+    @Override
+    public int getCountParentCode(String fieldCode) {
+        Example queryExample = new Example(WindRelationPO.class);
+        Example.Criteria criteria = queryExample.createCriteria();
+        criteria.andEqualTo("parentCode",fieldCode);
+        criteria.andEqualTo("type",TypeRelationEnum.COMPANY_NUMBER.getCode());
+        return  windRelationMapper.selectCountByExample(queryExample);
+    }
+
+
 }