|
@ -108,7 +108,7 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public Result<OrganizationCodeResultDTO> getNeighborHoodCoding(String customerId, String gridId) { |
|
|
public Result<OrganizationCodeResultDTO> getNeighborHoodCoding(String customerId, String gridId,Boolean updateFlag) { |
|
|
if (StringUtils.isBlank(customerId) || StringUtils.isBlank(gridId)) { |
|
|
if (StringUtils.isBlank(customerId) || StringUtils.isBlank(gridId)) { |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); |
|
|
} |
|
|
} |
|
@ -137,7 +137,9 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
IcOrganizationCodeInfoEntity newEntity = new IcOrganizationCodeInfoEntity(); |
|
|
IcOrganizationCodeInfoEntity newEntity = new IcOrganizationCodeInfoEntity(); |
|
|
newEntity.setCustomerId(customerId); |
|
|
newEntity.setCustomerId(customerId); |
|
|
newEntity.setCommunityId(communResult.getCommunityId()); |
|
|
newEntity.setCommunityId(communResult.getCommunityId()); |
|
|
|
|
|
if(updateFlag){ |
|
|
newEntity.setNeighborMaxNum(getNewMaxIndex(3, neighborMaxNum)); |
|
|
newEntity.setNeighborMaxNum(getNewMaxIndex(3, neighborMaxNum)); |
|
|
|
|
|
} |
|
|
baseDao.insert(newEntity); |
|
|
baseDao.insert(newEntity); |
|
|
} else { |
|
|
} else { |
|
|
Integer neighborMaxNum = Integer.valueOf(communEntity.getNeighborMaxNum()) + 1; |
|
|
Integer neighborMaxNum = Integer.valueOf(communEntity.getNeighborMaxNum()) + 1; |
|
@ -145,14 +147,18 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
String neiCode = getCompleteAreaCode(communResult.getAreaCode()) + getNewMaxIndex(3, neighborMaxNum); |
|
|
String neiCode = getCompleteAreaCode(communResult.getAreaCode()) + getNewMaxIndex(3, neighborMaxNum); |
|
|
IcNeighborHoodEntity isHaveCoding = icNeighborHoodDao.selectByCoding(neiCode,null); |
|
|
IcNeighborHoodEntity isHaveCoding = icNeighborHoodDao.selectByCoding(neiCode,null); |
|
|
while (null != isHaveCoding) { |
|
|
while (null != isHaveCoding) { |
|
|
|
|
|
//先更新已有的最大值
|
|
|
|
|
|
communEntity.setNeighborMaxNum(getNewMaxIndex(3, neighborMaxNum)); |
|
|
|
|
|
baseDao.updateNeiByCuIdAndCoId(communEntity); |
|
|
neighborMaxNum++; |
|
|
neighborMaxNum++; |
|
|
neiCode = getCompleteAreaCode(communResult.getAreaCode()) + getNewMaxIndex(3, neighborMaxNum); |
|
|
neiCode = getCompleteAreaCode(communResult.getAreaCode()) + getNewMaxIndex(3, neighborMaxNum); |
|
|
isHaveCoding = icNeighborHoodDao.selectByCoding(neiCode,null); |
|
|
isHaveCoding = icNeighborHoodDao.selectByCoding(neiCode,null); |
|
|
} |
|
|
} |
|
|
//更新该社区下最大的小区编号
|
|
|
//更新该社区下最大的小区编号
|
|
|
|
|
|
if(updateFlag) { |
|
|
communEntity.setNeighborMaxNum(getNewMaxIndex(3, neighborMaxNum)); |
|
|
communEntity.setNeighborMaxNum(getNewMaxIndex(3, neighborMaxNum)); |
|
|
baseDao.updateNeiByCuIdAndCoId(communEntity); |
|
|
baseDao.updateNeiByCuIdAndCoId(communEntity); |
|
|
|
|
|
} |
|
|
String neighborCode = getCompleteAreaCode(communResult.getAreaCode()) + getNewMaxIndex(3, neighborMaxNum); |
|
|
String neighborCode = getCompleteAreaCode(communResult.getAreaCode()) + getNewMaxIndex(3, neighborMaxNum); |
|
|
result.setCoding(neiCode); |
|
|
result.setCoding(neiCode); |
|
|
result.setSysCoding(neighborCode); |
|
|
result.setSysCoding(neighborCode); |
|
@ -162,7 +168,7 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public Result<OrganizationCodeResultDTO> getBuildingCoding(String customerId, String neighborhoodId) { |
|
|
public Result<OrganizationCodeResultDTO> getBuildingCoding(String customerId, String neighborhoodId,Boolean updateFlag) { |
|
|
if (StringUtils.isBlank(customerId) || StringUtils.isBlank(neighborhoodId)) { |
|
|
if (StringUtils.isBlank(customerId) || StringUtils.isBlank(neighborhoodId)) { |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); |
|
|
} |
|
|
} |
|
@ -175,7 +181,7 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
} |
|
|
} |
|
|
//如果小区编码为空,先生成小区编码并更新
|
|
|
//如果小区编码为空,先生成小区编码并更新
|
|
|
if (StringUtils.isBlank(neighborHood.getSysCoding())) { |
|
|
if (StringUtils.isBlank(neighborHood.getSysCoding())) { |
|
|
OrganizationCodeResultDTO org = getNeighborHoodCoding(customerId, neighborHood.getGridId()).getData(); |
|
|
OrganizationCodeResultDTO org = getNeighborHoodCoding(customerId, neighborHood.getGridId(),true).getData(); |
|
|
neighborHood.setCoding(org.getCoding()); |
|
|
neighborHood.setCoding(org.getCoding()); |
|
|
neighborHood.setSysCoding(org.getSysCoding()); |
|
|
neighborHood.setSysCoding(org.getSysCoding()); |
|
|
icNeighborHoodDao.updateById(neighborHood); |
|
|
icNeighborHoodDao.updateById(neighborHood); |
|
@ -189,13 +195,16 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
result.setCoding(communResult.getCoding() + "001"); |
|
|
result.setCoding(communResult.getCoding() + "001"); |
|
|
result.setSysCoding(communResult.getSysCoding() + "001"); |
|
|
result.setSysCoding(communResult.getSysCoding() + "001"); |
|
|
//补充该社区的楼栋最大数
|
|
|
//补充该社区的楼栋最大数
|
|
|
buildingEntity.setBuildingMaxNum("001"); |
|
|
// buildingEntity.setBuildingMaxNum("001");
|
|
|
} else { |
|
|
} else { |
|
|
Integer buildingMaxNum = Integer.valueOf(buildingEntity.getBuildingMaxNum()) + 1; |
|
|
Integer buildingMaxNum = Integer.valueOf(buildingEntity.getBuildingMaxNum()) + 1; |
|
|
//验证可编辑的编码是否有重复
|
|
|
//验证可编辑的编码是否有重复
|
|
|
String buildingCode = communResult.getCoding() + getNewMaxIndex(3, buildingMaxNum); |
|
|
String buildingCode = communResult.getCoding() + getNewMaxIndex(3, buildingMaxNum); |
|
|
IcBuildingEntity isHaveCoding = icBuildingDao.selectByCoding(buildingCode,null); |
|
|
IcBuildingEntity isHaveCoding = icBuildingDao.selectByCoding(buildingCode,null); |
|
|
while (null != isHaveCoding) { |
|
|
while (null != isHaveCoding) { |
|
|
|
|
|
//先更新已有的最大值
|
|
|
|
|
|
buildingEntity.setBuildingMaxNum(getNewMaxIndex(3, buildingMaxNum)); |
|
|
|
|
|
baseDao.updateBuildingByCuIdAndCoId(buildingEntity); |
|
|
buildingMaxNum++; |
|
|
buildingMaxNum++; |
|
|
buildingCode = communResult.getCoding() + getNewMaxIndex(3, buildingMaxNum); |
|
|
buildingCode = communResult.getCoding() + getNewMaxIndex(3, buildingMaxNum); |
|
|
isHaveCoding = icBuildingDao.selectByCoding(buildingCode,null); |
|
|
isHaveCoding = icBuildingDao.selectByCoding(buildingCode,null); |
|
@ -204,15 +213,19 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
result.setSysCoding(communResult.getSysCoding() + getNewMaxIndex(3, buildingMaxNum)); |
|
|
result.setSysCoding(communResult.getSysCoding() + getNewMaxIndex(3, buildingMaxNum)); |
|
|
|
|
|
|
|
|
//更新该社区下最大的楼栋编号
|
|
|
//更新该社区下最大的楼栋编号
|
|
|
|
|
|
if(updateFlag) { |
|
|
buildingEntity.setBuildingMaxNum(getNewMaxIndex(3, buildingMaxNum)); |
|
|
buildingEntity.setBuildingMaxNum(getNewMaxIndex(3, buildingMaxNum)); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if(updateFlag) { |
|
|
baseDao.updateBuildingByCuIdAndCoId(buildingEntity); |
|
|
baseDao.updateBuildingByCuIdAndCoId(buildingEntity); |
|
|
|
|
|
} |
|
|
return new Result<OrganizationCodeResultDTO>().ok(result); |
|
|
return new Result<OrganizationCodeResultDTO>().ok(result); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public Result<OrganizationCodeResultDTO> getUnitCoding(String customerId, String buildingId) { |
|
|
public Result<OrganizationCodeResultDTO> getUnitCoding(String customerId, String buildingId,Boolean updateFlag) { |
|
|
if (StringUtils.isBlank(customerId) || StringUtils.isBlank(buildingId)) { |
|
|
if (StringUtils.isBlank(customerId) || StringUtils.isBlank(buildingId)) { |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); |
|
|
} |
|
|
} |
|
@ -226,7 +239,7 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
//如果楼栋编码为空,先生成楼栋编码并更新
|
|
|
//如果楼栋编码为空,先生成楼栋编码并更新
|
|
|
if (StringUtils.isBlank(buildingEntity.getSysCoding())) { |
|
|
if (StringUtils.isBlank(buildingEntity.getSysCoding())) { |
|
|
ImportGeneralDTO neiInfo = icBuildingDao.selectBuildingById(buildingId); |
|
|
ImportGeneralDTO neiInfo = icBuildingDao.selectBuildingById(buildingId); |
|
|
OrganizationCodeResultDTO org = getBuildingCoding(customerId, neiInfo.getNeighborHoodId()).getData(); |
|
|
OrganizationCodeResultDTO org = getBuildingCoding(customerId, neiInfo.getNeighborHoodId(),true).getData(); |
|
|
buildingEntity.setCoding(org.getCoding()); |
|
|
buildingEntity.setCoding(org.getCoding()); |
|
|
buildingEntity.setSysCoding(org.getSysCoding()); |
|
|
buildingEntity.setSysCoding(org.getSysCoding()); |
|
|
icBuildingDao.updateById(buildingEntity); |
|
|
icBuildingDao.updateById(buildingEntity); |
|
@ -255,15 +268,17 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
result.setSysCoding(communResult.getSysCoding() + getNewMaxIndex(2, unitMaxNum)); |
|
|
result.setSysCoding(communResult.getSysCoding() + getNewMaxIndex(2, unitMaxNum)); |
|
|
|
|
|
|
|
|
//更新该社区下最大的单元编号
|
|
|
//更新该社区下最大的单元编号
|
|
|
|
|
|
if(updateFlag) { |
|
|
unitEntity.setUnitMaxNum(getNewMaxIndex(2, unitMaxNum)); |
|
|
unitEntity.setUnitMaxNum(getNewMaxIndex(2, unitMaxNum)); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
baseDao.updateUnitByCuIdAndCoId(unitEntity); |
|
|
baseDao.updateUnitByCuIdAndCoId(unitEntity); |
|
|
return new Result<OrganizationCodeResultDTO>().ok(result); |
|
|
return new Result<OrganizationCodeResultDTO>().ok(result); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public Result<OrganizationCodeResultDTO> getHouseCoding(String customerId, String unitId) { |
|
|
public Result<OrganizationCodeResultDTO> getHouseCoding(String customerId, String unitId,Boolean updateFlag) { |
|
|
if (StringUtils.isBlank(customerId) || StringUtils.isBlank(unitId)) { |
|
|
if (StringUtils.isBlank(customerId) || StringUtils.isBlank(unitId)) { |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); |
|
|
} |
|
|
} |
|
@ -277,7 +292,7 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
//如果单元编码为空,先生成单元编码并更新
|
|
|
//如果单元编码为空,先生成单元编码并更新
|
|
|
if (StringUtils.isBlank(unitEntity.getSysCoding())) { |
|
|
if (StringUtils.isBlank(unitEntity.getSysCoding())) { |
|
|
HouseInfoResultDTO buildingInfo = icBuildingUnitDao.getUnitDetail(unitId); |
|
|
HouseInfoResultDTO buildingInfo = icBuildingUnitDao.getUnitDetail(unitId); |
|
|
OrganizationCodeResultDTO org = getUnitCoding(customerId, buildingInfo.getBuildingId()).getData(); |
|
|
OrganizationCodeResultDTO org = getUnitCoding(customerId, buildingInfo.getBuildingId(),true).getData(); |
|
|
unitEntity.setCoding(org.getCoding()); |
|
|
unitEntity.setCoding(org.getCoding()); |
|
|
unitEntity.setSysCoding(org.getSysCoding()); |
|
|
unitEntity.setSysCoding(org.getSysCoding()); |
|
|
icBuildingUnitDao.updateById(unitEntity); |
|
|
icBuildingUnitDao.updateById(unitEntity); |
|
@ -289,14 +304,17 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
IcOrganizationCodeInfoEntity houseEntity = baseDao.selectByCommunityIdAndCustomerId(customerId, communResult.getCommunityId()); |
|
|
IcOrganizationCodeInfoEntity houseEntity = baseDao.selectByCommunityIdAndCustomerId(customerId, communResult.getCommunityId()); |
|
|
if (StringUtils.isBlank(houseEntity.getUnitMaxNum())) { |
|
|
if (StringUtils.isBlank(houseEntity.getUnitMaxNum())) { |
|
|
result.setCoding(communResult.getCoding() + "001"); |
|
|
result.setCoding(communResult.getCoding() + "001"); |
|
|
//补充该社区的单元最大数
|
|
|
//补充该社区的房屋最大数
|
|
|
houseEntity.setHouseMaxNum("001"); |
|
|
// houseEntity.setHouseMaxNum("001");
|
|
|
} else { |
|
|
} else { |
|
|
Integer houseMaxNum = Integer.valueOf(houseEntity.getUnitMaxNum()) + 1; |
|
|
Integer houseMaxNum = Integer.valueOf(houseEntity.getUnitMaxNum()) + 1; |
|
|
//验证可编辑的编码是否有重复
|
|
|
//验证可编辑的编码是否有重复
|
|
|
String houseCode = communResult.getCoding() + getNewMaxIndex(4, houseMaxNum); |
|
|
String houseCode = communResult.getCoding() + getNewMaxIndex(4, houseMaxNum); |
|
|
IcHouseEntity isHaveCoding = icHouseDao.selectByCoding(houseCode); |
|
|
IcHouseEntity isHaveCoding = icHouseDao.selectByCoding(houseCode); |
|
|
while (null != isHaveCoding) { |
|
|
while (null != isHaveCoding) { |
|
|
|
|
|
//先更新已有的最大值
|
|
|
|
|
|
houseEntity.setHouseMaxNum(getNewMaxIndex(4, houseMaxNum)); |
|
|
|
|
|
baseDao.updateHouseByCuIdAndCoId(houseEntity); |
|
|
houseMaxNum++; |
|
|
houseMaxNum++; |
|
|
houseCode = communResult.getCoding() + getNewMaxIndex(4, houseMaxNum); |
|
|
houseCode = communResult.getCoding() + getNewMaxIndex(4, houseMaxNum); |
|
|
isHaveCoding = icHouseDao.selectByCoding(houseCode); |
|
|
isHaveCoding = icHouseDao.selectByCoding(houseCode); |
|
@ -304,9 +322,9 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
result.setCoding(houseCode); |
|
|
result.setCoding(houseCode); |
|
|
|
|
|
|
|
|
//更新该社区下最大的房屋编号
|
|
|
//更新该社区下最大的房屋编号
|
|
|
houseEntity.setHouseMaxNum(getNewMaxIndex(4, houseMaxNum)); |
|
|
// houseEntity.setHouseMaxNum(getNewMaxIndex(4, houseMaxNum));
|
|
|
} |
|
|
} |
|
|
baseDao.updateHouseByCuIdAndCoId(houseEntity); |
|
|
// baseDao.updateHouseByCuIdAndCoId(houseEntity);
|
|
|
return new Result<OrganizationCodeResultDTO>().ok(result); |
|
|
return new Result<OrganizationCodeResultDTO>().ok(result); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -317,7 +335,7 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
* @date 2022/6/29 10:30 |
|
|
* @date 2022/6/29 10:30 |
|
|
* @params [maxLength, maxIndex] |
|
|
* @params [maxLength, maxIndex] |
|
|
*/ |
|
|
*/ |
|
|
private String getNewMaxIndex(Integer maxLength, Integer maxIndex) { |
|
|
public String getNewMaxIndex(Integer maxLength, Integer maxIndex) { |
|
|
String result = maxIndex.toString(); |
|
|
String result = maxIndex.toString(); |
|
|
while (result.length() < maxLength) { |
|
|
while (result.length() < maxLength) { |
|
|
result = "0" + result; |
|
|
result = "0" + result; |
|
|