From dcb28b052f870598515ff68b6bd70a9fbb9b3d0a Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Wed, 7 Jun 2023 16:50:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=80=8F=E8=A7=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD-=E5=88=86=E9=A1=B5+=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SalaryStatisticsReportService.java | 2 +- .../SalaryStatisticsReportServiceImpl.java | 22 +++++++++++++++++-- .../SalaryStatisticsReportWrapper.java | 6 ++--- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/com/engine/salary/report/service/SalaryStatisticsReportService.java b/src/com/engine/salary/report/service/SalaryStatisticsReportService.java index 88322266c..842317cf7 100644 --- a/src/com/engine/salary/report/service/SalaryStatisticsReportService.java +++ b/src/com/engine/salary/report/service/SalaryStatisticsReportService.java @@ -90,5 +90,5 @@ public interface SalaryStatisticsReportService { * @param salaryStatisticsItemPOS 自定义统计项目List * @return */ - List> buildDataPerspectiveRecords(SalaryStatisticsDataPerspectiveQueryParam param, SalaryStatisticsReportPO reportPO, SalaryStatisticsDimensionPO dimension, List salaryStatisticsItemPOS); + PageInfo> buildDataPerspectiveRecords(SalaryStatisticsDataPerspectiveQueryParam param, SalaryStatisticsReportPO reportPO, SalaryStatisticsDimensionPO dimension, List salaryStatisticsItemPOS); } diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java index dd14011cc..787062253 100644 --- a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java @@ -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> buildDataPerspectiveRecords(SalaryStatisticsDataPerspectiveQueryParam param, SalaryStatisticsReportPO reportPO, SalaryStatisticsDimensionPO dimension, List salaryStatisticsItemPOS) { + public PageInfo> buildDataPerspectiveRecords(SalaryStatisticsDataPerspectiveQueryParam param, SalaryStatisticsReportPO reportPO, SalaryStatisticsDimensionPO dimension, List salaryStatisticsItemPOS) { // 获取报表统计薪资项目 List 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 listByDimensionValue = salaryStatisticsReportData.getListByDimensionValue(); + if(CollectionUtils.isEmpty(listByDimensionValue)){ + throw new SalaryRunTimeException("该维度值中无数据!"); + } + // 同一个人放在一起 + listByDimensionValue = listByDimensionValue.stream().sorted(Comparator.comparing(SalaryAcctEmployeePO::getEmployeeId)).collect(Collectors.toList()); + PageInfo salaryAcctEmployeePOPageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), listByDimensionValue); // 构建核算结果数据 - return buildResultRecords(listByDimensionValue, map); + List> records = buildResultRecords(salaryAcctEmployeePOPageInfo.getList(), map); + PageInfo> 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> buildResultRecords(List listByDimensionValue, Map> map) { + // 获取人员信息 + Set employeeIds = listByDimensionValue.stream().map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toSet()); + List employeeList = getSalaryEmployeeService(user).listByIds(employeeIds.stream().collect(Collectors.toList())); + Map employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId); + List taxAgentList = getTaxAgentService(user).listAll(); Map 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())); diff --git a/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java b/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java index c48908c4e..26bd561e7 100644 --- a/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java +++ b/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java @@ -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 salaryItemIds = salaryStatisticsItemPOS.stream().filter(item -> StringUtils.isNotBlank(item.getItemValue())).map(p -> p.getItemValue().split(",")) .flatMap(Arrays::stream).map(Long::valueOf).collect(Collectors.toList()); - List> records = getSalaryStatisticsReportService(user).buildDataPerspectiveRecords(param, po, dimension, salaryStatisticsItemPOS); - PageInfo> pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), records); + PageInfo> pageInfo = getSalaryStatisticsReportService(user).buildDataPerspectiveRecords(param, po, dimension, salaryStatisticsItemPOS); List itemList = getSalaryItemService(user).listByIds(salaryItemIds); // 列表columns @@ -370,6 +368,8 @@ public class SalaryStatisticsReportWrapper extends Service { private List buildDataPerspectiveTableColumns(List salaryItems) { // 表格表头 List 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"));