diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/resi/ResiPortrayalCommonFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/resi/ResiPortrayalCommonFormDTO.java index 9679258c91..d5f763ceb4 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/resi/ResiPortrayalCommonFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/resi/ResiPortrayalCommonFormDTO.java @@ -1,5 +1,6 @@ package com.epmet.dto.form.resi; +import com.epmet.commons.tools.dto.form.PageFormDTO; import lombok.Data; /** @@ -8,7 +9,7 @@ import lombok.Data; * @Date 2023/4/11 17:03 */ @Data -public class ResiPortrayalCommonFormDTO { +public class ResiPortrayalCommonFormDTO extends PageFormDTO { /** * /gov/org/customeragency/agencygridtree返回的agencyId */ @@ -17,5 +18,16 @@ public class ResiPortrayalCommonFormDTO { * /gov/org/customeragency/agencygridtree返回level=grid时,orgType:grid;其他情况orgType:agency */ private String orgType; + + /** + * 查询居民列表 + * 年龄饼图/学历饼图返回的code + */ + private String code; + /** + * 学历:education + * 年龄:age + */ + private String codeType; } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/resi/ResiPortrayalDetailDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/resi/ResiPortrayalDetailDTO.java new file mode 100644 index 0000000000..e002b95d5d --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/resi/ResiPortrayalDetailDTO.java @@ -0,0 +1,74 @@ +package com.epmet.dto.result.resi; + +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; + +/** + * @Description 烟台居民画像,居民列表 + * @Author yzm + * @Date 2023/4/12 10:10 + */ +@Data +public class ResiPortrayalDetailDTO { + /** + * 居民id + */ + @ExcelIgnore + private String icResiUserId; + /** + * 姓名 + */ + @ExcelProperty(value = "姓名") + @ColumnWidth(25) + private String name; + /** + * 手机号 + */ + @ExcelProperty(value = "手机号") + @ColumnWidth(25) + private String mobile; + /** + * 性别:1男;2女;0未知 + */ + @ExcelIgnore + private String gender; + /** + * 性别名称 + */ + @ExcelProperty(value = "性别") + @ColumnWidth(25) + private String genderName; + /** + * 身份证 + */ + @ExcelProperty(value = "身份证号") + @ColumnWidth(25) + private String idCard; + + @ExcelProperty(value = "出生日期") + @ColumnWidth(25) + private String birthday; + + /** + * 年龄 + */ + @ExcelProperty(value = "年龄") + @ColumnWidth(10) + private Integer age; + /** + * 学历key + */ + @ExcelIgnore + private String educationCode; + /** + * 学历 + */ + @ExcelProperty(value = "学历") + @ColumnWidth(25) + private String educationName; + + +} + diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index b06cd27b4e..68aef04cda 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -63,6 +63,7 @@ import com.epmet.dto.form.resi.ResiPortrayalCommonFormDTO; import com.epmet.dto.result.*; 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.enums.IcResiUserTableEnum; import com.epmet.excel.PartyMemberAgeExportExcel; @@ -465,7 +466,6 @@ public class IcResiUserController implements ResultDataResolver { /** * desc: 导出居民信息 * - * @param customerId * @param tokenDto * @param pageFormDTO * @param response @@ -620,7 +620,6 @@ public class IcResiUserController implements ResultDataResolver { * * @param tokenDto * @param pageFormDTO - * @param response * @return void * @author LiuJanJun * @date 2021/11/19 4:24 下午 @@ -1451,7 +1450,6 @@ public class IcResiUserController implements ResultDataResolver { /** * Desc: 居民首次进入小程序,可以根据输入身份证信息查询在数字社区居民信息中的网格,匹配不成功提示 - * @param tokenDto * @param formDTO * @author zxc * @date 2022/8/5 11:17 @@ -1555,5 +1553,69 @@ public class IcResiUserController implements ResultDataResolver { return new Result>().ok(icResiUserService.queryEducationDistribute(tokenDto.getCustomerId(),tokenDto.getUserId(),formDTO.getOrgId(), formDTO.getOrgType())); } + /** + * 烟台需求:https://modao.cc/app/DUshpXWirii6amoDQsb8OP#screen=slfbvoz5w4z9f98 + * 居民画像,居民列表 + * + * @param tokenDto + * @param formDTO + * @return + */ + @MaskResponse(fieldNames = {"mobile", "idCard"},fieldsMaskType = {MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD}) + @PostMapping("portrayal-list") + public Result> queryPortrayalResiList(@LoginUser TokenDto tokenDto, @RequestBody ResiPortrayalCommonFormDTO formDTO) { + return new Result>().ok(icResiUserService.queryPortrayalResiList(tokenDto.getCustomerId(), tokenDto.getUserId(), + formDTO.getPageNo(), formDTO.getPageSize(), + formDTO.getOrgId(), formDTO.getOrgType(), + formDTO.getCodeType(), + formDTO.getCode())); + } + + /** + * 11、导出列表数据 + * + * @param response + * @param formDTO + * @throws Exception + */ + @PostMapping("portrayal-listexport") + public void exportMonitoringEquipment(HttpServletResponse response, + @RequestBody ResiPortrayalCommonFormDTO formDTO) throws Exception { + formDTO.setIsPage(false); + ExcelWriter excelWriter = null; + formDTO.setPageNo(NumConstant.ONE); + formDTO.setPageSize(NumConstant.TEN_THOUSAND); + try { + String fileName = "居民画像-居民列表" + DateUtils.format(new Date()) + ".xlsx"; + excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), ResiPortrayalDetailDTO.class).build(); + WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build(); + PageData data = null; + List list = null; + do { + // 默认查询本组织及下级 + data = icResiUserService.queryPortrayalResiList(EpmetRequestHolder.getLoginUserCustomerId(),EpmetRequestHolder.getLoginUserId(), + formDTO.getPageNo(),formDTO.getPageSize(), + formDTO.getOrgId(),formDTO.getOrgType(), + formDTO.getCodeType(),formDTO.getCode()); + list = data.getList(); + formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE); + excelWriter.write(list, writeSheet); + } while (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list) && list.size() == formDTO.getPageSize()); + } catch (EpmetException e) { + response.reset(); + response.setCharacterEncoding("UTF-8"); + response.setHeader("content-type", "application/json; charset=UTF-8"); + PrintWriter printWriter = response.getWriter(); + Result result = new Result<>().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), e.getMsg()); + printWriter.write(JSON.toJSONString(result)); + printWriter.close(); + } catch (Exception e) { + log.error("居民画像-居民列表export exception", e); + } finally { + if (excelWriter != null) { + excelWriter.finish(); + } + } + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java index 0730a83922..1f78eb3726 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java @@ -24,6 +24,7 @@ import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.IcVolunteerPolyDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; +import com.epmet.dto.result.resi.ResiPortrayalDetailDTO; import com.epmet.dto.result.resi.ResiPortrayalResultDTO; import com.epmet.entity.IcResiUserEntity; import org.apache.ibatis.annotations.MapKey; @@ -468,4 +469,18 @@ public interface IcResiUserDao extends BaseDao { List selectAgeAgeDistribute(@Param("customerId") String customerId, @Param("orgId") String orgId, @Param("orgType") String orgType); + + /** + * @param customerId + * @param orgId + * @param orgType + * @param codeType 学历:education 年龄:age + * @param code + * @return 居民画像,居民列表 + */ + List selectPortrayalResiList(@Param("customerId") String customerId, + @Param("orgId") String orgId, + @Param("orgType") String orgType, + @Param("codeType")String codeType, + @Param("code") String code); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java index e578e51724..ae394a3e98 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java @@ -28,6 +28,7 @@ import com.epmet.dto.form.*; import com.epmet.dto.result.*; 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.IcResiUserEntity; import com.epmet.excel.support.ExportResiUserItemDTO; @@ -561,7 +562,7 @@ public interface IcResiUserService extends BaseService { * @param orgType * @return */ - List queryAgeDistribute(String customerId,String staffId,String orgId, String orgType); + List queryAgeDistribute(String customerId, String staffId, String orgId, String orgType); /** * 烟台需求:https://modao.cc/app/DUshpXWirii6amoDQsb8OP#screen=slfbvoz5w4z9f98 @@ -572,5 +573,16 @@ public interface IcResiUserService extends BaseService { * @param orgType agency/grid * @return */ - List queryEducationDistribute(String customerId,String staffId,String orgId, String orgType); + List queryEducationDistribute(String customerId, String staffId, String orgId, String orgType); + + /** + * 烟台需求:https://modao.cc/app/DUshpXWirii6amoDQsb8OP#screen=slfbvoz5w4z9f98 + * 居民画像,居民列表 + * + * @return + */ + PageData queryPortrayalResiList(String customerId, String staffId, + Integer pageNo, Integer pageSize, + String orgId, String orgType, + String codeType,String code); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index 8e6b9a610a..e705af1993 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -62,6 +62,7 @@ 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; @@ -3941,14 +3942,19 @@ public class IcResiUserServiceImpl extends BaseServiceImpl 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> dictResult = epmetAdminOpenFeignClient.dictList(dictFormDTO); + if (!dictResult.success() || CollectionUtils.isEmpty(dictResult.getData())) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "学历字典获取失败", "学历字典获取失败"); + } + Map 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 list = baseDao.selectPortrayalResiList(customerId, orgId, orgType,codeType, code); + list.forEach(resi -> { + // 学历名称 + resi.setEducationName(educationMap.get(resi.getEducationCode())); + }); + PageInfo pageInfo = new PageInfo<>(list); + return new PageData<>(list, pageInfo.getTotal(), pageSize); + } + } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml index 107980a03c..ec82b7ce45 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml @@ -125,7 +125,14 @@ - and ${subCondition.tableName}.${subCondition.columnName} between #{subCondition.columnValue[0]} and #{subCondition.columnValue[1]} + and ${subCondition.tableName}.${subCondition.columnName} is not null + and ${subCondition.tableName}.${subCondition.columnName} !='' + + and ${subCondition.tableName}.${subCondition.columnName} >= #{subCondition.columnValue[0]} + + + and ${subCondition.tableName}.${subCondition.columnName} <= #{subCondition.columnValue[1]} + @@ -180,7 +187,14 @@ - and ${subCondition.tableName}.${subCondition.columnName} between #{subCondition.columnValue[0]} and #{subCondition.columnValue[1]} + and ${subCondition.tableName}.${subCondition.columnName} is not null + and ${subCondition.tableName}.${subCondition.columnName} !='' + + and ${subCondition.tableName}.${subCondition.columnName} >= #{subCondition.columnValue[0]} + + + and ${subCondition.tableName}.${subCondition.columnName} <= #{subCondition.columnValue[1]} + @@ -1546,13 +1560,13 @@ from ( SELECT u.ID, - YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) as age, + YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) as age, ( - case when YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) < 50 then '0' - when YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) >=50 and YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) <=59 then '1' - when YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) >=60 and YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) <=69 then '2' - when YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) >=70 and YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) <=79 then '3' - when YEAR(NOW())-SUBSTR(u.ID_CARD, 7, 4) >=80 then '4' + case when u.BIRTHDAY > DATE_SUB(CURDATE(),INTERVAL 50 year) then '0' + when u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 59 year) AND DATE_SUB(CURDATE(),INTERVAL 50 year) then '1' + when u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 69 year) AND DATE_SUB(CURDATE(),INTERVAL 60 year) then '2' + when u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 79 year) AND DATE_SUB(CURDATE(),INTERVAL 70 year) then '3' + when u.BIRTHDAY <= DATE_SUB(CURDATE(),INTERVAL 80 year) then '4' end ) as `code` FROM @@ -1560,8 +1574,9 @@ WHERE u.DEL_FLAG = '0' AND u.CUSTOMER_ID = #{customerId} - AND u.ID_CARD IS NOT NULL and u.`STATUS`='0' + and u.BIRTHDAY is not null + and u.BIRTHDAY !='' AND ( u.AGENCY_ID = #{orgId} OR u.PIDS LIKE concat('%',#{orgId},'%') ) @@ -1571,4 +1586,56 @@ )temp group by temp.`code` + + +