|
|
@ -16,6 +16,7 @@ import com.epmet.dto.result.HouseInfoResultDTO; |
|
|
|
import com.epmet.dto.result.OrganizationCodeResultDTO; |
|
|
|
import com.epmet.dto.result.OrganizationCommunityDTO; |
|
|
|
import com.epmet.entity.*; |
|
|
|
import com.epmet.enums.OrganizationTypeEnums; |
|
|
|
import com.epmet.redis.IcOrganizationCodeInfoRedis; |
|
|
|
import com.epmet.service.IcOrganizationCodeInfoService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@ -108,7 +109,7 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result<OrganizationCodeResultDTO> getNeighborHoodCoding(String customerId, String gridId,Boolean updateFlag) { |
|
|
|
public Result<OrganizationCodeResultDTO> getNeighborHoodCoding(String customerId, String gridId, Boolean updateFlag) { |
|
|
|
if (StringUtils.isBlank(customerId) || StringUtils.isBlank(gridId)) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); |
|
|
|
} |
|
|
@ -119,16 +120,16 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "未查到相关社区信息", "未查到相关社区信息"); |
|
|
|
} |
|
|
|
//查询该社区下是否存在数据
|
|
|
|
IcOrganizationCodeInfoEntity communEntity = baseDao.selectByCommunityIdAndCustomerId(customerId, communResult.getCommunityId()); |
|
|
|
IcOrganizationCodeInfoEntity communEntity = baseDao.selectByIdAndType(customerId, communResult.getCommunityId(), OrganizationTypeEnums.COMM.getCode()); |
|
|
|
if (null == communEntity) { |
|
|
|
Integer neighborMaxNum = 1; |
|
|
|
String neighborCode = getCompleteAreaCode(communResult.getAreaCode()) + getNewMaxIndex(3, neighborMaxNum); |
|
|
|
//开发测试需要检测,因为包含行政编码为空的社区,会出现小区编码重复的情况
|
|
|
|
IcNeighborHoodEntity isHaveCoding = icNeighborHoodDao.selectByCoding(neighborCode,null); |
|
|
|
IcNeighborHoodEntity isHaveCoding = icNeighborHoodDao.selectByCoding(neighborCode, null); |
|
|
|
while (null != isHaveCoding) { |
|
|
|
neighborMaxNum++; |
|
|
|
neighborCode = getCompleteAreaCode(communResult.getAreaCode()) + getNewMaxIndex(3, neighborMaxNum); |
|
|
|
isHaveCoding = icNeighborHoodDao.selectByCoding(neighborCode,null); |
|
|
|
isHaveCoding = icNeighborHoodDao.selectByCoding(neighborCode, null); |
|
|
|
} |
|
|
|
|
|
|
|
result.setCoding(neighborCode); |
|
|
@ -136,28 +137,29 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
|
//新增该社区辅助数据
|
|
|
|
IcOrganizationCodeInfoEntity newEntity = new IcOrganizationCodeInfoEntity(); |
|
|
|
newEntity.setCustomerId(customerId); |
|
|
|
newEntity.setCommunityId(communResult.getCommunityId()); |
|
|
|
if(updateFlag){ |
|
|
|
newEntity.setNeighborMaxNum(getNewMaxIndex(3, neighborMaxNum)); |
|
|
|
newEntity.setSysId(communResult.getCommunityId()); |
|
|
|
if (updateFlag) { |
|
|
|
newEntity.setMaxNum(getNewMaxIndex(3, neighborMaxNum)); |
|
|
|
} |
|
|
|
newEntity.setSysType(OrganizationTypeEnums.COMM.getCode()); |
|
|
|
baseDao.insert(newEntity); |
|
|
|
} else { |
|
|
|
Integer neighborMaxNum = Integer.valueOf(communEntity.getNeighborMaxNum()) + 1; |
|
|
|
Integer neighborMaxNum = StringUtils.isBlank(communEntity.getMaxNum()) ? 1 : Integer.valueOf(communEntity.getMaxNum()) + 1; |
|
|
|
//验证可编辑的编码是否有重复
|
|
|
|
String neiCode = getCompleteAreaCode(communResult.getAreaCode()) + getNewMaxIndex(3, neighborMaxNum); |
|
|
|
IcNeighborHoodEntity isHaveCoding = icNeighborHoodDao.selectByCoding(neiCode,null); |
|
|
|
IcNeighborHoodEntity isHaveCoding = icNeighborHoodDao.selectByCoding(neiCode, null); |
|
|
|
while (null != isHaveCoding) { |
|
|
|
//先更新已有的最大值
|
|
|
|
communEntity.setNeighborMaxNum(getNewMaxIndex(3, neighborMaxNum)); |
|
|
|
baseDao.updateNeiByCuIdAndCoId(communEntity); |
|
|
|
communEntity.setMaxNum(getNewMaxIndex(3, neighborMaxNum)); |
|
|
|
baseDao.updateMaxNumByIdAndType(communEntity); |
|
|
|
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)); |
|
|
|
baseDao.updateNeiByCuIdAndCoId(communEntity); |
|
|
|
if (updateFlag) { |
|
|
|
communEntity.setMaxNum(getNewMaxIndex(3, neighborMaxNum)); |
|
|
|
baseDao.updateMaxNumByIdAndType(communEntity); |
|
|
|
} |
|
|
|
String neighborCode = getCompleteAreaCode(communResult.getAreaCode()) + getNewMaxIndex(3, neighborMaxNum); |
|
|
|
result.setCoding(neiCode); |
|
|
@ -168,7 +170,7 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result<OrganizationCodeResultDTO> getBuildingCoding(String customerId, String neighborhoodId,Boolean updateFlag) { |
|
|
|
public Result<OrganizationCodeResultDTO> getBuildingCoding(String customerId, String neighborhoodId, Boolean updateFlag) { |
|
|
|
if (StringUtils.isBlank(customerId) || StringUtils.isBlank(neighborhoodId)) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); |
|
|
|
} |
|
|
@ -181,7 +183,7 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
|
} |
|
|
|
//如果小区编码为空,先生成小区编码并更新
|
|
|
|
if (StringUtils.isBlank(neighborHood.getSysCoding())) { |
|
|
|
OrganizationCodeResultDTO org = getNeighborHoodCoding(customerId, neighborHood.getGridId(),true).getData(); |
|
|
|
OrganizationCodeResultDTO org = getNeighborHoodCoding(customerId, neighborHood.getGridId(), true).getData(); |
|
|
|
neighborHood.setCoding(org.getCoding()); |
|
|
|
neighborHood.setSysCoding(org.getSysCoding()); |
|
|
|
icNeighborHoodDao.updateById(neighborHood); |
|
|
@ -189,43 +191,49 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
|
|
|
|
|
//获取社区id、小区编码
|
|
|
|
OrganizationCommunityDTO communResult = icNeighborHoodDao.selectCommunityByNeiId(neighborhoodId); |
|
|
|
//查询该社区下是否存在楼栋数据
|
|
|
|
IcOrganizationCodeInfoEntity buildingEntity = baseDao.selectByCommunityIdAndCustomerId(customerId, communResult.getCommunityId()); |
|
|
|
if (StringUtils.isBlank(buildingEntity.getBuildingMaxNum())) { |
|
|
|
result.setCoding(communResult.getCoding() + "001"); |
|
|
|
result.setSysCoding(communResult.getSysCoding() + "001"); |
|
|
|
//补充该社区的楼栋最大数
|
|
|
|
// buildingEntity.setBuildingMaxNum("001");
|
|
|
|
//查询该小区下是否存在楼栋数据
|
|
|
|
IcOrganizationCodeInfoEntity buildingEntity = baseDao.selectByIdAndType(customerId, neighborhoodId, OrganizationTypeEnums.NEI.getCode()); |
|
|
|
if (null == buildingEntity) { |
|
|
|
Integer maxNum = 1; |
|
|
|
result.setCoding(communResult.getCoding() + getNewMaxIndex(3, maxNum)); |
|
|
|
result.setSysCoding(communResult.getSysCoding() + getNewMaxIndex(3, maxNum)); |
|
|
|
//新增该楼栋辅助数据
|
|
|
|
IcOrganizationCodeInfoEntity newEntity = new IcOrganizationCodeInfoEntity(); |
|
|
|
newEntity.setCustomerId(customerId); |
|
|
|
newEntity.setSysId(neighborhoodId); |
|
|
|
if (updateFlag) { |
|
|
|
newEntity.setMaxNum(getNewMaxIndex(3, maxNum)); |
|
|
|
} |
|
|
|
newEntity.setSysType(OrganizationTypeEnums.NEI.getCode()); |
|
|
|
baseDao.insert(newEntity); |
|
|
|
} else { |
|
|
|
Integer buildingMaxNum = Integer.valueOf(buildingEntity.getBuildingMaxNum()) + 1; |
|
|
|
Integer buildingMaxNum = StringUtils.isBlank(buildingEntity.getMaxNum()) ? 1 : Integer.valueOf(buildingEntity.getMaxNum()) + 1; |
|
|
|
//验证可编辑的编码是否有重复
|
|
|
|
String buildingCode = communResult.getCoding() + getNewMaxIndex(3, buildingMaxNum); |
|
|
|
IcBuildingEntity isHaveCoding = icBuildingDao.selectByCoding(buildingCode,null); |
|
|
|
IcBuildingEntity isHaveCoding = icBuildingDao.selectByCoding(buildingCode, null); |
|
|
|
while (null != isHaveCoding) { |
|
|
|
//先更新已有的最大值
|
|
|
|
buildingEntity.setBuildingMaxNum(getNewMaxIndex(3, buildingMaxNum)); |
|
|
|
baseDao.updateBuildingByCuIdAndCoId(buildingEntity); |
|
|
|
buildingEntity.setMaxNum(getNewMaxIndex(3, buildingMaxNum)); |
|
|
|
baseDao.updateMaxNumByIdAndType(buildingEntity); |
|
|
|
buildingMaxNum++; |
|
|
|
buildingCode = communResult.getCoding() + getNewMaxIndex(3, buildingMaxNum); |
|
|
|
isHaveCoding = icBuildingDao.selectByCoding(buildingCode,null); |
|
|
|
isHaveCoding = icBuildingDao.selectByCoding(buildingCode, null); |
|
|
|
} |
|
|
|
result.setCoding(buildingCode); |
|
|
|
result.setSysCoding(communResult.getSysCoding() + getNewMaxIndex(3, buildingMaxNum)); |
|
|
|
|
|
|
|
//更新该社区下最大的楼栋编号
|
|
|
|
if(updateFlag) { |
|
|
|
buildingEntity.setBuildingMaxNum(getNewMaxIndex(3, buildingMaxNum)); |
|
|
|
if (updateFlag) { |
|
|
|
buildingEntity.setMaxNum(getNewMaxIndex(3, buildingMaxNum)); |
|
|
|
baseDao.updateMaxNumByIdAndType(buildingEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
if(updateFlag) { |
|
|
|
baseDao.updateBuildingByCuIdAndCoId(buildingEntity); |
|
|
|
} |
|
|
|
return new Result<OrganizationCodeResultDTO>().ok(result); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result<OrganizationCodeResultDTO> getUnitCoding(String customerId, String buildingId,Boolean updateFlag) { |
|
|
|
public Result<OrganizationCodeResultDTO> getUnitCoding(String customerId, String buildingId, Boolean updateFlag) { |
|
|
|
if (StringUtils.isBlank(customerId) || StringUtils.isBlank(buildingId)) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); |
|
|
|
} |
|
|
@ -238,8 +246,8 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
|
} |
|
|
|
//如果楼栋编码为空,先生成楼栋编码并更新
|
|
|
|
if (StringUtils.isBlank(buildingEntity.getSysCoding())) { |
|
|
|
ImportGeneralDTO neiInfo = icBuildingDao.selectBuildingById(buildingId); |
|
|
|
OrganizationCodeResultDTO org = getBuildingCoding(customerId, neiInfo.getNeighborHoodId(),true).getData(); |
|
|
|
ImportGeneralDTO neiInfo = icBuildingDao.selectBuildingById(buildingId); |
|
|
|
OrganizationCodeResultDTO org = getBuildingCoding(customerId, neiInfo.getNeighborHoodId(), true).getData(); |
|
|
|
buildingEntity.setCoding(org.getCoding()); |
|
|
|
buildingEntity.setSysCoding(org.getSysCoding()); |
|
|
|
icBuildingDao.updateById(buildingEntity); |
|
|
@ -247,15 +255,23 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
|
|
|
|
|
//获取社区id、楼栋编码
|
|
|
|
OrganizationCommunityDTO communResult = icBuildingDao.selectCommunityByBuildingId(buildingId); |
|
|
|
//查询该社区下是否存在单元数据
|
|
|
|
IcOrganizationCodeInfoEntity unitEntity = baseDao.selectByCommunityIdAndCustomerId(customerId, communResult.getCommunityId()); |
|
|
|
if (StringUtils.isBlank(unitEntity.getUnitMaxNum())) { |
|
|
|
result.setCoding(communResult.getCoding() + "01"); |
|
|
|
result.setSysCoding(communResult.getSysCoding() + "01"); |
|
|
|
//补充该社区的单元最大数
|
|
|
|
unitEntity.setUnitMaxNum("01"); |
|
|
|
//查询该楼栋下是否存在单元数据
|
|
|
|
IcOrganizationCodeInfoEntity unitEntity = baseDao.selectByIdAndType(customerId, buildingId, OrganizationTypeEnums.BUI.getCode()); |
|
|
|
if (null == unitEntity) { |
|
|
|
Integer maxNum = 1; |
|
|
|
result.setCoding(communResult.getCoding() + getNewMaxIndex(2, maxNum)); |
|
|
|
result.setSysCoding(communResult.getSysCoding() + getNewMaxIndex(2, maxNum)); |
|
|
|
//新增该单元辅助数据
|
|
|
|
IcOrganizationCodeInfoEntity newEntity = new IcOrganizationCodeInfoEntity(); |
|
|
|
newEntity.setCustomerId(customerId); |
|
|
|
newEntity.setSysId(buildingId); |
|
|
|
if (updateFlag) { |
|
|
|
newEntity.setMaxNum(getNewMaxIndex(2, maxNum)); |
|
|
|
} |
|
|
|
newEntity.setSysType(OrganizationTypeEnums.BUI.getCode()); |
|
|
|
baseDao.insert(newEntity); |
|
|
|
} else { |
|
|
|
Integer unitMaxNum = Integer.valueOf(unitEntity.getUnitMaxNum()) + 1; |
|
|
|
Integer unitMaxNum = StringUtils.isBlank(unitEntity.getMaxNum()) ? 1 : Integer.valueOf(unitEntity.getMaxNum()) + 1; |
|
|
|
//验证可编辑的编码是否有重复
|
|
|
|
String unitCode = communResult.getCoding() + getNewMaxIndex(2, unitMaxNum); |
|
|
|
IcBuildingUnitEntity isHaveCoding = icBuildingUnitDao.selectByCoding(unitCode); |
|
|
@ -268,17 +284,17 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
|
result.setSysCoding(communResult.getSysCoding() + getNewMaxIndex(2, unitMaxNum)); |
|
|
|
|
|
|
|
//更新该社区下最大的单元编号
|
|
|
|
if(updateFlag) { |
|
|
|
unitEntity.setUnitMaxNum(getNewMaxIndex(2, unitMaxNum)); |
|
|
|
if (updateFlag) { |
|
|
|
unitEntity.setMaxNum(getNewMaxIndex(2, unitMaxNum)); |
|
|
|
baseDao.updateMaxNumByIdAndType(unitEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
baseDao.updateUnitByCuIdAndCoId(unitEntity); |
|
|
|
return new Result<OrganizationCodeResultDTO>().ok(result); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result<OrganizationCodeResultDTO> getHouseCoding(String customerId, String unitId,Boolean updateFlag) { |
|
|
|
public Result<OrganizationCodeResultDTO> getHouseCoding(String customerId, String unitId, Boolean updateFlag) { |
|
|
|
if (StringUtils.isBlank(customerId) || StringUtils.isBlank(unitId)) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); |
|
|
|
} |
|
|
@ -291,8 +307,8 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
|
} |
|
|
|
//如果单元编码为空,先生成单元编码并更新
|
|
|
|
if (StringUtils.isBlank(unitEntity.getSysCoding())) { |
|
|
|
HouseInfoResultDTO buildingInfo = icBuildingUnitDao.getUnitDetail(unitId); |
|
|
|
OrganizationCodeResultDTO org = getUnitCoding(customerId, buildingInfo.getBuildingId(),true).getData(); |
|
|
|
HouseInfoResultDTO buildingInfo = icBuildingUnitDao.getUnitDetail(unitId); |
|
|
|
OrganizationCodeResultDTO org = getUnitCoding(customerId, buildingInfo.getBuildingId(), true).getData(); |
|
|
|
unitEntity.setCoding(org.getCoding()); |
|
|
|
unitEntity.setSysCoding(org.getSysCoding()); |
|
|
|
icBuildingUnitDao.updateById(unitEntity); |
|
|
@ -300,21 +316,29 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
|
|
|
|
|
//获取社区id、单元编码
|
|
|
|
OrganizationCommunityDTO communResult = icBuildingUnitDao.selectCommunityByUnitId(unitId); |
|
|
|
//查询该社区下是否存在单元数据
|
|
|
|
IcOrganizationCodeInfoEntity houseEntity = baseDao.selectByCommunityIdAndCustomerId(customerId, communResult.getCommunityId()); |
|
|
|
if (StringUtils.isBlank(houseEntity.getUnitMaxNum())) { |
|
|
|
result.setCoding(communResult.getCoding() + "001"); |
|
|
|
//补充该社区的房屋最大数
|
|
|
|
// houseEntity.setHouseMaxNum("001");
|
|
|
|
//查询该单元下是否存在房屋数据
|
|
|
|
IcOrganizationCodeInfoEntity houseEntity = baseDao.selectByIdAndType(customerId, unitId, OrganizationTypeEnums.UNIT.getCode()); |
|
|
|
if (null == houseEntity) { |
|
|
|
Integer maxNum = 1; |
|
|
|
result.setCoding(communResult.getCoding() + getNewMaxIndex(4, maxNum)); |
|
|
|
//新增该单元辅助数据
|
|
|
|
IcOrganizationCodeInfoEntity newEntity = new IcOrganizationCodeInfoEntity(); |
|
|
|
newEntity.setCustomerId(customerId); |
|
|
|
newEntity.setSysId(unitId); |
|
|
|
if (updateFlag) { |
|
|
|
newEntity.setMaxNum(getNewMaxIndex(4, maxNum)); |
|
|
|
} |
|
|
|
newEntity.setSysType(OrganizationTypeEnums.UNIT.getCode()); |
|
|
|
baseDao.insert(newEntity); |
|
|
|
} else { |
|
|
|
Integer houseMaxNum = Integer.valueOf(houseEntity.getUnitMaxNum()) + 1; |
|
|
|
Integer houseMaxNum = StringUtils.isBlank(houseEntity.getMaxNum()) ? 1 : Integer.valueOf(houseEntity.getMaxNum()) + 1; |
|
|
|
//验证可编辑的编码是否有重复
|
|
|
|
String houseCode = communResult.getCoding() + getNewMaxIndex(4, houseMaxNum); |
|
|
|
IcHouseEntity isHaveCoding = icHouseDao.selectByCoding(houseCode); |
|
|
|
while (null != isHaveCoding) { |
|
|
|
//先更新已有的最大值
|
|
|
|
houseEntity.setHouseMaxNum(getNewMaxIndex(4, houseMaxNum)); |
|
|
|
baseDao.updateHouseByCuIdAndCoId(houseEntity); |
|
|
|
houseEntity.setMaxNum(getNewMaxIndex(4, houseMaxNum)); |
|
|
|
baseDao.updateMaxNumByIdAndType(houseEntity); |
|
|
|
houseMaxNum++; |
|
|
|
houseCode = communResult.getCoding() + getNewMaxIndex(4, houseMaxNum); |
|
|
|
isHaveCoding = icHouseDao.selectByCoding(houseCode); |
|
|
@ -323,8 +347,8 @@ public class IcOrganizationCodeInfoServiceImpl extends BaseServiceImpl<IcOrganiz |
|
|
|
|
|
|
|
//更新该社区下最大的房屋编号
|
|
|
|
// houseEntity.setHouseMaxNum(getNewMaxIndex(4, houseMaxNum));
|
|
|
|
// baseDao.updateMaxNumByIdAndType(houseEntity);
|
|
|
|
} |
|
|
|
// baseDao.updateHouseByCuIdAndCoId(houseEntity);
|
|
|
|
return new Result<OrganizationCodeResultDTO>().ok(result); |
|
|
|
} |
|
|
|
|
|
|
|