Browse Source

【政策】查询功能demo

master
wangxianzhang 3 years ago
parent
commit
dfafac2fac
  1. 69
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/form/ResisByPolicyRulesFormDTO.java
  2. 21
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/ResiInfoResultDTO.java
  3. 8
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/DataAggregatorOpenFeignClient.java
  4. 6
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/impl/DataAggregatorOpenFeignClientFallback.java
  5. 31
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/IcUserController.java
  6. 12
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcResiUserDao.java
  7. 24
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/ResiService.java
  8. 3
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java
  9. 5
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java
  10. 5
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java
  11. 35
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java
  12. 74
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/ResiServiceImpl.java
  13. 24
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/IcResiUserDao.xml
  14. 69
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/HeartResisByPolicyRulesFormDTO.java
  15. 5
      epmet-module/epmet-heart/epmet-heart-server/pom.xml
  16. 10
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPolicyController.java
  17. 2
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPolicyService.java
  18. 32
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPolicyServiceImpl.java

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

@ -0,0 +1,69 @@
package com.epmet.dataaggre.dto.epmetuser.form;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Comparator;
import java.util.Map;
import java.util.Set;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResisByPolicyRulesFormDTO {
private Integer pageNo = 1;
private Integer pageSize = 20;
/**
* 规则map
*/
private Map<String, Set<PolicyRule>> rules;
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class PolicyRule implements Comparator<Integer> {
private String customerId;
/**
* resi:人员信息,house:房屋信息stat:统计信息
*/
private String groupType;
/**
* 与上一条的关系andor
*/
private String lastLogicalRel;
/**
* 查询类型等于不等于....;来源于字典表sql_query_type
*/
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);
}
}
}

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

@ -0,0 +1,21 @@
package com.epmet.dataaggre.dto.epmetuser.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResiInfoResultDTO {
private String name;
private String mobile;
private String idCard;
/**
* 小区全名包含小区前面的属性比如网格等
*/
private String neighborhoodFullName;
private Integer age;
}

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

@ -3,6 +3,7 @@ package com.epmet.dataaggre.feign;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dataaggre.dto.epmetuser.form.ResisByPolicyRulesFormDTO;
import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO; import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO;
import com.epmet.dataaggre.feign.impl.DataAggregatorOpenFeignClientFallbackFactory; import com.epmet.dataaggre.feign.impl.DataAggregatorOpenFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
@ -21,4 +22,11 @@ public interface DataAggregatorOpenFeignClient {
@PostMapping(value = "data/aggregator/org/export-send-msg") @PostMapping(value = "data/aggregator/org/export-send-msg")
Result exportGridLiveRes(@RequestBody GridLivelyFormDTO form); Result exportGridLiveRes(@RequestBody GridLivelyFormDTO form);
/**
* 政策人员预览
* @param input
* @return
*/
@PostMapping("data/aggregator/icuser/listByPolicyRules")
Result listByPolicyRules(@RequestBody ResisByPolicyRulesFormDTO input);
} }

6
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/impl/DataAggregatorOpenFeignClientFallback.java

@ -3,6 +3,7 @@ package com.epmet.dataaggre.feign.impl;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dataaggre.dto.epmetuser.form.ResisByPolicyRulesFormDTO;
import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO; import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO;
import com.epmet.dataaggre.feign.DataAggregatorOpenFeignClient; import com.epmet.dataaggre.feign.DataAggregatorOpenFeignClient;
@ -16,4 +17,9 @@ public class DataAggregatorOpenFeignClientFallback implements DataAggregatorOpen
public Result exportGridLiveRes(GridLivelyFormDTO form) { public Result exportGridLiveRes(GridLivelyFormDTO form) {
return ModuleUtils.feignConError(ServiceConstant.DATA_AGGREGATOR_SERVER, "pcworkRecordListExportSendMsg",form); return ModuleUtils.feignConError(ServiceConstant.DATA_AGGREGATOR_SERVER, "pcworkRecordListExportSendMsg",form);
} }
@Override
public Result listByPolicyRules(ResisByPolicyRulesFormDTO input) {
return ModuleUtils.feignConError(ServiceConstant.DATA_AGGREGATOR_SERVER, "listByPolicyRules", input);
}
} }

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

