diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index f10e88c565..dc329f28f8 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -67,6 +67,7 @@ public enum EpmetErrorCode { NOT_DEL_AGENCY(8202, "该机关存在下级机关,不允许删除"), NOT_DEL_AGENCY_PER(8205, "该机关存在工作人员,不允许删除"), NOT_DEL_DEPARTMENT(8206, "该部门存在工作人员,不允许删除"), + NOT_DEL_AGENCY_GRID(8207, "该机关存在网格,不允许删除"), REQUIRE_PERMISSION(8301, "您没有足够的操作权限"), diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java index 8fbd617cf2..afb9739daa 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java @@ -26,6 +26,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.constant.CustomerAgencyConstant; import com.epmet.constant.RoleKeyConstants; import com.epmet.dao.CustomerAgencyDao; +import com.epmet.dao.CustomerGridDao; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.GovStaffRoleDTO; import com.epmet.dto.form.*; @@ -64,6 +65,8 @@ public class AgencyServiceImpl implements AgencyService { private EpmetUserOpenFeignClient epmetUserOpenFeignClient; @Autowired private StaffServiceImpl staffServiceImpl; + @Autowired + private CustomerGridDao customerGridDao; /** * @param formDTO @@ -188,7 +191,14 @@ public class AgencyServiceImpl implements AgencyService { result.setMsg(EpmetErrorCode.NOT_DEL_AGENCY_PER.getMsg()); return result; } - //3:删除当前机关组织(逻辑删) + //3:组织下有网格,不允许删除 + int gridCount = customerGridDao.selectGridCountByAgencyId(formDTO.getAgencyId()); + if (gridCount > NumConstant.ZERO) { + result.setCode(EpmetErrorCode.NOT_DEL_AGENCY_GRID.getCode()); + result.setMsg(EpmetErrorCode.NOT_DEL_AGENCY_GRID.getMsg()); + return result; + } + //4:删除当前机关组织(逻辑删) if (customerAgencyDao.deleteById(formDTO.getAgencyId()) < NumConstant.ONE) { log.error(CustomerAgencyConstant.DEL_EXCEPTION); throw new RenException(CustomerAgencyConstant.DEL_EXCEPTION);