Browse Source

Merge remote-tracking branch 'origin/yantai_zhengwu_master' into dev

master
yinzuomei 2 years ago
parent
commit
e3fc37e732
  1. 14
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/resi/ResiPortrayalCommonFormDTO.java
  2. 74
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/resi/ResiPortrayalDetailDTO.java
  3. 68
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
  4. 15
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java
  5. 16
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java
  6. 49
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java
  7. 85
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

14
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其他情况orgTypeagency
*/
private String orgType;
/**
* 查询居民列表
* 年龄饼图/学历饼图返回的code
*/
private String code;
/**
* 学历education
* 年龄age
*/
private String codeType;
}

74
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;
}

68
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<List<ResiPortrayalResultDTO>>().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<PageData<ResiPortrayalDetailDTO>> queryPortrayalResiList(@LoginUser TokenDto tokenDto, @RequestBody ResiPortrayalCommonFormDTO formDTO) {
return new Result<PageData<ResiPortrayalDetailDTO>>().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<ResiPortrayalDetailDTO> data = null;
List<ResiPortrayalDetailDTO> 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<Object> 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();
}
}
}
}

15
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<IcResiUserEntity> {
List<ResiPortrayalResultDTO> 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<ResiPortrayalDetailDTO> selectPortrayalResiList(@Param("customerId") String customerId,
@Param("orgId") String orgId,
@Param("orgType") String orgType,
@Param("codeType")String codeType,
@Param("code") String code);
}

16
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<IcResiUserEntity> {
* @param orgType
* @return
*/
List<ResiPortrayalResultDTO> queryAgeDistribute(String customerId,String staffId,String orgId, String orgType);
List<ResiPortrayalResultDTO> 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<IcResiUserEntity> {
* @param orgType agency/grid
* @return
*/
List<ResiPortrayalResultDTO> queryEducationDistribute(String customerId,String staffId,String orgId, String orgType);
List<ResiPortrayalResultDTO> queryEducationDistribute(String customerId, String staffId, String orgId, String orgType);
/**
* 烟台需求https://modao.cc/app/DUshpXWirii6amoDQsb8OP#screen=slfbvoz5w4z9f98
* 居民画像居民列表
*
* @return
*/
PageData<ResiPortrayalDetailDTO> queryPortrayalResiList(String customerId, String staffId,
Integer pageNo, Integer pageSize,
String orgId, String orgType,
String codeType,String code);
}

49
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<IcResiUserDao, IcResi
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);
}
@ -3998,5 +4004,48 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
}
/**
* 烟台需求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);
list.forEach(resi -> {
// 学历名称
resi.setEducationName(educationMap.get(resi.getEducationCode()));
});
PageInfo<ResiPortrayalDetailDTO> pageInfo = new PageInfo<>(list);
return new PageData<>(list, pageInfo.getTotal(), pageSize);
}
}

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

@ -125,7 +125,14 @@
</if>
<if test="subCondition.queryType!= null and subCondition.queryType == 'daterange' ">
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} !=''
<if test='null != subCondition.columnValue[0] and subCondition.columnValue[0] != "" '>
and ${subCondition.tableName}.${subCondition.columnName} &gt;= #{subCondition.columnValue[0]}
</if>
<if test='null != subCondition.columnValue[1] and subCondition.columnValue[1] != "" '>
and ${subCondition.tableName}.${subCondition.columnName} &lt;= #{subCondition.columnValue[1]}
</if>
</if>
<if test="subCondition.queryType!= null and subCondition.queryType == 'notnull' ">
@ -180,7 +187,14 @@
</if>
<if test="subCondition.queryType!= null and subCondition.queryType == 'daterange' ">
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} !=''
<if test='null != subCondition.columnValue[0] and subCondition.columnValue[0] != "" '>
and ${subCondition.tableName}.${subCondition.columnName} &gt;= #{subCondition.columnValue[0]}
</if>
<if test='null != subCondition.columnValue[1] and subCondition.columnValue[1] != "" '>
and ${subCondition.tableName}.${subCondition.columnName} &lt;= #{subCondition.columnValue[1]}
</if>
</if>
<if test="subCondition.queryType!= null and subCondition.queryType == 'notnull' ">
@ -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) &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'
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 &lt;= 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 !=''
<if test='orgType == "agency" '>
AND ( u.AGENCY_ID = #{orgId} OR u.PIDS LIKE concat('%',#{orgId},'%') )
</if>
@ -1571,4 +1586,56 @@
)temp
group by temp.`code`
</select>
<!-- 居民画像,居民列表 codeType 学历:education 年龄:age -->
<select id="selectPortrayalResiList" parameterType="map" resultType="com.epmet.dto.result.resi.ResiPortrayalDetailDTO">
SELECT
u.ID AS icResiUserId,
u.`NAME` AS `name`,
u.MOBILE AS mobile,
u.ID_CARD AS idCard,
u.GENDER AS gender,
( CASE WHEN u.GENDER = '1' THEN '男' WHEN u.GENDER = '2' THEN '女' ELSE '未知' END ) AS genderName,
YEAR (
NOW())- SUBSTR( u.BIRTHDAY, 1, 4 ) AS age,
u.CULTURE AS educationCode,
'' AS educationName,
IFNULL(u.CULTURE,'')AS educationCode,
u.BIRTHDAY AS birthday
FROM
ic_resi_user u
WHERE
u.DEL_FLAG = '0'
AND u.CUSTOMER_ID = #{customerId}
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>
<if test='codeType == "education" '>
<if test="code != null and code != ''">
and u.CULTURE = #{code}
</if>
</if>
<if test='codeType == "age" '>
<if test=" 0 == code">
and u.BIRTHDAY > DATE_SUB(CURDATE(),INTERVAL 50 year)
</if>
<if test=" 1 == code">
and u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 59 year) AND DATE_SUB(CURDATE(),INTERVAL 50 year)
</if>
<if test=" 2 == code">
and u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 69 year) AND DATE_SUB(CURDATE(),INTERVAL 60 year)
</if>
<if test=" 3 == code">
and u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 79 year) AND DATE_SUB(CURDATE(),INTERVAL 70 year)
</if>
<if test=" 4 == code">
and u.BIRTHDAY &lt;= DATE_SUB(CURDATE(),INTERVAL 80 year)
</if>
</if>
order by u.ID asc
</select>
</mapper>

Loading…
Cancel
Save