@ -6,8 +6,11 @@ import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dataaggre.dto.epmetuser.form.IcUserCategoryFormDTO; 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.IcUserCategoryResultDTO;
import com.epmet.dataaggre.service.ResiService;
import com.epmet.dataaggre.service.epmetuser.EpmetUserService; import com.epmet.dataaggre.service.epmetuser.EpmetUserService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -15,6 +18,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
@RestController @RestController
@RequestMapping("icuser") @RequestMapping("icuser")
@ -23,6 +28,8 @@ public class IcUserController {
@Autowired @Autowired
private EpmetUserService epmetUserService; private EpmetUserService epmetUserService;
@Autowired
private ResiService icResiService;
/** /**
* 人员类别分析-各类别人数 * 人员类别分析-各类别人数
@ -38,5 +45,29 @@ public class IcUserController {
return new Result<List<IcUserCategoryResultDTO>>().ok(epmetUserService.queryIcUserCategoryData(formDTO)); return new Result<List<IcUserCategoryResultDTO>>().ok(epmetUserService.queryIcUserCategoryData(formDTO));
} }
/**
* 政策人员预览
* @param input
* @return
*/
@PostMapping("listByPolicyRules")
public Result 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");
if (CollectionUtils.isEmpty(resiRule)
&& CollectionUtils.isEmpty(houseRule)
&& CollectionUtils.isEmpty(houseStat)) {
return new Result();
}
icResiService.listByPolicyRules(pageNo, pageSize, resiRule, houseRule, houseStat);
return new Result();
}
} }

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

@ -18,7 +18,9 @@
package com.epmet.dataaggre.dao.epmetuser; package com.epmet.dataaggre.dao.epmetuser;
import com.epmet.commons.mybatis.dao.BaseDao; 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.IcResiInfoResultDTO;
import com.epmet.dataaggre.dto.epmetuser.result.ResiInfoResultDTO;
import com.epmet.dataaggre.dto.govproject.result.ProjectAnalysisResultDTO; import com.epmet.dataaggre.dto.govproject.result.ProjectAnalysisResultDTO;
import com.epmet.dataaggre.entity.epmetuser.IcResiUserEntity; import com.epmet.dataaggre.entity.epmetuser.IcResiUserEntity;
import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.IcResiUserDTO;
@ -26,6 +28,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* 用户基础信息 * 用户基础信息
@ -59,4 +62,13 @@ public interface IcResiUserDao extends BaseDao<IcResiUserEntity> {
@Param("queryPids") String queryPids, @Param("queryPids") String queryPids,
@Param("categoryKey") String categoryKey, @Param("categoryKey") String categoryKey,
@Param("search") String search); @Param("search") String search);
/**
* 政策查找居民
* @param houseIds
* @return
*/
List<ResiInfoResultDTO> listByPolicyRules(@Param("customerId") String customerId,
@Param("resiRules") Set<ResisByPolicyRulesFormDTO.PolicyRule> resiRules,
@Param("houseIds") List<String> houseIds);
} }

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

@ -0,0 +1,24 @@
package com.epmet.dataaggre.service;
import com.epmet.dataaggre.dto.epmetuser.form.ResisByPolicyRulesFormDTO;
import com.epmet.dataaggre.dto.epmetuser.result.ResiInfoResultDTO;
import java.util.List;
import java.util.Set;
/**
* 居民的service
*/
public interface ResiService {
/**
* 政策人员预览
* @param pageNo
* @param pageSize
* @param resiRule
* @param houseRule
*/
List<ResiInfoResultDTO> listByPolicyRules(Integer pageNo, Integer pageSize, Set<ResisByPolicyRulesFormDTO.PolicyRule> resiRule,
Set<ResisByPolicyRulesFormDTO.PolicyRule> houseRule,
Set<ResisByPolicyRulesFormDTO.PolicyRule> houseStat);
}

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

@ -13,6 +13,7 @@ import com.epmet.dto.IcResiUserDTO;
import com.epmet.dto.UserBaseInfoDTO; import com.epmet.dto.UserBaseInfoDTO;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* @Author zxc * @Author zxc
@ -199,4 +200,6 @@ public interface EpmetUserService {
* @return * @return
*/ */
List<StaffSelectResDTO> staffSelectList(List<String> staffIds); List<StaffSelectResDTO> staffSelectList(List<String> staffIds);
List<ResiInfoResultDTO> listByPolicyRules(String customerId, Set<ResisByPolicyRulesFormDTO.PolicyRule> resiRule, List<String> houseIds);
} }

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

@ -844,5 +844,8 @@ public class EpmetUserServiceImpl implements EpmetUserService {
return customerStaffDao.staffSelectList(staffIds); return customerStaffDao.staffSelectList(staffIds);
} }
@Override
public List<ResiInfoResultDTO> listByPolicyRules(String customerId, Set<ResisByPolicyRulesFormDTO.PolicyRule> resiRule, List<String> houseIds) {
return icResiUserDao.listByPolicyRules(customerId, resiRule, houseIds);
}
} }

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

@ -2,6 +2,7 @@ package com.epmet.dataaggre.service.govorg;
import com.epmet.commons.tools.redis.common.bean.BuildingInfoCache; import com.epmet.commons.tools.redis.common.bean.BuildingInfoCache;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dataaggre.dto.epmetuser.form.ResisByPolicyRulesFormDTO;
import com.epmet.dataaggre.dto.epmetuser.result.StaffSelectResDTO; import com.epmet.dataaggre.dto.epmetuser.result.StaffSelectResDTO;
import com.epmet.dataaggre.dto.govorg.CustomerAgencyDTO; import com.epmet.dataaggre.dto.govorg.CustomerAgencyDTO;
import com.epmet.dataaggre.dto.govorg.CustomerDepartmentDTO; import com.epmet.dataaggre.dto.govorg.CustomerDepartmentDTO;
@ -10,9 +11,11 @@ import com.epmet.dataaggre.dto.govorg.form.*;
import com.epmet.dataaggre.dto.govorg.result.*; import com.epmet.dataaggre.dto.govorg.result.*;
import com.epmet.dataaggre.dto.resigroup.result.OrgInfoCommonDTO; import com.epmet.dataaggre.dto.resigroup.result.OrgInfoCommonDTO;
import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity; import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity;
import com.epmet.dataaggre.entity.govorg.IcHouseEntity;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* @Author zxc * @Author zxc
@ -212,4 +215,6 @@ public interface GovOrgService {
* @return * @return
*/ */
CustomerAgencyEntity getRootAgencyByCustomerId(String customerId); CustomerAgencyEntity getRootAgencyByCustomerId(String customerId);
List<IcHouseEntity> listHousesByRules(Set<ResisByPolicyRulesFormDTO.PolicyRule> houseRule, Set<ResisByPolicyRulesFormDTO.PolicyRule> houseStat, Integer pageNo, Integer pageSize);
} }

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

@ -5,6 +5,7 @@ import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dingtalk.api.request.OapiRobotSendRequest; import com.dingtalk.api.request.OapiRobotSendRequest;
import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.Constant; import com.epmet.commons.tools.constant.Constant;
@ -26,10 +27,12 @@ import com.epmet.commons.tools.redis.common.bean.BuildingInfoCache;
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.redis.common.bean.GridInfoCache;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.EpmetRequestHolder;
import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dataaggre.constant.DataSourceConstant; import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.dao.govorg.*; import com.epmet.dataaggre.dao.govorg.*;
import com.epmet.dataaggre.dto.epmetuser.form.ResisByPolicyRulesFormDTO;
import com.epmet.dataaggre.dto.epmetuser.result.ListStaffResultDTO; import com.epmet.dataaggre.dto.epmetuser.result.ListStaffResultDTO;
import com.epmet.dataaggre.dto.epmetuser.result.StaffRoleListResultDTO; import com.epmet.dataaggre.dto.epmetuser.result.StaffRoleListResultDTO;
import com.epmet.dataaggre.dto.epmetuser.result.StaffSelectResDTO; import com.epmet.dataaggre.dto.epmetuser.result.StaffSelectResDTO;
@ -38,6 +41,7 @@ import com.epmet.dataaggre.dto.govorg.form.*;
import com.epmet.dataaggre.dto.govorg.result.*; import com.epmet.dataaggre.dto.govorg.result.*;
import com.epmet.dataaggre.dto.resigroup.result.OrgInfoCommonDTO; import com.epmet.dataaggre.dto.resigroup.result.OrgInfoCommonDTO;
import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity; import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity;
import com.epmet.dataaggre.entity.govorg.IcHouseEntity;
import com.epmet.dataaggre.excel.GridLivelyDetailExcel; import com.epmet.dataaggre.excel.GridLivelyDetailExcel;
import com.epmet.dataaggre.excel.GridLivelyExcel; import com.epmet.dataaggre.excel.GridLivelyExcel;
import com.epmet.dataaggre.service.commonservice.AreaCodeService; import com.epmet.dataaggre.service.commonservice.AreaCodeService;
@ -48,6 +52,7 @@ import com.epmet.dataaggre.service.govorg.GovOrgService;
import com.epmet.dataaggre.service.opercrm.CustomerRelation; import com.epmet.dataaggre.service.opercrm.CustomerRelation;
import com.epmet.dto.result.UploadImgResultDTO; import com.epmet.dto.result.UploadImgResultDTO;
import com.epmet.feign.OssFeignClient; import com.epmet.feign.OssFeignClient;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileItem;
@ -107,6 +112,8 @@ public class GovOrgServiceImpl implements GovOrgService {
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Autowired @Autowired
private ExecutorService executorService; private ExecutorService executorService;
@Autowired
private IcHouseDao houseDao;
/** /**
* @param staffId * @param staffId
@ -1079,4 +1086,32 @@ public class GovOrgServiceImpl implements GovOrgService {
query.eq(CustomerAgencyEntity::getPid, "0"); // 跟组织的pid为"0" query.eq(CustomerAgencyEntity::getPid, "0"); // 跟组织的pid为"0"
return customerAgencyDao.selectOne(query); return customerAgencyDao.selectOne(query);
} }
@Override
public List<IcHouseEntity> listHousesByRules(Set<ResisByPolicyRulesFormDTO.PolicyRule> houseRule, Set<ResisByPolicyRulesFormDTO.PolicyRule> statRule, Integer pageNo, Integer pageSize) {
if (CollectionUtils.isEmpty(houseRule) && CollectionUtils.isEmpty(statRule)) {
return new ArrayList<>();
}
String customerId = EpmetRequestHolder.getLoginUserCustomerId();
QueryWrapper<IcHouseEntity> query = new QueryWrapper<>();
query.eq("CUSTOMER_ID", customerId);
// 房屋属性
if (CollectionUtils.isNotEmpty(houseRule)) {
for (ResisByPolicyRulesFormDTO.PolicyRule rule : houseRule) {
query.eq(rule.getColKey(), rule.getColVal());
}
}
// 房屋的统计属性
if (CollectionUtils.isNotEmpty(statRule)) {
for (ResisByPolicyRulesFormDTO.PolicyRule rule : statRule) {
query.eq(rule.getColKey(), rule.getColVal());
}
}
PageHelper.startPage(pageNo, pageSize);
return houseDao.selectList(query);
}
} }

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

@ -0,0 +1,74 @@
package com.epmet.dataaggre.service.impl;
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.entity.govorg.IcHouseEntity;
import com.epmet.dataaggre.service.ResiService;
import com.epmet.dataaggre.service.epmetuser.EpmetUserService;
import com.epmet.dataaggre.service.govorg.GovOrgService;
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.util.stream.Collectors;
@Service
public class ResiServiceImpl implements ResiService {
@Autowired
private EpmetUserService epmetUserService;
@Autowired
private GovOrgService govOrgService;
@Override
public List<ResiInfoResultDTO> listByPolicyRules(Integer pageNo, Integer pageSize,
Set<ResisByPolicyRulesFormDTO.PolicyRule> resiRule,
Set<ResisByPolicyRulesFormDTO.PolicyRule> houseRule,
Set<ResisByPolicyRulesFormDTO.PolicyRule> houseStat) {
String customerId = EpmetRequestHolder.getLoginUserCustomerId();
// 结果集
List<ResiInfoResultDTO> resultResis = new ArrayList<>();
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());
}
if (houseIds != null && houseIds.size() == 0) {
// 用户使用了房屋和统计相关的条件,但是没查到房屋,我看就没有走下去了的必要了吧..
break;
}
// 查询居民
List<ResiInfoResultDTO> resis = epmetUserService.listByPolicyRules(customerId, resiRule, houseIds);
resultResis.addAll(resis);
// 满了20个,或者查不到居民和房屋了(数据空了),则跳出
// 没有用house的条件,没有循环的必要,查一次居民信息即可,跳出
if (resultResis.size() >= pageSize || houseIds == null ) {
break;
}
housePageNo ++;
} while (true);
// 够了20个,那就截取前20个,否则直接返回
if (resultResis.size() > 20) {
return resultResis.subList(0, 20);
}
return resultResis;
}
}

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

@ -69,4 +69,28 @@
and resi.STATUS='0' and resi.STATUS='0'
</select> </select>
<!--政策查找-->
<select id="listByPolicyRules" resultType="com.epmet.dataaggre.dto.epmetuser.result.ResiInfoResultDTO">
select `NAME`, `MOBILE`, `ID_CARD`, `VILLAGE_ID`, BIRTHDAY
from ic_resi_user
<foreach collection="resiRules" item="rule">
<if test="rule.colTable != 'ic_resi_user'"> inner join #{rule.colTable}</if>
</foreach>
<where>
<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则需要参与查询 -->
<if test="houseIds != null and houseIds.size() > 0">
and HOME_ID in
<foreach collection="houseIds" item="houseId" open="(" close=")" separator=",">
#{houseId}
</foreach>
</if>
</where>
</select>
</mapper> </mapper>

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

@ -0,0 +1,69 @@
package com.epmet.dto.form.resi;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Comparator;
import java.util.Map;
import java.util.Set;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class HeartResisByPolicyRulesFormDTO {
private Integer pageNo = 1;
private Integer pageSize = 20;
/**
* 规则map
*/
private Set<PolicyRule> rules;
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class PolicyRule implements Comparator<Integer> {
private String customerId;
/**
* resi:人员信息,house:房屋信息stat:统计信息
*/
private String groupType;
/**
* 与上一条的关系andor
*/
private String lastLogicalRel;
/**
* 查询类型等于不等于....;来源于字典表sql_query_type
*/
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);
}
}
}

