Browse Source

烟台居民画像年龄分布

dev
yinzuomei 2 years ago
parent
commit
c59fb31876
  1. 4
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
  2. 4
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java
  3. 4
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java
  4. 48
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java
  5. 34
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

4
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java

@ -1538,8 +1538,8 @@ public class IcResiUserController implements ResultDataResolver {
* @return
*/
@PostMapping("age-distribute")
public Result<List<ResiPortrayalResultDTO>> queryAgeDistribute(@RequestBody ResiPortrayalCommonFormDTO formDTO) {
return new Result<List<ResiPortrayalResultDTO>>().ok(icResiUserService.queryAgeDistribute(formDTO.getOrgId(), formDTO.getOrgType()));
public Result<List<ResiPortrayalResultDTO>> queryAgeDistribute(@LoginUser TokenDto tokenDto,@RequestBody ResiPortrayalCommonFormDTO formDTO) {
return new Result<List<ResiPortrayalResultDTO>>().ok(icResiUserService.queryAgeDistribute(tokenDto.getCustomerId(),tokenDto.getUserId(),formDTO.getOrgId(), formDTO.getOrgType()));
}
/**

4
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java

@ -462,4 +462,8 @@ public interface IcResiUserDao extends BaseDao<IcResiUserEntity> {
List<ResiPortrayalResultDTO> queryEducationDistribute(@Param("customerId") String customerId,
@Param("orgId") String orgId,
@Param("orgType") String orgType);
List<ResiPortrayalResultDTO> selectAgeAgeDistribute(@Param("customerId") String customerId,
@Param("orgId") String orgId,
@Param("orgType") String orgType);
}

4
epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java

@ -548,11 +548,13 @@ public interface IcResiUserService extends BaseService<IcResiUserEntity> {
* 接口地址http://yapi.elinkservice.cn/project/356/interface/api/cat_1370
* 居民年龄分布饼图
*
* @param customerId
* @param staffId
* @param orgId
* @param orgType
* @return
*/
List<ResiPortrayalResultDTO> queryAgeDistribute(String orgId, String orgType);
List<ResiPortrayalResultDTO> queryAgeDistribute(String customerId,String staffId,String orgId, String orgType);
/**
* 烟台需求https://modao.cc/app/DUshpXWirii6amoDQsb8OP#screen=slfbvoz5w4z9f98

48
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

@ -3897,17 +3897,57 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
* 接口地址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 orgId, String orgType) {
// todo
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;
}
return null;
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岁以下");
case 1:
resultDTO.setCodeName("50-59岁");
case 2:
resultDTO.setCodeName("60-69岁");
case 3:
resultDTO.setCodeName("70-79岁");
case 4:
resultDTO.setCodeName("80岁以上");
default:
resultDTO.setCodeName(StrConstant.EPMETY_STR);
}
list.add(resultDTO);
}
return list;
}
/**
* 烟台需求https://modao.cc/app/DUshpXWirii6amoDQsb8OP#screen=slfbvoz5w4z9f98

34
epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

@ -1538,5 +1538,37 @@
r.CULTURE
</select>
<!-- 烟台居民画像:年龄分布 -->
<select id="selectAgeAgeDistribute" parameterType="map" resultType="com.epmet.dto.result.resi.ResiPortrayalResultDTO">
select
temp.CODE,
count(temp.ID) as totalResi
from (
SELECT
u.ID,
YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) as age,
(
case when YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) &lt; 50 then '0'
when YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) &gt;=50 and YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) &lt;=59 then '1'
when YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) &gt;=60 and YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) &lt;=69 then '2'
when YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) &gt;=70 and YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) &lt;=79 then '3'
when YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) &gt;=80 then '4'
end
) as `code`
FROM
ic_resi_user u
WHERE
u.DEL_FLAG = '0'
AND u.CUSTOMER_ID = #{customerId}
AND u.ID_CARD IS NOT NULL
and u.`STATUS`='0'
<if test='orgType == "agency" '>
AND ( u.AGENCY_ID = #{orgId} OR u.PIDS LIKE concat('%',#{orgId},'%') )
</if>
<if test='orgType == "grid" '>
and u.GRID_ID = #{orgId}
</if>
)temp
group by temp.`code`
</select>
</mapper>

Loading…
Cancel
Save