Browse Source

【政策】人员导出,做了一半

dev
wangxianzhang 3 years ago
parent
commit
50d02c0966
  1. 6
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/form/ResisByPolicyRulesFormDTO.java
  2. 5
      epmet-module/data-aggregator/data-aggregator-server/pom.xml
  3. 20
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/IcUserController.java
  4. 21
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/ResisByPolicyExcel.java
  5. 23
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/ResiService.java
  6. 62
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/ResiServiceImpl.java
  7. 15
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResisByPolicyRulesFormDTO.java
  8. 8
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java
  9. 5
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java
  10. 55
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPolicyController.java
  11. 10
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPolicyService.java
  12. 22
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPolicyServiceImpl.java

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

@ -24,10 +24,12 @@ public class ResisByPolicyRulesFormDTO {
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;
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class RuleList {
private String ruleName;
private List<ResiRule> resiRule;

5
epmet-module/data-aggregator/data-aggregator-server/pom.xml

@ -13,6 +13,11 @@
<artifactId>data-aggregator-server</artifactId>
<dependencies>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-heart-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-tools</artifactId>

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

@ -2,6 +2,8 @@ package com.epmet.dataaggre.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
@ -19,6 +21,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -83,4 +87,20 @@ public class IcUserController {
return new Result<PageData<ResiByPolicyInfoResultDTO>>().ok(page);
}
/**
* 导出政策查找到的居民
* @param input
*/
@PostMapping("exportByPolicy")
public void exportResisByPolicy(@RequestBody ResisByPolicyRulesFormDTO input, HttpServletResponse response) {
try {
icResiService.exportResisByPolicy(
input.getOrgId(), input.getOrgType(), input.getNeighborHoodId(), input.getBuildingId(), input.getUnitId(),
input.getHouseId(), input.getIdCard(), input.getName(), input.getPageNo(), input.getPageSize(),
input.getRuleId(), input.getRuleList().getResiRule(), input.getRuleList().getHouseRule(), input.getRuleList().getStatRule(), response);
} catch (IOException e) {
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "导出Excel文件失败", "导出Excel文件失败");
}
}
}

21
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/ResisByPolicyExcel.java

@ -0,0 +1,21 @@
package com.epmet.dataaggre.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
public class ResisByPolicyExcel {
@ExcelProperty("姓名")
private String name;
@ExcelProperty("手机号")
private String mobile;
@ExcelProperty("身份证号")
private String idCard;
/**
* 小区全名包含小区前面的属性比如网格等
*/
@ExcelProperty("小区名")
private String neighborHoodName;
@ExcelProperty("年龄")
private Integer age;
}

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

@ -5,6 +5,8 @@ import com.epmet.dataaggre.dto.epmetuser.form.ResisByPolicyRulesFormDTO;
import com.epmet.dataaggre.dto.epmetuser.result.ResiByPolicyInfoResultDTO;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Set;
@ -26,4 +28,25 @@ public interface ResiService {
List<ResisByPolicyRulesFormDTO.ResiRule> resiRule,
List<ResisByPolicyRulesFormDTO.HouseRule> houseRule,
List<ResisByPolicyRulesFormDTO.StatRule> statRule);
/**
* 政策找居民导出
* @param orgId
* @param orgType
* @param neighborHoodId
* @param buildingId
* @param unitId
* @param houseId
* @param idCard
* @param name
* @param pageNo
* @param pageSize
* @param ruleId
*/
void exportResisByPolicy(String orgId, String orgType, String neighborHoodId, String buildingId, String unitId,
String houseId, String idCard, String name, Integer pageNo, Integer pageSize,
String ruleId, List<ResisByPolicyRulesFormDTO.ResiRule> resiRule,
List<ResisByPolicyRulesFormDTO.HouseRule> houseRule,
List<ResisByPolicyRulesFormDTO.StatRule> statRule,
HttpServletResponse response) throws IOException;
}

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

