diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java index 4a0dee5f1f..b1087949c0 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java @@ -307,6 +307,6 @@ public interface CustomerAgencyDao extends BaseDao { int updateSubAgencyAreaCode(@Param("customerId") String customerId, @Param("originalParentAreaCode")String originalParentAreaCode,@Param("operateUserId") String operateUserId); - int updateSubAgencyAreaCodeById(@Param("customerId")String customerId, @Param("agencyId")String agencyId, @Param("userId") String userId); + int updateSubAgencyAreaCodeById(@Param("customerId")String customerId, @Param("agencyId")String agencyId, @Param("operateUserId") String operateUserId); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java index eedb383a94..4d3d2668e8 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java @@ -101,4 +101,8 @@ public interface CustomerDepartmentDao extends BaseDao * @Date 2020/12/15 10:05 **/ int delDeptById(@Param("deptId")String deptId,@Param("operateUserId") String operateUserId); + + int updateSubDeptAreaCode(@Param("customerId") String customerId, + @Param("areaCode")String areaCode, + @Param("operateUserId") String operateUserId); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java index 48dacdf82d..3bf28b37a9 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java @@ -351,4 +351,8 @@ public interface CustomerGridDao extends BaseDao { * @Description 网格组织信息 **/ CustomerGridDTO gridAgencyByGrid(@Param("gridId") String gridId); + + int updateSubGridAreaCode(@Param("customerId") String customerId, + @Param("agencyId")String agencyId, + @Param("operateUserId") String operateUserId); } 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 a820bd7005..0c3d4df35c 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 @@ -33,6 +33,7 @@ import com.epmet.constant.CustomerAgencyConstant; import com.epmet.constant.OrgInfoConstant; import com.epmet.constant.RoleKeyConstants; import com.epmet.dao.CustomerAgencyDao; +import com.epmet.dao.CustomerDepartmentDao; import com.epmet.dao.CustomerGridDao; import com.epmet.dao.IcBuildingDao; import com.epmet.dto.CustomerAgencyDTO; @@ -93,7 +94,8 @@ public class AgencyServiceImpl implements AgencyService { private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; @Autowired private IcBuildingDao icBuildingDao; - + @Autowired + private CustomerDepartmentDao customerDepartmentDao; /** * @param formDTO @@ -153,12 +155,16 @@ public class AgencyServiceImpl implements AgencyService { originalEntity.setContacts(formDTO.getContacts()); originalEntity.setMobile(formDTO.getMobile()); if (StringUtils.isNotBlank(formDTO.getAreaCode()) && !formDTO.getAreaCode().equals(originalEntity.getAreaCode())) { + CustomerAgencyEntity parent = customerAgencyDao.selectById(originalEntity.getPid()); //如果修改了areaCode。 if(StringUtils.isNotBlank(originalEntity.getAreaCode())){ //如果原来这个组织有area_code再去更新,没有其实应该按照pids去更新。 - customerAgencyDao.updateSubAgencyAreaCode(originalEntity.getCustomerId(), originalEntity.getAreaCode(), formDTO.getUserId()); - }else{ + // customerAgencyDao.updateSubAgencyAreaCode(originalEntity.getCustomerId(), originalEntity.getAreaCode(), formDTO.getUserId()); customerAgencyDao.updateSubAgencyAreaCodeById(originalEntity.getCustomerId(), originalEntity.getId(), formDTO.getUserId()); + //网格的 + customerGridDao.updateSubGridAreaCode(originalEntity.getCustomerId(), originalEntity.getId(), formDTO.getUserId()); + //部门的 + customerDepartmentDao.updateSubDeptAreaCode(originalEntity.getCustomerId(), originalEntity.getAreaCode(), formDTO.getUserId()); } //判断areaCodeSwitch:open: 选择地区编码必填;closed: 无需选择地区编码 @@ -171,6 +177,7 @@ public class AgencyServiceImpl implements AgencyService { throw new RenException(EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getCode(), EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getMsg()); } originalEntity.setAreaCode(formDTO.getAreaCode()); + originalEntity.setParentAreaCode(parent.getAreaCode()); }else{ //如果选择的是other,需要自定义一个编码 AddAreaCodeFormDTO addAreaCodeFormDTO = new AddAreaCodeFormDTO(); @@ -182,6 +189,7 @@ public class AgencyServiceImpl implements AgencyService { throw new RenException("自定义area_code异常" + addAreaCodeResult.getInternalMsg()); } originalEntity.setAreaCode(addAreaCodeResult.getData()); + originalEntity.setParentAreaCode(parent.getAreaCode()); } } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerDepartmentDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerDepartmentDao.xml index 9bbe9e96b7..a3a5f3317d 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerDepartmentDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerDepartmentDao.xml @@ -87,4 +87,13 @@ UPDATED_TIME=NOW() where id=#{deptId} + + + update customer_department + SET AREA_CODE = '', + UPDATED_BY=#{operateUserId}, + UPDATED_TIME = NOW() + where customer_id=#{customerId} + AND AREA_CODE LIKE concat(#{areaCode}, '%' ) + \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml index 4c34ea5bed..ef9e5ca8c3 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml @@ -755,4 +755,12 @@ AND cg.id = #{gridId} + + update customer_grid + SET AREA_CODE = '', + UPDATED_BY=#{operateUserId}, + UPDATED_TIME = NOW() + where customer_id=#{customerId} + AND pids LIKE concat('%',#{agencyId}, '%' ) +