薪酬系统-福利档案,新增档案逻辑添加日志

This commit is contained in:
sy 2023-07-28 15:42:37 +08:00
parent ed99e186e1
commit 4b1b1077db
1 changed files with 103 additions and 90 deletions

View File

@ -403,101 +403,114 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
//新增社保公积金其他福利档案福利档案基础信息
private List<InsuranceArchivesBaseInfoPO> addNewInsuranceBaseInfo(List<InsuranceArchivesBaseInfoPO> baseInfoPOList, Long currentEmployeeId) {
List<InsuranceArchivesSocialSchemePO> socialList = new ArrayList<>();
List<InsuranceArchivesFundSchemePO> fundList = new ArrayList<>();
List<InsuranceArchivesOtherSchemePO> 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<InsuranceArchivesSocialSchemePO> socialList = new ArrayList<>();
List<InsuranceArchivesFundSchemePO> fundList = new ArrayList<>();
List<InsuranceArchivesOtherSchemePO> 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<List<InsuranceArchivesSocialSchemePO>> partition = Lists.partition(socialList, 100);
partition.forEach(getSocialSchemeMapper()::batchSave);
}
//导入公积金档案
if (CollectionUtils.isNotEmpty(fundList)) {
//根据人员id和个税扣缴义务人id删除对应档案
fundList.forEach(getFundSchemeMapper()::deleteByEmployeeIdAndPayOrg);
List<List<InsuranceArchivesFundSchemePO>> partition = Lists.partition(fundList, 100);
partition.forEach(getFundSchemeMapper()::batchSave);
}
//导入其他福利档案
if (CollectionUtils.isNotEmpty(otherList)) {
//根据人员id和个税扣缴义务人id删除对应档案
otherList.forEach(getOtherSchemeMapper()::deleteByEmployeeIdAndPayOrg);
List<List<InsuranceArchivesOtherSchemePO>> partition = Lists.partition(otherList, 100);
partition.forEach(getOtherSchemeMapper()::batchSave);
}
//导入福利档案基础信息
if (CollectionUtils.isNotEmpty(baseInfoPOList)) {
//根据人员id和个税扣缴义务人id删除对应档案
baseInfoPOList.forEach(getInsuranceBaseInfoMapper()::deleteByEmployeeIdAndPayOrg);
// //分批批量删除
List<Long> baseInfoEmployeeIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getEmployeeId).collect(Collectors.toList());
//查询目标人员的剩余的福利档案基础信息社保公积金其他福利档案id
List<InsuranceArchivesBaseInfoPO> moreBaseInfoPOS = new ArrayList<>();
List<List<Long>> partitionInfo = Lists.partition((List<Long>) baseInfoEmployeeIds, 1000);
partitionInfo.forEach(part -> moreBaseInfoPOS.addAll(
getInsuranceBaseInfoMapper().getInsuranceBaseInfoListByInsuranceDetail(part)));
List<InsuranceArchivesBaseInfoPO> 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<List<InsuranceArchivesBaseInfoPO>> 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<List<InsuranceArchivesSocialSchemePO>> 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<List<InsuranceArchivesFundSchemePO>> 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<List<InsuranceArchivesOtherSchemePO>> partition = Lists.partition(otherList, 100);
partition.forEach(getOtherSchemeMapper()::batchSave);
log.info("新增其他福利档案成功");
}
//导入福利档案基础信息
if (CollectionUtils.isNotEmpty(baseInfoPOList)) {
//根据人员id和个税扣缴义务人id删除对应档案
baseInfoPOList.forEach(getInsuranceBaseInfoMapper()::deleteByEmployeeIdAndPayOrg);
log.info("删除历史福利档案基础信息");
// //分批批量删除
List<Long> baseInfoEmployeeIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getEmployeeId).collect(Collectors.toList());
return baseInfoPOList;
//查询目标人员的剩余的福利档案基础信息社保公积金其他福利档案id
List<InsuranceArchivesBaseInfoPO> moreBaseInfoPOS = new ArrayList<>();
log.info("查询目标人员的剩余的福利档案基础信息社保、公积金、其他福利档案id");
List<List<Long>> partitionInfo = Lists.partition((List<Long>) baseInfoEmployeeIds, 1000);
partitionInfo.forEach(part -> moreBaseInfoPOS.addAll(
getInsuranceBaseInfoMapper().getInsuranceBaseInfoListByInsuranceDetail(part)));
List<InsuranceArchivesBaseInfoPO> 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<List<InsuranceArchivesBaseInfoPO>> 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