@ -1,27 +1,43 @@
package com.epmet.dataaggre.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.builder.ExcelWriterSheetBuilder;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.EpmetRequestHolder;
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.result.GridsInfoListResultDTO;
import com.epmet.dataaggre.entity.govorg.IcHouseEntity;
import com.epmet.dataaggre.excel.ResisByPolicyExcel;
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 com.epmet.feign.EpmetHeartOpenFeignClient;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.*;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class ResiServiceImpl implements ResiService {
public class ResiServiceImpl implements ResiService, ResultDataResolver {
@Autowired
private EpmetUserService epmetUserService;
@ -29,6 +45,9 @@ public class ResiServiceImpl implements ResiService {
@Autowired
private GovOrgService govOrgService;
@Autowired
private EpmetHeartOpenFeignClient heartOpenFeignClient;
@Override
public PageData<ResiByPolicyInfoResultDTO> listByPolicyRules(String orgId, String orgType, String neighborHoodId, String buildingId, String unitId,
String houseId, String idCard, String name, Integer pageNo, Integer pageSize,
@ -132,4 +151,45 @@ public class ResiServiceImpl implements ResiService {
});
}
@Override
public void exportResisByPolicy(String orgId, String orgType, String neighborHoodId, String buildingId, String unitId,
String houseId, String idCard, String name, Integer pageNo, Integer pageSize,
String ruleId, List<ResisByPolicyRulesFormDTO.ResiRule> resiRule,
List<ResisByPolicyRulesFormDTO.HouseRule> houseRule,
List<ResisByPolicyRulesFormDTO.StatRule> statRule,
HttpServletResponse response) throws IOException {
if (StringUtils.isNotBlank(ruleId)) {
// 从heart取,覆盖形参
com.epmet.dto.form.resi.ResisByPolicyRulesFormDTO.RuleList ruleList = getResultDataOrThrowsException(
heartOpenFeignClient.listPolicyRules4QueryAndExport(ruleId),
ServiceConstant.EPMET_HEART_SERVER,
EpmetErrorCode.SERVER_ERROR.getCode(),
null, null);
resiRule = ConvertUtils.sourceToTarget(ruleList.getResiRule(), ResisByPolicyRulesFormDTO.ResiRule.class);
houseRule = ConvertUtils.sourceToTarget(ruleList.getHouseRule(), ResisByPolicyRulesFormDTO.HouseRule.class);
statRule = ConvertUtils.sourceToTarget(ruleList.getStatRule(), ResisByPolicyRulesFormDTO.StatRule.class);
}
ServletOutputStream ostream = response.getOutputStream();
ExcelWriterSheetBuilder sheetBuilder = EasyExcel.write(ostream, ResisByPolicyExcel.class).sheet("居民列表");
// 循环填充数据
do {
PageData<ResiByPolicyInfoResultDTO> resis = this.listByPolicyRules(orgId, orgType, neighborHoodId, buildingId, unitId,
houseId, idCard, name, pageNo, pageSize, resiRule, houseRule, statRule);
List<ResiByPolicyInfoResultDTO> list = resis.getList();
List<ResisByPolicyExcel> excelDatas = ConvertUtils.sourceToTarget(list, ResisByPolicyExcel.class);
if (CollectionUtils.isEmpty(excelDatas)) {
break;
}
//sheetBuilder.write(excelDatas);
} while (true);
System.out.println(666);
}
}

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

@ -1,10 +1,14 @@
package com.epmet.dto.form.resi;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResisByPolicyRulesFormDTO {
private String ruleId;
private String orgId;
@ -16,19 +20,22 @@ public class ResisByPolicyRulesFormDTO {
private String name;
private String mobile;
private String idCard;
private RuleList ruleList;
private RuleList ruleList = new RuleList();
private Integer pageNo;
private Integer pageSize;
@Data
@NoArgsConstructor
@AllArgsConstructor
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 ResiRule {
private String ruleDesc;
private String nextLogicalRel;
@ -41,6 +48,8 @@ public class ResisByPolicyRulesFormDTO {
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class HouseRule {
private String colTable;
private String colKey;
@ -51,6 +60,8 @@ public class ResisByPolicyRulesFormDTO {
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class StatRule {
private String colKey;
private String colVal;

8
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java

@ -14,6 +14,7 @@ import com.epmet.dto.form.demand.DemandRecId;
import com.epmet.dto.form.demand.IcEventCommentToDemandFromDTO;
import com.epmet.dto.form.demand.UserDemandNameQueryFormDTO;
import com.epmet.dto.form.resi.ResiVolunteerAuthenticateFormDTO;
import com.epmet.dto.form.resi.ResisByPolicyRulesFormDTO;
import com.epmet.dto.form.resi.VolunteerCommonFormDTO;
import com.epmet.dto.result.PartyUnitListResultDTO;
import com.epmet.dto.result.demand.IcResiDemandDictDTO;
@ -158,4 +159,11 @@ public interface EpmetHeartOpenFeignClient {
@PostMapping("/heart/resi/volunteer/addVolunteer")
Result addVolunteer(@RequestBody ResiVolunteerAuthenticateFormDTO formDTO);
/**
* 为预览和导出提供规则列表查询
* @return
*/
@PostMapping("/heart/policy/rules4ResiListAndExport/{ruleId}")
Result<ResisByPolicyRulesFormDTO.RuleList> listPolicyRules4QueryAndExport(@PathVariable("ruleId") String ruleId);
}

5
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java

@ -16,6 +16,7 @@ import com.epmet.dto.form.demand.IcEventCommentToDemandFromDTO;
import com.epmet.dto.form.demand.ServiceItemSelectFormDTO;
import com.epmet.dto.form.demand.UserDemandNameQueryFormDTO;
import com.epmet.dto.form.resi.ResiVolunteerAuthenticateFormDTO;
import com.epmet.dto.form.resi.ResisByPolicyRulesFormDTO;
import com.epmet.dto.form.resi.VolunteerCommonFormDTO;
import com.epmet.dto.result.PartyUnitListResultDTO;
import com.epmet.dto.result.demand.IcResiDemandDictDTO;
@ -161,4 +162,8 @@ public class EpmetHeartOpenFeignClientFallback implements EpmetHeartOpenFeignCli
return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "addVolunteer", formDTO);
}
@Override
public Result<ResisByPolicyRulesFormDTO.RuleList> listPolicyRules4QueryAndExport(String ruleId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "listPolicyRules4QueryAndExport", ruleId);
}
}

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

@ -1,5 +1,6 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.EpmetRequestHolder;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.dto.form.PageFormDTO;
@ -15,12 +16,15 @@ 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.IcPolicyRuleDetailEntity;
import com.epmet.service.IcPolicyService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@ -48,6 +52,11 @@ public class IcPolicyController {
return new Result<List<IcPolicyItemResultDTO>>().ok(list);
}
/**
* 政策找人居民列表
* @param input
* @return
*/
@PostMapping("resiuserlist")
public Result listResiUserByPolicyRules(@RequestBody ResisByPolicyRulesFormDTO input) {
// 调整错位的逻辑符号位置
@ -162,4 +171,50 @@ public class IcPolicyController {
public Result<IcPolicyDTO> policyDetail(@LoginUser TokenDto tokenDto,@PathVariable("policyId") String policyId) {
return new Result<IcPolicyDTO>().ok(icPolicyService.policyDetail(tokenDto.getCustomerId(),policyId));
}
/**
* 为预览和导出提供规则列表查询
* @return
*/
@PostMapping("rules4ResiListAndExport/{ruleId}")
public Result<ResisByPolicyRulesFormDTO.RuleList> listPolicyRules4QueryAndExport(@PathVariable("ruleId") String ruleId) {
Map<String, List<IcPolicyRuleDetailEntity>> ruleMap = icPolicyService.listPolicyRules4QueryAndExport(EpmetRequestHolder.getLoginUserCustomerId(), ruleId);
ResisByPolicyRulesFormDTO.RuleList data = new ResisByPolicyRulesFormDTO.RuleList();
// 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.getNextLogicalRel(), r.getItemGroupId(),
r.getItemId(), r.getQueryType(), r.getColTable(), r.getColKey(), r.getColVal()))
.collect(Collectors.toList());
data.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.getNextLogicalRel(), r.getQueryType()))
.collect(Collectors.toList());
data.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.getNextLogicalRel(),
r.getRuleDesc(), r.getQueryType(), r.getColTable()))
.collect(Collectors.toList());
data.setStatRule(statRules);
}
return new Result<ResisByPolicyRulesFormDTO.RuleList>().ok(data);
}
}

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

