diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index 40fd7c751..c42b5bfd6 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -701,20 +701,13 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService List socialList = new ArrayList<>(); List fundList = new ArrayList<>(); List otherList = new ArrayList<>(); - //分别新建福利档案基础信息相关的社保、公积金、其他福利档案可以进行增员的人员列表 - List toPaySocialEmployeeIdList = new ArrayList<>(); - List toPayFundEmployeeIdList = new ArrayList<>(); - List toPayOtherEmployeeIdList = new ArrayList<>(); - //分别新建福利档案基础信息相关的社保、公积金、其他福利档案不可以进行增员的人员列表 - List noPaySocialEmployeeIdList = new ArrayList<>(); - List noPayFundEmployeeIdList = new ArrayList<>(); - List noPayOtherEmployeeIdList = new ArrayList<>(); - //新建最终可以进行增员的人员列表 - List toPayEmployeeIdList = new ArrayList<>(); - //新建最终不可以进行增员的人员列表 - List noPayEmployeeIds = new ArrayList<>(); - //获取待处理的员工id列表 - List employeeIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getEmployeeId).collect(Collectors.toList()); + + //新建最终可以进行增员的福利档案基础信息id列表 + List toPayBaseInfoIdList = new ArrayList<>(); + //新建最终不可以进行增员的福利档案基础信息id列表 + List noPayBaseInfoIds = new ArrayList<>(); + //获取待处理的福利档案基础信息id列表 + List baseInfoIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); //设置最后缴纳月的比较月份 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); String todayMonth = simpleDateFormat.format(new Date()); @@ -722,12 +715,16 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService List socialIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList()); List fundIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList()); List otherIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList()); + + List toStopSocialIds = new ArrayList<>(); + List toStopFundIds = new ArrayList<>(); + List toStopOtherIds = new ArrayList<>(); //获取可进行增员的社保档案相关人员数据 if (socialIds.size() > 0) { //获取社保档案 socialList = getSocialSchemeMapper().getSocialById(socialIds); //筛选可增员的社保档案相关人员信息 - toPaySocialEmployeeIdList = socialList.stream().filter(f-> + toStopSocialIds = socialList.stream().filter(f-> { boolean flag = true; if (f.getSocialStartTime() == null || f.getSocialStartTime().length() == 0 || f.getSocialSchemeId() == null) { @@ -738,16 +735,15 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService } return flag; }) - .map(InsuranceArchivesSocialSchemePO::getEmployeeId).collect(Collectors.toList()); - //获取不可增员的社保档案相关人员信息 - if (toPaySocialEmployeeIdList.size() != baseInfoPOList.size()) { - noPaySocialEmployeeIdList = (List) CollectionUtils.subtract(employeeIds, toPaySocialEmployeeIdList); - } + .map(InsuranceArchivesSocialSchemePO::getId).collect(Collectors.toList()); + List finalToStopSocialIds = toStopSocialIds; + toPayBaseInfoIdList = baseInfoPOList.stream().filter(f -> finalToStopSocialIds.contains(f.getSocialArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); + } if (fundIds.size() > 0) { fundList = getFundSchemeMapper().getFundById(fundIds); - toPayFundEmployeeIdList = fundList.stream().filter(f-> + toStopFundIds = fundList.stream().filter(f-> { boolean flag = true; if (f.getFundStartTime() == null || f.getFundStartTime().length() == 0 || f.getFundSchemeId() == null) { @@ -759,13 +755,13 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService return flag; }) .map(InsuranceArchivesFundSchemePO::getEmployeeId).collect(Collectors.toList()); - if (toPayFundEmployeeIdList.size() != baseInfoPOList.size()) { - noPayFundEmployeeIdList = (List) CollectionUtils.subtract(employeeIds, toPayFundEmployeeIdList); - } + List finalToStopFundIds = toStopFundIds; + toPayBaseInfoIdList = (List) CollectionUtils.union(toPayBaseInfoIdList, baseInfoPOList.stream().filter(f -> finalToStopFundIds.contains(f.getFundArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList())); + } if (otherIds.size() > 0) { otherList = getOtherSchemeMapper().getOtherById(otherIds); - toPayOtherEmployeeIdList = otherList.stream().filter(f-> + toStopOtherIds = otherList.stream().filter(f-> { boolean flag = true; if (f.getOtherStartTime() == null || f.getOtherStartTime().length() == 0 || f.getOtherSchemeId() == null) { @@ -777,26 +773,19 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService return flag; }) .map(InsuranceArchivesOtherSchemePO::getEmployeeId).collect(Collectors.toList()); - if (toPayOtherEmployeeIdList.size() != baseInfoPOList.size()) { - noPayOtherEmployeeIdList = (List) CollectionUtils.subtract(employeeIds, toPayOtherEmployeeIdList); - } - } - //获取最终基础信息表中的可增员数据 - if (noPaySocialEmployeeIdList.size() == 0 && noPayFundEmployeeIdList.size() == 0 && noPayOtherEmployeeIdList.size() ==0) { - //社保、公积金、其他福利档案的可增员的人员信息与入参中的人员信息一致时 - toPayEmployeeIdList = employeeIds; - } else { - //社保、公积金、其他福利档案的可增员的人员信息与入参中的人员信息不一致时,取三类档案可增员的人员并集,作为最终可增员的人员信息 - toPayEmployeeIdList = (List) CollectionUtils.union(CollectionUtils.union(toPaySocialEmployeeIdList, toPayFundEmployeeIdList), toPayOtherEmployeeIdList); - //入参人员信息和最终可增员的人员信息做差集,获得最终不可增员的人员信息 - noPayEmployeeIds = (List) CollectionUtils.subtract(employeeIds, toPayEmployeeIdList); + List finalToStopOtherIds = toStopOtherIds; + toPayBaseInfoIdList = (List) CollectionUtils.union(toPayBaseInfoIdList, baseInfoPOList.stream().filter(f -> finalToStopOtherIds.contains(f.getOtherArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList())); + } + //获取最终基础信息表中的不可增员数据 + noPayBaseInfoIds = (List) CollectionUtils.subtract(baseInfoIds, toPayBaseInfoIdList); + //其他的个税扣缴义务人下的在缴员工中存在该员工,在缴员工未进入停缴员工时,不可进行增员 //进行增员操作 - if (toPayEmployeeIdList.size() > 0) { - getInsuranceBaseInfoMapper().updateRunStatusByEmployeeIds(InsuranceArchivesBaseInfoPO.builder() - .employeeIds(toPayEmployeeIdList).runStatus(EmployeeStatusEnum.PAYING.getValue()).build()); + if (toPayBaseInfoIdList.size() > 0) { + getInsuranceBaseInfoMapper().updateRunStatusByIds(InsuranceArchivesBaseInfoPO.builder() + .ids(toPayBaseInfoIdList).runStatus(EmployeeStatusEnum.PAYING.getValue()).build()); } Map resultMap = new HashMap<>(2); @@ -805,7 +794,7 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService // 批量设为定薪提示 //输出结果,此处需区分单一增员和批量增员 - if (baseInfoPOList.size() == toPayEmployeeIdList.size()) { + if (baseInfoPOList.size() == toPayBaseInfoIdList.size()) { //增员成功 if (baseInfoPOList.size() == 1) { resultMsg = "增员成功"; @@ -820,9 +809,9 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService resultMsg = "增员失败,失败原因:数据未正常维护"; } else { resultMsg = "部分或全部失败:【共提交增员数据" - + employeeIds.size() - +"条,成功" + toPayEmployeeIdList.size() - +"条,失败" + noPayEmployeeIds.size() + + baseInfoIds.size() + +"条,成功" + toPayBaseInfoIdList.size() + +"条,失败" + noPayBaseInfoIds.size() +"条,失败原因:数据未正常维护】"; }