|
|
@ -62,6 +62,8 @@ import com.epmet.dto.result.*; |
|
|
|
import com.epmet.dto.result.demand.IcResiDemandDictDTO; |
|
|
|
import com.epmet.dto.result.demand.OptionDTO; |
|
|
|
import com.epmet.dto.result.resi.IcResiNonDynamicResultDTO; |
|
|
|
import com.epmet.dto.result.resi.ResiPortrayalDetailDTO; |
|
|
|
import com.epmet.dto.result.resi.ResiPortrayalResultDTO; |
|
|
|
import com.epmet.entity.*; |
|
|
|
import com.epmet.enums.RenHuConditionEnum; |
|
|
|
import com.epmet.excel.EpidemicPreventionExportExcel; |
|
|
@ -81,6 +83,7 @@ import com.google.common.cache.CacheBuilder; |
|
|
|
import lombok.SneakyThrows; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.compress.utils.Lists; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
@ -3890,4 +3893,177 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi |
|
|
|
return fzBig.multiply(NumConstant.ONE_HUNDRED_DECIMAL).divide(totalBig, NumConstant.TWO, BigDecimal.ROUND_HALF_UP); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 烟台需求:https://modao.cc/app/DUshpXWirii6amoDQsb8OP#screen=slfbvoz5w4z9f98
|
|
|
|
* 接口地址:http://yapi.elinkservice.cn/project/356/interface/api/cat_1370
|
|
|
|
* 居民年龄分布饼图 |
|
|
|
* |
|
|
|
* @param customerId |
|
|
|
* @param staffId |
|
|
|
* @param orgId |
|
|
|
* @param orgType |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<ResiPortrayalResultDTO> queryAgeDistribute(String customerId,String staffId,String orgId, String orgType) { |
|
|
|
if (StringUtils.isBlank(orgId)) { |
|
|
|
orgId = CustomerStaffRedis.getStaffInfo(customerId, staffId).getAgencyId(); |
|
|
|
orgType = OrgTypeEnum.AGENCY.getCode(); |
|
|
|
} |
|
|
|
List<ResiPortrayalResultDTO> resultList=getDefaultAgeDistribute(); |
|
|
|
List<ResiPortrayalResultDTO> list=baseDao.selectAgeAgeDistribute(customerId,orgId,orgType); |
|
|
|
if(CollectionUtils.isEmpty(list)){ |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
Map<String,Integer> resultMap = list.stream().collect(Collectors.toMap(ResiPortrayalResultDTO::getCode,ResiPortrayalResultDTO::getTotalResi)); |
|
|
|
resultList.forEach(result->{ |
|
|
|
if (MapUtils.isNotEmpty(resultMap) && resultMap.containsKey(result.getCode())) { |
|
|
|
result.setTotalResi(resultMap.get(result.getCode())); |
|
|
|
} |
|
|
|
}); |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
private List<ResiPortrayalResultDTO> getDefaultAgeDistribute() { |
|
|
|
List<ResiPortrayalResultDTO> list = new ArrayList<>(); |
|
|
|
for (int code = 0; code <= 4; code++) { |
|
|
|
ResiPortrayalResultDTO resultDTO = new ResiPortrayalResultDTO(); |
|
|
|
resultDTO.setTotalResi(NumConstant.ZERO); |
|
|
|
resultDTO.setCode(String.valueOf(code)); |
|
|
|
switch (code) { |
|
|
|
case 0: |
|
|
|
resultDTO.setCodeName("50岁以下"); |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
resultDTO.setCodeName("50-59岁"); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
resultDTO.setCodeName("60-69岁"); |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
resultDTO.setCodeName("70-79岁"); |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
resultDTO.setCodeName("80岁以上"); |
|
|
|
break; |
|
|
|
default: |
|
|
|
resultDTO.setCodeName(StrConstant.EPMETY_STR); |
|
|
|
} |
|
|
|
list.add(resultDTO); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 烟台需求:https://modao.cc/app/DUshpXWirii6amoDQsb8OP#screen=slfbvoz5w4z9f98
|
|
|
|
* 接口地址:http://yapi.elinkservice.cn/project/356/interface/api/cat_1370
|
|
|
|
* 居民学历分布饼图 |
|
|
|
* |
|
|
|
* @param orgId |
|
|
|
* @param orgType agency/grid |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<ResiPortrayalResultDTO> queryEducationDistribute(String customerId, String staffId, String orgId, String orgType) { |
|
|
|
if (StringUtils.isBlank(orgId)) { |
|
|
|
orgId = CustomerStaffRedis.getStaffInfo(customerId, staffId).getAgencyId(); |
|
|
|
orgType = OrgTypeEnum.AGENCY.getCode(); |
|
|
|
} |
|
|
|
// 获取文化程度字典
|
|
|
|
DictListFormDTO dictFormDTO = new DictListFormDTO(); |
|
|
|
dictFormDTO.setDictType(DictTypeEnum.EDUCATION.getCode()); |
|
|
|
Result<List<DictListResultDTO>> dictResult = epmetAdminOpenFeignClient.dictList(dictFormDTO); |
|
|
|
if (!dictResult.success() || CollectionUtils.isEmpty(dictResult.getData())) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "学历字典获取失败", "学历字典获取失败"); |
|
|
|
} |
|
|
|
//按照学历分组,查询居民数量
|
|
|
|
List<ResiPortrayalResultDTO> totalList = baseDao.queryEducationDistribute(customerId, orgId, orgType); |
|
|
|
Map<String,Integer> map = totalList.stream().collect(Collectors.toMap(ResiPortrayalResultDTO::getCode,ResiPortrayalResultDTO::getTotalResi)); |
|
|
|
List<ResiPortrayalResultDTO> resultDTOList = new ArrayList<>(); |
|
|
|
dictResult.getData().forEach(dict -> { |
|
|
|
ResiPortrayalResultDTO resultDTO = new ResiPortrayalResultDTO(); |
|
|
|
resultDTO.setCode(dict.getValue()); |
|
|
|
resultDTO.setCodeName(dict.getLabel()); |
|
|
|
resultDTO.setTotalResi(NumConstant.ZERO); |
|
|
|
if(MapUtils.isNotEmpty(map)&&map.containsKey(dict.getValue())){ |
|
|
|
resultDTO.setTotalResi(map.get(dict.getValue())); |
|
|
|
} |
|
|
|
resultDTOList.add(resultDTO); |
|
|
|
}); |
|
|
|
return resultDTOList; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 烟台需求:https://modao.cc/app/DUshpXWirii6amoDQsb8OP#screen=slfbvoz5w4z9f98
|
|
|
|
* 居民画像,居民列表 |
|
|
|
* |
|
|
|
* @param customerId |
|
|
|
* @param staffId |
|
|
|
* @param pageNo |
|
|
|
* @param pageSize |
|
|
|
* @param orgId |
|
|
|
* @param orgType |
|
|
|
* @param codeType 学历:education 年龄:age |
|
|
|
* @param code:年龄饼图/学历饼图返回的code |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public PageData<ResiPortrayalDetailDTO> queryPortrayalResiList(String customerId, String staffId, |
|
|
|
Integer pageNo, Integer pageSize, |
|
|
|
String orgId, String orgType, |
|
|
|
String codeType, |
|
|
|
String code) { |
|
|
|
// 获取文化程度字典
|
|
|
|
DictListFormDTO dictFormDTO = new DictListFormDTO(); |
|
|
|
dictFormDTO.setDictType(DictTypeEnum.EDUCATION.getCode()); |
|
|
|
Result<List<DictListResultDTO>> dictResult = epmetAdminOpenFeignClient.dictList(dictFormDTO); |
|
|
|
if (!dictResult.success() || CollectionUtils.isEmpty(dictResult.getData())) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "学历字典获取失败", "学历字典获取失败"); |
|
|
|
} |
|
|
|
Map<String, String> educationMap = dictResult.getData().stream().collect(Collectors.toMap(DictListResultDTO::getValue, DictListResultDTO::getLabel)); |
|
|
|
|
|
|
|
if (StringUtils.isBlank(orgId)) { |
|
|
|
orgId = CustomerStaffRedis.getStaffInfo(customerId, staffId).getAgencyId(); |
|
|
|
orgType = OrgTypeEnum.AGENCY.getCode(); |
|
|
|
} |
|
|
|
PageHelper.startPage(pageNo, pageSize); |
|
|
|
List<ResiPortrayalDetailDTO> list = baseDao.selectPortrayalResiList(customerId, orgId, orgType,codeType, code); |
|
|
|
if(CollectionUtils.isNotEmpty(list)){ |
|
|
|
Set<String> houseIds=list.stream().map(m -> m.getHomeId()).collect(Collectors.toSet()); |
|
|
|
//查询房子名称
|
|
|
|
Result<List<HouseInfoDTO>> houseInfoRes = govOrgOpenFeignClient.queryListHouseInfo(houseIds, customerId); |
|
|
|
List<HouseInfoDTO> houseInfoDTOList = houseInfoRes.success() && !CollectionUtils.isEmpty(houseInfoRes.getData()) ? houseInfoRes.getData() : new ArrayList<>(); |
|
|
|
Map<String, HouseInfoDTO> houseInfoMap = houseInfoDTOList.stream().collect(Collectors.toMap(HouseInfoDTO::getHomeId, Function.identity())); |
|
|
|
|
|
|
|
list.forEach(resi -> { |
|
|
|
// 学历名称
|
|
|
|
resi.setEducationName(educationMap.get(resi.getEducationCode())); |
|
|
|
GridInfoCache gridInfoCache = CustomerOrgRedis.getGridInfo(resi.getGridId()); |
|
|
|
if (null != gridInfoCache) { |
|
|
|
resi.setGridName(gridInfoCache.getGridNamePath()); |
|
|
|
} |
|
|
|
if (houseInfoMap.containsKey(resi.getHomeId()) && null != houseInfoMap.get(resi.getHomeId())) { |
|
|
|
HouseInfoDTO houseInfoDTO = houseInfoMap.get(resi.getHomeId()); |
|
|
|
String buildName = StringUtils.isNotBlank(houseInfoDTO.getBuildingName()) ? houseInfoDTO.getBuildingName() : StrConstant.EPMETY_STR; |
|
|
|
resi.setBuildName(buildName); |
|
|
|
|
|
|
|
String neighBorName = StringUtils.isNotBlank(houseInfoDTO.getNeighborHoodName()) ? houseInfoDTO.getNeighborHoodName() : StrConstant.EPMETY_STR; |
|
|
|
resi.setVillageName(neighBorName); |
|
|
|
|
|
|
|
String unitName = StringUtils.isNotBlank(houseInfoDTO.getUnitName()) ? houseInfoDTO.getUnitName() : StrConstant.EPMETY_STR; |
|
|
|
resi.setUnitName(unitName); |
|
|
|
|
|
|
|
String doorName = StringUtils.isNotBlank(houseInfoDTO.getDoorName()) ? houseInfoDTO.getDoorName() : StrConstant.EPMETY_STR; |
|
|
|
resi.setDoorName(doorName); |
|
|
|
resi.setHomeName(neighBorName.concat(buildName).concat(unitName).concat(doorName)); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
PageInfo<ResiPortrayalDetailDTO> pageInfo = new PageInfo<>(list); |
|
|
|
return new PageData<>(list, pageInfo.getTotal(), pageSize); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|