|
|
@ -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); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|