报表数据透视提速

This commit is contained in:
Harryxzy 2023-06-08 14:00:51 +08:00
parent 3d11c74d32
commit 4b574c9e57
1 changed files with 18 additions and 13 deletions

View File

@ -390,10 +390,6 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary
// 获取本期报表分权后的核算人员
List<SalaryAcctEmployeePO> salaryAcctEmployeeList = getSalaryAcctEmployeeService(user).listBySalaryStatisticsReportParam(queryParam);
List<Long> salaryAcctEmployeeIds = salaryAcctEmployeeList.stream().map(SalaryAcctEmployeePO::getId).collect(Collectors.toList());
// 获取核算结果
List<SalaryAcctResultPO> salaryAcctResultValues = getSalaryAcctResultService(user).listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmployeeIds, salaryItemIds);
// 设置dimensionValue为维度值
SalaryStatisticsReportDataDTO salaryStatisticsReportData = SalaryStatisticsReportDataDTO.builder()
.list(salaryAcctEmployeeList)
@ -405,24 +401,33 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary
.dimensionValue(param.getDimensionValue())
.build();
Map<Long, List<SalaryAcctResultPO>> salaryAcctEmpResultMap = SalaryEntityUtil.group2Map(salaryAcctResultValues, SalaryAcctResultPO::getSalaryAcctEmpId);
Map<Long, Map<String, String>> map = new HashMap<>();
salaryAcctEmpResultMap.forEach((k, v) -> {
Map<String, String> collect = v.stream().collect(Collectors.toMap(p -> Util.null2String(p.getSalaryItemId()), p -> Util.null2o(p.getResultValue()), (key1, key2) -> key2));
map.put(k, collect);
});
// 获取根据维度值过滤出的本次核算人员信息
calculateReportRecordsByDimension(dimension, SalaryStatisticsReportDataQueryParam.builder().build(), salaryStatisticsReportData, map);
calculateReportRecordsByDimension(dimension, SalaryStatisticsReportDataQueryParam.builder().build(), salaryStatisticsReportData, Collections.EMPTY_MAP);
List<SalaryAcctEmployeePO> listByDimensionValue = salaryStatisticsReportData.getListByDimensionValue();
if(CollectionUtils.isEmpty(listByDimensionValue)){
throw new SalaryRunTimeException("该维度值中无数据!");
}
// 同一个人放在一起
listByDimensionValue = listByDimensionValue.stream().sorted(Comparator.comparing(SalaryAcctEmployeePO::getEmployeeId)).collect(Collectors.toList());
List<SalaryAcctEmployeePO> salaryAcctEmployeePOList = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), listByDimensionValue);
// 获取此分页的核算人员
List<Long> salaryAcctEmployeeIds = salaryAcctEmployeePOList.stream().map(SalaryAcctEmployeePO::getId).collect(Collectors.toList());
// 获取核算结果
List<SalaryAcctResultPO> salaryAcctResultValues = getSalaryAcctResultService(user).listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmployeeIds, salaryItemIds);
// 封装核算结果
Map<Long, List<SalaryAcctResultPO>> salaryAcctEmpResultMap = SalaryEntityUtil.group2Map(salaryAcctResultValues, SalaryAcctResultPO::getSalaryAcctEmpId);
Map<Long, Map<String, String>> map = new HashMap<>();
salaryAcctEmpResultMap.forEach((k, v) -> {
Map<String, String> collect = v.stream().collect(Collectors.toMap(p -> Util.null2String(p.getSalaryItemId()), p -> Util.null2o(p.getResultValue()), (key1, key2) -> key2));
map.put(k, collect);
});
// 构建核算结果数据
List<Map<String, Object>> records = buildResultRecords(listByDimensionValue, map);
PageInfo<Map<String, Object>> pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), records);
List<Map<String, Object>> records = buildResultRecords(salaryAcctEmployeePOList, map);
PageInfo<Map<String, Object>> pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize());
pageInfo.setTotal(listByDimensionValue.size());
pageInfo.setList(records);
return pageInfo;
}