diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseInformationController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseInformationController.java index 314940ecf8..21ca6fb933 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseInformationController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseInformationController.java @@ -262,7 +262,7 @@ public class HouseInformationController { */ @PostMapping("getNeighborHoodCoding/{gridId}") public Result getNeighborHoodCoding(@LoginUser TokenDto tokenDTO, @PathVariable("gridId") String gridId) { - return icOrganizationCodeInfoService.getNeighborHoodCoding(tokenDTO.getCustomerId(),gridId); + return icOrganizationCodeInfoService.getNeighborHoodCoding(tokenDTO.getCustomerId(),gridId,false); } /** @@ -274,7 +274,7 @@ public class HouseInformationController { */ @PostMapping("getBuildingCoding/{neighborhoodId}") public Result getBuildingCoding(@LoginUser TokenDto tokenDTO, @PathVariable("neighborhoodId") String neighborhoodId) { - return icOrganizationCodeInfoService.getBuildingCoding(tokenDTO.getCustomerId(),neighborhoodId); + return icOrganizationCodeInfoService.getBuildingCoding(tokenDTO.getCustomerId(),neighborhoodId,false); } /** @@ -286,6 +286,6 @@ public class HouseInformationController { */ @PostMapping("getHouseCoding/{unitId}") public Result getHouseCoding(@LoginUser TokenDto tokenDTO, @PathVariable("unitId") String unitId) { - return icOrganizationCodeInfoService.getHouseCoding(tokenDTO.getCustomerId(),unitId); + return icOrganizationCodeInfoService.getHouseCoding(tokenDTO.getCustomerId(),unitId,false); } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcOrganizationCodeInfoService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcOrganizationCodeInfoService.java index c0e3bb5545..58791b1b44 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcOrganizationCodeInfoService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcOrganizationCodeInfoService.java @@ -85,7 +85,7 @@ public interface IcOrganizationCodeInfoService extends BaseService */ - Result getNeighborHoodCoding(String customerId, String gridId); + Result getNeighborHoodCoding(String customerId, String gridId,Boolean updateFlag); /** * @describe: 【双实录入】获取楼栋编码 @@ -94,7 +94,7 @@ public interface IcOrganizationCodeInfoService extends BaseService */ - Result getBuildingCoding(String customerId, String neighborhoodId); + Result getBuildingCoding(String customerId, String neighborhoodId,Boolean updateFlag); /** * @describe: 【双实录入】获取单元编码 @@ -103,7 +103,7 @@ public interface IcOrganizationCodeInfoService extends BaseService */ - Result getUnitCoding(String customerId, String buildingId); + Result getUnitCoding(String customerId, String buildingId,Boolean updateFlag); /** * @describe: 【双实录入】获取房屋编码 @@ -112,5 +112,5 @@ public interface IcOrganizationCodeInfoService extends BaseService */ - Result getHouseCoding(String customerId, String unitId); + Result getHouseCoding(String customerId, String unitId,Boolean updateFlag); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java index cdcb22272a..981e1f10b4 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java @@ -90,6 +90,10 @@ public class BuildingServiceImpl implements BuildingService { private ExecutorService executorService; @Autowired private IcOrganizationCodeInfoService icOrganizationCodeInfoService; + @Autowired + private IcOrganizationCodeInfoDao icOrganizationCodeInfoDao; + @Autowired + private IcOrganizationCodeInfoServiceImpl icOrganizationCodeInfoServiceImpl; @Override @@ -106,6 +110,7 @@ public class BuildingServiceImpl implements BuildingService { if(null != isHaveCoding){ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "该楼栋编码已存在,请勿重复!","该楼栋编码已存在,请勿重复!"); } + updateBuildingMaxNum(customerId,formDTO); } IcBuildingDTO icBuildingDTO = ConvertUtils.sourceToTarget(formDTO, IcBuildingDTO.class); icBuildingDTO.setCustomerId(customerId); @@ -121,7 +126,7 @@ public class BuildingServiceImpl implements BuildingService { icBuildingUnit.setBuildingId(entity.getId()); icBuildingUnit.setUnitName((i + 1) + "单元"); icBuildingUnit.setUnitNum(String.valueOf(i + 1)); - Result codeResult = icOrganizationCodeInfoService.getUnitCoding(customerId,entity.getId()); + Result codeResult = icOrganizationCodeInfoService.getUnitCoding(customerId,entity.getId(),true); if(!codeResult.success() || null == codeResult.getData()){ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "生成单元编码异常,请联系管理员","生成单元编码异常,请联系管理员"); } @@ -133,6 +138,32 @@ public class BuildingServiceImpl implements BuildingService { } + /** + * @describe: 如果编码未改动提交,则最大数+1 + * @author wangtong + * @date 2022/7/5 10:43 + * @params [formDTO] + * @return void + */ + private void updateBuildingMaxNum(String customerId,IcBulidingAddFormDTO formDTO){ + //获取楼栋id、行政编码 + OrganizationCommunityDTO communResult = icNeighborHoodDao.selectCommunityByNeiId(formDTO.getNeighborHoodId()); + //如果是自增的,则最大数+1 + IcOrganizationCodeInfoEntity communEntity = icOrganizationCodeInfoDao.selectByCommunityIdAndCustomerId(customerId, communResult.getCommunityId()); + Integer buildMaxNum = org.apache.commons.lang3.StringUtils.isBlank(communEntity.getBuildingMaxNum())?1:Integer.valueOf(communEntity.getBuildingMaxNum()) + 1; + Integer submitMaxNum = null; + try { + submitMaxNum = Integer.valueOf(formDTO.getCoding().substring(formDTO.getCoding().length()-3)); + }catch (Exception e){ + e.printStackTrace(); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "编码转换失败", "编码转换失败"); + } + if(buildMaxNum.intValue() == submitMaxNum.intValue()){ + communEntity.setBuildingMaxNum(icOrganizationCodeInfoServiceImpl.getNewMaxIndex(3, buildMaxNum)); + icOrganizationCodeInfoDao.updateBuildingByCuIdAndCoId(communEntity); + } + } + @Override public List treeList(String customerId, String staffId) { CustomerStaffInfoCacheResult agency = CustomerStaffRedis.getStaffInfo(customerId, staffId); @@ -460,6 +491,7 @@ public class BuildingServiceImpl implements BuildingService { if(null != isHaveCoding){ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "该楼栋编码已存在,请勿重复!","该楼栋编码已存在,请勿重复!"); } + updateBuildingMaxNum(customerId,formDTO); } IcBuildingDTO icBuildingDTO = ConvertUtils.sourceToTarget(formDTO, IcBuildingDTO.class); icBuildingDTO.setId(formDTO.getBuildingId()); @@ -502,7 +534,7 @@ public class BuildingServiceImpl implements BuildingService { icBuildingUnit.setCustomerId(customerId); icBuildingUnit.setUnitName(unitNum + "单元"); icBuildingUnit.setUnitNum(unitNum); - Result codeResult = icOrganizationCodeInfoService.getUnitCoding(customerId,icBuilding.getId()); + Result codeResult = icOrganizationCodeInfoService.getUnitCoding(customerId,icBuilding.getId(),true); if(!codeResult.success() || null == codeResult.getData()){ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "生成单元编码异常,请联系管理员","生成单元编码异常,请联系管理员"); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index 127eef5f0e..78dd6ce923 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -127,6 +127,12 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { private OssFeignClient ossFeignClient; @Autowired private EpmetAdminOpenFeignClient epmetAdminOpenFeignClient; + @Autowired + private IcOrganizationCodeInfoDao icOrganizationCodeInfoDao; + @Autowired + private IcOrganizationCodeInfoServiceImpl icOrganizationCodeInfoServiceImpl; + @Autowired + private IcBuildingUnitDao icBuildingUnitDao; @Override @@ -143,6 +149,7 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { if(null != isHaveCoding){ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "该房屋编码已存在,请勿重复!","该房屋编码已存在,请勿重复!"); } + updateHouseMaxNum(customerId,formDTO); } IcHouseEntity icHouseDTO = ConvertUtils.sourceToTarget(formDTO, IcHouseEntity.class); icHouseDTO.setCustomerId(customerId); @@ -164,6 +171,32 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { icHouseDao.updateById(entity); } + /** + * @describe: 如果编码未改动提交,则最大数+1 + * @author wangtong + * @date 2022/7/5 10:53 + * @params [customerId, formDTO] + * @return void + */ + private void updateHouseMaxNum(String customerId, IcHouseAddFormDTO formDTO){ + //获取社区id、单元编码 + OrganizationCommunityDTO communResult = icBuildingUnitDao.selectCommunityByUnitId(formDTO.getBuildingUnitId()); + //如果是自增的,则最大数+1 + IcOrganizationCodeInfoEntity communEntity = icOrganizationCodeInfoDao.selectByCommunityIdAndCustomerId(customerId, communResult.getCommunityId()); + Integer houseMaxNum = org.apache.commons.lang3.StringUtils.isBlank(communEntity.getHouseMaxNum())?1:Integer.valueOf(communEntity.getHouseMaxNum()) + 1; + Integer submitMaxNum = null; + try { + submitMaxNum = Integer.valueOf(formDTO.getCoding().substring(formDTO.getCoding().length()-4)); + }catch (Exception e){ + e.printStackTrace(); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "编码转换失败", "编码转换失败"); + } + if(houseMaxNum.intValue() == submitMaxNum.intValue()){ + communEntity.setHouseMaxNum(icOrganizationCodeInfoServiceImpl.getNewMaxIndex(4, houseMaxNum)); + icOrganizationCodeInfoDao.updateHouseByCuIdAndCoId(communEntity); + } + } + private String getHouseName(IcHouseAddFormDTO formDTO) { //设置房间名 楼栋-单元号-门牌号 IcBuildingDTO icBuilding = icBuildingService.get(formDTO.getBuildingId()); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcOrganizationCodeInfoServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcOrganizationCodeInfoServiceImpl.java index 992cf837c4..803a73cde8 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcOrganizationCodeInfoServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcOrganizationCodeInfoServiceImpl.java @@ -108,7 +108,7 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl getNeighborHoodCoding(String customerId, String gridId) { + public Result getNeighborHoodCoding(String customerId, String gridId,Boolean updateFlag) { if (StringUtils.isBlank(customerId) || StringUtils.isBlank(gridId)) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); } @@ -137,7 +137,9 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl getBuildingCoding(String customerId, String neighborhoodId) { + public Result getBuildingCoding(String customerId, String neighborhoodId,Boolean updateFlag) { if (StringUtils.isBlank(customerId) || StringUtils.isBlank(neighborhoodId)) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); } @@ -175,7 +181,7 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl().ok(result); } @Override @Transactional(rollbackFor = Exception.class) - public Result getUnitCoding(String customerId, String buildingId) { + public Result getUnitCoding(String customerId, String buildingId,Boolean updateFlag) { if (StringUtils.isBlank(customerId) || StringUtils.isBlank(buildingId)) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); } @@ -226,7 +239,7 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl().ok(result); @@ -263,7 +278,7 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl getHouseCoding(String customerId, String unitId) { + public Result getHouseCoding(String customerId, String unitId,Boolean updateFlag) { if (StringUtils.isBlank(customerId) || StringUtils.isBlank(unitId)) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); } @@ -277,7 +292,7 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl().ok(result); } @@ -317,7 +335,7 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl