Browse Source

【政策】预览接口

dev
wangxianzhang 3 years ago
parent
commit
ea9dfed809
  1. 88
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/form/ResisByPolicyRulesFormDTO.java
  2. 26
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/ResiByPolicyInfoResultDTO.java
  3. 5
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/DataAggregatorOpenFeignClient.java
  4. 30
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/IcUserController.java
  5. 14
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcResiUserDao.java
  6. 13
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/IcNeighborhoodDao.java
  7. 11
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/ResiService.java
  8. 4
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java
  9. 7
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java
  10. 8
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java
  11. 57
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java
  12. 90
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/ResiServiceImpl.java
  13. 45
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/IcResiUserDao.xml
  14. 15
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/IcNeighborhoodDao.xml
  15. 86
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/HeartResisByPolicyRulesFormDTO.java
  16. 62
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResisByPolicyRulesFormDTO.java
  17. 4
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiByPolicyInfoResultDTO.java
  18. 8
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPolicyController.java
  19. 4
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPolicyService.java
  20. 64
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPolicyServiceImpl.java
  21. 2
      epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/V0.0.36__house_add_avgysr.sql

88
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/form/ResisByPolicyRulesFormDTO.java

@ -5,6 +5,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -12,58 +13,63 @@ import java.util.Set;
@NoArgsConstructor
@AllArgsConstructor
public class ResisByPolicyRulesFormDTO {
private String ruleId;
private String orgId;
private String orgType;
private String neighborHoodId;
private String buildingId;
private String unitId;
private String houseId;
private String name;
private String mobile;
private String idCard;
private RuleList ruleList = new RuleList();
private Integer pageNo;
private Integer pageSize;
private Integer pageNo = 1;
private Integer pageSize = 20;
/**
* 规则map
*/
private Map<String, Set<PolicyRule>> rules;
@Data
public static class RuleList {
private String ruleName;
private List<ResiRule> resiRule;
private List<HouseRule> houseRule;
private List<StatRule> statRule;
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class PolicyRule implements Comparator<Integer> {
private String customerId;
/**
* resi:人员信息,house:房屋信息stat:统计信息
*/
private String groupType;
/**
* 与上一条的关系andor
*/
public static class ResiRule {
private String ruleDesc;
private String lastLogicalRel;
/**
* 查询类型等于不等于....;来源于字典表sql_query_type
*/
private String itemGroupId;
private String itemId;
private String queryType;
/**
* 表名人员信息有值
*/
private String colTable;
/**
* 人员信息存储组件对应的列名房屋信息存储ic_house表的列名统计信息应该是定义到字典表这里存储字典key就行吧
*/
private String colKey;
/**
* 参数值
*/
private String colVal;
}
/**
* 排序字段;同一group_type升序
*/
private Integer sort;
@Override
public int compare(Integer o1, Integer o2) {
return o1.compareTo(o2);
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class HouseRule {
private String colTable;
private String colKey;
private String colVal;
private String ruleDesc;
private String lastLogicalRel;
private String queryType;
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class StatRule {
private String colKey;
private String colVal;
private String lastLogicalRel;
private String ruleDesc;
private String queryType;
private String colTable;
}
}

26
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/ResiByPolicyInfoResultDTO.java

@ -0,0 +1,26 @@
package com.epmet.dataaggre.dto.epmetuser.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResiByPolicyInfoResultDTO {
private String icResiUserId;
private String name;
private String mobile;
private String idCard;
/**
* 小区全名包含小区前面的属性比如网格等
*/
private String gridId;
private String neighborhoodId;
private String neighborHoodName;
private Integer age;
private Date birthday;
}

5
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/DataAggregatorOpenFeignClient.java

@ -4,12 +4,15 @@ package com.epmet.dataaggre.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dataaggre.dto.epmetuser.form.ResisByPolicyRulesFormDTO;
import com.epmet.dataaggre.dto.epmetuser.result.ResiByPolicyInfoResultDTO;
import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO;
import com.epmet.dataaggre.feign.impl.DataAggregatorOpenFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@FeignClient(name = ServiceConstant.DATA_AGGREGATOR_SERVER, fallbackFactory = DataAggregatorOpenFeignClientFallbackFactory.class)
// @FeignClient(name = ServiceConstant.DATA_AGGREGATOR_SERVER, fallbackFactory= DataAggregatorOpenFeignClientFallbackFactory.class,url = "localhost:8114")
public interface DataAggregatorOpenFeignClient {
@ -28,5 +31,5 @@ public interface DataAggregatorOpenFeignClient {
* @return
*/
@PostMapping("data/aggregator/icuser/listByPolicyRules")
Result listByPolicyRules(@RequestBody ResisByPolicyRulesFormDTO input);
Result<List<ResiByPolicyInfoResultDTO>> listByPolicyRules(@RequestBody ResisByPolicyRulesFormDTO input);
}

30
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/IcUserController.java

@ -8,6 +8,7 @@ import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dataaggre.dto.epmetuser.form.IcUserCategoryFormDTO;
import com.epmet.dataaggre.dto.epmetuser.form.ResisByPolicyRulesFormDTO;
import com.epmet.dataaggre.dto.epmetuser.result.IcUserCategoryResultDTO;
import com.epmet.dataaggre.dto.epmetuser.result.ResiByPolicyInfoResultDTO;
import com.epmet.dataaggre.service.ResiService;
import com.epmet.dataaggre.service.epmetuser.EpmetUserService;
import org.apache.commons.collections4.CollectionUtils;
@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -51,23 +53,33 @@ public class IcUserController {
* @return
*/
@PostMapping("listByPolicyRules")
public Result listByPolicyRules(@RequestBody ResisByPolicyRulesFormDTO input) {
public Result<List<ResiByPolicyInfoResultDTO>> listByPolicyRules(@RequestBody ResisByPolicyRulesFormDTO input) {
Integer pageNo = input.getPageNo();
Integer pageSize = input.getPageSize();
Map<String, Set<ResisByPolicyRulesFormDTO.PolicyRule>> rules = input.getRules();
Set<ResisByPolicyRulesFormDTO.PolicyRule> resiRule = rules.get("resi");
Set<ResisByPolicyRulesFormDTO.PolicyRule> houseRule = rules.get("house");
Set<ResisByPolicyRulesFormDTO.PolicyRule> houseStat = rules.get("stat");
List<ResisByPolicyRulesFormDTO.ResiRule> resiRule = input.getRuleList().getResiRule();
List<ResisByPolicyRulesFormDTO.HouseRule> houseRule = input.getRuleList().getHouseRule();
List<ResisByPolicyRulesFormDTO.StatRule> statRule = input.getRuleList().getStatRule();
String orgId = input.getOrgId();
String orgType = input.getOrgType();
String neighborHoodId = input.getNeighborHoodId();
String buildingId = input.getBuildingId();
String unitId = input.getUnitId();
String houseId = input.getHouseId();
String idCard = input.getIdCard();
String name = input.getName();
// 全都为空,则返回空
if (CollectionUtils.isEmpty(resiRule)
&& CollectionUtils.isEmpty(houseRule)
&& CollectionUtils.isEmpty(houseStat)) {
return new Result();
&& CollectionUtils.isEmpty(statRule)) {
return new Result().ok(new ArrayList<>());
}
icResiService.listByPolicyRules(pageNo, pageSize, resiRule, houseRule, houseStat);
return new Result();
List<ResiByPolicyInfoResultDTO> resis = icResiService.listByPolicyRules(orgId, orgType, neighborHoodId, buildingId, unitId,
houseId, idCard, name, pageNo, pageSize, resiRule, houseRule, statRule);
return new Result<List<ResiByPolicyInfoResultDTO>>().ok(resis);
}
}

14
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcResiUserDao.java

@ -20,7 +20,7 @@ package com.epmet.dataaggre.dao.epmetuser;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.dto.epmetuser.form.ResisByPolicyRulesFormDTO;
import com.epmet.dataaggre.dto.epmetuser.result.IcResiInfoResultDTO;
import com.epmet.dataaggre.dto.epmetuser.result.ResiInfoResultDTO;
import com.epmet.dataaggre.dto.epmetuser.result.ResiByPolicyInfoResultDTO;
import com.epmet.dataaggre.dto.govproject.result.ProjectAnalysisResultDTO;
import com.epmet.dataaggre.entity.epmetuser.IcResiUserEntity;
import com.epmet.dto.IcResiUserDTO;
@ -68,7 +68,15 @@ public interface IcResiUserDao extends BaseDao<IcResiUserEntity> {
* @param houseIds
* @return
*/
List<ResiInfoResultDTO> listByPolicyRules(@Param("customerId") String customerId,
@Param("resiRules") Set<ResisByPolicyRulesFormDTO.PolicyRule> resiRules,
List<ResiByPolicyInfoResultDTO> listByPolicyRules(@Param("customerId") String customerId,
@Param("orgId") String orgId,
@Param("orgType") String orgType,
@Param("neighborHoodId") String neighborHoodId,
@Param("buildingId") String buildingId,
@Param("unitId") String unitId,
@Param("houseId") String houseId,
@Param("idCard") String idCard,
@Param("name") String name,
@Param("resiRules") List<ResisByPolicyRulesFormDTO.ResiRule> resiRule,
@Param("houseIds") List<String> houseIds);
}

13
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/IcNeighborhoodDao.java

@ -0,0 +1,13 @@
package com.epmet.dataaggre.dao.govorg;
import com.epmet.commons.tools.redis.common.bean.BuildingInfoCache;
import com.epmet.dto.IcNeighborHoodDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface IcNeighborhoodDao {
List<IcNeighborHoodDTO> neighborhoodsByIds(@Param("neighborhoodIds") List<String> neighborhoodIds);
}

11
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/ResiService.java

@ -1,7 +1,7 @@
package com.epmet.dataaggre.service;
import com.epmet.dataaggre.dto.epmetuser.form.ResisByPolicyRulesFormDTO;
import com.epmet.dataaggre.dto.epmetuser.result.ResiInfoResultDTO;
import com.epmet.dataaggre.dto.epmetuser.result.ResiByPolicyInfoResultDTO;
import java.util.List;
import java.util.Set;
@ -18,7 +18,10 @@ public interface ResiService {
* @param resiRule
* @param houseRule
*/
List<ResiInfoResultDTO> listByPolicyRules(Integer pageNo, Integer pageSize, Set<ResisByPolicyRulesFormDTO.PolicyRule> resiRule,
Set<ResisByPolicyRulesFormDTO.PolicyRule> houseRule,
Set<ResisByPolicyRulesFormDTO.PolicyRule> houseStat);
List<ResiByPolicyInfoResultDTO> listByPolicyRules(
String orgId, String orgType, String neighborHoodId, String buildingId, String unitId,
String houseId, String idCard, String name, Integer pageNo, Integer pageSize,
List<ResisByPolicyRulesFormDTO.ResiRule> resiRule,
List<ResisByPolicyRulesFormDTO.HouseRule> houseRule,
List<ResisByPolicyRulesFormDTO.StatRule> statRule);
}

4
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java

@ -201,5 +201,7 @@ public interface EpmetUserService {
*/
List<StaffSelectResDTO> staffSelectList(List<String> staffIds);
List<ResiInfoResultDTO> listByPolicyRules(String customerId, Set<ResisByPolicyRulesFormDTO.PolicyRule> resiRule, List<String> houseIds);
List<ResiByPolicyInfoResultDTO> listByPolicyRules(String customerId, String orgId, String orgType, String neighborHoodId, String buildingId, String unitId,
String houseId, String idCard, String name, Integer pageNo, Integer pageSize,
List<ResisByPolicyRulesFormDTO.ResiRule> resiRule, List<String> houseIds);
}

7
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java

@ -845,7 +845,10 @@ public class EpmetUserServiceImpl implements EpmetUserService {
}
@Override
public List<ResiInfoResultDTO> listByPolicyRules(String customerId, Set<ResisByPolicyRulesFormDTO.PolicyRule> resiRule, List<String> houseIds) {
return icResiUserDao.listByPolicyRules(customerId, resiRule, houseIds);
public List<ResiByPolicyInfoResultDTO> listByPolicyRules(String customerId, String orgId, String orgType, String neighborHoodId, String buildingId, String unitId,
String houseId, String idCard, String name, Integer pageNo, Integer pageSize,
List<ResisByPolicyRulesFormDTO.ResiRule> resiRule, List<String> houseIds) {
return icResiUserDao.listByPolicyRules(customerId, orgId, orgType, neighborHoodId, buildingId, unitId, houseId, idCard, name, resiRule, houseIds);
}
}

8
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java

@ -12,6 +12,8 @@ import com.epmet.dataaggre.dto.govorg.result.*;
import com.epmet.dataaggre.dto.resigroup.result.OrgInfoCommonDTO;
import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity;
import com.epmet.dataaggre.entity.govorg.IcHouseEntity;
import com.epmet.dto.IcNeighborHoodDTO;
import com.epmet.dto.result.NeighborHoodListResultDTO;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@ -216,5 +218,9 @@ public interface GovOrgService {
*/
CustomerAgencyEntity getRootAgencyByCustomerId(String customerId);
List<IcHouseEntity> listHousesByRules(Set<ResisByPolicyRulesFormDTO.PolicyRule> houseRule, Set<ResisByPolicyRulesFormDTO.PolicyRule> houseStat, Integer pageNo, Integer pageSize);
List<IcHouseEntity> listHousesByRules(String customerId, String orgId, String orgType, String neighborHoodId, String buildingId,
String unitId, String houseId, List<ResisByPolicyRulesFormDTO.HouseRule> houseRule,
List<ResisByPolicyRulesFormDTO.StatRule> statRule, Integer pageNo, Integer pageSize);
List<IcNeighborHoodDTO> neighborhoodsByIds(List<String> neighborhoodIds);
}

57
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java

@ -50,6 +50,7 @@ import com.epmet.dataaggre.service.epmetuser.EpmetUserService;
import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService;
import com.epmet.dataaggre.service.govorg.GovOrgService;
import com.epmet.dataaggre.service.opercrm.CustomerRelation;
import com.epmet.dto.IcNeighborHoodDTO;
import com.epmet.dto.result.UploadImgResultDTO;
import com.epmet.feign.OssFeignClient;
import com.github.pagehelper.PageHelper;
@ -114,6 +115,8 @@ public class GovOrgServiceImpl implements GovOrgService {
private ExecutorService executorService;
@Autowired
private IcHouseDao houseDao;
@Autowired
private IcNeighborhoodDao neighborhoodDao;
/**
* @param staffId
@ -1087,26 +1090,67 @@ public class GovOrgServiceImpl implements GovOrgService {
return customerAgencyDao.selectOne(query);
}
public String getOrgIdPath(String orgId, String orgType) {
if ("agency".equals(orgType)) {
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(orgId);
if (agencyInfo != null) {
String pids = agencyInfo.getPids();
String id = agencyInfo.getId();
if (StringUtils.isBlank(pids)) {
return id;
} else {
return pids.concat(":").concat(id);
}
}
} else {
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(orgId);
return gridInfo.getPids().concat(":").concat(gridInfo.getId());
}
return null;
}
@Override
public List<IcHouseEntity> listHousesByRules(Set<ResisByPolicyRulesFormDTO.PolicyRule> houseRule, Set<ResisByPolicyRulesFormDTO.PolicyRule> statRule, Integer pageNo, Integer pageSize) {
public List<IcHouseEntity> listHousesByRules(String customerId, String orgId, String orgType, String neighborHoodId, String buildingId,
String unitId, String houseId, List<ResisByPolicyRulesFormDTO.HouseRule> houseRule,
List<ResisByPolicyRulesFormDTO.StatRule> statRule, Integer pageNo, Integer pageSize) {
if (CollectionUtils.isEmpty(houseRule) && CollectionUtils.isEmpty(statRule)) {
return new ArrayList<>();
}
String customerId = EpmetRequestHolder.getLoginUserCustomerId();
QueryWrapper<IcHouseEntity> query = new QueryWrapper<>();
if (StringUtils.isNotBlank(orgId) && StringUtils.isNotBlank(orgType)) {
String orgIdPath = getOrgIdPath(orgId, orgType);
query.likeRight(StringUtils.isNotBlank(orgIdPath), "ORG_ID_PATH", orgIdPath);
}
if (StringUtils.isNotBlank(customerId)) {
query.eq("CUSTOMER_ID", customerId);
}
if (StringUtils.isNotBlank(neighborHoodId)) {
query.eq("NEIGHBOR_HOOD_ID", neighborHoodId);
}
if (StringUtils.isNotBlank(buildingId)) {
query.eq("BUILDING_ID", buildingId);
}
if (StringUtils.isNotBlank(unitId)) {
query.eq("BUILDING_UNIT_ID", unitId);
}
if (StringUtils.isNotBlank(houseId)) {
query.eq("ID", houseId);
}
// 房屋属性
if (CollectionUtils.isNotEmpty(houseRule)) {
for (ResisByPolicyRulesFormDTO.PolicyRule rule : houseRule) {
for (ResisByPolicyRulesFormDTO.HouseRule rule : houseRule) {
query.eq(rule.getColKey(), rule.getColVal());
}
}
// 房屋的统计属性
if (CollectionUtils.isNotEmpty(statRule)) {
for (ResisByPolicyRulesFormDTO.PolicyRule rule : statRule) {
for (ResisByPolicyRulesFormDTO.StatRule rule : statRule) {
query.eq(rule.getColKey(), rule.getColVal());
}
}
@ -1114,4 +1158,9 @@ public class GovOrgServiceImpl implements GovOrgService {
PageHelper.startPage(pageNo, pageSize);
return houseDao.selectList(query);
}
@Override
public List<IcNeighborHoodDTO> neighborhoodsByIds(List<String> neighborhoodIds) {
return neighborhoodDao.neighborhoodsByIds(neighborhoodIds);
}
}

90
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/ResiServiceImpl.java

@ -1,19 +1,21 @@
package com.epmet.dataaggre.service.impl;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.utils.EpmetRequestHolder;
import com.epmet.dataaggre.dto.epmetuser.form.ResisByPolicyRulesFormDTO;
import com.epmet.dataaggre.dto.epmetuser.result.ResiInfoResultDTO;
import com.epmet.dataaggre.dto.epmetuser.result.ResiByPolicyInfoResultDTO;
import com.epmet.dataaggre.dto.govorg.result.GridsInfoListResultDTO;
import com.epmet.dataaggre.entity.govorg.IcHouseEntity;
import com.epmet.dataaggre.service.ResiService;
import com.epmet.dataaggre.service.epmetuser.EpmetUserService;
import com.epmet.dataaggre.service.govorg.GovOrgService;
import com.epmet.dto.IcNeighborHoodDTO;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.time.*;
import java.util.*;
import java.util.stream.Collectors;
@Service
@ -26,38 +28,45 @@ public class ResiServiceImpl implements ResiService {
private GovOrgService govOrgService;
@Override
public List<ResiInfoResultDTO> listByPolicyRules(Integer pageNo, Integer pageSize,
Set<ResisByPolicyRulesFormDTO.PolicyRule> resiRule,
Set<ResisByPolicyRulesFormDTO.PolicyRule> houseRule,
Set<ResisByPolicyRulesFormDTO.PolicyRule> houseStat) {
public List<ResiByPolicyInfoResultDTO> listByPolicyRules(String orgId, String orgType, String neighborHoodId, String buildingId, String unitId,
String houseId, String idCard, String name, Integer pageNo, Integer pageSize,
List<ResisByPolicyRulesFormDTO.ResiRule> resiRule,
List<ResisByPolicyRulesFormDTO.HouseRule> houseRule,
List<ResisByPolicyRulesFormDTO.StatRule> statRule) {
String customerId = EpmetRequestHolder.getLoginUserCustomerId();
// 结果集
List<ResiInfoResultDTO> resultResis = new ArrayList<>();
List<ResiByPolicyInfoResultDTO> resultResis = new ArrayList<>();
// 1.用户没配置house和stat规则,直接按照居民规则查询
if (CollectionUtils.isEmpty(houseRule) && CollectionUtils.isEmpty(statRule)) {
return epmetUserService.listByPolicyRules(customerId, orgId, orgType, neighborHoodId, buildingId, unitId,
houseId, idCard, name, pageNo, pageSize, resiRule, null);
}
// 2.用户至少配置了house和stat规则的一个,那么就先查询房屋出来,然后根据房屋去找居民
int housePageNo = 0;
do {
// houseIds 为null,说明用户没有指定house和统计的规则,则不应该使用这两项来查询,sql中不应该有这方面的条件
List<String> houseIds = null;
// 拿到房屋id列表,去查询居民列表
if (CollectionUtils.isNotEmpty(houseRule) || CollectionUtils.isNotEmpty(houseStat)) {
List<IcHouseEntity> houseEntities = govOrgService.listHousesByRules(houseRule, houseStat, housePageNo, 50);
houseIds = houseEntities.stream().map(icHouseEntity -> icHouseEntity.getId()).collect(Collectors.toList());
}
List<IcHouseEntity> houseEntities = govOrgService.listHousesByRules(customerId, orgId, orgType, neighborHoodId, buildingId, unitId,
houseId, houseRule, statRule, housePageNo, 50);
List<String> houseIds = houseEntities.stream().map(icHouseEntity -> icHouseEntity.getId()).collect(Collectors.toList());
if (houseIds != null && houseIds.size() == 0) {
if (houseIds.size() == 0) {
// 用户使用了房屋和统计相关的条件,但是没查到房屋,我看就没有走下去了的必要了吧..
break;
}
// 查询居民
List<ResiInfoResultDTO> resis = epmetUserService.listByPolicyRules(customerId, resiRule, houseIds);
List<ResiByPolicyInfoResultDTO> resis = epmetUserService.listByPolicyRules(
customerId, orgId, orgType, neighborHoodId, buildingId, unitId,
houseId, idCard, name, pageNo, pageSize, resiRule, houseIds);
resultResis.addAll(resis);
// 满了20个,或者查不到居民和房屋了(数据空了),则跳出
// 没有用house的条件,没有循环的必要,查一次居民信息即可,跳出
if (resultResis.size() >= pageSize || houseIds == null ) {
if (resultResis.size() >= pageSize) {
break;
}
@ -66,9 +75,50 @@ public class ResiServiceImpl implements ResiService {
// 够了20个,那就截取前20个,否则直接返回
if (resultResis.size() > 20) {
return resultResis.subList(0, 20);
resultResis = resultResis.subList(0, 20);
}
// 补充额外信息
fillResisExtraInfoForPolicy(resultResis);
return resultResis;
}
/**
* 补充额外信息
* @param resultResis
*/
private void fillResisExtraInfoForPolicy(List<ResiByPolicyInfoResultDTO> resultResis) {
List<String> gridIds = new ArrayList<>();
List<String> neighborhoodIds = new ArrayList<>();
resultResis.stream().forEach((r) -> {
gridIds.add(r.getGridId());
neighborhoodIds.add(r.getNeighborhoodId());
});
// 统一收集网格和小区信息
Map<String, String> gridIdAndName = govOrgService.gridListByIds(gridIds)
.stream()
.collect(Collectors.toMap(GridsInfoListResultDTO::getGridId, GridsInfoListResultDTO::getName));
Map<String, String> neighborhoodIdAndName = govOrgService.neighborhoodsByIds(neighborhoodIds)
.stream().collect(Collectors.toMap(IcNeighborHoodDTO::getId, IcNeighborHoodDTO::getNeighborHoodName));
resultResis.stream().forEach((r) -> {
// 小区名称
r.setNeighborHoodName(gridIdAndName.get(r.getGridId()).concat("-").concat(neighborhoodIdAndName.get(r.getNeighborhoodId())));
// 出生日期 & 年龄
if (r.getBirthday() != null) {
Integer age = null;
try {
LocalDate birthdayLocalDate = LocalDateTime.ofInstant(r.getBirthday().toInstant(), ZoneId.systemDefault()).toLocalDate();
age = Period.between(birthdayLocalDate, LocalDate.now()).getYears();
} catch (DateTimeException e) {
throw new EpmetException("居民生日计算错误");
}
r.setAge(age);
}
});
}
}

45
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/IcResiUserDao.xml

@ -70,20 +70,59 @@
</select>
<!--政策查找-->
<select id="listByPolicyRules" resultType="com.epmet.dataaggre.dto.epmetuser.result.ResiInfoResultDTO">
select `NAME`, `MOBILE`, `ID_CARD`, `VILLAGE_ID`, BIRTHDAY
<select id="listByPolicyRules" resultType="com.epmet.dataaggre.dto.epmetuser.result.ResiByPolicyInfoResultDTO">
select `ID` as icResiUserId,
`GRID_ID`,
`NAME`,
`MOBILE`,
`ID_CARD`,
`VILLAGE_ID` as neighborhoodId,
`BIRTHDAY`
from ic_resi_user
<foreach collection="resiRules" item="rule">
<if test="rule.colTable != 'ic_resi_user'"> inner join #{rule.colTable}</if>
</foreach>
<where>
ic_resi_user.CUSTOMER_ID=#{customerId}
<!--组织过滤-->
<if test="orgId != null and orgId != '' and orgType != null and orgType != ''">
<choose>
<when test="orgType == 'agency'">
and ic_resi_user.AGENCY_ID=#{orgId}
</when>
<otherwise>
and ic_resi_user.GRID_ID=#{orgId}
</otherwise>
</choose>
</if>
<!-- 小区等条件 -->
<if test="neighborHoodId != null">
and ic_resi_user.VILLAGE_ID=#{neighborHoodId}
</if>
<if test="buildingId != null">
and ic_resi_user.BUILD_ID=#{buildingId}
</if>
<if test="unitId != null">
and ic_resi_user.UNIT_ID=#{unitId}
</if>
<if test="houseId != null">
and ic_resi_user.HOME_ID=#{houseId}
</if>
<if test="idCard != null">
and ic_resi_user.ID_CARD like CONCAT('%'#{idCard}, '%')
</if>
<if test="name != null">
and ic_resi_user.NAME like CONCAT('%'#{name}, '%')
</if>
<!-- resi规则列表 -->
<if test="resiRules != null and resiRules.size() > 0">
<foreach collection="resiRules" item="rule">
${rule.lastLogicalRel} ${rule.colTable}.${rule.colKey} ${rule.queryType} #{rule.colVal}
</foreach>
</if>
<!-- houseIds为null说明用户没配置这方面条件,不应参与查询 ,不为null则需要参与查询 -->
<!-- 房屋id列表 -->
<if test="houseIds != null and houseIds.size() > 0">
and HOME_ID in
<foreach collection="houseIds" item="houseId" open="(" close=")" separator=",">

15
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/IcNeighborhoodDao.xml

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dataaggre.dao.govorg.IcNeighborhoodDao">
<!--id批量查询小区列表-->
<select id="neighborhoodsByIds" resultType="com.epmet.dto.IcNeighborHoodDTO">
select ID, NEIGHBOR_HOOD_NAME
from ic_neighbor_hood
where ID in
<foreach collection="neighborhoodIds" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</select>
</mapper>

86
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/HeartResisByPolicyRulesFormDTO.java

@ -5,6 +5,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -12,58 +13,57 @@ import java.util.Set;
@NoArgsConstructor
@AllArgsConstructor
public class HeartResisByPolicyRulesFormDTO {
private Integer pageNo = 1;
private Integer pageSize = 20;
/**
* 规则map
*/
private Set<PolicyRule> rules;
private String ruleId;
private String orgId;
private String orgType;
private String neighborHoodId;
private String buildingId;
private String unitId;
private String houseId;
private String name;
private String mobile;
private String idCard;
private RuleList ruleList;
private Integer pageNo;
private Integer pageSize;
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class PolicyRule implements Comparator<Integer> {
private String customerId;
/**
* resi:人员信息,house:房屋信息stat:统计信息
*/
private String groupType;
public static class RuleList {
private String ruleName;
private List<ResisByPolicyRulesFormDTO.ResiRule> resiRule;
private List<ResisByPolicyRulesFormDTO.HouseRule> houseRule;
private List<ResisByPolicyRulesFormDTO.StatRule> statRule;
}
/**
* 与上一条的关系andor
*/
@Data
public static class ResiRule {
private String ruleDesc;
private String lastLogicalRel;
/**
* 查询类型等于不等于....;来源于字典表sql_query_type
*/
private String itemGroupId;
private String itemId;
private String queryType;
/**
* 表名人员信息有值
*/
private String colTable;
/**
* 人员信息存储组件对应的列名房屋信息存储ic_house表的列名统计信息应该是定义到字典表这里存储字典key就行吧
*/
private String colKey;
/**
* 参数值
*/
private String colVal;
}
/**
* 排序字段;同一group_type升序
*/
private Integer sort;
@Override
public int compare(Integer o1, Integer o2) {
return o1.compareTo(o2);
@Data
public static class HouseRule {
private String colTable;
private String colKey;
private String colVal;
private String ruleDesc;
private String lastLogicalRel;
private String queryType;
}
@Data
public static class StatRule {
private String colKey;
private String colVal;
private String lastLogicalRel;
private String ruleDesc;
private String queryType;
private String colTable;
}
}

62
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResisByPolicyRulesFormDTO.java

@ -0,0 +1,62 @@
package com.epmet.dto.form.resi;
import lombok.Data;
import java.util.List;
@Data
public class ResisByPolicyRulesFormDTO {
private String ruleId;
private String orgId;
private String orgType;
private String neighborHoodId;
private String buildingId;
private String unitId;
private String houseId;
private String name;
private String mobile;
private String idCard;
private RuleList ruleList;
private Integer pageNo;
private Integer pageSize;
@Data
public static class RuleList {
private String ruleName;
private List<ResiRule> resiRule;
private List<HouseRule> houseRule;
private List<StatRule> statRule;
}
@Data
public static class ResiRule {
private String ruleDesc;
private String lastLogicalRel;
private String itemGroupId;
private String itemId;
private String queryType;
private String colTable;
private String colKey;
private String colVal;
}
@Data
public static class HouseRule {
private String colTable;
private String colKey;
private String colVal;
private String ruleDesc;
private String lastLogicalRel;
private String queryType;
}
@Data
public static class StatRule {
private String colKey;
private String colVal;
private String lastLogicalRel;
private String ruleDesc;
private String queryType;
private String colTable;
}
}

4
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/ResiInfoResultDTO.java → epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiByPolicyInfoResultDTO.java

@ -1,4 +1,4 @@
package com.epmet.dataaggre.dto.epmetuser.result;
package com.epmet.dto.result.resi;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -7,7 +7,7 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResiInfoResultDTO {
public class ResiByPolicyInfoResultDTO {
private String name;
private String mobile;

8
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPolicyController.java

@ -13,6 +13,7 @@ import com.epmet.dto.form.resi.HeartResisByPolicyRulesFormDTO;
import com.epmet.dto.IcPolicyRuleDTO;
import com.epmet.dto.form.policy.IcPolicyFormDTO;
import com.epmet.dto.form.policy.IcPolicyPageFormDTO;
import com.epmet.dto.form.resi.ResisByPolicyRulesFormDTO;
import com.epmet.service.IcPolicyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -46,11 +47,8 @@ public class IcPolicyController {
}
@PostMapping("resiuserlist")
public Result listResiUserByPolicyRules(@RequestBody HeartResisByPolicyRulesFormDTO input) {
//todo
String ruleId = "a";
String customerId = EpmetRequestHolder.getLoginUserCustomerId();
icPolicyService.listResiUserByPolicyRules(customerId, ruleId, 1, 20);
public Result listResiUserByPolicyRules(@RequestBody ResisByPolicyRulesFormDTO input) {
icPolicyService.listResiUserByPolicyRules(input);
return null;
}
/**

4
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPolicyService.java

@ -7,6 +7,8 @@ import com.epmet.dto.IcPolicyItemResultDTO;
import com.epmet.dto.IcPolicyRuleDTO;
import com.epmet.dto.form.policy.IcPolicyFormDTO;
import com.epmet.dto.form.policy.IcPolicyPageFormDTO;
import com.epmet.dto.form.resi.ResisByPolicyRulesFormDTO;
import com.epmet.dto.result.resi.ResiByPolicyInfoResultDTO;
import com.epmet.entity.IcPolicyEntity;
import java.util.List;
@ -45,5 +47,5 @@ public interface IcPolicyService extends BaseService<IcPolicyEntity> {
IcPolicyDTO policyDetail(String customerId,String policyId);
void listResiUserByPolicyRules(String customerId, String ruleId, Integer pageNo, Integer pageSize);
List<ResiByPolicyInfoResultDTO> listResiUserByPolicyRules(ResisByPolicyRulesFormDTO input);
}

64
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPolicyServiceImpl.java

@ -3,6 +3,9 @@ package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.utils.EpmetRequestHolder;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcPolicyDao;
import com.epmet.dao.IcPolicyRuleDetailDao;
@ -17,11 +20,11 @@ import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.*;
import com.epmet.dto.IcPolicyCategoryDTO;
import com.epmet.dto.IcPolicyDTO;
import com.epmet.dto.IcPolicyItemResultDTO;
import com.epmet.dto.result.resi.ResiByPolicyInfoResultDTO;
import com.epmet.entity.IcPolicyEntity;
import com.epmet.entity.IcPolicyRuleDetailEntity;
import com.epmet.dto.IcPolicyRuleDTO;
@ -47,7 +50,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.Map;
/**
* 政策表
@ -56,7 +58,7 @@ import java.util.Map;
* @since v1.0.0 2022-07-18
*/
@Service
public class IcPolicyServiceImpl extends BaseServiceImpl<IcPolicyDao, IcPolicyEntity> implements IcPolicyService {
public class IcPolicyServiceImpl extends BaseServiceImpl<IcPolicyDao, IcPolicyEntity> implements IcPolicyService, ResultDataResolver {
@Autowired
private IcPolicyRuleDetailDao policyRuleDetailDao;
@ -310,19 +312,61 @@ public class IcPolicyServiceImpl extends BaseServiceImpl<IcPolicyDao, IcPolicyEn
}
@Override
public void listResiUserByPolicyRules(String customerId, String ruleId, Integer pageNo, Integer pageSize) {
public List<ResiByPolicyInfoResultDTO> listResiUserByPolicyRules(com.epmet.dto.form.resi.ResisByPolicyRulesFormDTO input) {
String customerId = EpmetRequestHolder.getLoginUserCustomerId();
String ruleId = input.getRuleId();
ResisByPolicyRulesFormDTO aggForm = ConvertUtils.sourceToTarget(input, ResisByPolicyRulesFormDTO.class);
// 穿了规则id,按照规则id来,忽略规则list
if (StringUtils.isNotBlank(ruleId)) {
LambdaQueryWrapper<IcPolicyRuleDetailEntity> query = new LambdaQueryWrapper();
query.eq(IcPolicyRuleDetailEntity::getCustomerId, customerId);
query.eq(IcPolicyRuleDetailEntity::getRuleId, ruleId);
List<IcPolicyRuleDetailEntity> rules = policyRuleDetailDao.selectList(query);
// 将查询出的数据转化成aggre服务能接受的格式
Map<String, Set<ResisByPolicyRulesFormDTO.PolicyRule>> rulesMap = rules.stream().map((r) -> new ResisByPolicyRulesFormDTO.PolicyRule(
customerId, r.getGroupType(), r.getLastLogicalRel(), r.getQueryType(), r.getColTable(), r.getColKey(), r.getColVal(), r.getSort())
).collect(Collectors.groupingBy(ResisByPolicyRulesFormDTO.PolicyRule::getGroupType, Collectors.toSet()));
Map<String, List<IcPolicyRuleDetailEntity>> ruleMap = rules.stream().collect(Collectors.groupingBy(IcPolicyRuleDetailEntity::getGroupType, Collectors.toList()));
// resi规则
List<IcPolicyRuleDetailEntity> originResiRules = ruleMap.get("resi");
if (CollectionUtils.isNotEmpty(originResiRules)) {
List<ResisByPolicyRulesFormDTO.ResiRule> resiRules = originResiRules
.stream()
.map((r) -> new ResisByPolicyRulesFormDTO.ResiRule(r.getRuleDesc(), r.getLastLogicalRel(), r.getItemGroupId(),
r.getItemId(), r.getQueryType(), r.getColTable(), r.getColKey(), r.getColVal()))
.collect(Collectors.toList());
aggForm.getRuleList().setResiRule(resiRules);
}
// house规则
List<IcPolicyRuleDetailEntity> originHouseRules = ruleMap.get("house");
if (CollectionUtils.isNotEmpty(originHouseRules)) {
List<ResisByPolicyRulesFormDTO.HouseRule> houseRules = originHouseRules
.stream()
.map((r) -> new ResisByPolicyRulesFormDTO.HouseRule(r.getColTable(), r.getColKey(), r.getColVal(),
r.getRuleDesc(), r.getLastLogicalRel(), r.getQueryType()))
.collect(Collectors.toList());
aggForm.getRuleList().setHouseRule(houseRules);
}
// stat规则
List<IcPolicyRuleDetailEntity> originStatRules = ruleMap.get("stat");
if (CollectionUtils.isNotEmpty(originStatRules)) {
List<ResisByPolicyRulesFormDTO.StatRule> statRules = originStatRules
.stream()
.map((r) -> new ResisByPolicyRulesFormDTO.StatRule(r.getColKey(), r.getColVal(), r.getLastLogicalRel(),
r.getRuleDesc(), r.getQueryType(), r.getColTable()))
.collect(Collectors.toList());
aggForm.getRuleList().setStatRule(statRules);
}
}
ResisByPolicyRulesFormDTO aggForm = new ResisByPolicyRulesFormDTO(pageNo, pageSize, rulesMap);
Result result = dataAggregatorOpenFeignClient.listByPolicyRules(aggForm);
List<com.epmet.dataaggre.dto.epmetuser.result.ResiByPolicyInfoResultDTO> resis = getResultDataOrReturnNull(dataAggregatorOpenFeignClient.listByPolicyRules(aggForm), ServiceConstant.DATA_AGGREGATOR_SERVER);
return resis.stream()
.map((r) -> new ResiByPolicyInfoResultDTO(r.getName(), r.getMobile(), r.getIdCard(), r.getNeighborhoodFullName(), r.getAge()))
.collect(Collectors.toList());
}
}

2
epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/V0.0.36__house_add_avgysr.sql

@ -1 +1 @@
alter table ic_house add column AVG_RSR decimal(10, 4) comment '人均月收入' after RESI_NUMBER;
alter table ic_house add column AVG_YSR decimal(10,4) comment '家庭平均月收入' default -1 after RESI_NUMBER;
Loading…
Cancel
Save