Browse Source

居民画像 房屋画像加缓存

master
qushutong 2 years ago
parent
commit
f5b77a2f2d
  1. 53
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  2. 5
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
  3. 11
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java
  4. 40
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java
  5. 44
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

53
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -1100,4 +1100,57 @@ public class RedisKeys {
public static String getSubUserHouseList(String orgType,String agencyId) { public static String getSubUserHouseList(String orgType,String agencyId) {
return rootPrefix.concat("govorg:house:subUserHouseList:".concat(orgType).concat(StrConstant.COLON).concat(agencyId)); return rootPrefix.concat("govorg:house:subUserHouseList:".concat(orgType).concat(StrConstant.COLON).concat(agencyId));
} }
/**
*
* @description: 年龄人画像
* @author qushutong
* @date 2023/11/2 18:08
* @param
* @return java.lang.String
* @Version1.0
**/
public static String getAgeDistribute() {
return rootPrefix.concat("resi:icresiuser:agechart:".concat("age"));
}
/**
*
* @description: 年龄人画像
* @author qushutong
* @date 2023/11/2 18:08
* @param
* @return java.lang.String
* @Version1.0
**/
public static String getEducationDistribute() {
return rootPrefix.concat("resi:icresiuser:educhart:".concat("education"));
}
/**
*
* @description: 房屋画像 房屋用途
* @author qushutong
* @date 2023/11/3 9:33
* @param
* @return java.lang.String
* @Version1.0
**/
public static String getHousePurposeCountKey() {
return rootPrefix.concat("resi:icresiuser:housechart:".concat("housepurpose"));
}
/**
*
* @description: 房屋画像 房屋用途
* @author qushutong
* @date 2023/11/3 9:33
* @param
* @return java.lang.String
* @Version1.0
**/
public static String getHouseStatusCountKey() {
return rootPrefix.concat("resi:icresiuser:housechart:".concat("housestatus"));
}
} }

5
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java

