|
|
@ -29,6 +29,7 @@ import com.alibaba.fastjson.JSON; |
|
|
|
import com.epmet.commons.tools.annotation.LoginUser; |
|
|
|
import com.epmet.commons.tools.aop.NoRepeatSubmit; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
|
|
@ -357,16 +358,14 @@ public class IcResiUserController { |
|
|
|
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId()); |
|
|
|
String staffOrgPath = null; |
|
|
|
if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) { |
|
|
|
staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(":").concat(staffInfoCacheResult.getAgencyId()); |
|
|
|
staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(StrConstant.COLON).concat(staffInfoCacheResult.getAgencyId()); |
|
|
|
} else { |
|
|
|
staffOrgPath = staffInfoCacheResult.getAgencyId(); |
|
|
|
} |
|
|
|
pageFormDTO.setCustomerId(customerId); |
|
|
|
pageFormDTO.setPageFlag(false); |
|
|
|
|
|
|
|
List<FormItemResult> resiFormAllItems = icResiUserService.listFormItems(customerId, IC_RESI_FORM_CODE); |
|
|
|
Map<String, Map<String, FormItemResult>> otherSheetItems = resiFormAllItems.stream() |
|
|
|
.collect(Collectors.groupingBy(FormItemResult::getTableName, Collectors.toMap(FormItemResult::getColumnName, o -> o))); |
|
|
|
|
|
|
|
|
|
|
|
//获取模版文件
|
|
|
|
File file = getExportTemplateFile(customerId); |
|
|
@ -378,27 +377,35 @@ public class IcResiUserController { |
|
|
|
pageFormDTO.setPageNo(NumConstant.ONE); |
|
|
|
//子表是否停止查询
|
|
|
|
Set<String> stopSearchSet = new HashSet<>(); |
|
|
|
Map<String, WriteSheet> childTableWriteSheetMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
//获取表单项
|
|
|
|
List<FormItemResult> resiFormAllItems = icResiUserService.listFormItems(customerId, IC_RESI_FORM_CODE); |
|
|
|
//每个表对应的 item ;key:表名,value:<字段名:item对象>
|
|
|
|
Map<String, Map<String, FormItemResult>> tableItemMap = resiFormAllItems.stream() |
|
|
|
.collect(Collectors.groupingBy(FormItemResult::getTableName, |
|
|
|
Collectors.toMap(o->o.getColumnName().concat(NumConstant.ZERO == o.getColumnNum()? StrConstant.EPMETY_STR:o.getColumnNum().toString()), o -> o))); |
|
|
|
Map<String, WriteSheet> childTableWriteSheetMap = new HashMap<>(); |
|
|
|
//表数据写入
|
|
|
|
//通过枚举获取相关表并按照sheetNo排序
|
|
|
|
List<IcResiUserTableEnum> resiTableList = Arrays.stream(IcResiUserTableEnum.values()).sorted(Comparator.comparing(IcResiUserTableEnum::getSheetNo)).collect(Collectors.toList()); |
|
|
|
List<IcResiUserTableEnum> resiTableList = Arrays.stream(IcResiUserTableEnum.values()) |
|
|
|
.sorted(Comparator.comparing(IcResiUserTableEnum::getSheetNo)) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
for (IcResiUserTableEnum tableEnum : resiTableList) { |
|
|
|
String tableName = tableEnum.getTableName(); |
|
|
|
pageFormDTO.setPageNo(NumConstant.ONE); |
|
|
|
//循环一次 写入每个sheet
|
|
|
|
do { |
|
|
|
Map<String, FormItemResult> itemMap1 = otherSheetItems.get(tableName); |
|
|
|
Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(itemMap1, tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath); |
|
|
|
Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(tableItemMap.get(tableName), tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath); |
|
|
|
//如果 返回的条数小于每页显示的数 则退出查询
|
|
|
|
if (resiChildMap.keySet().size() < pageFormDTO.getPageSize()) { |
|
|
|
stopSearchSet.add(tableName); |
|
|
|
} |
|
|
|
//构建新的sheet
|
|
|
|
WriteSheet childWriteSheet = childTableWriteSheetMap.getOrDefault(tableName,EasyExcel.writerSheet(tableEnum.getSheetNo()).build()); |
|
|
|
childTableWriteSheetMap.put(tableName, childWriteSheet); |
|
|
|
//如果没有 构建新的writeSheet
|
|
|
|
WriteSheet writeSheet = childTableWriteSheetMap.getOrDefault(tableName,EasyExcel.writerSheet(tableEnum.getSheetNo()).build()); |
|
|
|
childTableWriteSheetMap.putIfAbsent(tableName, writeSheet); |
|
|
|
//写入数据
|
|
|
|
excelWriter.fill(new FillWrapper("t" + (tableEnum.getSheetNo() + NumConstant.ONE), resiChildMap.values()), childWriteSheet); |
|
|
|
excelWriter.fill(new FillWrapper("t" + (tableEnum.getSheetNo() + NumConstant.ONE), resiChildMap.values()), writeSheet); |
|
|
|
pageFormDTO.setPageNo(pageFormDTO.getPageNo() + NumConstant.ONE); |
|
|
|
//重置数据
|
|
|
|
resiChildMap.clear(); |
|
|
|