From 87701c7229bbaa6d4b79f957c5de6d5c62feb8dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Thu, 13 Apr 2023 15:13:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SalaryStatisticsReportServiceImpl.java | 1230 +++++++++-------- 1 file changed, 620 insertions(+), 610 deletions(-) diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java index 4fce6de56..0c6b761c7 100644 --- a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java @@ -1,7 +1,9 @@ package com.engine.salary.report.service.impl; +import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; import com.engine.salary.entity.taxagent.po.TaxAgentPO; @@ -23,7 +25,9 @@ import com.engine.salary.report.service.SalaryStatisticsReportService; import com.engine.salary.report.util.ReportTimeUtil; import com.engine.salary.service.SalaryAcctEmployeeService; import com.engine.salary.service.SalaryAcctResultService; +import com.engine.salary.service.SalaryEmployeeService; import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; import com.engine.salary.util.JsonUtil; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryI18nUtil; @@ -35,6 +39,7 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; +import weaver.hrm.User; import java.util.*; import java.util.stream.Collectors; @@ -64,6 +69,10 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary private TaxAgentService taxAgentService; + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + // private ExtEmployeeService extEmployeeService; // @Autowired // private HrmCommonEmployeeService hrmCommonEmployeeService; @@ -435,53 +444,54 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary private PageInfo> buildSubComRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { PageInfo> result = new PageInfo<>(); -// List> records = new ArrayList<>(); -// -// List employeeIds = data.getList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); -// List lastEmployeeIds = data.getLastList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); -// List sameEmployeeIds = data.getSameList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); -// Map comInfoMap = hrmCommonEmployeeService.querySubcompanyInfoByEmployeeIds(employeeIds, data.getTenantKey()); -// Map lastComInfoMap = hrmCommonEmployeeService.querySubcompanyInfoByEmployeeIds(lastEmployeeIds, data.getTenantKey()); -// Map sameComInfoMap = hrmCommonEmployeeService.querySubcompanyInfoByEmployeeIds(sameEmployeeIds, data.getTenantKey()); -// -// Set subComIds = new HashSet<>(); -// Map empIdSubComMap = new HashMap<>(); -// Map subComIdNameMap = new HashMap<>(); -// Map lastEmpIdSubComMap = new HashMap<>(); -// Map sameEmpIdSubComMap = new HashMap<>(); -// comInfoMap.forEach((k, v) -> { -// subComIdNameMap.put(v.getId(), v.getName()); -// empIdSubComMap.put(k, v.getId()); -// subComIds.add(v.getId()); -// }); -// lastComInfoMap.forEach((k, v) -> { -// lastEmpIdSubComMap.put(k, v.getId()); -// }); -// sameComInfoMap.forEach((k, v) -> { -// sameEmpIdSubComMap.put(k, v.getId()); -// }); -// -// subComIds.forEach(subComId -> { -// List subComEmployeePOS = data.getList().stream().filter(po -> Objects.equals(empIdSubComMap.get(po.getEmployeeId()), subComId)).collect(Collectors.toList()); -// List lastSubComEmployeePOS = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdSubComMap.get(po.getEmployeeId()), subComId)).collect(Collectors.toList()); -// List sameSubComEmployeePOS = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdSubComMap.get(po.getEmployeeId()), subComId)).collect(Collectors.toList()); -// Map temp = new HashMap<>(); -// temp.put(DM, subComIdNameMap.get(subComId)); -// temp.putAll(SalaryStatisticsReportBO.calculateItem(subComEmployeePOS, lastSubComEmployeePOS, sameSubComEmployeePOS, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(temp); -// }); -// -// List noGroupingList = data.getList().stream().filter(po -> empIdSubComMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdSubComMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdSubComMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// if (CollectionUtils.isNotEmpty(noGroupingList)) { -// Map noGrouping = new HashMap<>(); -// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); -// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(noGrouping); -// } -// -// result.setList(records); + List> records = new ArrayList<>(); + + List employeeIds = data.getList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + List lastEmployeeIds = data.getLastList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + List sameEmployeeIds = data.getSameList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + + Map comInfoMap = hrmCommonEmployeeService.querySubcompanyInfoByEmployeeIds(employeeIds, data.getTenantKey()); + Map lastComInfoMap = hrmCommonEmployeeService.querySubcompanyInfoByEmployeeIds(lastEmployeeIds, data.getTenantKey()); + Map sameComInfoMap = hrmCommonEmployeeService.querySubcompanyInfoByEmployeeIds(sameEmployeeIds, data.getTenantKey()); + + Set subComIds = new HashSet<>(); + Map empIdSubComMap = new HashMap<>(); + Map subComIdNameMap = new HashMap<>(); + Map lastEmpIdSubComMap = new HashMap<>(); + Map sameEmpIdSubComMap = new HashMap<>(); + comInfoMap.forEach((k, v) -> { + subComIdNameMap.put(v.getId(), v.getName()); + empIdSubComMap.put(k, v.getId()); + subComIds.add(v.getId()); + }); + lastComInfoMap.forEach((k, v) -> { + lastEmpIdSubComMap.put(k, v.getId()); + }); + sameComInfoMap.forEach((k, v) -> { + sameEmpIdSubComMap.put(k, v.getId()); + }); + + subComIds.forEach(subComId -> { + List subComEmployeePOS = data.getList().stream().filter(po -> Objects.equals(empIdSubComMap.get(po.getEmployeeId()), subComId)).collect(Collectors.toList()); + List lastSubComEmployeePOS = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdSubComMap.get(po.getEmployeeId()), subComId)).collect(Collectors.toList()); + List sameSubComEmployeePOS = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdSubComMap.get(po.getEmployeeId()), subComId)).collect(Collectors.toList()); + Map temp = new HashMap<>(); + temp.put(DM, subComIdNameMap.get(subComId)); + temp.putAll(SalaryStatisticsReportBO.calculateItem(subComEmployeePOS, lastSubComEmployeePOS, sameSubComEmployeePOS, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + }); + + List noGroupingList = data.getList().stream().filter(po -> empIdSubComMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdSubComMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdSubComMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(noGroupingList)) { + Map noGrouping = new HashMap<>(); + noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); + noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(noGrouping); + } + + result.setList(records); return result; } @@ -1065,569 +1075,569 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary return result; } -// private Map> getSimpleUserInfoList(SalaryStatisticsReportDataDTO data) { -// List employeeIds = data.getList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); -// List lastEmployeeIds = data.getLastList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); -// List sameEmployeeIds = data.getSameList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); -// -// List simpleUserInfoList; -// List lastSimpleUserInfoList; -// List sameSimpleUserInfoList; -// Map> map = Maps.newHashMap(); -// try { -// simpleUserInfoList = CollectionUtils.isEmpty(employeeIds) ? Lists.newArrayList() : remoteUserInfoService.querySimpleUserInfoByUserIds(employeeIds, data.getTenantKey()); -// lastSimpleUserInfoList = CollectionUtils.isEmpty(lastEmployeeIds) ? Lists.newArrayList() : remoteUserInfoService.querySimpleUserInfoByUserIds(lastEmployeeIds, data.getTenantKey()); -// sameSimpleUserInfoList = CollectionUtils.isEmpty(sameEmployeeIds) ? Lists.newArrayList() : remoteUserInfoService.querySimpleUserInfoByUserIds(sameEmployeeIds, data.getTenantKey()); -// } catch (Exception e) { -// log.info("获取员工个人信息失败: {}", e.getMessage()); -// return map; -// } -// map.put(NOW_INFO, simpleUserInfoList); -// map.put(LAST_INFO, lastSimpleUserInfoList); -// map.put(SAME_INFO, sameSimpleUserInfoList); -// return map; -// } -// -// private PageInfo> buildEducationRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { -// PageInfo> result = new PageInfo<>(); -// List> records = new ArrayList<>(); -// Map> simpleUserInfoMap = getSimpleUserInfoList(data); -// if (simpleUserInfoMap.isEmpty()) { -// return result; -// } -// -// Set educationIds = new HashSet<>(); -// Map educationMap = Maps.newHashMap(); -// -// Map empIdEducationMap = new HashMap<>(); -// Map lastEmpIdEducationMap = new HashMap<>(); -// Map sameEmpIdEducationMap = new HashMap<>(); -// simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { -// if (employee.getEducation() != null && employee.getEducation().getId() != null) { -// educationIds.add(employee.getEducation().getId()); -// empIdEducationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getEducation().getId()); -// educationMap.put(employee.getEducation().getId(), employee.getEducation().getName()); -// } -// }); -// simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { -// if (employee.getEducation() != null && employee.getEducation().getId() != null) { -// lastEmpIdEducationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getEducation().getId()); -// educationMap.put(employee.getEducation().getId(), employee.getEducation().getName()); -// } -// }); -// simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { -// if (employee.getEducation() != null && employee.getEducation().getId() != null) { -// sameEmpIdEducationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getEducation().getId()); -// educationMap.put(employee.getEducation().getId(), employee.getEducation().getName()); -// } -// }); -// -// educationIds.forEach(k -> { -// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdEducationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdEducationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdEducationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// Map temp = new HashMap<>(); -// temp.put(DM, educationMap.get(k)); -// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(temp); -// }); -// -// List noGroupingList = data.getList().stream().filter(po -> empIdEducationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdEducationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdEducationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// if (CollectionUtils.isNotEmpty(noGroupingList)) { -// Map noGrouping = new HashMap<>(); -// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); -// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(noGrouping); -// } -// -// result.setList(records); -// return result; -// } -// -// private PageInfo> buildDegreeRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { -// PageInfo> result = new PageInfo<>(); -// List> records = new ArrayList<>(); -// Map> simpleUserInfoMap = getSimpleUserInfoList(data); -// if (simpleUserInfoMap.isEmpty()) { -// return result; -// } -// -// Set degreeIds = new HashSet<>(); -// Map degreeMap = Maps.newHashMap(); -// -// Map empIdDegreeMap = new HashMap<>(); -// Map lastEmpIdDegreeMap = new HashMap<>(); -// Map sameEmpIdDegreeMap = new HashMap<>(); -// simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { -// if (employee.getDegree() != null && employee.getDegree().getId() != null) { -// degreeIds.add(employee.getDegree().getId()); -// empIdDegreeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getDegree().getId()); -// degreeMap.put(employee.getDegree().getId(), employee.getDegree().getName()); -// } -// }); -// simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { -// if (employee.getDegree() != null && employee.getDegree().getId() != null) { -// lastEmpIdDegreeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getDegree().getId()); -// degreeMap.put(employee.getDegree().getId(), employee.getDegree().getName()); -// } -// }); -// simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { -// if (employee.getDegree() != null && employee.getDegree().getId() != null) { -// sameEmpIdDegreeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getDegree().getId()); -// degreeMap.put(employee.getDegree().getId(), employee.getDegree().getName()); -// } -// }); -// -// degreeIds.forEach(k -> { -// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdDegreeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdDegreeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdDegreeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// Map temp = new HashMap<>(); -// temp.put(DM, degreeMap.get(k)); -// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(temp); -// }); -// -// List noGroupingList = data.getList().stream().filter(po -> empIdDegreeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdDegreeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdDegreeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// if (CollectionUtils.isNotEmpty(noGroupingList)) { -// Map noGrouping = new HashMap<>(); -// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); -// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(noGrouping); -// } -// -// result.setList(records); -// return result; -// } -// -// private PageInfo> buildNationRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { -// PageInfo> result = new PageInfo<>(); -// List> records = new ArrayList<>(); -// Map> simpleUserInfoMap = getSimpleUserInfoList(data); -// if (simpleUserInfoMap.isEmpty()) { -// return result; -// } -// -// Set nationIds = new HashSet<>(); -// Map nationMap = Maps.newHashMap(); -// -// Map empIdNationMap = new HashMap<>(); -// Map lastEmpIdNationMap = new HashMap<>(); -// Map sameEmpIdNationMap = new HashMap<>(); -// simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { -// if (employee.getNation() != null && employee.getNation().getId() != null) { -// nationIds.add(employee.getNation().getId()); -// empIdNationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getNation().getId()); -// nationMap.put(employee.getNation().getId(), employee.getNation().getName()); -// } -// }); -// simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { -// if (employee.getNation() != null && employee.getNation().getId() != null) { -// lastEmpIdNationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getNation().getId()); -// nationMap.put(employee.getNation().getId(), employee.getNation().getName()); -// } -// }); -// simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { -// if (employee.getNation() != null && employee.getNation().getId() != null) { -// sameEmpIdNationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getNation().getId()); -// nationMap.put(employee.getNation().getId(), employee.getNation().getName()); -// } -// }); -// -// nationIds.forEach(k -> { -// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdNationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdNationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdNationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// Map temp = new HashMap<>(); -// temp.put(DM, nationMap.get(k)); -// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(temp); -// }); -// -// List noGroupingList = data.getList().stream().filter(po -> empIdNationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdNationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdNationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// if (CollectionUtils.isNotEmpty(noGroupingList)) { -// Map noGrouping = new HashMap<>(); -// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); -// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(noGrouping); -// } -// -// result.setList(records); -// return result; -// } -// -// private PageInfo> buildHouseholdTypeRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { -// PageInfo> result = new PageInfo<>(); -// List> records = new ArrayList<>(); -// Map> simpleUserInfoMap = getSimpleUserInfoList(data); -// if (simpleUserInfoMap.isEmpty()) { -// return result; -// } -// -// Set householdTypeIds = new HashSet<>(); -// Map householdTypeMap = Maps.newHashMap(); -// -// Map empIdHouseholdTypeMap = new HashMap<>(); -// Map lastEmpIdHouseholdTypeMap = new HashMap<>(); -// Map sameEmpIdHouseholdTypeMap = new HashMap<>(); -// simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { -// if (employee.getHouseholdType() != null && employee.getHouseholdType().getId() != null) { -// householdTypeIds.add(employee.getHouseholdType().getId()); -// empIdHouseholdTypeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getHouseholdType().getId()); -// householdTypeMap.put(employee.getHouseholdType().getId(), employee.getHouseholdType().getName()); -// } -// }); -// simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { -// if (employee.getHouseholdType() != null && employee.getHouseholdType().getId() != null) { -// lastEmpIdHouseholdTypeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getHouseholdType().getId()); -// householdTypeMap.put(employee.getHouseholdType().getId(), employee.getHouseholdType().getName()); -// } -// }); -// simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { -// if (employee.getHouseholdType() != null && employee.getHouseholdType().getId() != null) { -// sameEmpIdHouseholdTypeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getHouseholdType().getId()); -// householdTypeMap.put(employee.getHouseholdType().getId(), employee.getHouseholdType().getName()); -// } -// }); -// -// householdTypeIds.forEach(k -> { -// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdHouseholdTypeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdHouseholdTypeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdHouseholdTypeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// Map temp = new HashMap<>(); -// temp.put(DM, householdTypeMap.get(k)); -// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(temp); -// }); -// -// List noGroupingList = data.getList().stream().filter(po -> empIdHouseholdTypeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdHouseholdTypeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdHouseholdTypeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// if (CollectionUtils.isNotEmpty(noGroupingList)) { -// Map noGrouping = new HashMap<>(); -// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); -// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(noGrouping); -// } -// -// result.setList(records); -// return result; -// } -// -// private PageInfo> buildPoliticsStatusRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { -// PageInfo> result = new PageInfo<>(); -// List> records = new ArrayList<>(); -// Map> simpleUserInfoMap = getSimpleUserInfoList(data); -// if (simpleUserInfoMap.isEmpty()) { -// return result; -// } -// -// Set politicsStatusIds = new HashSet<>(); -// Map politicsStatusMap = Maps.newHashMap(); -// -// Map empIdPoliticsStatusMap = new HashMap<>(); -// Map lastEmpIdPoliticsStatusMap = new HashMap<>(); -// Map sameEmpIdPoliticsStatusMap = new HashMap<>(); -// simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { -// if (employee.getPoliticsStatus() != null && employee.getPoliticsStatus().getId() != null) { -// politicsStatusIds.add(employee.getPoliticsStatus().getId()); -// empIdPoliticsStatusMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getPoliticsStatus().getId()); -// politicsStatusMap.put(employee.getPoliticsStatus().getId(), employee.getPoliticsStatus().getName()); -// } -// }); -// simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { -// if (employee.getPoliticsStatus() != null && employee.getPoliticsStatus().getId() != null) { -// lastEmpIdPoliticsStatusMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getPoliticsStatus().getId()); -// politicsStatusMap.put(employee.getPoliticsStatus().getId(), employee.getPoliticsStatus().getName()); -// } -// }); -// simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { -// if (employee.getPoliticsStatus() != null && employee.getPoliticsStatus().getId() != null) { -// sameEmpIdPoliticsStatusMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getPoliticsStatus().getId()); -// politicsStatusMap.put(employee.getPoliticsStatus().getId(), employee.getPoliticsStatus().getName()); -// } -// }); -// -// politicsStatusIds.forEach(k -> { -// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdPoliticsStatusMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdPoliticsStatusMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdPoliticsStatusMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// Map temp = new HashMap<>(); -// temp.put(DM, politicsStatusMap.get(k)); -// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(temp); -// }); -// -// List noGroupingList = data.getList().stream().filter(po -> empIdPoliticsStatusMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdPoliticsStatusMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdPoliticsStatusMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// if (CollectionUtils.isNotEmpty(noGroupingList)) { -// Map noGrouping = new HashMap<>(); -// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); -// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(noGrouping); -// } -// -// result.setList(records); -// return result; -// } -// -// private PageInfo> buildAgeRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { -// PageInfo> result = new PageInfo<>(); -// List> records = new ArrayList<>(); -// Map> simpleUserInfoMap = getSimpleUserInfoList(data); -// if (simpleUserInfoMap.isEmpty()) { -// return result; -// } -// -// Set ageSet = new HashSet<>(); -// -// Map empIdAgeMap = new HashMap<>(); -// Map lastEmpIdAgeMap = new HashMap<>(); -// Map sameEmpIdAgeMap = new HashMap<>(); -// simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { -// if (employee.getAge() != null) { -// ageSet.add(employee.getAge()); -// empIdAgeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge()); -// } -// }); -// simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { -// if (employee.getAge() != null) { -// lastEmpIdAgeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge()); -// } -// }); -// simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { -// if (employee.getAge() != null) { -// sameEmpIdAgeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge()); -// } -// }); -// -// List ages = Lists.newArrayList(ageSet); -// ages = ages.stream().sorted().collect(Collectors.toList()); -// -// ages.forEach(k -> { -// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdAgeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdAgeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdAgeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// Map temp = new HashMap<>(); -// temp.put(DM, k); -// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(temp); -// }); -// -// List noGroupingList = data.getList().stream().filter(po -> empIdAgeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdAgeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List sameNoGroupingList = data.getSameList().stream().filter(po -> lastEmpIdAgeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// if (CollectionUtils.isNotEmpty(noGroupingList)) { -// Map noGrouping = new HashMap<>(); -// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); -// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(noGrouping); -// } -// -// result.setList(records); -// return result; -// } -// -// private PageInfo> buildWorkYearRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { -// PageInfo> result = new PageInfo<>(); -// List> records = new ArrayList<>(); -// Map> simpleUserInfoMap = getSimpleUserInfoList(data); -// if (simpleUserInfoMap.isEmpty()) { -// return result; -// } -// -// Set workYearSet = new HashSet<>(); -// -// Map empIdWorkYearMap = new HashMap<>(); -// Map lastEmpIdWorkYearMap = new HashMap<>(); -// Map sameEmpIdWorkYearMap = new HashMap<>(); -// simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { -// if (employee.getWorkYear() != null) { -// workYearSet.add(employee.getWorkYear()); -// empIdWorkYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getWorkYear()); -// } -// }); -// simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { -// if (employee.getWorkYear() != null) { -// lastEmpIdWorkYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getWorkYear()); -// } -// }); -// simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { -// if (employee.getWorkYear() != null) { -// sameEmpIdWorkYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getWorkYear()); -// } -// }); -// List workYears = Lists.newArrayList(workYearSet); -// workYears = workYears.stream().sorted().collect(Collectors.toList()); -// -// workYears.forEach(k -> { -// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdWorkYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdWorkYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdWorkYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// Map temp = new HashMap<>(); -// temp.put(DM, k); -// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(temp); -// }); -// -// List noGroupingList = data.getList().stream().filter(po -> empIdWorkYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdWorkYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List sameNoGroupingList = data.getSameList().stream().filter(po -> lastEmpIdWorkYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// if (CollectionUtils.isNotEmpty(noGroupingList)) { -// Map noGrouping = new HashMap<>(); -// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); -// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(noGrouping); -// } -// -// result.setList(records); -// return result; -// } -// -// private PageInfo> buildCompanyYearRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { -// PageInfo> result = new PageInfo<>(); -// List> records = new ArrayList<>(); -// Map> simpleUserInfoMap = getSimpleUserInfoList(data); -// if (simpleUserInfoMap.isEmpty()) { -// return result; -// } -// -// Set companyYearSet = new HashSet<>(); -// -// Map empIdCompanyYearMap = new HashMap<>(); -// Map lastEmpIdCompanyYearMap = new HashMap<>(); -// Map sameEmpIdCompanyYearMap = new HashMap<>(); -// simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { -// if (StringUtils.isNotEmpty(employee.getCompanyYear())) { -// companyYearSet.add(employee.getCompanyYear()); -// empIdCompanyYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getCompanyYear()); -// } -// }); -// simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { -// if (StringUtils.isNotEmpty(employee.getCompanyYear())) { -// lastEmpIdCompanyYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getCompanyYear()); -// } -// }); -// simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { -// if (StringUtils.isNotEmpty(employee.getCompanyYear())) { -// sameEmpIdCompanyYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getCompanyYear()); -// } -// }); -// -// List companyYears = Lists.newArrayList(companyYearSet); -// companyYears = companyYears.stream().sorted().collect(Collectors.toList()); -// -// companyYears.forEach(k -> { -// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdCompanyYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdCompanyYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdCompanyYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); -// Map temp = new HashMap<>(); -// temp.put(DM, k); -// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(temp); -// }); -// -// List noGroupingList = data.getList().stream().filter(po -> empIdCompanyYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdCompanyYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdCompanyYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); -// if (CollectionUtils.isNotEmpty(noGroupingList)) { -// Map noGrouping = new HashMap<>(); -// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组"); -// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(noGrouping); -// } -// -// result.setList(records); -// return result; -// } -// -// private PageInfo> buildRationGroupSpacing4NoItemRecords(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { -// PageInfo> result = new PageInfo<>(); -// List> records = new ArrayList<>(); -// -// // 分组设置 -// List groups = JsonUtil.parseList(dimension.getSetting(), SalaryStatisticsDimensionSaveParam.Setting4RationGroupSpacing.class); -// -// -// result.setList(records); -// return result; -// } -// -// private PageInfo> buildRationGroupSpacing4Records(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { -// PageInfo> result = new PageInfo<>(); -// List> records = new ArrayList<>(); -// -// // 分组设置 -// List groups = JsonUtil.parseList(dimension.getSetting(), SalaryStatisticsDimensionSaveParam.Setting4RationGroupSpacing.class); -// -// Map empIdYearMap = new HashMap<>(); -// Map lastEmpIdYearMap = new HashMap<>(); -// Map sameEmpIdYearMap = new HashMap<>(); -// -// String groupBelong; -// if (StringUtils.isEmpty(dimension.getDimCode())) { -// groupBelong = SalaryStatisticsReportBO.G_NO_ITEM; -// } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_AGE) || dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_WORK_YEAR) || dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_COMPANY_YEAR)) { -// groupBelong = SalaryStatisticsReportBO.G_YEAR; -// // 年份数据 -// handle4GroupYear(dimension, empIdYearMap, lastEmpIdYearMap, sameEmpIdYearMap, data); -// } else { -// groupBelong = SalaryStatisticsReportBO.G_ITEM; -// } -// groups.forEach(k -> { -// List salaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupSpacing(k, groupBelong, dimension.getDimCode(), data.getList(), empIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); -// List lastSalaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupSpacing(k, groupBelong, dimension.getDimCode(), data.getLastList(), lastEmpIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); -// List sameSalaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupSpacing(k, groupBelong, dimension.getDimCode(), data.getSameList(), sameEmpIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); -// Map temp = new HashMap<>(); -// temp.put(DM, k.getStartValue() + "-" + k.getEndValue()); -// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); -// records.add(temp); -// }); -// -// result.setList(records); -// return result; -// } -// -// private void handle4GroupYear(SalaryStatisticsDimensionPO dimension, Map empIdYearMap, Map lastEmpIdYearMap, Map sameEmpIdYearMap, SalaryStatisticsReportDataDTO data) { -// Map> simpleUserInfoMap = getSimpleUserInfoList(data); -// if (simpleUserInfoMap.isEmpty()) { -// return; -// } -// simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { -// if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_AGE) && employee.getAge() != null) { -// empIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge().toString()); -// } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_WORK_YEAR) && employee.getWorkYear() != null) { -// empIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getWorkYear().toString()); -// } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_COMPANY_YEAR) && StringUtils.isNotEmpty(employee.getCompanyYear())) { -// empIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getCompanyYear()); -// } -// }); -// simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { -// if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_AGE) && employee.getAge() != null) { -// lastEmpIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge().toString()); -// } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_WORK_YEAR) && employee.getWorkYear() != null) { -// lastEmpIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getWorkYear().toString()); -// } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_COMPANY_YEAR) && StringUtils.isNotEmpty(employee.getCompanyYear())) { -// lastEmpIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getCompanyYear()); -// } -// }); -// simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { -// if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_AGE) && employee.getAge() != null) { -// sameEmpIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge().toString()); -// } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_WORK_YEAR) && employee.getWorkYear() != null) { -// sameEmpIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getWorkYear().toString()); -// } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_COMPANY_YEAR) && StringUtils.isNotEmpty(employee.getCompanyYear())) { -// sameEmpIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getCompanyYear()); -// } -// }); -// } + private Map> getSimpleUserInfoList(SalaryStatisticsReportDataDTO data) { + List employeeIds = data.getList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + List lastEmployeeIds = data.getLastList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + List sameEmployeeIds = data.getSameList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + + List simpleUserInfoList; + List lastSimpleUserInfoList; + List sameSimpleUserInfoList; + Map> map = Maps.newHashMap(); + try { + simpleUserInfoList = CollectionUtils.isEmpty(employeeIds) ? Lists.newArrayList() : remoteUserInfoService.querySimpleUserInfoByUserIds(employeeIds, data.getTenantKey()); + lastSimpleUserInfoList = CollectionUtils.isEmpty(lastEmployeeIds) ? Lists.newArrayList() : remoteUserInfoService.querySimpleUserInfoByUserIds(lastEmployeeIds, data.getTenantKey()); + sameSimpleUserInfoList = CollectionUtils.isEmpty(sameEmployeeIds) ? Lists.newArrayList() : remoteUserInfoService.querySimpleUserInfoByUserIds(sameEmployeeIds, data.getTenantKey()); + } catch (Exception e) { + log.info("获取员工个人信息失败: {}", e.getMessage()); + return map; + } + map.put(NOW_INFO, simpleUserInfoList); + map.put(LAST_INFO, lastSimpleUserInfoList); + map.put(SAME_INFO, sameSimpleUserInfoList); + return map; + } + + private PageInfo> buildEducationRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + Map> simpleUserInfoMap = getSimpleUserInfoList(data); + if (simpleUserInfoMap.isEmpty()) { + return result; + } + + Set educationIds = new HashSet<>(); + Map educationMap = Maps.newHashMap(); + + Map empIdEducationMap = new HashMap<>(); + Map lastEmpIdEducationMap = new HashMap<>(); + Map sameEmpIdEducationMap = new HashMap<>(); + simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { + if (employee.getEducation() != null && employee.getEducation().getId() != null) { + educationIds.add(employee.getEducation().getId()); + empIdEducationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getEducation().getId()); + educationMap.put(employee.getEducation().getId(), employee.getEducation().getName()); + } + }); + simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { + if (employee.getEducation() != null && employee.getEducation().getId() != null) { + lastEmpIdEducationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getEducation().getId()); + educationMap.put(employee.getEducation().getId(), employee.getEducation().getName()); + } + }); + simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { + if (employee.getEducation() != null && employee.getEducation().getId() != null) { + sameEmpIdEducationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getEducation().getId()); + educationMap.put(employee.getEducation().getId(), employee.getEducation().getName()); + } + }); + + educationIds.forEach(k -> { + List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdEducationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdEducationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdEducationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + Map temp = new HashMap<>(); + temp.put(DM, educationMap.get(k)); + temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + }); + + List noGroupingList = data.getList().stream().filter(po -> empIdEducationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdEducationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdEducationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(noGroupingList)) { + Map noGrouping = new HashMap<>(); + noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); + noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(noGrouping); + } + + result.setList(records); + return result; + } + + private PageInfo> buildDegreeRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + Map> simpleUserInfoMap = getSimpleUserInfoList(data); + if (simpleUserInfoMap.isEmpty()) { + return result; + } + + Set degreeIds = new HashSet<>(); + Map degreeMap = Maps.newHashMap(); + + Map empIdDegreeMap = new HashMap<>(); + Map lastEmpIdDegreeMap = new HashMap<>(); + Map sameEmpIdDegreeMap = new HashMap<>(); + simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { + if (employee.getDegree() != null && employee.getDegree().getId() != null) { + degreeIds.add(employee.getDegree().getId()); + empIdDegreeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getDegree().getId()); + degreeMap.put(employee.getDegree().getId(), employee.getDegree().getName()); + } + }); + simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { + if (employee.getDegree() != null && employee.getDegree().getId() != null) { + lastEmpIdDegreeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getDegree().getId()); + degreeMap.put(employee.getDegree().getId(), employee.getDegree().getName()); + } + }); + simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { + if (employee.getDegree() != null && employee.getDegree().getId() != null) { + sameEmpIdDegreeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getDegree().getId()); + degreeMap.put(employee.getDegree().getId(), employee.getDegree().getName()); + } + }); + + degreeIds.forEach(k -> { + List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdDegreeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdDegreeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdDegreeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + Map temp = new HashMap<>(); + temp.put(DM, degreeMap.get(k)); + temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + }); + + List noGroupingList = data.getList().stream().filter(po -> empIdDegreeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdDegreeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdDegreeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(noGroupingList)) { + Map noGrouping = new HashMap<>(); + noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); + noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(noGrouping); + } + + result.setList(records); + return result; + } + + private PageInfo> buildNationRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + Map> simpleUserInfoMap = getSimpleUserInfoList(data); + if (simpleUserInfoMap.isEmpty()) { + return result; + } + + Set nationIds = new HashSet<>(); + Map nationMap = Maps.newHashMap(); + + Map empIdNationMap = new HashMap<>(); + Map lastEmpIdNationMap = new HashMap<>(); + Map sameEmpIdNationMap = new HashMap<>(); + simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { + if (employee.getNation() != null && employee.getNation().getId() != null) { + nationIds.add(employee.getNation().getId()); + empIdNationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getNation().getId()); + nationMap.put(employee.getNation().getId(), employee.getNation().getName()); + } + }); + simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { + if (employee.getNation() != null && employee.getNation().getId() != null) { + lastEmpIdNationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getNation().getId()); + nationMap.put(employee.getNation().getId(), employee.getNation().getName()); + } + }); + simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { + if (employee.getNation() != null && employee.getNation().getId() != null) { + sameEmpIdNationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getNation().getId()); + nationMap.put(employee.getNation().getId(), employee.getNation().getName()); + } + }); + + nationIds.forEach(k -> { + List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdNationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdNationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdNationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + Map temp = new HashMap<>(); + temp.put(DM, nationMap.get(k)); + temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + }); + + List noGroupingList = data.getList().stream().filter(po -> empIdNationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdNationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdNationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(noGroupingList)) { + Map noGrouping = new HashMap<>(); + noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); + noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(noGrouping); + } + + result.setList(records); + return result; + } + + private PageInfo> buildHouseholdTypeRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + Map> simpleUserInfoMap = getSimpleUserInfoList(data); + if (simpleUserInfoMap.isEmpty()) { + return result; + } + + Set householdTypeIds = new HashSet<>(); + Map householdTypeMap = Maps.newHashMap(); + + Map empIdHouseholdTypeMap = new HashMap<>(); + Map lastEmpIdHouseholdTypeMap = new HashMap<>(); + Map sameEmpIdHouseholdTypeMap = new HashMap<>(); + simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { + if (employee.getHouseholdType() != null && employee.getHouseholdType().getId() != null) { + householdTypeIds.add(employee.getHouseholdType().getId()); + empIdHouseholdTypeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getHouseholdType().getId()); + householdTypeMap.put(employee.getHouseholdType().getId(), employee.getHouseholdType().getName()); + } + }); + simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { + if (employee.getHouseholdType() != null && employee.getHouseholdType().getId() != null) { + lastEmpIdHouseholdTypeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getHouseholdType().getId()); + householdTypeMap.put(employee.getHouseholdType().getId(), employee.getHouseholdType().getName()); + } + }); + simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { + if (employee.getHouseholdType() != null && employee.getHouseholdType().getId() != null) { + sameEmpIdHouseholdTypeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getHouseholdType().getId()); + householdTypeMap.put(employee.getHouseholdType().getId(), employee.getHouseholdType().getName()); + } + }); + + householdTypeIds.forEach(k -> { + List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdHouseholdTypeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdHouseholdTypeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdHouseholdTypeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + Map temp = new HashMap<>(); + temp.put(DM, householdTypeMap.get(k)); + temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + }); + + List noGroupingList = data.getList().stream().filter(po -> empIdHouseholdTypeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdHouseholdTypeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdHouseholdTypeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(noGroupingList)) { + Map noGrouping = new HashMap<>(); + noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); + noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(noGrouping); + } + + result.setList(records); + return result; + } + + private PageInfo> buildPoliticsStatusRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + Map> simpleUserInfoMap = getSimpleUserInfoList(data); + if (simpleUserInfoMap.isEmpty()) { + return result; + } + + Set politicsStatusIds = new HashSet<>(); + Map politicsStatusMap = Maps.newHashMap(); + + Map empIdPoliticsStatusMap = new HashMap<>(); + Map lastEmpIdPoliticsStatusMap = new HashMap<>(); + Map sameEmpIdPoliticsStatusMap = new HashMap<>(); + simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { + if (employee.getPoliticsStatus() != null && employee.getPoliticsStatus().getId() != null) { + politicsStatusIds.add(employee.getPoliticsStatus().getId()); + empIdPoliticsStatusMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getPoliticsStatus().getId()); + politicsStatusMap.put(employee.getPoliticsStatus().getId(), employee.getPoliticsStatus().getName()); + } + }); + simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { + if (employee.getPoliticsStatus() != null && employee.getPoliticsStatus().getId() != null) { + lastEmpIdPoliticsStatusMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getPoliticsStatus().getId()); + politicsStatusMap.put(employee.getPoliticsStatus().getId(), employee.getPoliticsStatus().getName()); + } + }); + simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { + if (employee.getPoliticsStatus() != null && employee.getPoliticsStatus().getId() != null) { + sameEmpIdPoliticsStatusMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getPoliticsStatus().getId()); + politicsStatusMap.put(employee.getPoliticsStatus().getId(), employee.getPoliticsStatus().getName()); + } + }); + + politicsStatusIds.forEach(k -> { + List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdPoliticsStatusMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdPoliticsStatusMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdPoliticsStatusMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + Map temp = new HashMap<>(); + temp.put(DM, politicsStatusMap.get(k)); + temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + }); + + List noGroupingList = data.getList().stream().filter(po -> empIdPoliticsStatusMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdPoliticsStatusMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdPoliticsStatusMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(noGroupingList)) { + Map noGrouping = new HashMap<>(); + noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); + noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(noGrouping); + } + + result.setList(records); + return result; + } + + private PageInfo> buildAgeRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + Map> simpleUserInfoMap = getSimpleUserInfoList(data); + if (simpleUserInfoMap.isEmpty()) { + return result; + } + + Set ageSet = new HashSet<>(); + + Map empIdAgeMap = new HashMap<>(); + Map lastEmpIdAgeMap = new HashMap<>(); + Map sameEmpIdAgeMap = new HashMap<>(); + simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { + if (employee.getAge() != null) { + ageSet.add(employee.getAge()); + empIdAgeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge()); + } + }); + simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { + if (employee.getAge() != null) { + lastEmpIdAgeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge()); + } + }); + simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { + if (employee.getAge() != null) { + sameEmpIdAgeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge()); + } + }); + + List ages = Lists.newArrayList(ageSet); + ages = ages.stream().sorted().collect(Collectors.toList()); + + ages.forEach(k -> { + List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdAgeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdAgeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdAgeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + Map temp = new HashMap<>(); + temp.put(DM, k); + temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + }); + + List noGroupingList = data.getList().stream().filter(po -> empIdAgeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdAgeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List sameNoGroupingList = data.getSameList().stream().filter(po -> lastEmpIdAgeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(noGroupingList)) { + Map noGrouping = new HashMap<>(); + noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); + noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(noGrouping); + } + + result.setList(records); + return result; + } + + private PageInfo> buildWorkYearRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + Map> simpleUserInfoMap = getSimpleUserInfoList(data); + if (simpleUserInfoMap.isEmpty()) { + return result; + } + + Set workYearSet = new HashSet<>(); + + Map empIdWorkYearMap = new HashMap<>(); + Map lastEmpIdWorkYearMap = new HashMap<>(); + Map sameEmpIdWorkYearMap = new HashMap<>(); + simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { + if (employee.getWorkYear() != null) { + workYearSet.add(employee.getWorkYear()); + empIdWorkYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getWorkYear()); + } + }); + simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { + if (employee.getWorkYear() != null) { + lastEmpIdWorkYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getWorkYear()); + } + }); + simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { + if (employee.getWorkYear() != null) { + sameEmpIdWorkYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getWorkYear()); + } + }); + List workYears = Lists.newArrayList(workYearSet); + workYears = workYears.stream().sorted().collect(Collectors.toList()); + + workYears.forEach(k -> { + List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdWorkYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdWorkYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdWorkYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + Map temp = new HashMap<>(); + temp.put(DM, k); + temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + }); + + List noGroupingList = data.getList().stream().filter(po -> empIdWorkYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdWorkYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List sameNoGroupingList = data.getSameList().stream().filter(po -> lastEmpIdWorkYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(noGroupingList)) { + Map noGrouping = new HashMap<>(); + noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); + noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(noGrouping); + } + + result.setList(records); + return result; + } + + private PageInfo> buildCompanyYearRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + Map> simpleUserInfoMap = getSimpleUserInfoList(data); + if (simpleUserInfoMap.isEmpty()) { + return result; + } + + Set companyYearSet = new HashSet<>(); + + Map empIdCompanyYearMap = new HashMap<>(); + Map lastEmpIdCompanyYearMap = new HashMap<>(); + Map sameEmpIdCompanyYearMap = new HashMap<>(); + simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { + if (StringUtils.isNotEmpty(employee.getCompanyYear())) { + companyYearSet.add(employee.getCompanyYear()); + empIdCompanyYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getCompanyYear()); + } + }); + simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { + if (StringUtils.isNotEmpty(employee.getCompanyYear())) { + lastEmpIdCompanyYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getCompanyYear()); + } + }); + simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { + if (StringUtils.isNotEmpty(employee.getCompanyYear())) { + sameEmpIdCompanyYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getCompanyYear()); + } + }); + + List companyYears = Lists.newArrayList(companyYearSet); + companyYears = companyYears.stream().sorted().collect(Collectors.toList()); + + companyYears.forEach(k -> { + List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdCompanyYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdCompanyYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdCompanyYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + Map temp = new HashMap<>(); + temp.put(DM, k); + temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + }); + + List noGroupingList = data.getList().stream().filter(po -> empIdCompanyYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdCompanyYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdCompanyYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(noGroupingList)) { + Map noGrouping = new HashMap<>(); + noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组"); + noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(noGrouping); + } + + result.setList(records); + return result; + } + + private PageInfo> buildRationGroupSpacing4NoItemRecords(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + + // 分组设置 + List groups = JsonUtil.parseList(dimension.getSetting(), SalaryStatisticsDimensionSaveParam.Setting4RationGroupSpacing.class); + + + result.setList(records); + return result; + } + + private PageInfo> buildRationGroupSpacing4Records(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + + // 分组设置 + List groups = JsonUtil.parseList(dimension.getSetting(), SalaryStatisticsDimensionSaveParam.Setting4RationGroupSpacing.class); + + Map empIdYearMap = new HashMap<>(); + Map lastEmpIdYearMap = new HashMap<>(); + Map sameEmpIdYearMap = new HashMap<>(); + + String groupBelong; + if (StringUtils.isEmpty(dimension.getDimCode())) { + groupBelong = SalaryStatisticsReportBO.G_NO_ITEM; + } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_AGE) || dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_WORK_YEAR) || dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_COMPANY_YEAR)) { + groupBelong = SalaryStatisticsReportBO.G_YEAR; + // 年份数据 + handle4GroupYear(dimension, empIdYearMap, lastEmpIdYearMap, sameEmpIdYearMap, data); + } else { + groupBelong = SalaryStatisticsReportBO.G_ITEM; + } + groups.forEach(k -> { + List salaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupSpacing(k, groupBelong, dimension.getDimCode(), data.getList(), empIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); + List lastSalaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupSpacing(k, groupBelong, dimension.getDimCode(), data.getLastList(), lastEmpIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); + List sameSalaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupSpacing(k, groupBelong, dimension.getDimCode(), data.getSameList(), sameEmpIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); + Map temp = new HashMap<>(); + temp.put(DM, k.getStartValue() + "-" + k.getEndValue()); + temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + }); + + result.setList(records); + return result; + } + + private void handle4GroupYear(SalaryStatisticsDimensionPO dimension, Map empIdYearMap, Map lastEmpIdYearMap, Map sameEmpIdYearMap, SalaryStatisticsReportDataDTO data) { + Map> simpleUserInfoMap = getSimpleUserInfoList(data); + if (simpleUserInfoMap.isEmpty()) { + return; + } + simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { + if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_AGE) && employee.getAge() != null) { + empIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge().toString()); + } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_WORK_YEAR) && employee.getWorkYear() != null) { + empIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getWorkYear().toString()); + } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_COMPANY_YEAR) && StringUtils.isNotEmpty(employee.getCompanyYear())) { + empIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getCompanyYear()); + } + }); + simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { + if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_AGE) && employee.getAge() != null) { + lastEmpIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge().toString()); + } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_WORK_YEAR) && employee.getWorkYear() != null) { + lastEmpIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getWorkYear().toString()); + } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_COMPANY_YEAR) && StringUtils.isNotEmpty(employee.getCompanyYear())) { + lastEmpIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getCompanyYear()); + } + }); + simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { + if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_AGE) && employee.getAge() != null) { + sameEmpIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge().toString()); + } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_WORK_YEAR) && employee.getWorkYear() != null) { + sameEmpIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getWorkYear().toString()); + } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_COMPANY_YEAR) && StringUtils.isNotEmpty(employee.getCompanyYear())) { + sameEmpIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getCompanyYear()); + } + }); + } private PageInfo> buildRationGroupIndividual4Records(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { PageInfo> result = new PageInfo<>();