@ -57,6 +57,7 @@ import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.remote.EpmetUserRemoteService; import com.epmet.remote.EpmetUserRemoteService;
import com.epmet.service.HouseService; import com.epmet.service.HouseService;
import com.epmet.service.IcHouseService;
import com.epmet.util.ExcelPoiUtils; import com.epmet.util.ExcelPoiUtils;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
@ -109,6 +110,9 @@ public class HouseController implements ResultDataResolver {
@Autowired @Autowired
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
@Autowired
private IcHouseService icHouseService;
@ReportRequest @ReportRequest
@PostMapping("houselist") @PostMapping("houselist")
@MaskResponse(fieldNames = {"ownerIdCard", "ownerPhone"}, @MaskResponse(fieldNames = {"ownerIdCard", "ownerPhone"},
@ -397,6 +401,7 @@ public class HouseController implements ResultDataResolver {
**/ **/
@PostMapping("housechartRedis") @PostMapping("housechartRedis")
public Result houseChartRedis() { public Result houseChartRedis() {
icHouseService.updataHouseCount();
return new Result<>().ok(houseService.houseChartRedis()); return new Result<>().ok(houseService.houseChartRedis());
} }

11
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java

@ -146,4 +146,15 @@ public interface IcHouseService extends BaseService<IcHouseEntity> {
HouseCountPictureResultDTO getHouseStatusCount(HouseCountPictureFormDTO dto); HouseCountPictureResultDTO getHouseStatusCount(HouseCountPictureFormDTO dto);
PageData<HousePictureListResultDTO> getHousePictureList(HouseCountPictureFormDTO dto); PageData<HousePictureListResultDTO> getHousePictureList(HouseCountPictureFormDTO dto);
/**
*
* @description: 缓存房屋画像
* @author qushutong
* @date 2023/11/3 9:59
* @param
* @return void
* @Version1.0
**/
void updataHouseCount();
} }

40
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java

@ -45,6 +45,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.record.PageBreakRecord; import org.apache.poi.hssf.record.PageBreakRecord;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -320,6 +321,7 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
/** /**
* 房屋全名小区楼栋单元房间号 * 房屋全名小区楼栋单元房间号
*
* @return * @return
*/ */
@Override @Override
@ -436,7 +438,32 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
@Override @Override
public HouseCountPictureResultDTO getHousePurposeCount(HouseCountPictureFormDTO dto) { public HouseCountPictureResultDTO getHousePurposeCount(HouseCountPictureFormDTO dto) {
HouseCountPictureResultDTO resultDTO;
// 如果缓存中有 并且是烟台市级别的 可以从缓存取。一级页面缓存处理
if (null != redisUtils.get(RedisKeys.getHousePurposeCountKey()) && "1535072605630230530".equals(dto.getOrgId()) && "1535072605630230530".equals(dto.getOrgIdPath())) {
resultDTO = (HouseCountPictureResultDTO) redisUtils.get(RedisKeys.getHousePurposeCountKey());
} else {
resultDTO = getHouseCountPictureResultDTO(dto);
}
return resultDTO;
}
@Override
public void updataHouseCount() {
HouseCountPictureFormDTO dto = new HouseCountPictureFormDTO();
dto.setOrgId("1535072605630230530");
dto.setOrgIdPath("1535072605630230530");
dto.setOrgType("city");
HouseCountPictureResultDTO houseCountPictureResultDTO = getHouseCountPictureResultDTO(dto);
redisUtils.set(RedisKeys.getHousePurposeCountKey(), houseCountPictureResultDTO, RedisUtils.DEFAULT_EXPIRE);
// 房屋用途
HouseCountPictureResultDTO houseStatusDTO = getHouseStatusDTO(dto);
redisUtils.set(RedisKeys.getHouseStatusCountKey(), houseStatusDTO, RedisUtils.DEFAULT_EXPIRE);
}
@NotNull
private HouseCountPictureResultDTO getHouseCountPictureResultDTO(HouseCountPictureFormDTO dto) {
HouseCountPictureResultDTO resultDTO = new HouseCountPictureResultDTO(); HouseCountPictureResultDTO resultDTO = new HouseCountPictureResultDTO();
Map<String, String> type = new HashMap<>(); Map<String, String> type = new HashMap<>();
@ -504,7 +531,19 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
@Override @Override
public HouseCountPictureResultDTO getHouseStatusCount(HouseCountPictureFormDTO dto) { public HouseCountPictureResultDTO getHouseStatusCount(HouseCountPictureFormDTO dto) {
HouseCountPictureResultDTO resultDTO;
// 如果缓存中有 并且是烟台市级别的 可以从缓存取。一级页面缓存处理
if (null != redisUtils.get(RedisKeys.getHousePurposeCountKey()) && "1535072605630230530".equals(dto.getOrgId()) && "1535072605630230530".equals(dto.getOrgIdPath())) {
resultDTO = (HouseCountPictureResultDTO) redisUtils.get(RedisKeys.getHouseStatusCountKey());
} else {
resultDTO = getHouseStatusDTO(dto);
}
return resultDTO;
}
@NotNull
private HouseCountPictureResultDTO getHouseStatusDTO(HouseCountPictureFormDTO dto) {
HouseCountPictureResultDTO resultDTO = new HouseCountPictureResultDTO(); HouseCountPictureResultDTO resultDTO = new HouseCountPictureResultDTO();
Map<String, String> type = new HashMap<>(); Map<String, String> type = new HashMap<>();
@ -551,7 +590,6 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
list.add(houseCountPictureListResultDTO); list.add(houseCountPictureListResultDTO);
} }
resultDTO.setList(list); resultDTO.setList(list);
return resultDTO; return resultDTO;
} }

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

@ -230,6 +230,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
/** /**
* 该接口供开发人员手动调用 * 该接口供开发人员手动调用
* 项目上经常要求删除某个社区的人房数据 索性写一个接口供开发人员调用 * 项目上经常要求删除某个社区的人房数据 索性写一个接口供开发人员调用
*
* @param formDTO * @param formDTO
* @return * @return
*/ */
@ -467,6 +468,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
/** /**
* 为党员信息生成家庭地址 * 为党员信息生成家庭地址
*
* @param customerId * @param customerId
* @param gridId * @param gridId
* @param homeId * @param homeId
@ -809,8 +811,8 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
} }
/** /**
* @description: 生成居民变更记录
* @return * @return
* @description: 生成居民变更记录
* @author: sun * @author: sun
*/ */
public void icUserChangeRecord(IcResiUserEntity entity, LinkedHashMap<String, String> map) { public void icUserChangeRecord(IcResiUserEntity entity, LinkedHashMap<String, String> map) {
@ -3043,6 +3045,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
/** /**
* 获取组织下志愿者列表 * 获取组织下志愿者列表
* 居民信息里的志愿者 * 居民信息里的志愿者
*
* @param customerId * @param customerId
* @param agencyId * @param agencyId
* @Param customerId * @Param customerId
@ -3167,6 +3170,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
/** /**
* 目前只返回id,和姓名 * 目前只返回id,和姓名
*
* @param icResiUserIdList * @param icResiUserIdList
* @return * @return
*/ */
@ -3400,6 +3404,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
/** /**
* desc:设置居民的pids pids为agencyId的pids+agencyId 即包含组织本身 如果pids 为空则pids 为agencyId * desc:设置居民的pids pids为agencyId的pids+agencyId 即包含组织本身 如果pids 为空则pids 为agencyId
*
* @param entity * @param entity
*/ */
@Override @Override
@ -3625,6 +3630,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
/** /**
* Desc: 居民首次进入小程序可以根据输入身份证信息查询在数字社区居民信息中的网格匹配不成功提示 * Desc: 居民首次进入小程序可以根据输入身份证信息查询在数字社区居民信息中的网格匹配不成功提示
*
* @param formDTO * @param formDTO
* @author zxc * @author zxc
* @date 2022/8/5 11:17 * @date 2022/8/5 11:17
@ -3751,7 +3757,6 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
} }
/** /**
* 更新育龄妇女状态定时任务 * 更新育龄妇女状态定时任务
* *
@ -3906,8 +3911,8 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
} }
/** /**
* @Description 人户状况统计查询
* @param formDTO * @param formDTO
* @Description 人户状况统计查询
* @Author zxc * @Author zxc
* @Date 2022/11/16 09:22 * @Date 2022/11/16 09:22
*/ */
@ -3967,9 +3972,9 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
} }
/** /**
* @Description
* @param total 总人数 * @param total 总人数
* @param fz 分子人数 * @param fz 分子人数
* @Description
* @Author zxc * @Author zxc
* @Date 2022/11/16 10:12 * @Date 2022/11/16 10:12
*/ */
@ -3993,6 +3998,15 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
@Override @Override
public ResiPortrayalResult queryAgeDistribute(String customerId, String staffId, String orgId, String orgType) { public ResiPortrayalResult queryAgeDistribute(String customerId, String staffId, String orgId, String orgType) {
ResiPortrayalResult result = new ResiPortrayalResult(); ResiPortrayalResult result = new ResiPortrayalResult();
if (null != redisUtils.get(RedisKeys.getAgeDistribute()) && StringUtils.isBlank(orgId) && StringUtils.isBlank(orgType)) {
result = (ResiPortrayalResult) redisUtils.get(RedisKeys.getAgeDistribute());
} else {
result = queryage(customerId, staffId, orgId, orgType, result);
}
return result;
}
private ResiPortrayalResult queryage(String customerId, String staffId, String orgId, String orgType, ResiPortrayalResult result) {
if (StringUtils.isBlank(orgId)) { if (StringUtils.isBlank(orgId)) {
orgId = CustomerStaffRedis.getStaffInfo(customerId, staffId).getAgencyId(); orgId = CustomerStaffRedis.getStaffInfo(customerId, staffId).getAgencyId();
orgType = OrgTypeEnum.AGENCY.getCode(); orgType = OrgTypeEnum.AGENCY.getCode();
@ -4021,6 +4035,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
return result; return result;
} }
private List<ResiPortrayalResultDTO> getDefaultAgeDistribute() { private List<ResiPortrayalResultDTO> getDefaultAgeDistribute() {
List<ResiPortrayalResultDTO> list = new ArrayList<>(); List<ResiPortrayalResultDTO> list = new ArrayList<>();
for (int code = 0; code <= 4; code++) { for (int code = 0; code <= 4; code++) {
@ -4064,6 +4079,15 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
@Override @Override
public ResiPortrayalResult queryEducationDistribute(String customerId, String staffId, String orgId, String orgType) { public ResiPortrayalResult queryEducationDistribute(String customerId, String staffId, String orgId, String orgType) {
ResiPortrayalResult result = new ResiPortrayalResult(); ResiPortrayalResult result = new ResiPortrayalResult();
if (null != redisUtils.get(RedisKeys.getEducationDistribute()) && StringUtils.isBlank(orgId) && StringUtils.isBlank(orgType)) {
result = (ResiPortrayalResult) redisUtils.get(RedisKeys.getEducationDistribute());
} else {
result = queryEdu(customerId, staffId, orgId, orgType, result);
}
return result;
}
private ResiPortrayalResult queryEdu(String customerId, String staffId, String orgId, String orgType, ResiPortrayalResult result) {
if (StringUtils.isBlank(orgId)) { if (StringUtils.isBlank(orgId)) {
orgId = CustomerStaffRedis.getStaffInfo(customerId, staffId).getAgencyId(); orgId = CustomerStaffRedis.getStaffInfo(customerId, staffId).getAgencyId();
orgType = OrgTypeEnum.AGENCY.getCode(); orgType = OrgTypeEnum.AGENCY.getCode();
@ -4343,7 +4367,19 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取该组织的userchart失败" + agencyResultDTO.getAgencyId(), "获取该组织的userchart失败"); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取该组织的userchart失败" + agencyResultDTO.getAgencyId(), "获取该组织的userchart失败");
} }
} }
// 缓存 画像人年纪,学历
updateUserDistribute();
return true; return true;
} }
public void updateUserDistribute() {
ResiPortrayalResult result = new ResiPortrayalResult();
ResiPortrayalResult resiPortrayalResult = queryage("1535072605621841922", "1535072605630230530", "", "", result);
redisUtils.set(RedisKeys.getAgeDistribute(), resiPortrayalResult, RedisUtils.DEFAULT_EXPIRE);
ResiPortrayalResult portrayalResult = new ResiPortrayalResult();
ResiPortrayalResult resiEducationResult = queryEdu("1535072605621841922", "1535072605630230530", "", "", portrayalResult);
redisUtils.set(RedisKeys.getEducationDistribute(), resiEducationResult, RedisUtils.DEFAULT_EXPIRE);
}
} }
Loading…
Cancel
Save