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. 124
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java
  5. 408
      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) {
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.remote.EpmetUserRemoteService;
import com.epmet.service.HouseService;
import com.epmet.service.IcHouseService;
import com.epmet.util.ExcelPoiUtils;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
@ -109,6 +110,9 @@ public class HouseController implements ResultDataResolver {
@Autowired
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
@Autowired
private IcHouseService icHouseService;
@ReportRequest
@PostMapping("houselist")
@MaskResponse(fieldNames = {"ownerIdCard", "ownerPhone"},
@ -397,6 +401,7 @@ public class HouseController implements ResultDataResolver {
**/
@PostMapping("housechartRedis")
public Result houseChartRedis() {
icHouseService.updataHouseCount();
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);
PageData<HousePictureListResultDTO> getHousePictureList(HouseCountPictureFormDTO dto);
/**
*
* @description: 缓存房屋画像
* @author qushutong
* @date 2023/11/3 9:59
* @param
* @return void
* @Version1.0
**/
void updataHouseCount();
}

124
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.lang3.StringUtils;
import org.apache.poi.hssf.record.PageBreakRecord;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -259,7 +260,7 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
}
dto.setCategoryList(categories);
HouseInfoCache houseInfo = CustomerIcHouseRedis.getHouseInfo(item.getCustomerId(), item.getId());
if (null != houseInfo){
if (null != houseInfo) {
StringBuffer str = new StringBuffer();
str.append(houseInfo.getBuildingName()).append(houseInfo.getUnitName()).append(houseInfo.getDoorName());
dto.setHouseName(str.toString());
@ -320,6 +321,7 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
/**
* 房屋全名小区楼栋单元房间号
*
* @return
*/
@Override
@ -350,7 +352,7 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
return;
}
BigDecimal avgYsrD = null;
if (avgYsr != null){
if (avgYsr != null) {
avgYsrD = new BigDecimal(avgYsr.toString());
}
int i = baseDao.updateIcHouseResiNumber(houseId.toString(), Integer.valueOf(resiNumber.toString()), avgYsrD);
@ -388,10 +390,10 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
// 校验小区
IcNeighborHoodEntity icNeighborHoodEntity = icNeighborHoodDao.getNeighborHoodInfoByName(formDTO);
if(icNeighborHoodEntity != null && StringUtils.isNotBlank(icNeighborHoodEntity.getId())){
if (icNeighborHoodEntity != null && StringUtils.isNotBlank(icNeighborHoodEntity.getId())) {
formDTO.setVillageId(icNeighborHoodEntity.getId());
checkHomeInfoResultInfo.setVillageId(icNeighborHoodEntity.getId());
}else{
} else {
checkHomeInfoResultInfo.setCode("1");
checkHomeInfoResultInfo.setMsg("小区名称未匹配到数据");
return new Result<CheckHomeInfoResultInfo>().ok(checkHomeInfoResultInfo);
@ -399,10 +401,10 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
// 校验楼宇
IcBuildingEntity icBuildingEntity = icBuildingDao.getBuildingInfoByName(formDTO);
if(icBuildingEntity != null && StringUtils.isNotBlank(icBuildingEntity.getId())){
if (icBuildingEntity != null && StringUtils.isNotBlank(icBuildingEntity.getId())) {
formDTO.setBuildId(icBuildingEntity.getId());
checkHomeInfoResultInfo.setBuildId(icBuildingEntity.getId());
}else{
} else {
checkHomeInfoResultInfo.setCode("1");
checkHomeInfoResultInfo.setMsg("楼宇名称未匹配到数据");
return new Result<CheckHomeInfoResultInfo>().ok(checkHomeInfoResultInfo);
@ -410,10 +412,10 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
// 校验单元
IcBuildingUnitEntity icBuildingUnitEntity = buildingUnitDao.getbuildingUnitInfoByName(formDTO);
if(icBuildingUnitEntity != null && StringUtils.isNotBlank(icBuildingUnitEntity.getId())){
if (icBuildingUnitEntity != null && StringUtils.isNotBlank(icBuildingUnitEntity.getId())) {
formDTO.setUnitId(icBuildingUnitEntity.getId());
checkHomeInfoResultInfo.setUnitId(icBuildingUnitEntity.getId());
}else{
} else {
checkHomeInfoResultInfo.setCode("1");
checkHomeInfoResultInfo.setMsg("单元名称未匹配到数据");
return new Result<CheckHomeInfoResultInfo>().ok(checkHomeInfoResultInfo);
@ -422,11 +424,11 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
// 校验房屋
IcHouseEntity icHouseEntity = baseDao.getHouseInfoByName(formDTO);
checkHomeInfoResultInfo.setCode("0");
if(icHouseEntity != null && StringUtils.isNotBlank(icHouseEntity.getId())){
if (icHouseEntity != null && StringUtils.isNotBlank(icHouseEntity.getId())) {
checkHomeInfoResultInfo.setHomeId(icHouseEntity.getId());
checkHomeInfoResultInfo.setMsg("该房屋为已存在房屋");
checkHomeInfoResultInfo.setIsAdd("0");
}else{
} else {
checkHomeInfoResultInfo.setMsg("该房屋暂不存在");
checkHomeInfoResultInfo.setIsAdd("1");
}
@ -436,63 +438,88 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
@Override
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();
Map<String,String> type = new HashMap<>();
Map<String, String> type = new HashMap<>();
resultDTO.setTotal(0);
if (dto.getOrgType().equals("community") || dto.getOrgType().equals("street") ||dto.getOrgType().equals("district") ||dto.getOrgType().equals("city")){
if (dto.getOrgType().equals("community") || dto.getOrgType().equals("street") || dto.getOrgType().equals("district") || dto.getOrgType().equals("city")) {
dto.setOrgType("agency");
}
List<HouseCountPictureListResultDTO> list = baseDao.getHousePurposeCount(dto.getOrgId(),dto.getOrgType(),dto.getTimeStart(),dto.getTimeEnd());
List<HouseCountPictureListResultDTO> list = baseDao.getHousePurposeCount(dto.getOrgId(), dto.getOrgType(), dto.getTimeStart(), dto.getTimeEnd());
list.forEach(
result->{
resultDTO.setTotal(resultDTO.getTotal()+result.getCount());
type.put(result.getType(),result.getType());
result -> {
resultDTO.setTotal(resultDTO.getTotal() + result.getCount());
type.put(result.getType(), result.getType());
}
);
HouseCountPictureListResultDTO houseCountPictureListResultDTO = new HouseCountPictureListResultDTO();
if (type.get("1") == null){
if (type.get("1") == null) {
houseCountPictureListResultDTO = new HouseCountPictureListResultDTO();
houseCountPictureListResultDTO.setType("1");
houseCountPictureListResultDTO.setCount(0);
list.add(houseCountPictureListResultDTO);
}
if (type.get("2") == null){
if (type.get("2") == null) {
houseCountPictureListResultDTO = new HouseCountPictureListResultDTO();
houseCountPictureListResultDTO.setType("2");
houseCountPictureListResultDTO.setCount(0);
list.add(houseCountPictureListResultDTO);
}
if (type.get("3") == null){
if (type.get("3") == null) {
houseCountPictureListResultDTO = new HouseCountPictureListResultDTO();
houseCountPictureListResultDTO.setType("3");
houseCountPictureListResultDTO.setCount(0);
list.add(houseCountPictureListResultDTO);
}
if (type.get("4") == null){
if (type.get("4") == null) {
houseCountPictureListResultDTO = new HouseCountPictureListResultDTO();
houseCountPictureListResultDTO.setType("4");
houseCountPictureListResultDTO.setCount(0);
list.add(houseCountPictureListResultDTO);
}
if (type.get("5") == null){
if (type.get("5") == null) {
houseCountPictureListResultDTO = new HouseCountPictureListResultDTO();
houseCountPictureListResultDTO.setType("5");
houseCountPictureListResultDTO.setCount(0);
list.add(houseCountPictureListResultDTO);
}
if (type.get("6") == null){
if (type.get("6") == null) {
houseCountPictureListResultDTO = new HouseCountPictureListResultDTO();
houseCountPictureListResultDTO.setType("6");
houseCountPictureListResultDTO.setCount(0);
list.add(houseCountPictureListResultDTO);
}
if (type.get("7") == null){
if (type.get("7") == null) {
houseCountPictureListResultDTO = new HouseCountPictureListResultDTO();
houseCountPictureListResultDTO.setType("7");
houseCountPictureListResultDTO.setCount(0);
@ -504,54 +531,65 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
@Override
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();
Map<String,String> type = new HashMap<>();
Map<String, String> type = new HashMap<>();
resultDTO.setTotal(0);
if (dto.getOrgType().equals("community") || dto.getOrgType().equals("street") ||dto.getOrgType().equals("district") ||dto.getOrgType().equals("city")){
if (dto.getOrgType().equals("community") || dto.getOrgType().equals("street") || dto.getOrgType().equals("district") || dto.getOrgType().equals("city")) {
dto.setOrgType("agency");
}
List<HouseCountPictureListResultDTO> list =baseDao.getHouseStatusCount(dto.getOrgId(),dto.getOrgType(),dto.getTimeStart(),dto.getTimeEnd());
List<HouseCountPictureListResultDTO> list = baseDao.getHouseStatusCount(dto.getOrgId(), dto.getOrgType(), dto.getTimeStart(), dto.getTimeEnd());
list.forEach(
result->{
type.put(result.getType(),result.getType());
resultDTO.setTotal(resultDTO.getTotal()+result.getCount());
result -> {
type.put(result.getType(), result.getType());
resultDTO.setTotal(resultDTO.getTotal() + result.getCount());
}
);
HouseCountPictureListResultDTO houseCountPictureListResultDTO = new HouseCountPictureListResultDTO();
if (type.get("1") == null){
if (type.get("1") == null) {
houseCountPictureListResultDTO = new HouseCountPictureListResultDTO();
houseCountPictureListResultDTO.setType("1");
houseCountPictureListResultDTO.setCount(0);
list.add(houseCountPictureListResultDTO);
}
if (type.get("2") == null){
if (type.get("2") == null) {
houseCountPictureListResultDTO = new HouseCountPictureListResultDTO();
houseCountPictureListResultDTO.setType("2");
houseCountPictureListResultDTO.setCount(0);
list.add(houseCountPictureListResultDTO);
}
if (type.get("3") == null){
if (type.get("3") == null) {
houseCountPictureListResultDTO = new HouseCountPictureListResultDTO();
houseCountPictureListResultDTO.setType("3");
houseCountPictureListResultDTO.setCount(0);
list.add(houseCountPictureListResultDTO);
}
if (type.get("0") == null){
if (type.get("0") == null) {
houseCountPictureListResultDTO = new HouseCountPictureListResultDTO();
houseCountPictureListResultDTO.setType("0");
houseCountPictureListResultDTO.setCount(0);
list.add(houseCountPictureListResultDTO);
}
resultDTO.setList(list);
return resultDTO;
}
@ -560,22 +598,22 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
// 列表/导出查询
PageHelper.startPage(dto.getPageNo(), dto.getPageSize());
if (dto.getOrgType().equals("community") || dto.getOrgType().equals("street") ||dto.getOrgType().equals("district") ||dto.getOrgType().equals("city")){
if (dto.getOrgType().equals("community") || dto.getOrgType().equals("street") || dto.getOrgType().equals("district") || dto.getOrgType().equals("city")) {
dto.setOrgType("agency");
}
List<HousePictureListResultDTO> list = baseDao.getHousePictureList(dto.getOrgId(),dto.getOrgType(),dto.getTimeStart(),dto.getTimeEnd(),dto.getPurpose(),dto.getRentFlag());
List<HousePictureListResultDTO> list = baseDao.getHousePictureList(dto.getOrgId(), dto.getOrgType(), dto.getTimeStart(), dto.getTimeEnd(), dto.getPurpose(), dto.getRentFlag());
list.forEach(entity->{
list.forEach(entity -> {
String[] agencyIds = entity.getOrgIdPath().split(":");
LambdaQueryWrapper<CustomerAgencyEntity> queryWrapperAgency = new LambdaQueryWrapper<CustomerAgencyEntity>().in(CustomerAgencyEntity::getId,agencyIds);
LambdaQueryWrapper<CustomerAgencyEntity> queryWrapperAgency = new LambdaQueryWrapper<CustomerAgencyEntity>().in(CustomerAgencyEntity::getId, agencyIds);
List<CustomerAgencyEntity> customerAgencyEntities = customerAgencyDao.selectList(queryWrapperAgency);
customerAgencyEntities.forEach(agency->{
if (agency.getLevel().equals("district")){
customerAgencyEntities.forEach(agency -> {
if (agency.getLevel().equals("district")) {
entity.setDistrictName(agency.getOrganizationName());
}else if (agency.getLevel().equals("street")){
} else if (agency.getLevel().equals("street")) {
entity.setStreetName(agency.getOrganizationName());
}else if (agency.getLevel().equals("community")){
} else if (agency.getLevel().equals("community")) {
entity.setCommunityName(agency.getOrganizationName());
}
});
@ -583,6 +621,6 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
PageInfo<HousePictureListResultDTO> pageInfo = new PageInfo<>(list);
return new PageData<>(list,pageInfo.getTotal());
return new PageData<>(list, pageInfo.getTotal());
}
}

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

File diff suppressed because it is too large
Loading…
Cancel
Save