|
|
@ -27,7 +27,6 @@ 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; |
|
|
@ -40,7 +39,6 @@ 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.GetSkipDirectionFormDTO; |
|
|
|
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.*; |
|
|
@ -75,6 +73,8 @@ import java.awt.image.BufferedImage; |
|
|
|
import java.io.*; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.util.*; |
|
|
|
import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.zip.ZipEntry; |
|
|
|
import java.util.zip.ZipOutputStream; |
|
|
@ -177,6 +177,8 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result saveNew(EpidemicBuildingUnitDTO dto) { |
|
|
|
dto.setUnit(dto.getUnit().trim().toUpperCase()); |
|
|
|
dto.setRoomNo(dto.getRoomNo().trim().toUpperCase()); |
|
|
|
Map<String, Object> params = new HashMap<>(8); |
|
|
|
params.put("buildingId", dto.getBuildingId().toString()); |
|
|
|
params.put("unit", dto.getUnit()); |
|
|
@ -185,19 +187,19 @@ 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); |
|
|
|
if (dto.getBuildingId() != null && dto.getUnit() != null && dto.getRoomNo() != null) { |
|
|
|
String showCode = getRoomCodeShow(dto.getBuildingId(), dto.getUnit(), dto.getRoomNo()); |
|
|
|
dto.setRoomCodeShow(showCode); |
|
|
|
} |
|
|
|
EpidemicBuildingUnitEntity entity = ConvertUtils.sourceToTarget(dto, EpidemicBuildingUnitEntity.class); |
|
|
|
insert(entity); |
|
|
|
entity.setRoomCode(entity.getId().toString()); |
|
|
|
updateById(entity); |
|
|
|
saveOrUpdateOwners(dto.getOwners(), entity.getId()); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(EpidemicBuildingUnitDTO dto) { |
|
|
@ -208,6 +210,8 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result updateNew(EpidemicBuildingUnitDTO dto) { |
|
|
|
dto.setUnit(dto.getUnit().trim().toUpperCase()); |
|
|
|
dto.setRoomNo(dto.getRoomNo().trim().toUpperCase()); |
|
|
|
checkData(dto); |
|
|
|
EpidemicBuildingUnitEntity entity = ConvertUtils.sourceToTarget(dto, EpidemicBuildingUnitEntity.class); |
|
|
|
updateById(entity); |
|
|
@ -386,19 +390,19 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updateMaCode() { |
|
|
|
Map<String, Object> params = new HashMap<>(4); |
|
|
|
params.put("roomMaCode", "0"); |
|
|
|
List<EpidemicBuildingUnitEntity> list = baseDao.selectList(getWrapper(params)); |
|
|
|
List<EpidemicRoomCodeDTO> list = baseDao.listNoRoomCode(); |
|
|
|
if (!list.isEmpty()) { |
|
|
|
for (EpidemicBuildingUnitEntity epidemicBuildingUnitEntity : list) { |
|
|
|
if (epidemicBuildingUnitEntity.getBuildingId() != null && StringUtils.isNotBlank(epidemicBuildingUnitEntity.getUnit())) { |
|
|
|
// updateUnitMaCode(epidemicBuildingUnitEntity);
|
|
|
|
if (StringUtils.isNotBlank(epidemicBuildingUnitEntity.getRoomNo())) { |
|
|
|
updateRoomMaCode(epidemicBuildingUnitEntity); |
|
|
|
} |
|
|
|
List<EpidemicBuildingUnitEntity> updateList = new ArrayList<>(); |
|
|
|
for (EpidemicRoomCodeDTO dto : list) { |
|
|
|
if (dto.getBuildingId() != null && StringUtils.isNotBlank(dto.getUnit()) && StringUtils.isNotBlank(dto.getRoomNo())) { |
|
|
|
EpidemicBuildingUnitEntity entity = new EpidemicBuildingUnitEntity(); |
|
|
|
entity.setRoomCode(dto.getId().toString()); |
|
|
|
entity.setRoomCodeShow(getRoomCodeShow(dto.getBuildingId(), dto.getUnit(), dto.getRoomNo())); |
|
|
|
entity.setId(dto.getId()); |
|
|
|
updateList.add(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
updateBatchById(list); |
|
|
|
updateBatchById(updateList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -411,10 +415,9 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
log.info("处理" + list.size() + "条无编码房屋"); |
|
|
|
list.forEach(item -> { |
|
|
|
EpidemicBuildingUnitEntity entity = new EpidemicBuildingUnitEntity(); |
|
|
|
String roomCode = getRoomCode(item.getPlotMaCode(), item.getBuildingMaCode(), item.getRoomMaCode()); |
|
|
|
entity.setId(item.getId()); |
|
|
|
entity.setBuildingId(item.getBuildingId()); |
|
|
|
entity.setRoomCode(roomCode); |
|
|
|
entity.setRoomCode(item.getId().toString()); |
|
|
|
updateList.add(entity); |
|
|
|
}); |
|
|
|
updateBatchById(updateList); |
|
|
@ -445,22 +448,22 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
// 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); |
|
|
|
} |
|
|
|
//
|
|
|
|
// 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() { |
|
|
@ -686,8 +689,8 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
EpidemicUserInfoEntity check = optional.get(); |
|
|
|
check.setPlot(epidemicUserInfoEntity.getPlot()); |
|
|
|
check.setBuildingNo(epidemicUserInfoEntity.getBuildingNo()); |
|
|
|
check.setUnit(epidemicUserInfoEntity.getUnit()); |
|
|
|
check.setRoomNo(epidemicUserInfoEntity.getRoomNo()); |
|
|
|
check.setUnit(epidemicUserInfoEntity.getUnit().trim().toUpperCase()); |
|
|
|
check.setRoomNo(epidemicUserInfoEntity.getRoomNo().trim().toUpperCase()); |
|
|
|
check.setRelation(epidemicUserInfoEntity.getRelation()); |
|
|
|
updateList.add(check); |
|
|
|
} |
|
|
@ -695,15 +698,24 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
|
|
|
|
// 改为批量插入和批量按ID更新
|
|
|
|
if (!addList.isEmpty()) { |
|
|
|
addList.forEach(item -> { |
|
|
|
item.setUnit(item.getUnit().trim().toUpperCase()); |
|
|
|
item.setRoomNo(item.getRoomNo().trim().toUpperCase()); |
|
|
|
}); |
|
|
|
epidemicUserInfoService.insertBatch(addList); |
|
|
|
} |
|
|
|
if (!updateList.isEmpty()) { |
|
|
|
updateList.forEach(item -> { |
|
|
|
item.setUnit(item.getUnit().trim().toUpperCase()); |
|
|
|
item.setRoomNo(item.getRoomNo().trim().toUpperCase()); |
|
|
|
}); |
|
|
|
epidemicUserInfoService.updateBatchById(updateList); |
|
|
|
} |
|
|
|
// 补充人房关系
|
|
|
|
|
|
|
|
List<EpidemicUnitInfoResultDTO> unitList = listAllUnitInfo(parentAndAllDeptDTO.getGrid()); |
|
|
|
List<EpidemicUnitInfoResultDTO> unitList = listAllUnitInfo(parentAndAllDeptDTO.getGridId().toString()); |
|
|
|
List<EpidemicUnitOwnerEntity> addOwner = new ArrayList<>(); |
|
|
|
List<EpidemicBuildingUnitEntity> updateUnitList = new ArrayList<>(); |
|
|
|
for (EpidemicUserInfoEntity item : addList) { |
|
|
|
// 只有信息完整的才进行匹配
|
|
|
|
Optional<EpidemicUnitInfoResultDTO> unitOptional = unitList.stream().filter(unit -> unit.getPlotName().equals(item.getPlot()) && unit.getBuildingName().equals(item.getBuildingNo()) && unit.getUnit().equals(item.getUnit()) && unit.getRoomNo().equals(item.getRoomNo())).findFirst(); |
|
|
@ -725,12 +737,6 @@ 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().getPlotMaCode(), buildingOptional.get().getBuildingMaCode(), roomCode)); |
|
|
|
unitEntity.setGridId(parentAndAllDeptDTO.getGridId().toString()); |
|
|
|
unitEntity.setGridName(parentAndAllDeptDTO.getGrid()); |
|
|
|
unitEntity.setCommunityId(parentAndAllDeptDTO.getCommunityId().toString()); |
|
|
@ -738,6 +744,12 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
unitEntity.setStreetId(parentAndAllDeptDTO.getStreetId().toString()); |
|
|
|
unitEntity.setStreetName(parentAndAllDeptDTO.getStreet()); |
|
|
|
insert(unitEntity); |
|
|
|
unitEntity.setRoomCode(unitEntity.getId().toString()); |
|
|
|
if (item.getUnit() != null && item.getRoomNo() != null) { |
|
|
|
String showCode = getRoomCodeShow(buildingOptional.get().getId(), item.getUnit(), item.getRoomNo()); |
|
|
|
unitEntity.setRoomCodeShow(showCode); |
|
|
|
} |
|
|
|
updateUnitList.add(unitEntity); |
|
|
|
|
|
|
|
// 新增的房屋也要放到待筛选列表,后续循环便可认为该房屋是已存在的
|
|
|
|
EpidemicUnitInfoResultDTO newUnit = new EpidemicUnitInfoResultDTO(); |
|
|
@ -749,7 +761,6 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
newUnit.setUnit(item.getUnit().trim().toUpperCase()); |
|
|
|
newUnit.setUnitId(unitEntity.getId()); |
|
|
|
newUnit.setRoomNo(item.getRoomNo().trim().toUpperCase()); |
|
|
|
newUnit.setRoomMaCode(roomCode); |
|
|
|
unitList.add(newUnit); |
|
|
|
|
|
|
|
EpidemicUnitOwnerEntity entity = new EpidemicUnitOwnerEntity(); |
|
|
@ -785,12 +796,7 @@ 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().getPlotMaCode(), buildingOptional.get().getBuildingMaCode(), roomCode)); |
|
|
|
|
|
|
|
unitEntity.setGridId(parentAndAllDeptDTO.getGridId().toString()); |
|
|
|
unitEntity.setGridName(parentAndAllDeptDTO.getGrid()); |
|
|
|
unitEntity.setCommunityId(parentAndAllDeptDTO.getCommunityId().toString()); |
|
|
@ -798,6 +804,12 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
unitEntity.setStreetId(parentAndAllDeptDTO.getStreetId().toString()); |
|
|
|
unitEntity.setStreetName(parentAndAllDeptDTO.getStreet()); |
|
|
|
insert(unitEntity); |
|
|
|
unitEntity.setRoomCode(unitEntity.getId().toString()); |
|
|
|
if (item.getUnit() != null && item.getRoomNo() != null) { |
|
|
|
String showCode = getRoomCodeShow(buildingOptional.get().getId(), item.getUnit(), item.getRoomNo()); |
|
|
|
unitEntity.setRoomCodeShow(showCode); |
|
|
|
} |
|
|
|
updateUnitList.add(unitEntity); |
|
|
|
EpidemicUnitOwnerEntity entity = new EpidemicUnitOwnerEntity(); |
|
|
|
entity.setIdCard(item.getIdCard()); |
|
|
|
entity.setUnitId(unitEntity.getId()); |
|
|
@ -809,13 +821,51 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
epidemicUnitOwnerService.insertBatch(addOwner); |
|
|
|
if (!addOwner.isEmpty()) { |
|
|
|
epidemicUnitOwnerService.insertBatch(addOwner); |
|
|
|
} |
|
|
|
if (!updateUnitList.isEmpty()) { |
|
|
|
updateBatchById(updateUnitList); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private String getRoomCode(Integer plotMaCode, Integer buildingMaCode, Integer roomMaCode) { |
|
|
|
private String getRoomCodeShow(Long buildingId, String unit, String roomNo) { |
|
|
|
String orgId = "370211010042"; |
|
|
|
return orgId.concat(String.format("%03d", plotMaCode)).concat(String.format("%03d", buildingMaCode).concat(String.format("%05d", roomMaCode))); |
|
|
|
String showBuildingCode = buildingId.toString().substring(buildingId.toString().length() - 6); |
|
|
|
return orgId.concat(showBuildingCode).concat(getRoomMaCode(unit, roomNo)); |
|
|
|
} |
|
|
|
|
|
|
|
private String getRoomMaCode(String unit, String roomNo) { |
|
|
|
String unitCode; |
|
|
|
String roomCode; |
|
|
|
String unitNum = getNumbers(unit); |
|
|
|
String roomNum = getNumbers(roomNo); |
|
|
|
if (StringUtils.isBlank(unitNum)) { |
|
|
|
unitNum = "0"; |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(roomNum)) { |
|
|
|
roomNum = "0"; |
|
|
|
} |
|
|
|
|
|
|
|
if (unitNum.length() < 3) { |
|
|
|
unitCode = String.format("%03d", Integer.parseInt(unitNum)); |
|
|
|
} else { |
|
|
|
unitCode = unitNum.substring(unitNum.length() - 3); |
|
|
|
} |
|
|
|
if (roomNum.length() < 3) { |
|
|
|
roomCode = String.format("%03d", Integer.parseInt(roomNum)); |
|
|
|
} else { |
|
|
|
roomCode = roomNum.substring(roomNum.length() - 3); |
|
|
|
} |
|
|
|
return unitCode.concat(roomCode); |
|
|
|
} |
|
|
|
|
|
|
|
public String getNumbers(String content) { |
|
|
|
Pattern pattern = Pattern.compile("[^0-9]"); |
|
|
|
Matcher matcher = pattern.matcher(content); |
|
|
|
return matcher.replaceAll("").trim(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|