diff --git a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java index c930230f9..42f5bce5f 100644 --- a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java @@ -7907,7 +7907,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { // 获取上月的社保福利台账数据 Date lastMonthDate = SalaryDateUtil.localDateToDate(SalaryDateUtil.dateToLocalDate(param.getSalaryMonthDate()).minusMonths(1)); - List lastInsuranceAccountBatchPOS = getInsuranceAccountBatchMapper().listByBillMonth(SalaryDateUtil.getFormatLocalDate(lastMonthDate), null); + List lastInsuranceAccountBatchPOS = getInsuranceAccountBatchMapper().listByBillMonth(SalaryDateUtil.getFormatYearMonth(lastMonthDate), null); // 没有归档的义务人 List lastNotFiledTaxAgentIds = lastInsuranceAccountBatchPOS.stream().filter(po -> po.getBillStatus().equals(BillStatusEnum.NOT_ARCHIVED.getValue())).map(InsuranceAccountBatchPO::getPaymentOrganization).collect(Collectors.toList()); @@ -7917,16 +7917,25 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { lastInsuranceAccountDetailPOS = lastInsuranceAccountDetailPOS.stream() .filter(f -> f.getPaymentStatus().equals(PaymentStatusEnum.COMMON.getValue())) .collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(notFiledTaxAgentIds)) { + + if (CollectionUtils.isNotEmpty(lastNotFiledTaxAgentIds)) { // 过滤未归档的 lastInsuranceAccountDetailPOS = lastInsuranceAccountDetailPOS.stream() - .filter(f -> !notFiledTaxAgentIds.contains(f.getPaymentOrganization()) && !lastNotFiledTaxAgentIds.contains(f.getPaymentOrganization())) + .filter(f -> !lastNotFiledTaxAgentIds.contains(f.getPaymentOrganization())) .collect(Collectors.toList()); } + List changeDetail = new ArrayList<>(); // 过滤出本月社保、公积金、其他方案发生变化的台账明细 Map lastMonthDetailMap = SalaryEntityUtil.convert2Map(lastInsuranceAccountDetailPOS, po -> po.getPaymentOrganization() + "_split" + po.getEmployeeId()); - List changeDetail = new ArrayList<>(); + Set thisMonthKey = SalaryEntityUtil.convert2Map(insuranceAccountDetailPOS, po -> po.getPaymentOrganization() + "_split" + po.getEmployeeId()).keySet(); + // 获取本月减少的key + List lessKey = lastMonthDetailMap.keySet().stream().filter(key -> !thisMonthKey.contains(key)).collect(Collectors.toList()); + for (String key : lessKey) { + InsuranceAccountDetailPO lastMonthPO = lastMonthDetailMap.get(key); + changeDetail.add(lastMonthPO); + } + for (InsuranceAccountDetailPO thisMonthPO : insuranceAccountDetailPOS) { InsuranceAccountDetailPO lastMonthPO = lastMonthDetailMap.get(thisMonthPO.getPaymentOrganization() + "_split" + thisMonthPO.getEmployeeId()); if (lastMonthPO == null) {