|
|
@ -85,7 +85,7 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
/** |
|
|
|
* 导出房屋内家庭成员时本地缓存 |
|
|
|
*/ |
|
|
|
private static final Cache<String,List<HouseIcResiUserResultDTO.HouseMemberResultDTO>> memberCacheMap = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MINUTES).expireAfterWrite(30,TimeUnit.MINUTES).build(); |
|
|
|
private static final Cache<String, List<HouseIcResiUserResultDTO.HouseMemberResultDTO>> memberCacheMap = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MINUTES).expireAfterWrite(30, TimeUnit.MINUTES).build(); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IcHouseService icHouseService; |
|
|
@ -131,28 +131,29 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void addHouse(String customerId, IcHouseAddFormDTO formDTO) { |
|
|
|
//同一楼栋,单元内,房屋名称唯一
|
|
|
|
Integer count = icHouseDao.checkDoorNameUq(formDTO.getNeighborHoodId(), formDTO.getBuildingId(), formDTO.getBuildingUnitId(), formDTO.getDoorName(),null); |
|
|
|
Integer count = icHouseDao.checkDoorNameUq(formDTO.getNeighborHoodId(), formDTO.getBuildingId(), formDTO.getBuildingUnitId(), formDTO.getDoorName(), null); |
|
|
|
if (null != count && count > 0) { |
|
|
|
throw new RenException(EpmetErrorCode.DOOR_NAME_EXITED.getCode(), EpmetErrorCode.DOOR_NAME_EXITED.getMsg()); |
|
|
|
} |
|
|
|
IcHouseDTO icHouseDTO= ConvertUtils.sourceToTarget(formDTO, IcHouseDTO.class); |
|
|
|
IcHouseDTO icHouseDTO = ConvertUtils.sourceToTarget(formDTO, IcHouseDTO.class); |
|
|
|
icHouseDTO.setCustomerId(customerId); |
|
|
|
icHouseDTO.setHouseName(getHouseName(formDTO)); |
|
|
|
icHouseService.save(icHouseDTO); |
|
|
|
} |
|
|
|
|
|
|
|
private String getHouseName(IcHouseAddFormDTO formDTO){ |
|
|
|
private String getHouseName(IcHouseAddFormDTO formDTO) { |
|
|
|
//设置房间名 楼栋-单元号-门牌号
|
|
|
|
IcBuildingDTO icBuilding = icBuildingService.get(formDTO.getBuildingId()); |
|
|
|
IcBuildingUnitDTO icBuildingUnit = icBuildingUnitService.get(formDTO.getBuildingUnitId()); |
|
|
|
String doorName = formDTO.getDoorName(); |
|
|
|
String buildingName = Optional.ofNullable(icBuilding).map(u->u.getBuildingName()).orElse(""); |
|
|
|
String unitName = Optional.ofNullable(icBuildingUnit).map(u->u.getUnitNum()).orElse(""); |
|
|
|
return new StringBuilder().append(buildingName).append("-").append(unitName).append("-").append(doorName).toString(); |
|
|
|
String buildingName = Optional.ofNullable(icBuilding).map(u -> u.getBuildingName()).orElse(""); |
|
|
|
String unitName = Optional.ofNullable(icBuildingUnit).map(u -> u.getUnitNum()).orElse(""); |
|
|
|
return new StringBuilder().append(buildingName).append("-").append(unitName).append("-").append(doorName).toString(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 更新 |
|
|
|
* |
|
|
|
* @param customerId |
|
|
|
* @param formDTO |
|
|
|
*/ |
|
|
@ -160,7 +161,7 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void updateHouse(String customerId, IcHouseAddFormDTO formDTO) { |
|
|
|
//同一楼栋,单元内,房屋名称唯一
|
|
|
|
Integer count = icHouseDao.checkDoorNameUq(formDTO.getNeighborHoodId(), formDTO.getBuildingId(), formDTO.getBuildingUnitId(),formDTO.getDoorName(), formDTO.getHouseId()); |
|
|
|
Integer count = icHouseDao.checkDoorNameUq(formDTO.getNeighborHoodId(), formDTO.getBuildingId(), formDTO.getBuildingUnitId(), formDTO.getDoorName(), formDTO.getHouseId()); |
|
|
|
if (null != count && count > 0) { |
|
|
|
throw new RenException(EpmetErrorCode.DOOR_NAME_EXITED.getCode(), EpmetErrorCode.DOOR_NAME_EXITED.getMsg()); |
|
|
|
} |
|
|
@ -176,11 +177,12 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
houseChangeRecord(formDTO.getHouseId(), customerId, icHouseDTO); |
|
|
|
icHouseService.update(icHouseDTO); |
|
|
|
//删除房屋缓存
|
|
|
|
icHouseRedis.delHouseInfo(formDTO.getHouseId(),customerId); |
|
|
|
icHouseRedis.delHouseInfo(formDTO.getHouseId(), customerId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Desc: 房屋变更记录 |
|
|
|
* |
|
|
|
* @param houseId |
|
|
|
* @param customerId |
|
|
|
* @param houseDTO |
|
|
@ -189,18 +191,18 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public void houseChangeRecord(String houseId, String customerId, IcHouseDTO houseDTO){ |
|
|
|
public void houseChangeRecord(String houseId, String customerId, IcHouseDTO houseDTO) { |
|
|
|
IcHouseEntity entity = icHouseService.selectById(houseId); |
|
|
|
entity.setOwnerName(null == entity.getOwnerName() ? "" : entity.getOwnerName()); |
|
|
|
entity.setOwnerPhone(null == entity.getOwnerPhone() ? "" : entity.getOwnerPhone()); |
|
|
|
entity.setOwnerIdCard(null == entity.getOwnerIdCard() ? "" : entity.getOwnerIdCard()); |
|
|
|
if (null == entity){ |
|
|
|
if (null == entity) { |
|
|
|
throw new EpmetException("不存在此房屋..."); |
|
|
|
} |
|
|
|
StringBuilder sbBefore = new StringBuilder(); |
|
|
|
StringBuilder sbAfter = new StringBuilder(); |
|
|
|
List<IcHouseChangeDetailEntity> entityList = new ArrayList<>(); |
|
|
|
if (!houseDTO.getHouseType().equals(entity.getHouseType())){ |
|
|
|
if (!houseDTO.getHouseType().equals(entity.getHouseType())) { |
|
|
|
sbAfter.append(HouseChangeEnums.HOUSE_TYPE.getColumnName()).append(":").append(null == houseDTO.getHouseTypeName() ? HouseTypeEnums.getTypeValue(houseDTO.getHouseType()) : houseDTO.getHouseTypeName()).append(";"); |
|
|
|
sbBefore.append(HouseChangeEnums.HOUSE_TYPE.getColumnName()).append(":").append(HouseTypeEnums.getTypeValue(entity.getHouseType())).append(";"); |
|
|
|
IcHouseChangeDetailEntity e = new IcHouseChangeDetailEntity(); |
|
|
@ -209,7 +211,7 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
e.setChangeAfter(null == houseDTO.getHouseTypeName() ? HouseTypeEnums.getTypeValue(houseDTO.getHouseType()) : houseDTO.getHouseTypeName()); |
|
|
|
entityList.add(e); |
|
|
|
} |
|
|
|
if (!houseDTO.getPurpose().equals(entity.getPurpose())){ |
|
|
|
if (!houseDTO.getPurpose().equals(entity.getPurpose())) { |
|
|
|
sbAfter.append(HouseChangeEnums.PURPOSE.getColumnName()).append(":").append(null == houseDTO.getPurposeName() ? HousePurposeEnums.getTypeValue(houseDTO.getPurpose()) : houseDTO.getPurposeName()).append(";"); |
|
|
|
sbBefore.append(HouseChangeEnums.PURPOSE.getColumnName()).append(":").append(HousePurposeEnums.getTypeValue(entity.getPurpose())).append(";"); |
|
|
|
IcHouseChangeDetailEntity e = new IcHouseChangeDetailEntity(); |
|
|
@ -218,7 +220,7 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
e.setChangeBefore(HousePurposeEnums.getTypeValue(entity.getPurpose())); |
|
|
|
entityList.add(e); |
|
|
|
} |
|
|
|
if (!houseDTO.getRentFlag().equals(entity.getRentFlag())){ |
|
|
|
if (!houseDTO.getRentFlag().equals(entity.getRentFlag())) { |
|
|
|
sbAfter.append(HouseChangeEnums.RENT_FLAG.getColumnName()).append(":").append(null == houseDTO.getRentName() ? HouseRentFlagEnums.getTypeValue(houseDTO.getRentFlag()) : houseDTO.getRentName()).append(";"); |
|
|
|
sbBefore.append(HouseChangeEnums.RENT_FLAG.getColumnName()).append(":").append(HouseRentFlagEnums.getTypeValue(entity.getRentFlag())).append(";"); |
|
|
|
IcHouseChangeDetailEntity e = new IcHouseChangeDetailEntity(); |
|
|
@ -227,7 +229,7 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
e.setChangeBefore(HouseRentFlagEnums.getTypeValue(entity.getRentFlag())); |
|
|
|
entityList.add(e); |
|
|
|
} |
|
|
|
if (null != houseDTO.getOwnerName() && !houseDTO.getOwnerName().equals(entity.getOwnerName())){ |
|
|
|
if (null != houseDTO.getOwnerName() && !houseDTO.getOwnerName().equals(entity.getOwnerName())) { |
|
|
|
sbAfter.append(HouseChangeEnums.OWNER_NAME.getColumnName()).append(":").append(StringUtils.isNotBlank(houseDTO.getOwnerName()) ? houseDTO.getOwnerName() : "无").append(";"); |
|
|
|
sbBefore.append(HouseChangeEnums.OWNER_NAME.getColumnName()).append(":").append(StringUtils.isNotBlank(entity.getOwnerName()) ? entity.getOwnerName() : "无").append(";"); |
|
|
|
IcHouseChangeDetailEntity e = new IcHouseChangeDetailEntity(); |
|
|
@ -236,7 +238,7 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
e.setChangeBefore(StringUtils.isNotBlank(entity.getOwnerName()) ? entity.getOwnerName() : "无"); |
|
|
|
entityList.add(e); |
|
|
|
} |
|
|
|
if (null != houseDTO.getOwnerPhone() && !houseDTO.getOwnerPhone().equals(entity.getOwnerPhone())){ |
|
|
|
if (null != houseDTO.getOwnerPhone() && !houseDTO.getOwnerPhone().equals(entity.getOwnerPhone())) { |
|
|
|
sbAfter.append(HouseChangeEnums.OWNER_PHONE.getColumnName()).append(":").append(StringUtils.isNotBlank(houseDTO.getOwnerPhone()) ? houseDTO.getOwnerPhone() : "无").append(";"); |
|
|
|
sbBefore.append(HouseChangeEnums.OWNER_PHONE.getColumnName()).append(":").append(StringUtils.isNotBlank(entity.getOwnerPhone()) ? entity.getOwnerPhone() : "无").append(";"); |
|
|
|
IcHouseChangeDetailEntity e = new IcHouseChangeDetailEntity(); |
|
|
@ -245,7 +247,7 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
e.setChangeBefore(StringUtils.isNotBlank(entity.getOwnerPhone()) ? entity.getOwnerPhone() : "无"); |
|
|
|
entityList.add(e); |
|
|
|
} |
|
|
|
if (null != houseDTO.getOwnerIdCard() && !houseDTO.getOwnerIdCard().equals(entity.getOwnerIdCard())){ |
|
|
|
if (null != houseDTO.getOwnerIdCard() && !houseDTO.getOwnerIdCard().equals(entity.getOwnerIdCard())) { |
|
|
|
sbAfter.append(HouseChangeEnums.OWNER_ID_CARD.getColumnName()).append(":").append(StringUtils.isNotBlank(houseDTO.getOwnerIdCard()) ? houseDTO.getOwnerIdCard() : "无").append(";"); |
|
|
|
sbBefore.append(HouseChangeEnums.OWNER_ID_CARD.getColumnName()).append(":").append(StringUtils.isNotBlank(entity.getOwnerIdCard()) ? entity.getOwnerIdCard() : "无").append(";"); |
|
|
|
IcHouseChangeDetailEntity e = new IcHouseChangeDetailEntity(); |
|
|
@ -254,7 +256,7 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
e.setChangeBefore(StringUtils.isNotBlank(entity.getOwnerIdCard()) ? entity.getOwnerIdCard() : "无"); |
|
|
|
entityList.add(e); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(sbAfter)){ |
|
|
|
if (StringUtils.isNotBlank(sbAfter)) { |
|
|
|
String before = sbBefore.substring(NumConstant.ZERO, sbBefore.length() - NumConstant.ONE); |
|
|
|
String after = sbAfter.substring(NumConstant.ZERO, sbAfter.length() - NumConstant.ONE); |
|
|
|
HouseAgencyInfoResultDTO houseAgencyInfo = icHouseDao.getHouseAgencyInfo(houseId); |
|
|
@ -280,15 +282,16 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
|
|
|
|
/** |
|
|
|
* 删除 |
|
|
|
* |
|
|
|
* @param houseId |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delHouse(String houseId) { |
|
|
|
//单个删除房屋,房屋内有居民不允许删除
|
|
|
|
NeighborHoodManageDelFormDTO formDTO=new NeighborHoodManageDelFormDTO(); |
|
|
|
NeighborHoodManageDelFormDTO formDTO = new NeighborHoodManageDelFormDTO(); |
|
|
|
formDTO.setType(CustomerGridConstant.HOUSE); |
|
|
|
List<String> ids=new ArrayList<>(); |
|
|
|
List<String> ids = new ArrayList<>(); |
|
|
|
ids.add(houseId); |
|
|
|
formDTO.setIds(ids); |
|
|
|
allDelete(formDTO); |
|
|
@ -302,24 +305,25 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
if (StringUtils.isNotBlank(formDTO.getAgencyId())) { |
|
|
|
pids = getPids(formDTO.getAgencyId()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(formDTO.getLevel()) && OrgTypeEnum.AGENCY.getCode().equals(formDTO.getLevel())){ |
|
|
|
if (StringUtils.isNotBlank(formDTO.getLevel()) && OrgTypeEnum.AGENCY.getCode().equals(formDTO.getLevel())) { |
|
|
|
pids = getPids(formDTO.getAgencyId()); |
|
|
|
} |
|
|
|
formDTO.setPids(pids); |
|
|
|
PageInfo<IcHouseListResultDTO> pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(),formDTO.getIsPage()) |
|
|
|
.doSelectPageInfo(() -> icHouseDao.searchHouseByPage(formDTO)); |
|
|
|
PageInfo<IcHouseListResultDTO> pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()) |
|
|
|
.doSelectPageInfo(() -> icHouseDao.searchHouseByPage(formDTO)); |
|
|
|
|
|
|
|
|
|
|
|
List<IcHouseListResultDTO> records = pageInfo.getList(); |
|
|
|
records.forEach(item->{ |
|
|
|
records.forEach(item -> { |
|
|
|
item.setHouseType(HouseTypeEnums.getTypeValue(item.getHouseTypeKey())); |
|
|
|
item.setPurpose(HousePurposeEnums.getTypeValue(item.getPurposeKey())); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return new PageData<>(records == null? new ArrayList<>():records,pageInfo.getTotal()); |
|
|
|
return new PageData<>(records == null ? new ArrayList<>() : records, pageInfo.getTotal()); |
|
|
|
} |
|
|
|
public String getPids(String agencyId){ |
|
|
|
|
|
|
|
public String getPids(String agencyId) { |
|
|
|
String pids = null; |
|
|
|
CustomerAgencyDTO agency = agencyservice.getAgencyById(agencyId); |
|
|
|
|
|
|
@ -340,33 +344,33 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
public void exportBuildinginfo(IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception { |
|
|
|
//如果类型是house 查房屋
|
|
|
|
//导出房屋
|
|
|
|
PageData<IcHouseListResultDTO> icHouseExcels = new PageData<>(new ArrayList<>(),NumConstant.ZERO); |
|
|
|
PageData<IcHouseListResultDTO> icHouseExcels = new PageData<>(new ArrayList<>(), NumConstant.ZERO); |
|
|
|
List<IcHouseListResultDTO> list = new ArrayList<>(); |
|
|
|
Integer pageNo = NumConstant.ONE; |
|
|
|
do { |
|
|
|
formDTO.setPageNo(pageNo); |
|
|
|
icHouseExcels = getHouseList(formDTO); |
|
|
|
if (CollectionUtils.isEmpty(icHouseExcels.getList())){ |
|
|
|
if (CollectionUtils.isEmpty(icHouseExcels.getList())) { |
|
|
|
break; |
|
|
|
} |
|
|
|
list.addAll(icHouseExcels.getList()); |
|
|
|
pageNo++; |
|
|
|
}while (icHouseExcels.getList().size() == formDTO.getPageSize()); |
|
|
|
} while (icHouseExcels.getList().size() == formDTO.getPageSize()); |
|
|
|
TemplateExportParams templatePath = new TemplateExportParams("excel/house_export.xlsx"); |
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("maplist", list); |
|
|
|
ExcelPoiUtils.exportExcel(templatePath ,map,"房屋信息录入表",response); |
|
|
|
ExcelPoiUtils.exportExcel(templatePath, map, "房屋信息录入表", response); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<HouseInfoDTO> queryListHouseInfo(Set<String> houseIdList, String customerId) { |
|
|
|
if(org.apache.commons.collections4.CollectionUtils.isEmpty(houseIdList)){ |
|
|
|
if (org.apache.commons.collections4.CollectionUtils.isEmpty(houseIdList)) { |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
List<HouseInfoDTO> result = new ArrayList<>(); |
|
|
|
houseIdList.forEach(h -> { |
|
|
|
HouseInfoDTO houseInfo = icHouseRedis.getHouseInfo(h, customerId); |
|
|
|
if (null != houseInfo){ |
|
|
|
if (null != houseInfo) { |
|
|
|
result.add(houseInfo); |
|
|
|
} |
|
|
|
}); |
|
|
@ -381,11 +385,11 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
excelReader = EasyExcel.read(inputStream).build(); |
|
|
|
// 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener
|
|
|
|
ReadSheet readSheet = EasyExcel.readSheet(0).head(HouseInfoModel.class) |
|
|
|
.registerReadListener(new ImportHouseInfoListener(formDTO,icBuildingDao,icHouseRedis,neighborHoodService,icHouseService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId(),houseService)) |
|
|
|
.registerReadListener(new ImportHouseInfoListener(formDTO, icBuildingDao, icHouseRedis, neighborHoodService, icHouseService, epmetCommonServiceOpenFeignClient, importTask.getData().getTaskId(), houseService)) |
|
|
|
.build(); |
|
|
|
excelReader.read(readSheet); |
|
|
|
} catch (Exception e){ |
|
|
|
log.error("dispose exception",e); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("dispose exception", e); |
|
|
|
ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); |
|
|
|
input.setOperatorId(formDTO.getUserId()); |
|
|
|
input.setTaskId(importTask.getData().getTaskId()); |
|
|
@ -402,79 +406,80 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
|
|
|
|
/** |
|
|
|
* Desc 小区管理中批量删除 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2022/3/1 4:57 下午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void allDelete(NeighborHoodManageDelFormDTO formDTO) { |
|
|
|
if (CollectionUtils.isEmpty(formDTO.getIds())){ |
|
|
|
if (CollectionUtils.isEmpty(formDTO.getIds())) { |
|
|
|
return; |
|
|
|
} |
|
|
|
List<String> ids = formDTO.getIds(); |
|
|
|
if (formDTO.getType().equals(CustomerGridConstant.NEIGHBORHOOD)){ |
|
|
|
if (formDTO.getType().equals(CustomerGridConstant.NEIGHBORHOOD)) { |
|
|
|
List<NeighborHoodManageDelResultDTO> exists = icHouseDao.selectExistBuildingByNeighborHoodIds(ids); |
|
|
|
if (!CollectionUtils.isEmpty(exists)){ |
|
|
|
if (!CollectionUtils.isEmpty(exists)) { |
|
|
|
exists.forEach(e -> { |
|
|
|
for (int i = NumConstant.ZERO; i < ids.size(); i++) { |
|
|
|
if (ids.get(i).equals(e.getNeighborHoodId())){ |
|
|
|
if (ids.get(i).equals(e.getNeighborHoodId())) { |
|
|
|
ids.remove(i); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
if (!CollectionUtils.isEmpty(ids)){ |
|
|
|
if (!CollectionUtils.isEmpty(ids)) { |
|
|
|
icNeighborHoodDao.deleteBatchIds(ids); |
|
|
|
} |
|
|
|
if (!CollectionUtils.isEmpty(exists)){ |
|
|
|
if (!CollectionUtils.isEmpty(exists)) { |
|
|
|
String collect = exists.stream().map(m -> m.getName()).collect(Collectors.joining(",")); |
|
|
|
EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.setMsg(String.format("%s内包含楼栋信息,暂无法删除",collect)); |
|
|
|
EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.setMsg(String.format("%s内包含楼栋信息,暂无法删除", collect)); |
|
|
|
throw new EpmetException(EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.getCode()); |
|
|
|
} |
|
|
|
}else if (formDTO.getType().equals(CustomerGridConstant.BUILDING)){ |
|
|
|
} else if (formDTO.getType().equals(CustomerGridConstant.BUILDING)) { |
|
|
|
List<NeighborHoodManageDelResultDTO> exists = icHouseDao.selectExistHouseByBuildingIds(ids); |
|
|
|
if (!CollectionUtils.isEmpty(exists)){ |
|
|
|
if (!CollectionUtils.isEmpty(exists)) { |
|
|
|
exists.forEach(e -> { |
|
|
|
for (int i = NumConstant.ZERO; i < ids.size(); i++) { |
|
|
|
if (ids.get(i).equals(e.getBuildingId())){ |
|
|
|
if (ids.get(i).equals(e.getBuildingId())) { |
|
|
|
ids.remove(i); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
if (!CollectionUtils.isEmpty(ids)){ |
|
|
|
if (!CollectionUtils.isEmpty(ids)) { |
|
|
|
icBuildingDao.deleteBatchIds(ids); |
|
|
|
} |
|
|
|
if (!CollectionUtils.isEmpty(exists)){ |
|
|
|
if (!CollectionUtils.isEmpty(exists)) { |
|
|
|
String collect = exists.stream().map(m -> m.getName()).collect(Collectors.joining(",")); |
|
|
|
EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.setMsg(String.format("%s内包含房屋信息,暂无法删除",collect)); |
|
|
|
EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.setMsg(String.format("%s内包含房屋信息,暂无法删除", collect)); |
|
|
|
throw new EpmetException(EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.getCode()); |
|
|
|
} |
|
|
|
}else if (formDTO.getType().equals(CustomerGridConstant.HOUSE)){ |
|
|
|
} else if (formDTO.getType().equals(CustomerGridConstant.HOUSE)) { |
|
|
|
Result<List<String>> existUsers = epmetUserOpenFeignClient.getExistUserByHouseIds(ids); |
|
|
|
if (!existUsers.success()){ |
|
|
|
if (!existUsers.success()) { |
|
|
|
throw new EpmetException("根据房屋IDs查询房屋下是否有存在居民失败..."); |
|
|
|
} |
|
|
|
List<String> exists = existUsers.getData(); |
|
|
|
if (!CollectionUtils.isEmpty(exists)){ |
|
|
|
if (!CollectionUtils.isEmpty(exists)) { |
|
|
|
exists.forEach(e -> { |
|
|
|
for (int i = NumConstant.ZERO; i < ids.size(); i++) { |
|
|
|
if (ids.get(i).equals(e)){ |
|
|
|
if (ids.get(i).equals(e)) { |
|
|
|
ids.remove(i); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
if (!CollectionUtils.isEmpty(ids)){ |
|
|
|
if (!CollectionUtils.isEmpty(ids)) { |
|
|
|
icHouseDao.deleteBatchIds(ids); |
|
|
|
} |
|
|
|
if (!CollectionUtils.isEmpty(exists)){ |
|
|
|
if (!CollectionUtils.isEmpty(exists)) { |
|
|
|
List<String> list = icHouseDao.selectHouseNames(exists); |
|
|
|
String collect = list.stream().collect(Collectors.joining(",")); |
|
|
|
EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.setMsg(String.format("%s内包含居民信息,暂无法删除",collect)); |
|
|
|
EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.setMsg(String.format("%s内包含居民信息,暂无法删除", collect)); |
|
|
|
throw new EpmetException(EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
@ -485,8 +490,8 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
HouseInfoDTO houseInfo = icHouseRedis.getHouseInfo(houseId, customerId); |
|
|
|
if (null != houseInfo && StringUtils.isNotBlank(houseInfo.getAgencyId())) { |
|
|
|
AgencyInfoCache agencyInfoCache = CustomerOrgRedis.getAgencyInfo(houseInfo.getAgencyId()); |
|
|
|
houseInfo.setAgencyPathName(StringUtils.isNotBlank(agencyInfoCache.getAllParentName())?agencyInfoCache.getAllParentName().concat(StrConstant.HYPHEN).concat(agencyInfoCache.getOrganizationName()):agencyInfoCache.getOrganizationName()); |
|
|
|
houseInfo.setAreaCode(StringUtils.isNotBlank(agencyInfoCache.getAreaCode())?agencyInfoCache.getAreaCode():StrConstant.EPMETY_STR); |
|
|
|
houseInfo.setAgencyPathName(StringUtils.isNotBlank(agencyInfoCache.getAllParentName()) ? agencyInfoCache.getAllParentName().concat(StrConstant.HYPHEN).concat(agencyInfoCache.getOrganizationName()) : agencyInfoCache.getOrganizationName()); |
|
|
|
houseInfo.setAreaCode(StringUtils.isNotBlank(agencyInfoCache.getAreaCode()) ? agencyInfoCache.getAreaCode() : StrConstant.EPMETY_STR); |
|
|
|
} else { |
|
|
|
houseInfo.setAgencyPathName(StrConstant.EPMETY_STR); |
|
|
|
houseInfo.setAreaCode(StrConstant.EPMETY_STR); |
|
|
@ -596,6 +601,7 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
|
|
|
|
/** |
|
|
|
* Desc: 根据类型更新排序 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2022/5/6 08:50 |
|
|
@ -603,10 +609,10 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void updateSort(UpdateSortFormDTO formDTO) { |
|
|
|
if (formDTO.getType().equals(CustomerGridConstant.HOUSE)){ |
|
|
|
if (formDTO.getType().equals(CustomerGridConstant.HOUSE)) { |
|
|
|
IcHouseDTO icHouseDTO = ConvertUtils.sourceToTarget(formDTO, IcHouseDTO.class); |
|
|
|
icHouseService.update(icHouseDTO); |
|
|
|
}else if(formDTO.getType().equals(CustomerGridConstant.BUILDING)){ |
|
|
|
} else if (formDTO.getType().equals(CustomerGridConstant.BUILDING)) { |
|
|
|
IcBuildingDTO icBuildingDTO = ConvertUtils.sourceToTarget(formDTO, IcBuildingDTO.class); |
|
|
|
icBuildingService.update(icBuildingDTO); |
|
|
|
} |
|
|
@ -625,53 +631,53 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
int searchLevel = 0; |
|
|
|
|
|
|
|
//如果小区id不为空 则直接查询小区内的居民
|
|
|
|
if (StringUtils.isNotEmpty(formDTO.getNeighborHoodId())){ |
|
|
|
if (StringUtils.isNotEmpty(formDTO.getNeighborHoodId())) { |
|
|
|
searchLevel = 1; |
|
|
|
} |
|
|
|
//如果楼宇id不为空 则直接查询楼宇内的居民
|
|
|
|
if (StringUtils.isNotEmpty(formDTO.getBuildingId())){ |
|
|
|
if (StringUtils.isNotEmpty(formDTO.getBuildingId())) { |
|
|
|
searchLevel = 2; |
|
|
|
} |
|
|
|
//如果有具体的查询套件 则直接按照房屋Id 来查
|
|
|
|
if (StringUtils.isNotEmpty(formDTO.getOwnerName()) || StringUtils.isNotEmpty(formDTO.getOwnerPhone()) || StringUtils.isNotEmpty(formDTO.getRentFlag())){ |
|
|
|
if (StringUtils.isNotEmpty(formDTO.getOwnerName()) || StringUtils.isNotEmpty(formDTO.getOwnerPhone()) || StringUtils.isNotEmpty(formDTO.getRentFlag())) { |
|
|
|
searchLevel = 3; |
|
|
|
} |
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
PageData<IcHouseListResultDTO> houseData = this.getHouseList(formDTO); |
|
|
|
log.info("getHouseUser getHoseList cost:{}ms",System.currentTimeMillis() - start); |
|
|
|
log.info("getHouseUser getHoseList cost:{}ms", System.currentTimeMillis() - start); |
|
|
|
|
|
|
|
List<HouseMemberResultDTO> resultList = new ArrayList<>(); |
|
|
|
PageData<HouseMemberResultDTO> result = new PageData<>(resultList,houseData.getList().size()); |
|
|
|
PageData<HouseMemberResultDTO> result = new PageData<>(resultList, houseData.getList().size()); |
|
|
|
int finalSearchLevel = searchLevel; |
|
|
|
AtomicInteger num = new AtomicInteger((formDTO.getPageNo()-1) * formDTO.getPageSize()); |
|
|
|
AtomicInteger num = new AtomicInteger((formDTO.getPageNo() - 1) * formDTO.getPageSize()); |
|
|
|
|
|
|
|
houseData.getList().forEach(o ->{ |
|
|
|
houseData.getList().forEach(o -> { |
|
|
|
resiParam.setAgencyId(o.getAgencyId()); |
|
|
|
if (finalSearchLevel == 1){ |
|
|
|
if (finalSearchLevel == 1) { |
|
|
|
resiParam.setNeighborHoodId(o.getNeighborHoodId()); |
|
|
|
} |
|
|
|
if (finalSearchLevel == 2){ |
|
|
|
if (finalSearchLevel == 2) { |
|
|
|
resiParam.setBuildingId(o.getBuildingId()); |
|
|
|
} |
|
|
|
if (finalSearchLevel == 3){ |
|
|
|
if (finalSearchLevel == 3) { |
|
|
|
resiParam.setHouseId(o.getHouseId()); |
|
|
|
} |
|
|
|
|
|
|
|
this.getHouseMembers(resiParam, memberCacheMap,haveSearchCache); |
|
|
|
this.getHouseMembers(resiParam, memberCacheMap, haveSearchCache); |
|
|
|
List<HouseIcResiUserResultDTO.HouseMemberResultDTO> members = memberCacheMap.getIfPresent(o.getHouseId()); |
|
|
|
|
|
|
|
//序号 一个houseId为一个序号
|
|
|
|
int n = num.incrementAndGet(); |
|
|
|
|
|
|
|
//没有住户 则直接写房屋
|
|
|
|
if (CollectionUtils.isEmpty(members)){ |
|
|
|
if (CollectionUtils.isEmpty(members)) { |
|
|
|
HouseMemberResultDTO resultDTO = ConvertUtils.sourceToTarget(o, HouseMemberResultDTO.class); |
|
|
|
resultDTO.setNum(n); |
|
|
|
resultList.add(resultDTO); |
|
|
|
return; |
|
|
|
} |
|
|
|
//有住户 房屋信息是重复的
|
|
|
|
members.forEach(m->{ |
|
|
|
members.forEach(m -> { |
|
|
|
HouseMemberResultDTO resultDTO = ConvertUtils.sourceToTarget(m, HouseMemberResultDTO.class); |
|
|
|
resultDTO.setNum(n); |
|
|
|
resultDTO.setAgencyName(o.getAgencyName()); |
|
|
@ -694,37 +700,38 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
|
|
|
|
/** |
|
|
|
* desc:分情况获取 房屋内居民 |
|
|
|
* |
|
|
|
* @param resiParam |
|
|
|
* @param memberMap |
|
|
|
* @param haveSearchCache |
|
|
|
*/ |
|
|
|
public void getHouseMembers(RentTenantDataFormDTO resiParam, Cache<String, List<HouseIcResiUserResultDTO.HouseMemberResultDTO>> memberMap, Cache<String, Boolean> haveSearchCache) { |
|
|
|
String searchKey = resiParam.getHouseId()+resiParam.getBuildingId()+resiParam.getNeighborHoodId()+resiParam.getGridId()+resiParam.getAgencyId(); |
|
|
|
String searchKey = resiParam.getHouseId() + resiParam.getBuildingId() + resiParam.getNeighborHoodId() + resiParam.getGridId() + resiParam.getAgencyId(); |
|
|
|
Boolean haveSearch = haveSearchCache.getIfPresent(searchKey); |
|
|
|
//log.info("getHouseUser getHouseMembers searchKey:"+searchKey);
|
|
|
|
if (haveSearch!= null && haveSearch){ |
|
|
|
if (haveSearch != null && haveSearch) { |
|
|
|
return; |
|
|
|
} |
|
|
|
long startT = System.currentTimeMillis(); |
|
|
|
haveSearchCache.put(searchKey,true); |
|
|
|
haveSearchCache.put(searchKey, true); |
|
|
|
List<HouseIcResiUserResultDTO> memberListTemp = null; |
|
|
|
resiParam.setPageNo(NumConstant.ONE); |
|
|
|
do { |
|
|
|
Result<List<HouseIcResiUserResultDTO>> memberResult = epmetUserOpenFeignClient.getHouseMemberList(resiParam); |
|
|
|
log.debug("=======查询居民:"+ resiParam.getPageNo()+",size:"+resiParam.getPageSize()+",result:"+memberResult.getData().size()); |
|
|
|
log.debug("=======查询居民:" + resiParam.getPageNo() + ",size:" + resiParam.getPageSize() + ",result:" + memberResult.getData().size()); |
|
|
|
if (!memberResult.success()) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "调用user服务失败"); |
|
|
|
} |
|
|
|
memberListTemp = memberResult.getData(); |
|
|
|
log.debug("=======查询居民结果:"+ JSON.toJSONString(memberListTemp)); |
|
|
|
log.debug("=======查询居民结果:" + JSON.toJSONString(memberListTemp)); |
|
|
|
if (CollectionUtils.isEmpty(memberListTemp)) { |
|
|
|
break; |
|
|
|
} |
|
|
|
resiParam.setPageNo(resiParam.getPageNo()+1); |
|
|
|
resiParam.setPageNo(resiParam.getPageNo() + 1); |
|
|
|
memberListTemp.forEach(h -> memberMap.put(h.getHomeId(), h.getHouseMemberList())); |
|
|
|
|
|
|
|
} while (memberListTemp.size() == resiParam.getPageSize()); |
|
|
|
log.info("getHouseUser getHouseMembers cost:{}ms,param:{}",System.currentTimeMillis() - startT,JSON.toJSONString(resiParam)); |
|
|
|
log.info("getHouseUser getHouseMembers cost:{}ms,param:{}", System.currentTimeMillis() - startT, JSON.toJSONString(resiParam)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -783,13 +790,13 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void downloadZip(HttpServletResponse response,IcHouseListFormDTO formDTO) throws Exception { |
|
|
|
public void downloadZip(HttpServletResponse response, IcHouseListFormDTO formDTO) throws Exception { |
|
|
|
// 查询pids
|
|
|
|
String pids = null; |
|
|
|
if (StringUtils.isNotBlank(formDTO.getAgencyId())) { |
|
|
|
pids = getPids(formDTO.getAgencyId()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(formDTO.getLevel()) && OrgTypeEnum.AGENCY.getCode().equals(formDTO.getLevel())){ |
|
|
|
if (StringUtils.isNotBlank(formDTO.getLevel()) && OrgTypeEnum.AGENCY.getCode().equals(formDTO.getLevel())) { |
|
|
|
pids = getPids(formDTO.getAgencyId()); |
|
|
|
} |
|
|
|
formDTO.setPids(pids); |
|
|
@ -808,10 +815,10 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
|
|
|
|
List<IcHouseListResultDTO> houseList = icHouseDao.searchHouseByPage(formDTO); |
|
|
|
|
|
|
|
for(IcHouseListResultDTO house : houseList){ |
|
|
|
for (IcHouseListResultDTO house : houseList) { |
|
|
|
|
|
|
|
BufferedImage image = BarcodeUtils.drawQRImage(house.getNeighborHoodName() + house.getBuildingName() +house.getUnitNum()+ house.getDoorName(), |
|
|
|
HouseQrcodeEnum.PREFIX.getCode()+"?houseCode="+house.getHouseCode()); |
|
|
|
BufferedImage image = BarcodeUtils.drawQRImage(house.getNeighborHoodName() + house.getBuildingName() + house.getUnitNum() + house.getDoorName(), |
|
|
|
HouseQrcodeEnum.PREFIX.getCode() + "?houseCode=" + house.getHouseCode() + "&customerId=" + house.getCustomerId() + "&gridId=" + house.getGridId()); |
|
|
|
|
|
|
|
try { |
|
|
|
byte[] buf = new byte[8192]; |
|
|
@ -825,7 +832,7 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
} |
|
|
|
inputStream.close(); |
|
|
|
} catch (IOException e) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "组装zip信息有误","组装zip信息有误"); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "组装zip信息有误", "组装zip信息有误"); |
|
|
|
} |
|
|
|
} |
|
|
|
zip.close(); |
|
|
@ -850,12 +857,12 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
* 获取文件名 |
|
|
|
*/ |
|
|
|
public static String getFileName(IcHouseListResultDTO house) { |
|
|
|
return house.getNeighborHoodName() + File.separator +house.getBuildingName() + File.separator +house.getUnitNum() + File.separator + house.getDoorName() + HouseQrcodeEnum.SUFFIX.getCode(); |
|
|
|
return house.getNeighborHoodName() + File.separator + house.getBuildingName() + File.separator + house.getUnitNum() + File.separator + house.getDoorName() + HouseQrcodeEnum.SUFFIX.getCode(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String createHouseCode(String customerId, String buildingId, String areaCode) { |
|
|
|
if(StringUtils.isBlank(customerId) || StringUtils.isBlank(buildingId) ||StringUtils.isBlank(areaCode)){ |
|
|
|
if (StringUtils.isBlank(customerId) || StringUtils.isBlank(buildingId) || StringUtils.isBlank(areaCode)) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所有字段不可为空", "所有字段不可为空"); |
|
|
|
} |
|
|
|
String result = ""; |
|
|
@ -899,8 +906,8 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "未查到房屋信息", "未查到房屋信息"); |
|
|
|
} |
|
|
|
//url组成:小程序地址?房屋编码
|
|
|
|
String url = HouseQrcodeEnum.PREFIX.getCode() + "?houseCode=" + house.getHouseCode(); |
|
|
|
String fileName = house.getNeighborHoodName() + house.getBuildingName() +house.getUnitNum()+ house.getDoorName()+".png"; |
|
|
|
String url = HouseQrcodeEnum.PREFIX.getCode() + "?houseCode=" + house.getHouseCode() + "&customerId=" + house.getCustomerId() + "&gridId=" + house.getGridId(); |
|
|
|
String fileName = house.getNeighborHoodName() + house.getBuildingName() + house.getUnitNum() + house.getDoorName() + ".png"; |
|
|
|
BufferedImage image = BarcodeUtils.drawQRImage(house.getNeighborHoodName() + house.getBuildingName() + house.getUnitNum() + house.getDoorName(), url); |
|
|
|
|
|
|
|
|
|
|
@ -938,7 +945,7 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
@Override |
|
|
|
public Result<IcHouseInfoResultDTO> getHouseInfoByCode(IcHouseInfoFormDTO formDTO) { |
|
|
|
IcHouseEntity house = icHouseDao.selectByHouseCode(formDTO.getHouseCode()); |
|
|
|
HouseInfoCache cache = CustomerIcHouseRedis.getHouseInfo(formDTO.getCustomerId(),house.getId()); |
|
|
|
HouseInfoCache cache = CustomerIcHouseRedis.getHouseInfo(formDTO.getCustomerId(), house.getId()); |
|
|
|
IcHouseInfoResultDTO resut = ConvertUtils.sourceToTarget(cache, IcHouseInfoResultDTO.class); |
|
|
|
resut.setHouseId(cache.getHomeId()); |
|
|
|
return new Result<IcHouseInfoResultDTO>().ok(resut); |
|
|
|