|
|
@ -91,7 +91,9 @@ public class IcResiUserExportServiceImpl implements IcResiUserExportService { |
|
|
|
* @date 2022/4/22 1:35 下午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void exportIcResiUser(TokenDto tokenDto, ExportResiUserFormDTO exportResiUserFormDTO, HttpServletResponse response) { |
|
|
|
public Page<Map<String, Object>> exportIcResiUser(TokenDto tokenDto, ExportResiUserFormDTO exportResiUserFormDTO, HttpServletResponse response, boolean onlyGetData) { |
|
|
|
Page<Map<String, Object>> mapListPage = null; |
|
|
|
|
|
|
|
//校验参数
|
|
|
|
this.validateSearchForm(tokenDto, exportResiUserFormDTO); |
|
|
|
IcResiUserPageFormDTO searchForm = exportResiUserFormDTO.getSearchForm(); |
|
|
@ -99,6 +101,7 @@ public class IcResiUserExportServiceImpl implements IcResiUserExportService { |
|
|
|
String templateId = exportResiUserFormDTO.getTemplateId(); |
|
|
|
|
|
|
|
ExcelWriter excelWriter = null; |
|
|
|
WriteSheet writeSheet = null; |
|
|
|
try { |
|
|
|
//获取用户配置的导出条件
|
|
|
|
Result<IcCustomExportResultDTO> exportConfigResult = this.getIcCustomExportConfig(searchForm.getCustomerId(), templateId, exportResiUserFormDTO.getExportConfig()); |
|
|
@ -114,6 +117,10 @@ public class IcResiUserExportServiceImpl implements IcResiUserExportService { |
|
|
|
|
|
|
|
List<IcCustomExportResultDTO.SqlColumn> allShowColumns = new ArrayList<>(exportConfigData.getShowSqlColumns()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!onlyGetData){ |
|
|
|
|
|
|
|
//需要合并的列
|
|
|
|
List<Integer> mergeColumnIndexList = new ArrayList<>(); |
|
|
|
for (int i = 0; i < allShowColumns.size(); i++) { |
|
|
@ -122,7 +129,6 @@ public class IcResiUserExportServiceImpl implements IcResiUserExportService { |
|
|
|
mergeColumnIndexList.add(i); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int[] mergeColumnIndex = mergeColumnIndexList.stream().filter(Objects::nonNull).mapToInt(i -> i).toArray(); |
|
|
|
// 从那一列开始合并
|
|
|
|
int mergeRowIndex = exportConfigData.getHeaderRow(); |
|
|
@ -143,7 +149,8 @@ public class IcResiUserExportServiceImpl implements IcResiUserExportService { |
|
|
|
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
|
|
|
.registerWriteHandler(writeHandler).build(); |
|
|
|
|
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").head(exportConfigData.getHeaders()).build(); |
|
|
|
writeSheet = EasyExcel.writerSheet("Sheet1").head(exportConfigData.getHeaders()).build(); |
|
|
|
} |
|
|
|
|
|
|
|
String staffOrgPath = null; |
|
|
|
if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) { |
|
|
@ -151,7 +158,6 @@ public class IcResiUserExportServiceImpl implements IcResiUserExportService { |
|
|
|
} else { |
|
|
|
staffOrgPath = staffInfoCacheResult.getAgencyId(); |
|
|
|
} |
|
|
|
Page<Map<String, Object>> mapListPage = null; |
|
|
|
|
|
|
|
allShowColumns.addAll(exportConfigData.getHiddenSqlColumns()); |
|
|
|
do { |
|
|
@ -168,6 +174,24 @@ public class IcResiUserExportServiceImpl implements IcResiUserExportService { |
|
|
|
List<IcCustomExportResultDTO.SqlColumn> showSqlColumns = exportConfigData.getShowSqlColumns(); |
|
|
|
Set<String> hiddenColumnSet = exportConfigData.getHiddenSqlColumns().stream().map(IcCustomExportResultDTO.SqlColumn::getColumnName).collect(Collectors.toSet()); |
|
|
|
result.forEach(o -> { |
|
|
|
getDataForResi(itemOriginMap, staffInfoCacheResult, resultData, showSqlColumns, hiddenColumnSet, o); |
|
|
|
}); |
|
|
|
if (!onlyGetData){ |
|
|
|
excelWriter.write(resultData, writeSheet); |
|
|
|
} |
|
|
|
} while (mapListPage.getResult().size() == searchForm.getPageSize()); |
|
|
|
} catch (IOException e) { |
|
|
|
log.error("exportIcResiUser exception", e); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), e.getMessage(), "导出失败"); |
|
|
|
} finally { |
|
|
|
if (excelWriter != null) { |
|
|
|
excelWriter.finish(); |
|
|
|
} |
|
|
|
} |
|
|
|
return mapListPage; |
|
|
|
} |
|
|
|
|
|
|
|
private void getDataForResi(Map<String, ExportResiUserItemDTO> itemOriginMap, CustomerStaffInfoCacheResult staffInfoCacheResult, List<List<Object>> resultData, List<IcCustomExportResultDTO.SqlColumn> showSqlColumns, Set<String> hiddenColumnSet, Map<String, Object> o) { |
|
|
|
List<Object> singleRowData = new ArrayList<>(); |
|
|
|
Map<String, Object> originalConditionMap = new ConcurrentHashMap<>(); |
|
|
|
o.forEach((key, value) -> { |
|
|
@ -205,17 +229,6 @@ public class IcResiUserExportServiceImpl implements IcResiUserExportService { |
|
|
|
singleRowData.add(newValue); |
|
|
|
}); |
|
|
|
resultData.add(singleRowData); |
|
|
|
}); |
|
|
|
excelWriter.write(resultData, writeSheet); |
|
|
|
} while (mapListPage.getResult().size() == searchForm.getPageSize()); |
|
|
|
} catch (IOException e) { |
|
|
|
log.error("exportIcResiUser exception", e); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), e.getMessage(), "导出失败"); |
|
|
|
} finally { |
|
|
|
if (excelWriter != null) { |
|
|
|
excelWriter.finish(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|