数据透视功能-分页+排序

This commit is contained in:
Harryxzy 2023-06-07 16:50:09 +08:00
parent deaa9acfa0
commit dcb28b052f
3 changed files with 24 additions and 6 deletions

View File

@ -90,5 +90,5 @@ public interface SalaryStatisticsReportService {
* @param salaryStatisticsItemPOS 自定义统计项目List
* @return
*/
List<Map<String, Object>> buildDataPerspectiveRecords(SalaryStatisticsDataPerspectiveQueryParam param, SalaryStatisticsReportPO reportPO, SalaryStatisticsDimensionPO dimension, List<SalaryStatisticsItemPO> salaryStatisticsItemPOS);
PageInfo<Map<String, Object>> buildDataPerspectiveRecords(SalaryStatisticsDataPerspectiveQueryParam param, SalaryStatisticsReportPO reportPO, SalaryStatisticsDimensionPO dimension, List<SalaryStatisticsItemPO> salaryStatisticsItemPOS);
}

View File

@ -29,6 +29,7 @@ import com.engine.salary.service.impl.*;
import com.engine.salary.util.*;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@ -371,7 +372,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary
}
@Override
public List<Map<String, Object>> buildDataPerspectiveRecords(SalaryStatisticsDataPerspectiveQueryParam param, SalaryStatisticsReportPO reportPO, SalaryStatisticsDimensionPO dimension, List<SalaryStatisticsItemPO> salaryStatisticsItemPOS) {
public PageInfo<Map<String, Object>> buildDataPerspectiveRecords(SalaryStatisticsDataPerspectiveQueryParam param, SalaryStatisticsReportPO reportPO, SalaryStatisticsDimensionPO dimension, List<SalaryStatisticsItemPO> salaryStatisticsItemPOS) {
// 获取报表统计薪资项目
List<Long> salaryItemIds = salaryStatisticsItemPOS.stream().filter(item -> StringUtils.isNotBlank(item.getItemValue())).map(p -> p.getItemValue().split(","))
.flatMap(Arrays::stream).map(Long::valueOf).collect(Collectors.toList());
@ -413,8 +414,17 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary
// 获取根据维度值过滤出的本次核算人员信息
calculateReportRecordsByDimension(dimension, SalaryStatisticsReportDataQueryParam.builder().build(), salaryStatisticsReportData, map);
List<SalaryAcctEmployeePO> listByDimensionValue = salaryStatisticsReportData.getListByDimensionValue();
if(CollectionUtils.isEmpty(listByDimensionValue)){
throw new SalaryRunTimeException("该维度值中无数据!");
}
// 同一个人放在一起
listByDimensionValue = listByDimensionValue.stream().sorted(Comparator.comparing(SalaryAcctEmployeePO::getEmployeeId)).collect(Collectors.toList());
PageInfo<SalaryAcctEmployeePO> salaryAcctEmployeePOPageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), listByDimensionValue);
// 构建核算结果数据
return buildResultRecords(listByDimensionValue, map);
List<Map<String, Object>> records = buildResultRecords(salaryAcctEmployeePOPageInfo.getList(), map);
PageInfo<Map<String, Object>> pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), records);
pageInfo.setTotal(listByDimensionValue.size());
return pageInfo;
}
/**
@ -423,6 +433,11 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary
* @param map 薪资核算结果
*/
private List<Map<String, Object>> buildResultRecords(List<SalaryAcctEmployeePO> listByDimensionValue, Map<Long, Map<String, String>> map) {
// 获取人员信息
Set<Long> employeeIds = listByDimensionValue.stream().map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toSet());
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listByIds(employeeIds.stream().collect(Collectors.toList()));
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId);
List<TaxAgentPO> taxAgentList = getTaxAgentService(user).listAll();
Map<Long, String> taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentList, TaxAgentPO::getId, TaxAgentPO::getName);
@ -440,7 +455,10 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary
resultValueMap.forEach((k, v) -> {
finalMap.put(k + SalaryConstant.DYNAMIC_SUFFIX, v);
});
DataCollectionEmployee emp = employeeMap.get(se.getEmployeeId());
resultMap.put("id", se.getId().toString());
resultMap.put("username", emp == null ? "" : emp.getUsername());
resultMap.put("departmentName", emp == null ? "" : emp.getDepartmentName());
resultMap.put("salaryMonth", SalaryDateUtil.getFormatYearMonth(se.getSalaryMonth()));
resultMap.put("taxAgent", taxAgentMap.get(se.getTaxAgentId()));
resultMap.put("salarySob",SalarySobMap.get(se.getSalarySobId()));

View File

@ -36,7 +36,6 @@ import com.engine.salary.service.impl.SalaryItemServiceImpl;
import com.engine.salary.util.*;
import com.engine.salary.util.excel.ExcelUtilPlus;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.collections4.CollectionUtils;
@ -346,8 +345,7 @@ public class SalaryStatisticsReportWrapper extends Service {
List<Long> salaryItemIds = salaryStatisticsItemPOS.stream().filter(item -> StringUtils.isNotBlank(item.getItemValue())).map(p -> p.getItemValue().split(","))
.flatMap(Arrays::stream).map(Long::valueOf).collect(Collectors.toList());
List<Map<String, Object>> records = getSalaryStatisticsReportService(user).buildDataPerspectiveRecords(param, po, dimension, salaryStatisticsItemPOS);
PageInfo<Map<String, Object>> pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), records);
PageInfo<Map<String, Object>> pageInfo = getSalaryStatisticsReportService(user).buildDataPerspectiveRecords(param, po, dimension, salaryStatisticsItemPOS);
List<SalaryItemPO> itemList = getSalaryItemService(user).listByIds(salaryItemIds);
// 列表columns
@ -370,6 +368,8 @@ public class SalaryStatisticsReportWrapper extends Service {
private List<WeaTableColumn> buildDataPerspectiveTableColumns(List<SalaryItemPO> salaryItems) {
// 表格表头
List<WeaTableColumn> columns = new ArrayList<>();
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(87614, "姓名"), "userName"));
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(87614, "部门"), "departmentName"));
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(87614, "薪资所属月"), "salaryMonth"));
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), "taxAgent"));
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "账套"), "salarySob"));