|
|
@ -27,6 +27,8 @@ import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.StrConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.redis.RedisKeys; |
|
|
|
import com.elink.esua.epdc.commons.tools.redis.RedisUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.IdentityNoUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
@ -38,6 +40,7 @@ import com.elink.esua.epdc.dto.house.result.EpdcPopulationErrorResultDTO; |
|
|
|
import com.elink.esua.epdc.dto.personroom.EpidemicBuildingUnitDTO; |
|
|
|
import com.elink.esua.epdc.dto.personroom.EpidemicUnitOwnerDTO; |
|
|
|
import com.elink.esua.epdc.dto.personroom.form.GetHouseInfoFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.personroom.form.HouseInfoFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.personroom.form.HouseQrcodeZipFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.personroom.result.*; |
|
|
|
import com.elink.esua.epdc.vaccine.epidemic.entity.EpidemicUserErrorEntity; |
|
|
@ -112,6 +115,9 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
@Autowired |
|
|
|
private QrCodeProperties qrCodeProperties; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RedisUtils redisUtils; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<EpidemicBuildingUnitDTO> page(Map<String, Object> params) { |
|
|
|
IPage<EpidemicBuildingUnitDTO> page = getPage(params); |
|
|
@ -178,6 +184,13 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
throw new RenException("房屋已存在"); |
|
|
|
} |
|
|
|
checkData(dto); |
|
|
|
if (dto.getBuildingId() != null && dto.getUnit() != null) { |
|
|
|
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); |
|
|
|
} |
|
|
|
EpidemicBuildingUnitEntity entity = ConvertUtils.sourceToTarget(dto, EpidemicBuildingUnitEntity.class); |
|
|
|
insert(entity); |
|
|
|
saveOrUpdateOwners(dto.getOwners(), entity.getId()); |
|
|
@ -325,14 +338,28 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public int getMaxCode() { |
|
|
|
Integer maxCode = baseDao.getMaxCode(); |
|
|
|
public int getRoomMaxCode(Long buildingId, String unit) { |
|
|
|
Integer maxCode = baseDao.getRoomMaxCode(buildingId, unit); |
|
|
|
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 void updateErrorRoom() { |
|
|
|
List<EpidemicBuildingUnitEntity> list = baseDao.getErrorRoom(); |
|
|
@ -362,13 +389,59 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
params.put("roomMaCode", "0"); |
|
|
|
List<EpidemicBuildingUnitEntity> list = baseDao.selectList(getWrapper(params)); |
|
|
|
if (!list.isEmpty()) { |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
list.get(i).setRoomMaCode(i + 1); |
|
|
|
for (EpidemicBuildingUnitEntity epidemicBuildingUnitEntity : list) { |
|
|
|
if (epidemicBuildingUnitEntity.getBuildingId() != null && StringUtils.isNotBlank(epidemicBuildingUnitEntity.getUnit())) { |
|
|
|
updateUnitMaCode(epidemicBuildingUnitEntity); |
|
|
|
if (StringUtils.isNotBlank(epidemicBuildingUnitEntity.getRoomNo())) { |
|
|
|
updateRoomMaCode(epidemicBuildingUnitEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
updateBatchById(list); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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()); |
|
|
|
Object obj = redisUtils.get(key); |
|
|
|
if (null != obj) { |
|
|
|
int maCodeCache = (int) obj; |
|
|
|
maCodeCache = maCodeCache + 1; |
|
|
|
entity.setRoomMaCode(maCodeCache); |
|
|
|
redisUtils.set(key, maCodeCache, RedisUtils.HOUR_ONE_EXPIRE); |
|
|
|
return; |
|
|
|
} |
|
|
|
int maCode = getRoomMaxCode(entity.getBuildingId(), entity.getUnit()); |
|
|
|
maCode = maCode + 1; |
|
|
|
entity.setRoomMaCode(maCode); |
|
|
|
redisUtils.set(key, maCode, RedisUtils.HOUR_ONE_EXPIRE); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result createBatchHouseCodeAndUrl() { |
|
|
|
epidemicPlotBuildingService.updateMaCode(); |
|
|
@ -608,7 +681,7 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
epidemicUserInfoService.updateBatchById(updateList); |
|
|
|
} |
|
|
|
// 补充人房关系
|
|
|
|
int roomCode = getMaxCode(); |
|
|
|
|
|
|
|
List<EpidemicUnitInfoResultDTO> unitList = listAllUnitInfo(parentAndAllDeptDTO.getGrid()); |
|
|
|
List<EpidemicUnitOwnerEntity> addOwner = new ArrayList<>(); |
|
|
|
for (EpidemicUserInfoEntity item : addList) { |
|
|
@ -632,6 +705,9 @@ 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 roomCode = getRoomMaxCode(buildingOptional.get().getId(), item.getUnit().trim().toUpperCase()); |
|
|
|
roomCode = roomCode + 1; |
|
|
|
unitEntity.setRoomMaCode(roomCode); |
|
|
|
unitEntity.setRoomCode(getRoomCode(buildingOptional.get().getBuildingMaCode(), roomCode)); |
|
|
@ -689,6 +765,9 @@ 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 roomCode = getRoomMaxCode(buildingOptional.get().getId(), item.getUnit().trim().toUpperCase()); |
|
|
|
roomCode = roomCode + 1; |
|
|
|
unitEntity.setRoomMaCode(roomCode); |
|
|
|
unitEntity.setRoomCode(getRoomCode(buildingOptional.get().getBuildingMaCode(), roomCode)); |
|
|
@ -742,6 +821,13 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
return new Result<HouseInfoResultDTO>().ok(houseInfoResultDTO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result updateHouseInfo(HouseInfoFormDTO formDTO) { |
|
|
|
EpidemicBuildingUnitEntity entity = ConvertUtils.sourceToTarget(formDTO, EpidemicBuildingUnitEntity.class); |
|
|
|
baseDao.updateById(entity); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
public String createHouseQrCodeUrl(String roomCode, String name) throws Exception { |
|
|
|
//url组成:小程序地址?房屋编码
|
|
|
|
String url = qrCodeProperties.getPre() + roomCode; |
|
|
|