@ -10,8 +10,10 @@ 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 com.epmet.entity.IcPolicyRuleDetailEntity;
import java.util.List;
import java.util.Map;
/**
* 政策表
@ -48,4 +50,12 @@ public interface IcPolicyService extends BaseService<IcPolicyEntity> {
IcPolicyDTO policyDetail(String customerId,String policyId);
PageData<ResiByPolicyInfoResultDTO> listResiUserByPolicyRules(ResisByPolicyRulesFormDTO input);
/**
* 政策规则查询
* @param customerId
* @param ruleId
* @return
*/
Map<String, List<IcPolicyRuleDetailEntity>> listPolicyRules4QueryAndExport(String customerId, String ruleId);
}

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

@ -322,15 +322,7 @@ public class IcPolicyServiceImpl extends BaseServiceImpl<IcPolicyDao, IcPolicyEn
// 穿了规则id,按照规则id来,忽略规则list
if (StringUtils.isNotBlank(ruleId)) {
LambdaQueryWrapper<IcPolicyRuleDetailEntity> query = new LambdaQueryWrapper();
query.eq(IcPolicyRuleDetailEntity::getCustomerId, customerId);
query.eq(IcPolicyRuleDetailEntity::getRuleId, ruleId);
query.orderByAsc(IcPolicyRuleDetailEntity::getSort);
List<IcPolicyRuleDetailEntity> rules = policyRuleDetailDao.selectList(query);
// 将查询出的数据转化成aggre服务能接受的格式
Map<String, List<IcPolicyRuleDetailEntity>> ruleMap = rules.stream().collect(Collectors.groupingBy(IcPolicyRuleDetailEntity::getGroupType, Collectors.toList()));
Map<String, List<IcPolicyRuleDetailEntity>> ruleMap = listPolicyRules4QueryAndExport(customerId, ruleId);
// resi规则
List<IcPolicyRuleDetailEntity> originResiRules = ruleMap.get("resi");
if (CollectionUtils.isNotEmpty(originResiRules)) {
@ -376,4 +368,16 @@ public class IcPolicyServiceImpl extends BaseServiceImpl<IcPolicyDao, IcPolicyEn
return new PageData<ResiByPolicyInfoResultDTO>(list, result.getData().getTotal());
}
public Map<String, List<IcPolicyRuleDetailEntity>> listPolicyRules4QueryAndExport(String customerId, String ruleId) {
ResisByPolicyRulesFormDTO form = new ResisByPolicyRulesFormDTO();
LambdaQueryWrapper<IcPolicyRuleDetailEntity> query = new LambdaQueryWrapper();
query.eq(IcPolicyRuleDetailEntity::getCustomerId, customerId);
query.eq(IcPolicyRuleDetailEntity::getRuleId, ruleId);
query.orderByAsc(IcPolicyRuleDetailEntity::getSort);
List<IcPolicyRuleDetailEntity> rules = policyRuleDetailDao.selectList(query);
// 将查询出的数据转化成aggre服务能接受的格式
return rules.stream().collect(Collectors.groupingBy(IcPolicyRuleDetailEntity::getGroupType, Collectors.toList()));
}
}
Loading…
Cancel
Save