5
epmet-module/epmet-heart/epmet-heart-server/pom.xml

@ -12,6 +12,11 @@
<packaging>jar</packaging> <packaging>jar</packaging>
<dependencies> <dependencies>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>data-aggregator-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency> <dependency>
<groupId>com.epmet</groupId> <groupId>com.epmet</groupId>
<artifactId>epmet-heart-client</artifactId> <artifactId>epmet-heart-client</artifactId>

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

@ -1,7 +1,9 @@
package com.epmet.controller; package com.epmet.controller;
import com.epmet.commons.tools.utils.EpmetRequestHolder;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.IcPolicyItemResultDTO; import com.epmet.dto.IcPolicyItemResultDTO;
import com.epmet.dto.form.resi.HeartResisByPolicyRulesFormDTO;
import com.epmet.service.IcPolicyService; import com.epmet.service.IcPolicyService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -34,4 +36,12 @@ public class IcPolicyController {
return new Result<List<IcPolicyItemResultDTO>>().ok(list); return new Result<List<IcPolicyItemResultDTO>>().ok(list);
} }
@PostMapping("resiuserlist")
public Result listResiUserByPolicyRules(@RequestBody HeartResisByPolicyRulesFormDTO input) {
//todo
String ruleId = "a";
String customerId = EpmetRequestHolder.getLoginUserCustomerId();
icPolicyService.listResiUserByPolicyRules(customerId, ruleId, 1, 20);
return null;
}
} }

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

@ -20,4 +20,6 @@ public interface IcPolicyService extends BaseService<IcPolicyEntity> {
* @return * @return
*/ */
List<IcPolicyItemResultDTO> itemList(String customerId, String groupType); List<IcPolicyItemResultDTO> itemList(String customerId, String groupType);
void listResiUserByPolicyRules(String customerId, String ruleId, Integer pageNo, Integer pageSize);
} }

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

@ -1,17 +1,27 @@
package com.epmet.service.impl; 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.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.Constant; import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcPolicyDao; import com.epmet.dao.IcPolicyDao;
import com.epmet.dao.IcPolicyRuleDetailDao;
import com.epmet.dataaggre.dto.epmetuser.form.ResisByPolicyRulesFormDTO;
import com.epmet.dataaggre.feign.DataAggregatorOpenFeignClient;
import com.epmet.dto.IcPolicyItemResultDTO; import com.epmet.dto.IcPolicyItemResultDTO;
import com.epmet.entity.IcPolicyEntity; import com.epmet.entity.IcPolicyEntity;
import com.epmet.entity.IcPolicyRuleDetailEntity;
import com.epmet.service.IcPolicyService; import com.epmet.service.IcPolicyService;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/** /**
* 政策表 * 政策表
@ -22,6 +32,11 @@ import java.util.List;
@Service @Service
public class IcPolicyServiceImpl extends BaseServiceImpl<IcPolicyDao, IcPolicyEntity> implements IcPolicyService { public class IcPolicyServiceImpl extends BaseServiceImpl<IcPolicyDao, IcPolicyEntity> implements IcPolicyService {
@Autowired
private IcPolicyRuleDetailDao policyRuleDetailDao;
@Autowired
private DataAggregatorOpenFeignClient dataAggregatorOpenFeignClient;
/** /**
* 房屋信息统计信息查询有哪些可选项 * 房屋信息统计信息查询有哪些可选项
@ -41,4 +56,21 @@ public class IcPolicyServiceImpl extends BaseServiceImpl<IcPolicyDao, IcPolicyEn
} }
return resultList; return resultList;
} }
@Override
public void listResiUserByPolicyRules(String customerId, String ruleId, Integer pageNo, Integer pageSize) {
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()));
ResisByPolicyRulesFormDTO aggForm = new ResisByPolicyRulesFormDTO(pageNo, pageSize, rulesMap);
Result result = dataAggregatorOpenFeignClient.listByPolicyRules(aggForm);
}
} }
Loading…
Cancel
Save