From 4b1b1077db3a7eb264e1274df815a581c3d29375 Mon Sep 17 00:00:00 2001 From: sy Date: Fri, 28 Jul 2023 15:42:37 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E6=A1=A3=E6=A1=88=EF=BC=8C=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=A1=A3=E6=A1=88=E9=80=BB=E8=BE=91=E6=B7=BB=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SIArchivesServiceImpl.java | 193 ++++++++++-------- 1 file changed, 103 insertions(+), 90 deletions(-) diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index 3ea100d50..81f1ab168 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -403,101 +403,114 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService //新增社保、公积金、其他福利档案、福利档案基础信息 private List addNewInsuranceBaseInfo(List baseInfoPOList, Long currentEmployeeId) { - List socialList = new ArrayList<>(); - List fundList = new ArrayList<>(); - List otherList = new ArrayList<>(); - for (InsuranceArchivesBaseInfoPO baseInfoPO : baseInfoPOList) { - InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO = new InsuranceArchivesSocialSchemePO(); - insuranceArchivesSocialSchemePO.setTenantKey(""); - insuranceArchivesSocialSchemePO.setWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue()); - insuranceArchivesSocialSchemePO.setPaymentOrganization(baseInfoPO.getPaymentOrganization()); - insuranceArchivesSocialSchemePO.setNonPayment(NonPaymentEnum.YES.getValue()); - insuranceArchivesSocialSchemePO.setCreator(currentEmployeeId); - insuranceArchivesSocialSchemePO.setCreateTime(new Date()); - insuranceArchivesSocialSchemePO.setUpdateTime(new Date()); - insuranceArchivesSocialSchemePO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); - insuranceArchivesSocialSchemePO.setEmployeeId(baseInfoPO.getEmployeeId()); - socialList.add(insuranceArchivesSocialSchemePO); + try { + List socialList = new ArrayList<>(); + List fundList = new ArrayList<>(); + List otherList = new ArrayList<>(); + for (InsuranceArchivesBaseInfoPO baseInfoPO : baseInfoPOList) { + InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO = new InsuranceArchivesSocialSchemePO(); + insuranceArchivesSocialSchemePO.setTenantKey(""); + insuranceArchivesSocialSchemePO.setWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue()); + insuranceArchivesSocialSchemePO.setPaymentOrganization(baseInfoPO.getPaymentOrganization()); + insuranceArchivesSocialSchemePO.setNonPayment(NonPaymentEnum.YES.getValue()); + insuranceArchivesSocialSchemePO.setCreator(currentEmployeeId); + insuranceArchivesSocialSchemePO.setCreateTime(new Date()); + insuranceArchivesSocialSchemePO.setUpdateTime(new Date()); + insuranceArchivesSocialSchemePO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceArchivesSocialSchemePO.setEmployeeId(baseInfoPO.getEmployeeId()); + socialList.add(insuranceArchivesSocialSchemePO); - InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO = new InsuranceArchivesFundSchemePO(); - insuranceArchivesFundSchemePO.setTenantKey(""); - insuranceArchivesFundSchemePO.setWelfareType(WelfareTypeEnum.ACCUMULATION_FUND.getValue()); - insuranceArchivesFundSchemePO.setPaymentOrganization(baseInfoPO.getPaymentOrganization()); - insuranceArchivesFundSchemePO.setNonPayment(NonPaymentEnum.YES.getValue()); - insuranceArchivesFundSchemePO.setCreator(currentEmployeeId); - insuranceArchivesFundSchemePO.setCreateTime(new Date()); - insuranceArchivesFundSchemePO.setUpdateTime(new Date()); - insuranceArchivesFundSchemePO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); - insuranceArchivesFundSchemePO.setEmployeeId(baseInfoPO.getEmployeeId()); - fundList.add(insuranceArchivesFundSchemePO); + InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO = new InsuranceArchivesFundSchemePO(); + insuranceArchivesFundSchemePO.setTenantKey(""); + insuranceArchivesFundSchemePO.setWelfareType(WelfareTypeEnum.ACCUMULATION_FUND.getValue()); + insuranceArchivesFundSchemePO.setPaymentOrganization(baseInfoPO.getPaymentOrganization()); + insuranceArchivesFundSchemePO.setNonPayment(NonPaymentEnum.YES.getValue()); + insuranceArchivesFundSchemePO.setCreator(currentEmployeeId); + insuranceArchivesFundSchemePO.setCreateTime(new Date()); + insuranceArchivesFundSchemePO.setUpdateTime(new Date()); + insuranceArchivesFundSchemePO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceArchivesFundSchemePO.setEmployeeId(baseInfoPO.getEmployeeId()); + fundList.add(insuranceArchivesFundSchemePO); - InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO = new InsuranceArchivesOtherSchemePO(); - insuranceArchivesOtherSchemePO.setTenantKey(""); - insuranceArchivesOtherSchemePO.setWelfareType(WelfareTypeEnum.OTHER.getValue()); - insuranceArchivesOtherSchemePO.setPaymentOrganization(baseInfoPO.getPaymentOrganization()); - insuranceArchivesOtherSchemePO.setNonPayment(NonPaymentEnum.YES.getValue()); - insuranceArchivesOtherSchemePO.setCreator(currentEmployeeId); - insuranceArchivesOtherSchemePO.setCreateTime(new Date()); - insuranceArchivesOtherSchemePO.setUpdateTime(new Date()); - insuranceArchivesOtherSchemePO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); - insuranceArchivesOtherSchemePO.setEmployeeId(baseInfoPO.getEmployeeId()); - otherList.add(insuranceArchivesOtherSchemePO); + InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO = new InsuranceArchivesOtherSchemePO(); + insuranceArchivesOtherSchemePO.setTenantKey(""); + insuranceArchivesOtherSchemePO.setWelfareType(WelfareTypeEnum.OTHER.getValue()); + insuranceArchivesOtherSchemePO.setPaymentOrganization(baseInfoPO.getPaymentOrganization()); + insuranceArchivesOtherSchemePO.setNonPayment(NonPaymentEnum.YES.getValue()); + insuranceArchivesOtherSchemePO.setCreator(currentEmployeeId); + insuranceArchivesOtherSchemePO.setCreateTime(new Date()); + insuranceArchivesOtherSchemePO.setUpdateTime(new Date()); + insuranceArchivesOtherSchemePO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceArchivesOtherSchemePO.setEmployeeId(baseInfoPO.getEmployeeId()); + otherList.add(insuranceArchivesOtherSchemePO); - } - //导入社保档案 - if (CollectionUtils.isNotEmpty(socialList)) { - //根据人员id和个税扣缴义务人id删除对应档案 - socialList.forEach(getSocialSchemeMapper()::deleteByEmployeeIdAndPayOrg); - - List> partition = Lists.partition(socialList, 100); - partition.forEach(getSocialSchemeMapper()::batchSave); - } - //导入公积金档案 - if (CollectionUtils.isNotEmpty(fundList)) { - - //根据人员id和个税扣缴义务人id删除对应档案 - fundList.forEach(getFundSchemeMapper()::deleteByEmployeeIdAndPayOrg); - - List> partition = Lists.partition(fundList, 100); - partition.forEach(getFundSchemeMapper()::batchSave); - } - //导入其他福利档案 - if (CollectionUtils.isNotEmpty(otherList)) { - //根据人员id和个税扣缴义务人id删除对应档案 - otherList.forEach(getOtherSchemeMapper()::deleteByEmployeeIdAndPayOrg); - - List> partition = Lists.partition(otherList, 100); - partition.forEach(getOtherSchemeMapper()::batchSave); - } - //导入福利档案基础信息 - if (CollectionUtils.isNotEmpty(baseInfoPOList)) { - //根据人员id和个税扣缴义务人id删除对应档案 - baseInfoPOList.forEach(getInsuranceBaseInfoMapper()::deleteByEmployeeIdAndPayOrg); -// //分批批量删除 - List baseInfoEmployeeIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getEmployeeId).collect(Collectors.toList()); - - //查询目标人员的剩余的福利档案基础信息(社保、公积金、其他福利档案id) - List moreBaseInfoPOS = new ArrayList<>(); - - List> partitionInfo = Lists.partition((List) baseInfoEmployeeIds, 1000); - partitionInfo.forEach(part -> moreBaseInfoPOS.addAll( - getInsuranceBaseInfoMapper().getInsuranceBaseInfoListByInsuranceDetail(part))); - - List newInsuranceArchivesBaseInfoList = new ArrayList<>(); - //设置社保、公积金、其他福利档案id - for (InsuranceArchivesBaseInfoPO po : baseInfoPOList) { - InsuranceArchivesBaseInfoPO moreBaseInfo = moreBaseInfoPOS.stream().filter(s -> Objects.equals(s.getEmployeeId(), po.getEmployeeId()) && Objects.equals(s.getPaymentOrganization(), po.getPaymentOrganization())).findFirst().orElse(null); - po.setSocialArchivesId(moreBaseInfo.getSocialArchivesId()); - po.setFundArchivesId(moreBaseInfo.getFundArchivesId()); - po.setOtherArchivesId(moreBaseInfo.getOtherArchivesId()); - newInsuranceArchivesBaseInfoList.add(po); } - //分批批量入库 - List> partition = Lists.partition(newInsuranceArchivesBaseInfoList, 100); - partition.forEach(getInsuranceBaseInfoMapper()::batchSave); - } + //导入社保档案 + if (CollectionUtils.isNotEmpty(socialList)) { + log.info("新增社保档案数量:{}", socialList.size()); + //根据人员id和个税扣缴义务人id删除对应档案 + socialList.forEach(getSocialSchemeMapper()::deleteByEmployeeIdAndPayOrg); + log.info("删除历史社保档案"); + List> partition = Lists.partition(socialList, 100); + partition.forEach(getSocialSchemeMapper()::batchSave); + log.info("新增社保档案成功"); + } + //导入公积金档案 + if (CollectionUtils.isNotEmpty(fundList)) { + log.info("新增公积金档案数量:{}", fundList.size()); + //根据人员id和个税扣缴义务人id删除对应档案 + fundList.forEach(getFundSchemeMapper()::deleteByEmployeeIdAndPayOrg); + log.info("删除历史公积金档案"); + List> partition = Lists.partition(fundList, 100); + partition.forEach(getFundSchemeMapper()::batchSave); + log.info("新增公积金档案成功"); + } + //导入其他福利档案 + if (CollectionUtils.isNotEmpty(otherList)) { + log.info("新增其他福利档案数量:{}", otherList.size()); + //根据人员id和个税扣缴义务人id删除对应档案 + otherList.forEach(getOtherSchemeMapper()::deleteByEmployeeIdAndPayOrg); + log.info("删除历史其他福利档案"); + List> partition = Lists.partition(otherList, 100); + partition.forEach(getOtherSchemeMapper()::batchSave); + log.info("新增其他福利档案成功"); + } + //导入福利档案基础信息 + if (CollectionUtils.isNotEmpty(baseInfoPOList)) { + //根据人员id和个税扣缴义务人id删除对应档案 + baseInfoPOList.forEach(getInsuranceBaseInfoMapper()::deleteByEmployeeIdAndPayOrg); + log.info("删除历史福利档案基础信息"); + // //分批批量删除 + List baseInfoEmployeeIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getEmployeeId).collect(Collectors.toList()); - return baseInfoPOList; + //查询目标人员的剩余的福利档案基础信息(社保、公积金、其他福利档案id) + List moreBaseInfoPOS = new ArrayList<>(); + log.info("查询目标人员的剩余的福利档案基础信息(社保、公积金、其他福利档案id)"); + List> partitionInfo = Lists.partition((List) baseInfoEmployeeIds, 1000); + partitionInfo.forEach(part -> moreBaseInfoPOS.addAll( + getInsuranceBaseInfoMapper().getInsuranceBaseInfoListByInsuranceDetail(part))); + + List newInsuranceArchivesBaseInfoList = new ArrayList<>(); + //设置社保、公积金、其他福利档案id + log.info("设置社保、公积金、其他福利档案id"); + for (InsuranceArchivesBaseInfoPO po : baseInfoPOList) { + InsuranceArchivesBaseInfoPO moreBaseInfo = moreBaseInfoPOS.stream().filter(s -> Objects.equals(s.getEmployeeId(), po.getEmployeeId()) && Objects.equals(s.getPaymentOrganization(), po.getPaymentOrganization())).findFirst().orElse(null); + po.setSocialArchivesId(moreBaseInfo.getSocialArchivesId()); + po.setFundArchivesId(moreBaseInfo.getFundArchivesId()); + po.setOtherArchivesId(moreBaseInfo.getOtherArchivesId()); + newInsuranceArchivesBaseInfoList.add(po); + } + log.info("福利档案基础信息分批批量入库,入库数量:{}", newInsuranceArchivesBaseInfoList.size()); + //分批批量入库 + List> partition = Lists.partition(newInsuranceArchivesBaseInfoList, 100); + partition.forEach(getInsuranceBaseInfoMapper()::batchSave); + } + + return baseInfoPOList; + } catch (Exception e) { + log.info("新增福利档案出错:{}", e.getMessage(), e); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "福利档案新增失败")); + } } /** * 分批更新福利档案基础信息的runStatus From f2091cbba52c7b8af2733927426b98216998909c Mon Sep 17 00:00:00 2001 From: sy Date: Mon, 31 Jul 2023 09:54:48 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E6=A1=A3=E6=A1=88=EF=BC=8C=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=A1=A3=E6=A1=88=E9=80=BB=E8=BE=91=E6=B7=BB=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E5=BF=972?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/salary/service/impl/SIArchivesServiceImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index 81f1ab168..7a74d73fc 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -451,6 +451,7 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService //根据人员id和个税扣缴义务人id删除对应档案 socialList.forEach(getSocialSchemeMapper()::deleteByEmployeeIdAndPayOrg); log.info("删除历史社保档案"); + log.info("新增社保档案明细:{}", socialList); List> partition = Lists.partition(socialList, 100); partition.forEach(getSocialSchemeMapper()::batchSave); log.info("新增社保档案成功"); @@ -461,6 +462,7 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService //根据人员id和个税扣缴义务人id删除对应档案 fundList.forEach(getFundSchemeMapper()::deleteByEmployeeIdAndPayOrg); log.info("删除历史公积金档案"); + log.info("新增公积金档案明细:{}", fundList); List> partition = Lists.partition(fundList, 100); partition.forEach(getFundSchemeMapper()::batchSave); log.info("新增公积金档案成功"); @@ -471,6 +473,7 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService //根据人员id和个税扣缴义务人id删除对应档案 otherList.forEach(getOtherSchemeMapper()::deleteByEmployeeIdAndPayOrg); log.info("删除历史其他福利档案"); + log.info("新增其他福利档案明细:{}", otherList); List> partition = Lists.partition(otherList, 100); partition.forEach(getOtherSchemeMapper()::batchSave); log.info("新增其他福利档案成功"); @@ -502,6 +505,7 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService } log.info("福利档案基础信息分批批量入库,入库数量:{}", newInsuranceArchivesBaseInfoList.size()); //分批批量入库 + log.info("新增福利档案基础信息明细:{}", newInsuranceArchivesBaseInfoList); List> partition = Lists.partition(newInsuranceArchivesBaseInfoList, 100); partition.forEach(getInsuranceBaseInfoMapper()::batchSave); } From 109028e6454b3b3153f3c3680b6679742d4e59e9 Mon Sep 17 00:00:00 2001 From: sy Date: Wed, 2 Aug 2023 16:08:12 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E6=A1=A3=E6=A1=88=EF=BC=8C=E5=A2=9E=E9=87=8F?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86=E6=B7=BB=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=8B=A5=E5=B9=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SIArchivesServiceImpl.java | 183 +++++++++--------- 1 file changed, 95 insertions(+), 88 deletions(-) diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index 7a74d73fc..69ac06b3d 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -244,26 +244,27 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService @Transactional(rollbackFor = Exception.class) @Override public void handleChangeData(long currentEmployeeId) { - Util_DataCache.setObjVal("welfareChangeSign", "1"); - log.info("福利档案中增量数据处理逻辑开始:"); - // 所有增量人员列表 - List taxAgentEmpChangeList = getTaxAgentEmpChangeService(user).listAllByModule(TaxAgentEmpChangeModuleEnum.INSURANCE_ARCHIVE); - log.info("待处理的福利档案增量数据数量 {}:", taxAgentEmpChangeList.size()); - if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) { - Util_DataCache.setObjVal("welfareChangeSign", "0"); - return; - } - // 当前可以管辖的人员 - Collection taxAgentList = new ArrayList<>(); - if (currentEmployeeId != 1L) { - taxAgentList = getTaxAgentService(user).listAllTaxAgents(currentEmployeeId); - Collection finalTaxAgentList = taxAgentList; - taxAgentEmpChangeList = taxAgentEmpChangeList.stream().filter(f -> finalTaxAgentList.stream().anyMatch(e -> e.getId().equals(f.getTaxAgentId()))).collect(Collectors.toList()); + try { + Util_DataCache.setObjVal("welfareChangeSign", "1"); + log.info("福利档案中增量数据处理逻辑开始:"); + // 所有增量人员列表 + List taxAgentEmpChangeList = getTaxAgentEmpChangeService(user).listAllByModule(TaxAgentEmpChangeModuleEnum.INSURANCE_ARCHIVE); + log.info("待处理的福利档案增量数据数量 {}:", taxAgentEmpChangeList.size()); if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) { Util_DataCache.setObjVal("welfareChangeSign", "0"); return; } - } + // 当前可以管辖的人员 + Collection taxAgentList = new ArrayList<>(); + if (currentEmployeeId != 1L) { + taxAgentList = getTaxAgentService(user).listAllTaxAgents(currentEmployeeId); + Collection finalTaxAgentList = taxAgentList; + taxAgentEmpChangeList = taxAgentEmpChangeList.stream().filter(f -> finalTaxAgentList.stream().anyMatch(e -> e.getId().equals(f.getTaxAgentId()))).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) { + Util_DataCache.setObjVal("welfareChangeSign", "0"); + return; + } + } // Collection taxAgentList = getTaxAgentService(user).listAllTaxAgents(currentEmployeeId); // log.info("当前可以管辖的个税扣缴义务人数量 {}:", taxAgentList.size()); // taxAgentEmpChangeList = taxAgentEmpChangeList.stream().filter(f -> taxAgentList.stream().anyMatch(e -> e.getId().equals(f.getTaxAgentId()))).collect(Collectors.toList()); @@ -271,85 +272,91 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService // Util_DataCache.setObjVal("welfareChangeSign", "0"); // return; // } - log.info("根据当前可以管辖的个税扣缴义务人筛选出的可处理增量数据数量 {}:", taxAgentEmpChangeList.size()); - // 所有福利档案基础信息数据 - List baseInfoPOList = getInsuranceBaseInfoMapper().listAll(); - log.info("当前数据库中所有福利档案基础信息数据数量 {}:", baseInfoPOList.size()); - StopWatch sw = new StopWatch(); - sw.start("将增量数据进一步处理为新增、更新两类数据"); - InsuranceArchivesBaseInfoBO.ChangeData changeData = InsuranceArchivesBaseInfoBO.buildChangeData(taxAgentEmpChangeList, baseInfoPOList, currentEmployeeId); - sw.stop(); - // 批量修改福利档案 - if (CollectionUtils.isNotEmpty(changeData.getBaseInfoUpdateTodoList())) { - log.info("增量数据中待更新的数据数量 {}:", changeData.getBaseInfoUpdateTodoList().size()); - //对于即将调整为“待减员”的数据,更新社保、公积金、其他福利档案的停止缴纳时间 - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); - String today = simpleDateFormat.format(new Date()); - sw.start("生成增量数据中即将置为“待减员”的数据"); - List toStayDelList = changeData.getBaseInfoUpdateTodoList().stream() - .filter(f -> f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())) - .collect(Collectors.toList()); - if (toStayDelList.size() > 0) { - List> partitionUpdateEndTime = Lists.partition(toStayDelList, 100); - partitionUpdateEndTime.forEach(part->{ - List socialIds = part.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList()); - List fundIds = part.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList()); - List otherIds = part.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList()); - - getSocialSchemeMapper().batchUpdateEndTime(socialIds, today); - getFundSchemeMapper().batchUpdateEndTime(fundIds, today); - getOtherSchemeMapper().batchUpdateEndTime(otherIds, today); - }); - - } + log.info("根据当前可以管辖的个税扣缴义务人筛选出的可处理增量数据数量 {}:", taxAgentEmpChangeList.size()); + // 所有福利档案基础信息数据 + List baseInfoPOList = getInsuranceBaseInfoMapper().listAll(); + log.info("当前数据库中所有福利档案基础信息数据数量 {}:", baseInfoPOList.size()); + StopWatch sw = new StopWatch(); + sw.start("将增量数据进一步处理为新增、更新两类数据"); + InsuranceArchivesBaseInfoBO.ChangeData changeData = InsuranceArchivesBaseInfoBO.buildChangeData(taxAgentEmpChangeList, baseInfoPOList, currentEmployeeId); sw.stop(); + // 批量修改福利档案 + if (CollectionUtils.isNotEmpty(changeData.getBaseInfoUpdateTodoList())) { + log.info("增量数据中待更新的数据数量 {}:", changeData.getBaseInfoUpdateTodoList().size()); + //对于即将调整为“待减员”的数据,更新社保、公积金、其他福利档案的停止缴纳时间 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); + String today = simpleDateFormat.format(new Date()); + sw.start("生成增量数据中即将置为“待减员”的数据"); + List toStayDelList = changeData.getBaseInfoUpdateTodoList().stream() + .filter(f -> f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())) + .collect(Collectors.toList()); + if (toStayDelList.size() > 0) { + List> partitionUpdateEndTime = Lists.partition(toStayDelList, 100); + partitionUpdateEndTime.forEach(part->{ + List socialIds = part.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList()); + List fundIds = part.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList()); + List otherIds = part.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList()); + + getSocialSchemeMapper().batchUpdateEndTime(socialIds, today); + getFundSchemeMapper().batchUpdateEndTime(fundIds, today); + getOtherSchemeMapper().batchUpdateEndTime(otherIds, today); + }); - sw.start("生成增量数据中即将置为“逻辑删除”的数据"); - //对于逻辑删除的数据,同样逻辑删除相关的社保、公积金、其他福利档案 - List delList = changeData.getBaseInfoUpdateTodoList().stream() - .filter(f -> f.getDeleteType().equals(DeleteTypeEnum.DELETED.getValue())) - .collect(Collectors.toList()); - if (delList.size() > 0) { - for (InsuranceArchivesBaseInfoPO po : delList) { - getSocialSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesSocialSchemePO.builder() - .employeeId(po.getEmployeeId()) - .paymentOrganization(po.getPaymentOrganization()) - .build()); - getFundSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesFundSchemePO.builder() - .employeeId(po.getEmployeeId()) - .paymentOrganization(po.getPaymentOrganization()) - .build()); - getOtherSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesOtherSchemePO.builder() - .employeeId(po.getEmployeeId()) - .paymentOrganization(po.getPaymentOrganization()) - .build()); } + sw.stop(); + + sw.start("生成增量数据中即将置为“逻辑删除”的数据"); + //对于逻辑删除的数据,同样逻辑删除相关的社保、公积金、其他福利档案 + List delList = changeData.getBaseInfoUpdateTodoList().stream() + .filter(f -> f.getDeleteType().equals(DeleteTypeEnum.DELETED.getValue())) + .collect(Collectors.toList()); + log.info("福利档案-逻辑删除明细:{}", delList); + if (delList.size() > 0) { + for (InsuranceArchivesBaseInfoPO po : delList) { + getSocialSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesSocialSchemePO.builder() + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build()); + getFundSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesFundSchemePO.builder() + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build()); + getOtherSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesOtherSchemePO.builder() + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build()); + } + } + sw.stop(); + //修改福利档案基础信息 + sw.start("增量数据中待更新数据入库"); + log.info("福利档案-增量数据中待更新数据入库:{}", changeData.getBaseInfoUpdateTodoList()); + List> partitionUpdateBase = Lists.partition(changeData.getBaseInfoUpdateTodoList(), 100); + partitionUpdateBase.forEach(part-> getInsuranceBaseInfoMapper().batchUpdate(part)); + sw.stop(); + log.info("增量数据中待更新的数据处理完成!"); + } + + sw.start("处理增量数据中待新增的数据"); + // 批量新增福利档案 + if (CollectionUtils.isNotEmpty(changeData.getBaseInfoAddTodoList())) { + log.info("增量数据中待新增的数据数量 {}:", changeData.getBaseInfoAddTodoList().size()); + //新增社保、公积金、其他福利档案、福利档案基础信息 + addNewInsuranceBaseInfo(changeData.getBaseInfoAddTodoList(), currentEmployeeId); + log.info("增量数据中待新增的数据处理完成!"); } sw.stop(); - //修改福利档案基础信息 - sw.start("增量数据中待更新数据入库"); - List> partitionUpdateBase = Lists.partition(changeData.getBaseInfoUpdateTodoList(), 100); - partitionUpdateBase.forEach(part-> getInsuranceBaseInfoMapper().batchUpdate(part)); - sw.stop(); - log.info("增量数据中待更新的数据处理完成!"); - } - sw.start("处理增量数据中待新增的数据"); - // 批量新增福利档案 - if (CollectionUtils.isNotEmpty(changeData.getBaseInfoAddTodoList())) { - log.info("增量数据中待新增的数据数量 {}:", changeData.getBaseInfoAddTodoList().size()); - //新增社保、公积金、其他福利档案、福利档案基础信息 - addNewInsuranceBaseInfo(changeData.getBaseInfoAddTodoList(), currentEmployeeId); - log.info("增量数据中待新增的数据处理完成!"); + // 删除增量数据 + if (CollectionUtils.isNotEmpty(changeData.getChangeIds())) { + getTaxAgentEmpChangeService(user).deleleByIds(changeData.getChangeIds()); + } + log.info("各操作计时 {}", sw.prettyPrint()); + Util_DataCache.setObjVal("welfareChangeSign", "0"); + } catch (Exception e) { + log.info("福利档案-增量数据处理出错:{}", e.getMessage(), e); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "福利档案-增量数据处理出错")); } - sw.stop(); - - // 删除增量数据 - if (CollectionUtils.isNotEmpty(changeData.getChangeIds())) { - getTaxAgentEmpChangeService(user).deleleByIds(changeData.getChangeIds()); - } - log.info("各操作计时 {}", sw.prettyPrint()); - Util_DataCache.setObjVal("welfareChangeSign", "0"); } /** From 0749ab9d5b50a519d958fb29bcb05187ef48c3d7 Mon Sep 17 00:00:00 2001 From: sy Date: Wed, 2 Aug 2023 16:31:59 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E6=A1=A3=E6=A1=88=EF=BC=8C=E5=A2=9E=E9=87=8F?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86=E4=B8=AD=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=B7=BB=E5=8A=A0=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SIArchivesServiceImpl.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index 69ac06b3d..dbfde3e87 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -43,6 +43,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StopWatch; +import weaver.general.BaseBean; import weaver.general.Util; import weaver.hrm.User; @@ -58,6 +59,9 @@ import java.util.stream.Collectors; **/ @Slf4j public class SIArchivesServiceImpl extends Service implements SIArchivesService { + private final BaseBean baseBean = new BaseBean(); + + private final Boolean isLog = "true".equals(baseBean.getPropValue("hrmSalary", "log")); private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); @@ -290,6 +294,9 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService List toStayDelList = changeData.getBaseInfoUpdateTodoList().stream() .filter(f -> f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())) .collect(Collectors.toList()); + if (isLog) { + log.info("福利档案-待减员明细:{}", toStayDelList); + } if (toStayDelList.size() > 0) { List> partitionUpdateEndTime = Lists.partition(toStayDelList, 100); partitionUpdateEndTime.forEach(part->{ @@ -310,7 +317,9 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService List delList = changeData.getBaseInfoUpdateTodoList().stream() .filter(f -> f.getDeleteType().equals(DeleteTypeEnum.DELETED.getValue())) .collect(Collectors.toList()); - log.info("福利档案-逻辑删除明细:{}", delList); + if (isLog) { + log.info("福利档案-逻辑删除明细:{}", delList); + } if (delList.size() > 0) { for (InsuranceArchivesBaseInfoPO po : delList) { getSocialSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesSocialSchemePO.builder() @@ -330,7 +339,9 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService sw.stop(); //修改福利档案基础信息 sw.start("增量数据中待更新数据入库"); - log.info("福利档案-增量数据中待更新数据入库:{}", changeData.getBaseInfoUpdateTodoList()); + if (isLog) { + log.info("福利档案-增量数据中待更新数据入库明细:{}", changeData.getBaseInfoUpdateTodoList()); + } List> partitionUpdateBase = Lists.partition(changeData.getBaseInfoUpdateTodoList(), 100); partitionUpdateBase.forEach(part-> getInsuranceBaseInfoMapper().batchUpdate(part)); sw.stop(); From 5925bd56003faaf7f3509a92c4de6925581f6ff5 Mon Sep 17 00:00:00 2001 From: sy Date: Wed, 2 Aug 2023 16:39:20 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E6=A1=A3=E6=A1=88=EF=BC=8C=E5=A2=9E=E9=87=8F?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86-=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E6=A1=A3=E6=A1=88=E7=9B=B8=E5=85=B3=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=B7=BB=E5=8A=A0=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SIArchivesServiceImpl.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index dbfde3e87..48dc79fe2 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -469,7 +469,9 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService //根据人员id和个税扣缴义务人id删除对应档案 socialList.forEach(getSocialSchemeMapper()::deleteByEmployeeIdAndPayOrg); log.info("删除历史社保档案"); - log.info("新增社保档案明细:{}", socialList); + if (isLog) { + log.info("新增社保档案明细:{}", socialList); + } List> partition = Lists.partition(socialList, 100); partition.forEach(getSocialSchemeMapper()::batchSave); log.info("新增社保档案成功"); @@ -480,7 +482,9 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService //根据人员id和个税扣缴义务人id删除对应档案 fundList.forEach(getFundSchemeMapper()::deleteByEmployeeIdAndPayOrg); log.info("删除历史公积金档案"); - log.info("新增公积金档案明细:{}", fundList); + if (isLog) { + log.info("新增公积金档案明细:{}", fundList); + } List> partition = Lists.partition(fundList, 100); partition.forEach(getFundSchemeMapper()::batchSave); log.info("新增公积金档案成功"); @@ -491,7 +495,9 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService //根据人员id和个税扣缴义务人id删除对应档案 otherList.forEach(getOtherSchemeMapper()::deleteByEmployeeIdAndPayOrg); log.info("删除历史其他福利档案"); - log.info("新增其他福利档案明细:{}", otherList); + if (isLog) { + log.info("新增其他福利档案明细:{}", otherList); + } List> partition = Lists.partition(otherList, 100); partition.forEach(getOtherSchemeMapper()::batchSave); log.info("新增其他福利档案成功"); @@ -523,7 +529,9 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService } log.info("福利档案基础信息分批批量入库,入库数量:{}", newInsuranceArchivesBaseInfoList.size()); //分批批量入库 - log.info("新增福利档案基础信息明细:{}", newInsuranceArchivesBaseInfoList); + if (isLog) { + log.info("新增福利档案基础信息明细:{}", newInsuranceArchivesBaseInfoList); + } List> partition = Lists.partition(newInsuranceArchivesBaseInfoList, 100); partition.forEach(getInsuranceBaseInfoMapper()::batchSave); }