From 4b1b1077db3a7eb264e1274df815a581c3d29375 Mon Sep 17 00:00:00 2001 From: sy Date: Fri, 28 Jul 2023 15:42:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-=E7=A6=8F?= =?UTF-8?q?=E5=88=A9=E6=A1=A3=E6=A1=88=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=A1=A3?= =?UTF-8?q?=E6=A1=88=E9=80=BB=E8=BE=91=E6=B7=BB=E5=8A=A0=E6=97=A5=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