|
|
|
@ -185,8 +185,8 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
} |
|
|
|
checkData(dto); |
|
|
|
if (dto.getBuildingId() != null && dto.getUnit() != null) { |
|
|
|
int unitCode = getUnitNewCode(dto.getBuildingId(), dto.getUnit().trim().toUpperCase()); |
|
|
|
dto.setUnitMaCode(unitCode); |
|
|
|
// int unitCode = getUnitNewCode(dto.getBuildingId(), dto.getUnit().trim().toUpperCase());
|
|
|
|
// dto.setUnitMaCode(unitCode);
|
|
|
|
int roomCode = getRoomMaxCode(dto.getBuildingId(), dto.getUnit().trim().toUpperCase()); |
|
|
|
roomCode = roomCode + 1; |
|
|
|
dto.setRoomMaCode(roomCode); |
|
|
|
@ -339,26 +339,26 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
|
|
|
|
@Override |
|
|
|
public int getRoomMaxCode(Long buildingId, String unit) { |
|
|
|
Integer maxCode = baseDao.getRoomMaxCode(buildingId, unit); |
|
|
|
Integer maxCode = baseDao.getRoomMaxCode(buildingId, null); |
|
|
|
if (maxCode == null) { |
|
|
|
maxCode = 0; |
|
|
|
} |
|
|
|
return maxCode; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public int getUnitNewCode(Long buildingId, String unit) { |
|
|
|
Integer code = baseDao.getUnitCode(buildingId, unit); |
|
|
|
if (code != null && code != NumConstant.ZERO) { |
|
|
|
return code; |
|
|
|
} |
|
|
|
Integer maxCode = baseDao.getUnitMaxCode(buildingId); |
|
|
|
if (maxCode == null || maxCode == NumConstant.ZERO) { |
|
|
|
maxCode = 0; |
|
|
|
} |
|
|
|
maxCode = maxCode + 1; |
|
|
|
return maxCode; |
|
|
|
} |
|
|
|
// @Override
|
|
|
|
// public int getUnitNewCode(Long buildingId, String unit) {
|
|
|
|
// Integer code = baseDao.getUnitCode(buildingId, unit);
|
|
|
|
// if (code != null && code != NumConstant.ZERO) {
|
|
|
|
// return code;
|
|
|
|
// }
|
|
|
|
// Integer maxCode = baseDao.getUnitMaxCode(buildingId);
|
|
|
|
// if (maxCode == null || maxCode == NumConstant.ZERO) {
|
|
|
|
// maxCode = 0;
|
|
|
|
// }
|
|
|
|
// maxCode = maxCode + 1;
|
|
|
|
// return maxCode;
|
|
|
|
// }
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void updateErrorRoom() { |
|
|
|
@ -391,7 +391,7 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
if (!list.isEmpty()) { |
|
|
|
for (EpidemicBuildingUnitEntity epidemicBuildingUnitEntity : list) { |
|
|
|
if (epidemicBuildingUnitEntity.getBuildingId() != null && StringUtils.isNotBlank(epidemicBuildingUnitEntity.getUnit())) { |
|
|
|
updateUnitMaCode(epidemicBuildingUnitEntity); |
|
|
|
// updateUnitMaCode(epidemicBuildingUnitEntity);
|
|
|
|
if (StringUtils.isNotBlank(epidemicBuildingUnitEntity.getRoomNo())) { |
|
|
|
updateRoomMaCode(epidemicBuildingUnitEntity); |
|
|
|
} |
|
|
|
@ -401,30 +401,30 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void updateUnitMaCode(EpidemicBuildingUnitEntity entity) { |
|
|
|
String key = RedisKeys.getMaUnitCodeKey(entity.getBuildingId().toString(), entity.getUnit()); |
|
|
|
String nextKey = RedisKeys.getMaUnitNextCodeKey(entity.getBuildingId().toString()); |
|
|
|
Object obj = redisUtils.get(key); |
|
|
|
Object nextObj = redisUtils.get(nextKey); |
|
|
|
if (null != obj) { |
|
|
|
int maCodeCache = (int) obj; |
|
|
|
entity.setUnitMaCode(maCodeCache); |
|
|
|
redisUtils.set(key, maCodeCache, RedisUtils.HOUR_ONE_EXPIRE); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (null != nextObj) { |
|
|
|
int maCodeCache = (int) nextObj; |
|
|
|
entity.setUnitMaCode(maCodeCache); |
|
|
|
redisUtils.set(key, maCodeCache, RedisUtils.HOUR_ONE_EXPIRE); |
|
|
|
redisUtils.set(nextKey, maCodeCache + 1, RedisUtils.HOUR_ONE_EXPIRE); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
int maCode = getUnitNewCode(entity.getBuildingId(), entity.getUnit()); |
|
|
|
entity.setUnitMaCode(maCode); |
|
|
|
redisUtils.set(key, maCode, RedisUtils.HOUR_ONE_EXPIRE); |
|
|
|
redisUtils.set(nextKey, maCode + 1, RedisUtils.HOUR_ONE_EXPIRE); |
|
|
|
} |
|
|
|
// private void updateUnitMaCode(EpidemicBuildingUnitEntity entity) {
|
|
|
|
// String key = RedisKeys.getMaUnitCodeKey(entity.getBuildingId().toString(), entity.getUnit());
|
|
|
|
// String nextKey = RedisKeys.getMaUnitNextCodeKey(entity.getBuildingId().toString());
|
|
|
|
// Object obj = redisUtils.get(key);
|
|
|
|
// Object nextObj = redisUtils.get(nextKey);
|
|
|
|
// if (null != obj) {
|
|
|
|
// int maCodeCache = (int) obj;
|
|
|
|
// entity.setUnitMaCode(maCodeCache);
|
|
|
|
// redisUtils.set(key, maCodeCache, RedisUtils.HOUR_ONE_EXPIRE);
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// if (null != nextObj) {
|
|
|
|
// int maCodeCache = (int) nextObj;
|
|
|
|
// entity.setUnitMaCode(maCodeCache);
|
|
|
|
// redisUtils.set(key, maCodeCache, RedisUtils.HOUR_ONE_EXPIRE);
|
|
|
|
// redisUtils.set(nextKey, maCodeCache + 1, RedisUtils.HOUR_ONE_EXPIRE);
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// int maCode = getUnitNewCode(entity.getBuildingId(), entity.getUnit());
|
|
|
|
// entity.setUnitMaCode(maCode);
|
|
|
|
// redisUtils.set(key, maCode, RedisUtils.HOUR_ONE_EXPIRE);
|
|
|
|
// redisUtils.set(nextKey, maCode + 1, RedisUtils.HOUR_ONE_EXPIRE);
|
|
|
|
// }
|
|
|
|
|
|
|
|
private void updateRoomMaCode(EpidemicBuildingUnitEntity entity) { |
|
|
|
String key = RedisKeys.getMaRoomCodeKey(entity.getBuildingId().toString(), entity.getUnit()); |
|
|
|
@ -705,12 +705,12 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
unitEntity.setOwnerName(item.getUserName()); |
|
|
|
unitEntity.setMobile(item.getMobile()); |
|
|
|
unitEntity.setRoomType(NumConstant.ONE_STR); |
|
|
|
int unitCode = getUnitNewCode(buildingOptional.get().getId(), item.getUnit().trim().toUpperCase()); |
|
|
|
unitEntity.setUnitMaCode(unitCode); |
|
|
|
// int unitCode = getUnitNewCode(buildingOptional.get().getId(), item.getUnit().trim().toUpperCase());
|
|
|
|
// unitEntity.setUnitMaCode(unitCode);
|
|
|
|
int roomCode = getRoomMaxCode(buildingOptional.get().getId(), item.getUnit().trim().toUpperCase()); |
|
|
|
roomCode = roomCode + 1; |
|
|
|
unitEntity.setRoomMaCode(roomCode); |
|
|
|
unitEntity.setRoomCode(getRoomCode(buildingOptional.get().getBuildingMaCode(), roomCode)); |
|
|
|
unitEntity.setRoomCode(getRoomCode(buildingOptional.get().getPlotMaCode(), buildingOptional.get().getBuildingMaCode(), roomCode)); |
|
|
|
unitEntity.setGridId(parentAndAllDeptDTO.getGridId().toString()); |
|
|
|
unitEntity.setGridName(parentAndAllDeptDTO.getGrid()); |
|
|
|
unitEntity.setCommunityId(parentAndAllDeptDTO.getCommunityId().toString()); |
|
|
|
@ -765,12 +765,12 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
unitEntity.setOwnerName(item.getUserName()); |
|
|
|
unitEntity.setMobile(item.getMobile()); |
|
|
|
unitEntity.setRoomType(NumConstant.ONE_STR); |
|
|
|
int unitCode = getUnitNewCode(buildingOptional.get().getId(), item.getUnit().trim().toUpperCase()); |
|
|
|
unitEntity.setUnitMaCode(unitCode); |
|
|
|
// int unitCode = getUnitNewCode(buildingOptional.get().getId(), item.getUnit().trim().toUpperCase());
|
|
|
|
// unitEntity.setUnitMaCode(unitCode);
|
|
|
|
int roomCode = getRoomMaxCode(buildingOptional.get().getId(), item.getUnit().trim().toUpperCase()); |
|
|
|
roomCode = roomCode + 1; |
|
|
|
unitEntity.setRoomMaCode(roomCode); |
|
|
|
unitEntity.setRoomCode(getRoomCode(buildingOptional.get().getBuildingMaCode(), roomCode)); |
|
|
|
unitEntity.setRoomCode(getRoomCode(buildingOptional.get().getPlotMaCode(), buildingOptional.get().getBuildingMaCode(), roomCode)); |
|
|
|
unitEntity.setGridId(parentAndAllDeptDTO.getGridId().toString()); |
|
|
|
unitEntity.setGridName(parentAndAllDeptDTO.getGrid()); |
|
|
|
unitEntity.setCommunityId(parentAndAllDeptDTO.getCommunityId().toString()); |
|
|
|
@ -793,9 +793,9 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private String getRoomCode(Integer buildingMaCode, Integer roomMaCode) { |
|
|
|
private String getRoomCode(Integer plotMaCode, Integer buildingMaCode, Integer roomMaCode) { |
|
|
|
String orgId = "370211010042"; |
|
|
|
return orgId.concat(String.format("%05d", buildingMaCode).concat(String.format("%05d", roomMaCode))); |
|
|
|
return orgId.concat(String.format("%03d", plotMaCode)).concat(String.format("%03d", buildingMaCode).concat(String.format("%05d", roomMaCode))); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|