Merge remote-tracking branch 'remotes/origin/fix/230801-福利档案-增量处理逻辑添加日志' into release/2.9.3.2308.01

This commit is contained in:
sy 2023-08-04 10:55:27 +08:00
commit c623d32609
1 changed files with 222 additions and 179 deletions

View File

@ -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();
@ -244,26 +248,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<TaxAgentEmpChangePO> taxAgentEmpChangeList = getTaxAgentEmpChangeService(user).listAllByModule(TaxAgentEmpChangeModuleEnum.INSURANCE_ARCHIVE);
log.info("待处理的福利档案增量数据数量 {}", taxAgentEmpChangeList.size());
if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) {
Util_DataCache.setObjVal("welfareChangeSign", "0");
return;
}
// 当前可以管辖的人员
Collection<TaxAgentPO> taxAgentList = new ArrayList<>();
if (currentEmployeeId != 1L) {
taxAgentList = getTaxAgentService(user).listAllTaxAgents(currentEmployeeId);
Collection<TaxAgentPO> 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<TaxAgentEmpChangePO> taxAgentEmpChangeList = getTaxAgentEmpChangeService(user).listAllByModule(TaxAgentEmpChangeModuleEnum.INSURANCE_ARCHIVE);
log.info("待处理的福利档案增量数据数量 {}", taxAgentEmpChangeList.size());
if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) {
Util_DataCache.setObjVal("welfareChangeSign", "0");
return;
}
}
// 当前可以管辖的人员
Collection<TaxAgentPO> taxAgentList = new ArrayList<>();
if (currentEmployeeId != 1L) {
taxAgentList = getTaxAgentService(user).listAllTaxAgents(currentEmployeeId);
Collection<TaxAgentPO> 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<TaxAgentPO> 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 +276,98 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
// Util_DataCache.setObjVal("welfareChangeSign", "0");
// return;
// }
log.info("根据当前可以管辖的个税扣缴义务人筛选出的可处理增量数据数量 {}", taxAgentEmpChangeList.size());
// 所有福利档案基础信息数据
List<InsuranceArchivesBaseInfoPO> 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<InsuranceArchivesBaseInfoPO> toStayDelList = changeData.getBaseInfoUpdateTodoList().stream()
.filter(f -> f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()))
.collect(Collectors.toList());
if (toStayDelList.size() > 0) {
List<List<InsuranceArchivesBaseInfoPO>> partitionUpdateEndTime = Lists.partition(toStayDelList, 100);
partitionUpdateEndTime.forEach(part->{
List<Long> socialIds = part.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList());
List<Long> fundIds = part.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList());
List<Long> 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<InsuranceArchivesBaseInfoPO> baseInfoPOList = getInsuranceBaseInfoMapper().listAll();
log.info("当前数据库中所有福利档案基础信息数据数量 {}", baseInfoPOList.size());
StopWatch sw = new StopWatch();
sw.start("将增量数据进一步处理为新增、更新两类数据");
InsuranceArchivesBaseInfoBO.ChangeData changeData = InsuranceArchivesBaseInfoBO.buildChangeData(taxAgentEmpChangeList, baseInfoPOList, currentEmployeeId);
sw.stop();
sw.start("生成增量数据中即将置为“逻辑删除”的数据");
//对于逻辑删除的数据同样逻辑删除相关的社保公积金其他福利档案
List<InsuranceArchivesBaseInfoPO> 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());
// 批量修改福利档案
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<InsuranceArchivesBaseInfoPO> 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<List<InsuranceArchivesBaseInfoPO>> partitionUpdateEndTime = Lists.partition(toStayDelList, 100);
partitionUpdateEndTime.forEach(part->{
List<Long> socialIds = part.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList());
List<Long> fundIds = part.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList());
List<Long> otherIds = part.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList());
getSocialSchemeMapper().batchUpdateEndTime(socialIds, today);
getFundSchemeMapper().batchUpdateEndTime(fundIds, today);
getOtherSchemeMapper().batchUpdateEndTime(otherIds, today);
});
}
sw.stop();
sw.start("生成增量数据中即将置为“逻辑删除”的数据");
//对于逻辑删除的数据同样逻辑删除相关的社保公积金其他福利档案
List<InsuranceArchivesBaseInfoPO> delList = changeData.getBaseInfoUpdateTodoList().stream()
.filter(f -> f.getDeleteType().equals(DeleteTypeEnum.DELETED.getValue()))
.collect(Collectors.toList());
if (isLog) {
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("增量数据中待更新数据入库");
if (isLog) {
log.info("福利档案-增量数据中待更新数据入库明细:{}", changeData.getBaseInfoUpdateTodoList());
}
List<List<InsuranceArchivesBaseInfoPO>> 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<List<InsuranceArchivesBaseInfoPO>> 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");
}
/**
@ -403,101 +421,126 @@ 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("删除历史社保档案");
if (isLog) {
log.info("新增社保档案明细:{}", socialList);
}
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("删除历史公积金档案");
if (isLog) {
log.info("新增公积金档案明细:{}", fundList);
}
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("删除历史其他福利档案");
if (isLog) {
log.info("新增其他福利档案明细:{}", otherList);
}
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());
//分批批量入库
if (isLog) {
log.info("新增福利档案基础信息明细:{}", newInsuranceArchivesBaseInfoList);
}
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