|
|
@ -813,7 +813,7 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
resultDTO.setXzHouseTotalJSY(resultDTO.getXzHouseTotal() - lastMonthUserHouseStats.getXzHouseTotal()); |
|
|
|
resultDTO.setZzHouseTotalJSY(resultDTO.getZzHouseTotal() - lastMonthUserHouseStats.getZzHouseTotal());*/ |
|
|
|
|
|
|
|
// 24小时过期
|
|
|
|
// 24小时过期 redis LC 新增24小时失效的
|
|
|
|
redisTemplate.opsForValue().set(RedisKeys.getHousechart(formDTO.getOrgType(),formDTO.getOrgId()), resultDTO, RedisUtils.DEFAULT_EXPIRE, TimeUnit.SECONDS); |
|
|
|
|
|
|
|
return resultDTO; |
|
|
@ -839,6 +839,13 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
if ("village".equals(formDTO.getOrgType())) { |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
|
|
|
|
// redis 加缓存 LC 24小时失效
|
|
|
|
if (redisTemplate.opsForValue().get(RedisKeys.getSubUserHouseList(formDTO.getOrgType(),formDTO.getOrgId()))!=null){ |
|
|
|
return (List<SubUserHouseListResultDTO>)redisTemplate.opsForValue().get(RedisKeys.getSubUserHouseList(formDTO.getOrgType(),formDTO.getOrgId())); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//2.根据入参值查询直属下级列表(组织、网格、小区列表)
|
|
|
|
List<String> idList = new ArrayList<>(); |
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
@ -873,6 +880,9 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
//3.分别查询直属下级列表的房屋、居民统计数据
|
|
|
|
resultList = houseUserChartList(idList, map, orgType); |
|
|
|
|
|
|
|
// redis 加缓存 LC 24小时失效
|
|
|
|
redisTemplate.opsForValue().set(RedisKeys.getSubUserHouseList(formDTO.getOrgType(),formDTO.getOrgId()), resultList, RedisUtils.DEFAULT_EXPIRE, TimeUnit.SECONDS); |
|
|
|
|
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
@ -1108,6 +1118,100 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<SubUserHouseListResultDTO> houseUserChartListMust(List<String> idList, Map<String, String> map, String orgType) { |
|
|
|
List<SubUserHouseListResultDTO> list = new ArrayList<>(); |
|
|
|
//1.直属下级列表的房屋数据
|
|
|
|
List<HouseChartResultDTO> houseList = new ArrayList<>(); |
|
|
|
HouseChartFormDTO houseDTO = new HouseChartFormDTO(); |
|
|
|
houseDTO.setOrgType(orgType); |
|
|
|
for (String id : idList) { |
|
|
|
houseDTO.setOrgId(id); |
|
|
|
houseList.add(houseChart(houseDTO)); |
|
|
|
} |
|
|
|
//start 2022.11.17需求:http://zentao.elinkservice.cn/story-view-718.html
|
|
|
|
//原来饼图是:居民总数、常住人口数、流动人口数 后改为下面的人户状况饼图,后面如果所有客户都上线了,就把第2步的查询注释掉。
|
|
|
|
//2.直属下级列表的居民数据
|
|
|
|
UserChartFormDTO userDTO = new UserChartFormDTO(); |
|
|
|
userDTO.setOrgType(orgType); |
|
|
|
userDTO.setIdList(idList); |
|
|
|
Result<List<UserChartResultDTO>> userResult = epmetUserOpenFeignClient.userChartList(userDTO); |
|
|
|
if (!userResult.success()) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取居民人房统计数据失败" + userResult.getInternalMsg(), userResult.getMsg()); |
|
|
|
} |
|
|
|
//end
|
|
|
|
|
|
|
|
//3.汇总封装数据
|
|
|
|
SubUserHouseListResultDTO dto = null; |
|
|
|
for (String id : idList) { |
|
|
|
dto = new SubUserHouseListResultDTO(); |
|
|
|
dto.setOrgId(id); |
|
|
|
dto.setOrgName(map.get(id)); |
|
|
|
dto.setOrgType(orgType); |
|
|
|
for (HouseChartResultDTO h : houseList) { |
|
|
|
if (h.getOrgId().equals(id)) { |
|
|
|
// 房屋总数
|
|
|
|
dto.setHouseTotal(h.getHouseTotal()); |
|
|
|
// 自住房屋数
|
|
|
|
dto.setZzHouseTotal(h.getZzHouseTotal()); |
|
|
|
// dto.setZzHouseRatio(h.getZzHouseRatio());
|
|
|
|
// 出租房屋数
|
|
|
|
dto.setCzHouseTotal(h.getCzHouseTotal()); |
|
|
|
// dto.setCzHouseRatio(h.getCzHouseRatio());
|
|
|
|
// 闲置房屋数
|
|
|
|
dto.setXzHouseTotal(h.getXzHouseTotal()); |
|
|
|
// dto.setXzHouseRatio(h.getXzHouseRatio());
|
|
|
|
// dto.setWscHouseTotal(h.getWscHouseTotal());
|
|
|
|
// dto.setWscHouseRatio(h.getWscHouseRatio());
|
|
|
|
} |
|
|
|
} |
|
|
|
for (UserChartResultDTO u : userResult.getData()) { |
|
|
|
if (u.getOrgId().equals(id)) { |
|
|
|
// 人口总数
|
|
|
|
dto.setUserTotal(u.getUserTotal()); |
|
|
|
// 常住人口数
|
|
|
|
dto.setCzUserTotal(u.getCzUserTotal()); |
|
|
|
// dto.setCzUserRatio(u.getCzUserRatio());
|
|
|
|
// 流动人口数
|
|
|
|
dto.setLdUserTotal(u.getLdUserTotal()); |
|
|
|
// dto.setLdUserRatio(u.getLdUserRatio());
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 为每一个子级组织,查询开通了多少个社区
|
|
|
|
/* if ("agency".equals(dto.getOrgType())) { |
|
|
|
AgencyService agencyService = SpringContextUtils.getBean(AgencyService.class); |
|
|
|
if (agencyService != null) { |
|
|
|
UsingCommunityStatsResultDTO usingCommunityStats = agencyService.usingCommunityStats(dto.getOrgId(), dto.getOrgType()); |
|
|
|
if (usingCommunityStats != null) { |
|
|
|
dto.setUsingCommunityNum(usingCommunityStats.getUsingCommunityNum()); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if ("grid".equals(dto.getOrgType())) { |
|
|
|
// 网格这项数据为0
|
|
|
|
dto.setUsingCommunityNum(0); |
|
|
|
}*/ |
|
|
|
/*for (RHZKStatisticsResultDTO r : rhzkResult.getData()) { |
|
|
|
if (StringUtils.isNotBlank(r.getOrgId())){ |
|
|
|
if (r.getOrgId().equals(id)){ |
|
|
|
dto.setRhyzUserTotal(r.getRhyzUserTotal()); |
|
|
|
dto.setRhyzUserRatio(r.getRhyzUserRatio()); |
|
|
|
dto.setRzhbzUserTotal(r.getRzhbzUserTotal()); |
|
|
|
dto.setRzhbzUserRatio(r.getRzhbzUserRatio()); |
|
|
|
dto.setHzrbzUserTotal(r.getHzrbzUserTotal()); |
|
|
|
dto.setHzrbzUserRatio(r.getHzrbzUserRatio()); |
|
|
|
dto.setZbqcUserTotal(r.getZbqcUserTotal()); |
|
|
|
dto.setZbqcUserRatio(r.getZbqcUserRatio()); |
|
|
|
dto.setUserTotal(r.getUserTotal()); |
|
|
|
} |
|
|
|
} |
|
|
|
}*/ |
|
|
|
list.add(dto); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void downloadZip(HttpServletResponse response, IcHouseListFormDTO formDTO) throws Exception { |
|
|
|
if(NeighborhoodConstant.GRID.equals(formDTO.getLevel())){ |
|
|
@ -1537,6 +1641,37 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
return new PageData<SubUserHouseListResultDTO>(communityUserHouseStats, new PageInfo<>(communityIds).getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<SubUserHouseListResultDTO> usingCommunityUserHouseStatsMust(String orgId, String orgType, Integer pageNo, Integer pageSize) { |
|
|
|
|
|
|
|
String customerId = EpmetRequestHolder.getLoginUserCustomerId(); |
|
|
|
|
|
|
|
if (StringUtils.isBlank(orgId)) { |
|
|
|
// 没有传参数,使用当前登录人员所属的组织去查询
|
|
|
|
String userId = EpmetRequestHolder.getLoginUserId(); |
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, userId); |
|
|
|
if (staffInfo == null) { |
|
|
|
String errorMsg = String.format("查询当前工作人员信息失败。staffId:%s", userId); |
|
|
|
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), errorMsg, errorMsg); |
|
|
|
} |
|
|
|
|
|
|
|
orgId = staffInfo.getAgencyId(); |
|
|
|
orgType = "agency"; |
|
|
|
} |
|
|
|
|
|
|
|
PageHelper.startPage(pageNo, pageSize); |
|
|
|
List<String> communityIds = customerAgencyDao.getUsingCommunityList(customerId, orgId, CustomerOrgRedis.getOrgIdPath(orgId, orgType), null); |
|
|
|
// List<String> communityIds = customerAgencyDao.getCommunitysByOrgIdPath(customerId, orgId, CustomerOrgRedis.getOrgIdPath(orgId, orgType));
|
|
|
|
|
|
|
|
|
|
|
|
// 填充组织信息
|
|
|
|
Map<String, String> communityMap = communityIds.stream().collect(Collectors.toMap(id -> id, id -> concatAgencyNamePath(id))); |
|
|
|
List<SubUserHouseListResultDTO> communityUserHouseStats = houseUserChartListMust(communityIds, communityMap, "agency"); |
|
|
|
|
|
|
|
return new PageData<SubUserHouseListResultDTO>(communityUserHouseStats, new PageInfo<>(communityIds).getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
public String concatAgencyNamePath(String agencyId) { |
|
|
|
List<String> agencyNamePathList = new ArrayList(); |
|
|
|
|
|
|
@ -1611,4 +1746,119 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
PageInfo<HouseLangchaoListResultDTO> pageInfo = new PageInfo<>(list); |
|
|
|
return new PageData<>(list,pageInfo.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean houseChartRedis() { |
|
|
|
|
|
|
|
List<AgencyResultDTO> agencyResultDTOS = agencyservice.getAllCommunity("1535072605621841922"); |
|
|
|
|
|
|
|
for (AgencyResultDTO agencyResultDTO : agencyResultDTOS) { |
|
|
|
|
|
|
|
try { |
|
|
|
HouseChartFormDTO formDTO = new HouseChartFormDTO(); |
|
|
|
formDTO.setOrgId(agencyResultDTO.getAgencyId()); |
|
|
|
formDTO.setOrgType("agency"); |
|
|
|
|
|
|
|
|
|
|
|
HouseChartResultDTO resultDTO = new HouseChartResultDTO(); |
|
|
|
//计算百分比使用,保留小数点后两位
|
|
|
|
NumberFormat numberFormat = NumberFormat.getInstance(); |
|
|
|
numberFormat.setMaximumFractionDigits(NumConstant.TWO); |
|
|
|
|
|
|
|
//2.根据入参值查询对应的房屋统计数据
|
|
|
|
List<HouseChartResultDTO> list = icHouseDao.houseChart(formDTO.getOrgId(), formDTO.getOrgType()); |
|
|
|
//3.汇总数据
|
|
|
|
AtomicInteger houseTotal = new AtomicInteger(); |
|
|
|
list.forEach(l -> { |
|
|
|
houseTotal.addAndGet(l.getNum()); |
|
|
|
if (l.getRentFlag() == 0) { |
|
|
|
resultDTO.setZzHouseTotal(l.getNum()); |
|
|
|
} else if (l.getRentFlag() == 1) { |
|
|
|
resultDTO.setCzHouseTotal(l.getNum()); |
|
|
|
} else if (l.getRentFlag() == 2) { |
|
|
|
resultDTO.setXzHouseTotal(l.getNum()); |
|
|
|
} else if (l.getRentFlag() == 3) { |
|
|
|
resultDTO.setWscHouseTotal(l.getNum()); |
|
|
|
} |
|
|
|
}); |
|
|
|
resultDTO.setHouseTotal(houseTotal.get()); |
|
|
|
resultDTO.setZzHouseRatio(Double.valueOf((resultDTO.getHouseTotal() == 0 || resultDTO.getZzHouseTotal() > resultDTO.getHouseTotal()) ? "0" : numberFormat.format(((float) resultDTO.getZzHouseTotal() / (float) resultDTO.getHouseTotal()) * 100))); |
|
|
|
resultDTO.setCzHouseRatio(Double.valueOf((resultDTO.getHouseTotal() == 0 || resultDTO.getCzHouseTotal() > resultDTO.getHouseTotal()) ? "0" : numberFormat.format(((float) resultDTO.getCzHouseTotal() / (float) resultDTO.getHouseTotal()) * 100))); |
|
|
|
resultDTO.setXzHouseRatio(Double.valueOf((resultDTO.getHouseTotal() == 0 || resultDTO.getXzHouseTotal() > resultDTO.getHouseTotal()) ? "0" : numberFormat.format(((float) resultDTO.getXzHouseTotal() / (float) resultDTO.getHouseTotal()) * 100))); |
|
|
|
resultDTO.setWscHouseRatio(Double.valueOf((resultDTO.getHouseTotal() == 0 || resultDTO.getWscHouseTotal() > resultDTO.getHouseTotal()) ? "0" : numberFormat.format(((float) resultDTO.getWscHouseTotal() / (float) resultDTO.getHouseTotal()) * 100))); |
|
|
|
resultDTO.setOrgId(formDTO.getOrgId()); |
|
|
|
resultDTO.setOrgType(formDTO.getOrgType()); |
|
|
|
|
|
|
|
|
|
|
|
// 24小时过期 redis LC 新增24小时失效的
|
|
|
|
redisTemplate.opsForValue().set(RedisKeys.getHousechart(formDTO.getOrgType(),formDTO.getOrgId()), resultDTO, RedisUtils.DEFAULT_EXPIRE, TimeUnit.SECONDS); |
|
|
|
}catch (Exception e){ |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取该组织的housechart失败"+agencyResultDTO.getAgencyId(), "获取该组织的housechart失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean subUserHouseListRedis() { |
|
|
|
|
|
|
|
List<AgencyResultDTO> agencyResultDTOS = agencyservice.getAllCommunity("1535072605621841922"); |
|
|
|
|
|
|
|
for (AgencyResultDTO agencyResultDTO : agencyResultDTOS) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
List<SubUserHouseListResultDTO> resultList = new ArrayList<>(); |
|
|
|
|
|
|
|
HouseChartFormDTO formDTO = new HouseChartFormDTO(); |
|
|
|
|
|
|
|
formDTO.setOrgId(agencyResultDTO.getAgencyId()); |
|
|
|
formDTO.setOrgType("agency"); |
|
|
|
|
|
|
|
//2.根据入参值查询直属下级列表(组织、网格、小区列表)
|
|
|
|
List<String> idList = new ArrayList<>(); |
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
String orgType = ""; |
|
|
|
if ("agency".equals(formDTO.getOrgType())) { |
|
|
|
//获取组织缓存,判断组织级别
|
|
|
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(formDTO.getOrgId()); |
|
|
|
if (null == agencyInfo) { |
|
|
|
throw new RenException(String.format("查询组织信息失败%s", formDTO.getOrgId())); |
|
|
|
} |
|
|
|
//直属下级网格列表
|
|
|
|
if ("community".equals(agencyInfo.getLevel())) { |
|
|
|
orgType = "grid"; |
|
|
|
List<GridListResultDTO> list = customerGridDao.selectGridList(formDTO.getOrgId()); |
|
|
|
idList = list.stream().map(GridListResultDTO::getGridId).collect(Collectors.toList()); |
|
|
|
map = list.stream().collect(Collectors.toMap(GridListResultDTO::getGridId, GridListResultDTO::getGridName, (k1, k2) -> k1)); |
|
|
|
} else { |
|
|
|
//直属下级组织列表
|
|
|
|
orgType = "agency"; |
|
|
|
List<AgencyListResultDTO> list = customerAgencyDao.selectAgencyList(formDTO.getOrgId()); |
|
|
|
idList = list.stream().map(AgencyListResultDTO::getAgencyId).collect(Collectors.toList()); |
|
|
|
map = list.stream().collect(Collectors.toMap(AgencyListResultDTO::getAgencyId, AgencyListResultDTO::getAgencyName, (k1, k2) -> k1)); |
|
|
|
} |
|
|
|
} else if ("grid".equals(formDTO.getOrgType())) { |
|
|
|
//网格直属小区列表
|
|
|
|
orgType = "village"; |
|
|
|
List<IcNeighborHoodDTO> list = icNeighborHoodDao.selectNeighborList(formDTO.getOrgId()); |
|
|
|
idList = list.stream().map(IcNeighborHoodDTO::getId).collect(Collectors.toList()); |
|
|
|
map = list.stream().collect(Collectors.toMap(IcNeighborHoodDTO::getId, IcNeighborHoodDTO::getNeighborHoodName, (k1, k2) -> k1)); |
|
|
|
} |
|
|
|
|
|
|
|
//3.分别查询直属下级列表的房屋、居民统计数据
|
|
|
|
resultList = houseUserChartList(idList, map, orgType); |
|
|
|
|
|
|
|
// redis 加缓存 LC 24小时失效
|
|
|
|
redisTemplate.opsForValue().set(RedisKeys.getSubUserHouseList(formDTO.getOrgType(),formDTO.getOrgId()), resultList, RedisUtils.DEFAULT_EXPIRE, TimeUnit.SECONDS); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}catch (Exception e){ |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取该组织的subUserHouseListRedis失败"+agencyResultDTO.getAgencyId(), "获取该组织的subUserHouseListRedis失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|