From ffef539f2e0b3ccf830cf4d8f3c331247e118d00 Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Thu, 6 Jun 2024 18:07:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=82=E7=AB=8B=E9=9C=80=E6=B1=82=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/SalaryArchiveItemService.java | 9 ++++ .../impl/SalaryAcctEmployeeServiceImpl.java | 53 +++++++++++++------ .../impl/SalaryArchiveItemServiceImpl.java | 24 +++++++++ 3 files changed, 70 insertions(+), 16 deletions(-) diff --git a/src/com/engine/salary/service/SalaryArchiveItemService.java b/src/com/engine/salary/service/SalaryArchiveItemService.java index a1a9217c6..b8e842c7a 100644 --- a/src/com/engine/salary/service/SalaryArchiveItemService.java +++ b/src/com/engine/salary/service/SalaryArchiveItemService.java @@ -11,6 +11,7 @@ import com.engine.salary.util.page.PageInfo; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.util.Collection; +import java.util.Date; import java.util.List; import java.util.Map; @@ -119,6 +120,14 @@ public interface SalaryArchiveItemService { */ List getCurrentEffectiveItemList(Collection salaryArchivesIds, Collection salaryItemIds); + /** + * 获取薪资档案对应日期所生效的薪资项目 + * + * @param salaryArchivesIds + * @return + */ + List getCurrentEffectiveItemListByDate(Collection salaryArchivesIds, Collection salaryItemIds, Date date); + /** * 获取薪资档案对应的当前生效的薪资项目忽略值 diff --git a/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java index ec3194673..d94a01a5f 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java @@ -47,6 +47,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; +import weaver.conn.RecordSet; import weaver.hrm.User; import java.util.*; @@ -780,33 +781,53 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct } SalarySobCycleDTO salarySobCycleById = getSalaryAcctRecordService(user).getSalarySobCycleById(queryParam.getSalaryAcctRecordId()); LocalDateRange salaryCycle = salarySobCycleById.getSalaryCycle(); - // 获取薪资周期内发生过调薪的人 - List salaryAcctEmployeePOS = getSalaryAcctEmployeeMapper().listPage(queryParam); - List employeeIds = salaryAcctEmployeePOS.stream().map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toList()); + + // 获取薪资周期内发生过调薪的人 20240606逻辑变更,查建模台账 + // List salaryAcctEmployeePOS = getSalaryAcctEmployeeMapper().listPage(queryParam); + // List employeeIds = salaryAcctEmployeePOS.stream().map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toList()); + // SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + // TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(salarySobPO.getTaxAgentId()); + // List salaryArchivePOList = getSalaryArchiveService(user).listSome(SalaryArchivePO.builder().taxAgentId(salarySobPO.getTaxAgentId()).employeeIds(employeeIds).build()); + // List salaryArchiveIds = salaryArchivePOList.stream().map(SalaryArchivePO::getId).collect(Collectors.toList()); + // List adjustSalaryArchiveIds = getSalaryArchiveItemService(user).listArchiveIdByEffectiveTimeAndArchiveIds(salaryCycle, salaryArchiveIds); + + // 获取薪资周期内发生过调薪的人 20240606逻辑变更,查建模台账 SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(salarySobPO.getTaxAgentId()); - List salaryArchivePOList = getSalaryArchiveService(user).listSome(SalaryArchivePO.builder().taxAgentId(salarySobPO.getTaxAgentId()).employeeIds(employeeIds).build()); - List salaryArchiveIds = salaryArchivePOList.stream().map(SalaryArchivePO::getId).collect(Collectors.toList()); - List adjustSalaryArchiveIds = getSalaryArchiveItemService(user).listArchiveIdByEffectiveTimeAndArchiveIds(salaryCycle, salaryArchiveIds); + RecordSet rs = new RecordSet(); + rs.execute("select distinct xm from uf_txtzbd where dxsxy='" + SalaryDateUtil.getFormatYearMonth(salaryAcctRecordPO.getSalaryMonth()) + "'" ); + List adjustEmpIds = new ArrayList<>(); + while (rs.next()) { + adjustEmpIds.add(Long.valueOf(rs.getInt("xm"))); + } + + // 查询本次薪资核算人员 + List salaryAcctEmployeePOS = getSalaryAcctEmployeeMapper().listPage(queryParam); + List employeeIds = salaryAcctEmployeePOS.stream().map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toList()); + adjustEmpIds = adjustEmpIds.stream().filter(id -> employeeIds.contains(id)).collect(Collectors.toList()); + + List salaryArchivePOList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(adjustEmpIds)) { + salaryArchivePOList.addAll(getSalaryArchiveService(user).listSome(SalaryArchivePO.builder().employeeIds(adjustEmpIds).taxAgentId(salarySobPO.getTaxAgentId()).build())); + } List> resultList = new ArrayList<>(); - PageInfo archiveIdPageInfo = new PageInfo<>(); + PageInfo salaryArchivePOPageInfo = new PageInfo<>(); // 获取所有可被引用的薪资项目 List salaryItems = getSalaryArchiveItemService(user).getCanAdjustSalaryItems(); - if (CollectionUtils.isNotEmpty(adjustSalaryArchiveIds)) { + if (CollectionUtils.isNotEmpty(salaryArchivePOList)) { // 分页 - archiveIdPageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), adjustSalaryArchiveIds); - - // 获取薪资档案信息 - salaryArchivePOList = getSalaryArchiveService(user).listSome(SalaryArchivePO.builder().ids(archiveIdPageInfo.getList()).build()); + salaryArchivePOPageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), salaryArchivePOList); + List salaryArchiveIds = salaryArchivePOPageInfo.getList().stream().map(SalaryArchivePO::getId).collect(Collectors.toList()); // 获取人员信息 - Map employeeMap = SalaryEntityUtil.convert2Map(getSalaryEmployeeService(user).listByIds(employeeIds), DataCollectionEmployee::getEmployeeId); + Map employeeMap = SalaryEntityUtil.convert2Map(getSalaryEmployeeService(user).listByIds(adjustEmpIds), DataCollectionEmployee::getEmployeeId); List salaryItemIds = salaryItems.stream().map(SalaryItemPO::getId).collect(Collectors.toList()); // 获取当前生效的薪资项目 - List salaryArchiveItemCurrentList = getSalaryArchiveItemService(user).getCurrentEffectiveItemList(archiveIdPageInfo.getList(), salaryItemIds); + List salaryArchiveItemCurrentList = getSalaryArchiveItemService(user).getCurrentEffectiveItemListByDate(salaryArchiveIds, salaryItemIds, salaryCycle.getEndDate()); + // List salaryArchiveItemCurrentList = getSalaryArchiveItemService(user).getCurrentEffectiveItemList(salaryArchiveIds, salaryItemIds); Map> groupByArchiveId = SalaryEntityUtil.group2Map(salaryArchiveItemCurrentList, SalaryArchiveItemPO::getSalaryArchiveId); - for (SalaryArchivePO po : salaryArchivePOList) { + for (SalaryArchivePO po : salaryArchivePOPageInfo.getList()) { DataCollectionEmployee employee = employeeMap.get(po.getEmployeeId()); HashMap valueMap = new HashMap<>(); valueMap.put("userName", employee == null ? "" : employee.getUsername()); @@ -841,7 +862,7 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct } resultPageInfo.setList(resultList); - resultPageInfo.setTotal(archiveIdPageInfo.getTotal()); + resultPageInfo.setTotal(salaryArchivePOPageInfo.getTotal()); resultPageInfo.setPageSize(queryParam.getPageSize()); resultPageInfo.setPageNum(queryParam.getCurrent()); resultPageInfo.setColumns(columns); diff --git a/src/com/engine/salary/service/impl/SalaryArchiveItemServiceImpl.java b/src/com/engine/salary/service/impl/SalaryArchiveItemServiceImpl.java index 01372319a..2956709bc 100644 --- a/src/com/engine/salary/service/impl/SalaryArchiveItemServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryArchiveItemServiceImpl.java @@ -151,6 +151,17 @@ public class SalaryArchiveItemServiceImpl extends Service implements SalaryArchi .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getSalaryArchiveId() + "-" + f.getSalaryItemId()))), ArrayList::new)); } + @Override + public List getCurrentEffectiveItemListByDate(Collection salaryArchivesIds, Collection salaryItemIds, Date date) { + // 没有薪资项目时,给个不存在的,否则加载所有不合理 + salaryItemIds = CollectionUtils.isEmpty(salaryItemIds) ? Collections.singletonList(0L) : salaryItemIds; + // 薪资档案id + List salaryArchiveIds = CollectionUtils.isEmpty(salaryArchivesIds) ? Collections.singletonList(0L) : (List) salaryArchivesIds; + List salaryArchiveItems = this.getEffectiveItemListByDate(salaryArchiveIds, salaryItemIds, date); + return salaryArchiveItems.stream() + .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getSalaryArchiveId() + "-" + f.getSalaryItemId()))), ArrayList::new)); + } + /** * 获取当前已生效列表 * @@ -171,6 +182,19 @@ public class SalaryArchiveItemServiceImpl extends Service implements SalaryArchi return salaryArchiveItems; } + private List getEffectiveItemListByDate(Collection salaryArchiveIds, Collection salaryItemIds, Date date) { + List salaryArchiveItems = Lists.newArrayList(); + List> partition = Lists.partition(Lists.newArrayList(salaryArchiveIds), 999); + partition.forEach(part -> salaryArchiveItems.addAll( + salaryArchiveItemMapper.getEffectiveSalaryItems(SalaryArchiveItemQueryParam.builder() + .salaryArchivesIds(part) + .salaryItemIds(salaryItemIds) + .effectiveTime(date).build())) + ); + // 解密 + return salaryArchiveItems; + } + @Override public Map> getEffectiveItemListMap(Collection salaryArchiveIds, boolean isNoNeedSalaryItem, Collection salaryItemIds) {