diff --git a/src/com/engine/salary/biz/SIAccountBiz.java b/src/com/engine/salary/biz/SIAccountBiz.java index b81d66d74..9c6791098 100644 --- a/src/com/engine/salary/biz/SIAccountBiz.java +++ b/src/com/engine/salary/biz/SIAccountBiz.java @@ -252,18 +252,24 @@ public class SIAccountBiz extends Service { // empIds = empIds.stream().filter(employeeIdsInTaxAgent::contains).collect(Collectors.toList()); List socials = siArchivesBiz.getSocialByEmployeeIds(empIds); + //过滤出目标个税扣缴义务人相关信息 + socials = socials.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); List emp1 = socials.stream() .filter(s -> StringUtils.isBlank(s.getSocialEndTime()) || (SalaryDateUtil.stringToDate(s.getSocialEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getSocialEndTime() + "-01")))) .map(InsuranceArchivesSocialSchemePO::getEmployeeId) .collect(Collectors.toList()); List funds = siArchivesBiz.getFundByEmployeeIds(empIds); + //过滤出目标个税扣缴义务人相关信息 + funds = funds.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); List emp2 = funds.stream() .filter(s -> StringUtils.isBlank(s.getFundEndTime()) || (SalaryDateUtil.stringToDate(s.getFundEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getFundEndTime() + "-01")))) .map(InsuranceArchivesFundSchemePO::getEmployeeId) .collect(Collectors.toList()); List others = siArchivesBiz.getOtherByEmployeeIds(empIds); + //过滤出目标个税扣缴义务人相关信息 + others = others.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); List emp3 = others.stream() .filter(s -> StringUtils.isBlank(s.getOtherEndTime()) || (SalaryDateUtil.stringToDate(s.getOtherEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getOtherEndTime() + "-01")))) .map(InsuranceArchivesOtherSchemePO::getEmployeeId) @@ -323,7 +329,7 @@ public class SIAccountBiz extends Service { public void commonAccount(/*CountDownLatch countDownLatch, BlockingDeque results,*/ String billMonth, List ids, Long employeeId, String tenantKey, Long paymentOrganization) { /* try {*/ SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); - Map insuranceArchivesAccountPOS = siArchivesBiz.buildBatchAccount(ids); + Map insuranceArchivesAccountPOS = siArchivesBiz.buildBatchAccount(ids, paymentOrganization); List list = new ArrayList<>(); int count = 0; for (Map.Entry entry : insuranceArchivesAccountPOS.entrySet()) { @@ -943,7 +949,7 @@ public class SIAccountBiz extends Service { }); }); //核算开始 - accountSupplement(baseList, employeeIds, param.getBillMonth(), employeeId); + accountSupplement(baseList, employeeIds, param.getBillMonth(), employeeId, param.getPaymentOrganization()); updateBatchAccount(AccountParam.builder().billMonth(param.getBillMonth()).paymentOrganization(param.getPaymentOrganization()).build(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, currentUserName); } @@ -953,9 +959,9 @@ public class SIAccountBiz extends Service { * @param employeeIds 需要补缴的员工id * @return */ - public String accountSupplement(List baseList, List employeeIds, String billMonth, Long employeeId) { + public String accountSupplement(List baseList, List employeeIds, String billMonth, Long employeeId, Long paymentOrganization) { //(k,v) k-员工id v-员工对应的福利档案数据 - Map longInsuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds); + Map longInsuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds, paymentOrganization); //核算结果集 List pos = new ArrayList<>(); baseList.forEach(baseParam -> { @@ -1499,7 +1505,7 @@ public class SIAccountBiz extends Service { } - public void accountInspect(Collection ids, String billMonth, Long employeeId, String currentUserName) { + public void accountInspect(Collection ids, String billMonth, Long employeeId, String currentUserName, Long paymentOrganization) { List insuranceAccountInspectPOS = allInspects(ids, billMonth); SalaryAssert.notEmpty(insuranceAccountInspectPOS, SalaryI18nUtil.getI18nLabel(100515, "无核算数据")); List commonInspects = insuranceAccountInspectPOS.stream() @@ -1527,7 +1533,7 @@ public class SIAccountBiz extends Service { base.setSupplementaryMonth(e.getSupplementaryMonth()); baseList.add(base); }); - accountSupplement(baseList, baseList.stream().map(SupplementAccountBaseParam::getEmployeeId).collect(Collectors.toList()), billMonth, employeeId); + accountSupplement(baseList, baseList.stream().map(SupplementAccountBaseParam::getEmployeeId).collect(Collectors.toList()), billMonth, employeeId, paymentOrganization); } } diff --git a/src/com/engine/salary/biz/SIArchivesBiz.java b/src/com/engine/salary/biz/SIArchivesBiz.java index c47f1d4d8..84c939c7e 100644 --- a/src/com/engine/salary/biz/SIArchivesBiz.java +++ b/src/com/engine/salary/biz/SIArchivesBiz.java @@ -93,7 +93,7 @@ public class SIArchivesBiz { * @param user * @return */ - public Map getBaseForm(WelfareTypeEnum welfareType, Long employeeId, Long operateId, User user) { + public Map getBaseForm(WelfareTypeEnum welfareType, Long employeeId, Long operateId, User user, Long paymentOrganization) { Map data = new HashMap<>(16); SalaryAssert.notNull(employeeId, "员工id不可为空"); EmployBiz employBiz = new EmployBiz(); @@ -141,7 +141,7 @@ public class SIArchivesBiz { //返回数据 switch (welfareType) { case SOCIAL_SECURITY: - InsuranceArchivesSocialSchemeDTO insuranceArchivesSocialSchemeDTO = buildSocialForm(employeeId, operateId); + InsuranceArchivesSocialSchemeDTO insuranceArchivesSocialSchemeDTO = buildSocialForm(employeeId, operateId, paymentOrganization); List socialList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.SOCIAL_SECURITY.getValue())).collect(Collectors.toList()); List socialOptions = new ArrayList<>(); socialList.forEach(social -> { @@ -160,7 +160,7 @@ public class SIArchivesBiz { data.put("items", addGroups); break; case ACCUMULATION_FUND: - InsuranceArchivesFundSchemeDTO insuranceArchivesFundSchemeDTO = buildFundForm(employeeId, operateId); + InsuranceArchivesFundSchemeDTO insuranceArchivesFundSchemeDTO = buildFundForm(employeeId, operateId, paymentOrganization); List fundList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.ACCUMULATION_FUND.getValue())).collect(Collectors.toList()); List fundOptions = new ArrayList<>(); fundList.forEach(social -> { @@ -178,7 +178,7 @@ public class SIArchivesBiz { data.put("items", addGroups); break; case OTHER: - InsuranceArchivesOtherSchemeDTO insuranceArchivesOtherSchemeDTO = buildOtherForm(employeeId, operateId); + InsuranceArchivesOtherSchemeDTO insuranceArchivesOtherSchemeDTO = buildOtherForm(employeeId, operateId, paymentOrganization); List otherList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.OTHER.getValue())).collect(Collectors.toList()); List otherOptions = new ArrayList<>(); otherList.forEach(social -> { @@ -238,17 +238,17 @@ public class SIArchivesBiz { * @param schemeId * @return */ - public Map getPaymentForm(User user, WelfareTypeEnum welfareType, Long employeeId, long operateId, Long schemeId) { + public Map getPaymentForm(User user, WelfareTypeEnum welfareType, Long employeeId, long operateId, Long schemeId, Long paymentOrganization) { Map data = new HashMap<>(16); switch (welfareType) { case SOCIAL_SECURITY: - data = buildSocialPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue()); + data = buildSocialPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue(), paymentOrganization); break; case ACCUMULATION_FUND: - data = buildFundPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue()); + data = buildFundPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue(), paymentOrganization); break; case OTHER: - data = buildOtherPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue()); + data = buildOtherPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue(), paymentOrganization); break; default: } @@ -263,9 +263,9 @@ public class SIArchivesBiz { * @param operateId * @return */ - public Map buildOtherPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType) { + public Map buildOtherPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType, Long paymentOrganization) { Map dataMap = new HashMap<>(); - InsuranceArchivesOtherSchemeDTO data = buildOtherForm(employeeId, operateId); + InsuranceArchivesOtherSchemeDTO data = buildOtherForm(employeeId, operateId, paymentOrganization); if (data != null) { dataMap.put("data", JSONObject.parseObject(data.getOtherPaymentBaseString(), new TypeReference>() { })); @@ -285,10 +285,10 @@ public class SIArchivesBiz { * @param operateId * @return */ - public Map buildFundPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType) { + public Map buildFundPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType, Long paymentOrganization) { Map dataMap = new HashMap<>(); - InsuranceArchivesFundSchemeDTO data = buildFundForm(employeeId, operateId); + InsuranceArchivesFundSchemeDTO data = buildFundForm(employeeId, operateId, paymentOrganization); if (data != null) { dataMap.put("data", JSONObject.parseObject(data.getFundPaymentBaseString(), new TypeReference>() { })); @@ -308,9 +308,9 @@ public class SIArchivesBiz { * @param operateId * @return */ - public Map buildSocialPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType) { + public Map buildSocialPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType, Long paymentOrganization) { Map dataMap = new HashMap<>(); - InsuranceArchivesSocialSchemeDTO data = buildSocialForm(employeeId, operateId); + InsuranceArchivesSocialSchemeDTO data = buildSocialForm(employeeId, operateId, paymentOrganization); if (data != null) { dataMap.put("data", JSONObject.parseObject(data.getSchemePaymentBaseString(), new TypeReference>() { })); @@ -389,11 +389,15 @@ public class SIArchivesBiz { * @param operateId * @return */ - public InsuranceArchivesOtherSchemeDTO buildOtherForm(Long employeeId, Long operateId) { + public InsuranceArchivesOtherSchemeDTO buildOtherForm(Long employeeId, Long operateId, Long paymentOrganization) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); try { OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); - List otherList = otherSchemeMapper.getOtherByEmployeeId(Collections.singletonList(employeeId)); +// List otherList = otherSchemeMapper.getOtherByEmployeeId(Collections.singletonList(employeeId)); + List otherList = otherSchemeMapper.getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); InsuranceArchivesOtherSchemePOEncrypt.decryptList(otherList); InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO = otherList.size() != 0 ? otherList.get(0) : null; InsuranceArchivesOtherSchemeDTO data = InsuranceArchivesBO.convertOtherPOtoDTO(insuranceArchivesOtherSchemePO, employeeId); @@ -415,12 +419,16 @@ public class SIArchivesBiz { * @param operateId * @return */ - public InsuranceArchivesFundSchemeDTO buildFundForm(Long employeeId, Long operateId) { + public InsuranceArchivesFundSchemeDTO buildFundForm(Long employeeId, Long operateId, Long paymentOrganization) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); try { FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); - List fundList = fundSchemeMapper.getFundByEmployeeId(Collections.singletonList(employeeId)); +// List fundList = fundSchemeMapper.getFundByEmployeeId(Collections.singletonList(employeeId)); + List fundList = fundSchemeMapper.getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); InsuranceArchivesFundSchemePOEncrypt.decryptList(fundList); InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO = fundList.size() != 0 ? fundList.get(0) : null; InsuranceArchivesFundSchemeDTO data = InsuranceArchivesBO.convertFundPOtoDTO(insuranceArchivesFundSchemePO, employeeId); @@ -442,8 +450,8 @@ public class SIArchivesBiz { * @param operateId * @return */ - public InsuranceArchivesSocialSchemeDTO buildSocialForm(Long employeeId, Long operateId) { - InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO = getSocialByEmployeeId(employeeId); + public InsuranceArchivesSocialSchemeDTO buildSocialForm(Long employeeId, Long operateId, Long paymentOrganization) { + InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO = getSocialByEmployeeId(employeeId, paymentOrganization); InsuranceArchivesSocialSchemeDTO data = InsuranceArchivesBO.convertSocialPOtoDTO(insuranceArchivesSocialSchemePO, employeeId); if (insuranceArchivesSocialSchemePO == null) { data.setEmployeeId(employeeId); @@ -459,11 +467,14 @@ public class SIArchivesBiz { * @param employeeId * @return */ - public InsuranceArchivesSocialSchemePO getSocialByEmployeeId(Long employeeId) { + public InsuranceArchivesSocialSchemePO getSocialByEmployeeId(Long employeeId, Long paymentOrganization) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); try { SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); - List socialList = socialSchemeMapper.getSocialByEmployeeId(Collections.singletonList(employeeId)); + List socialList = socialSchemeMapper.getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); InsuranceArchivesSocialSchemePOEncrypt.decryptList(socialList); return socialList.size() != 0 ? socialList.get(0) : null; } finally { @@ -520,6 +531,55 @@ public class SIArchivesBiz { } } + /** + * 根据人员id和个税扣缴人id获取记录 + */ + public List getSocialByEmployeeIdAndPayOrg(List insuranceArchivesEmployeePOS) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + List allList = new ArrayList<>(); + for (InsuranceArchivesEmployeePO po : insuranceArchivesEmployeePOS) { + List socialList = socialSchemeMapper.getSocialByEmployeeIdAndPayOrg(po); + allList.addAll(socialList); + } + return allList; + } finally { + sqlSession.close(); + } + } + + + public List getFundByEmployeeIdAndPayOrg(List insuranceArchivesEmployeePOS) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); + List allList = new ArrayList<>(); + for (InsuranceArchivesEmployeePO po : insuranceArchivesEmployeePOS) { + List fundList = fundSchemeMapper.getFundByEmployeeIdAndPayOrg(po); + allList.addAll(fundList); + } + return allList; + } finally { + sqlSession.close(); + } + } + + public List getOtherByEmployeeIdAndPayOrg(List insuranceArchivesEmployeePOS) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); + List allList = new ArrayList<>(); + for (InsuranceArchivesEmployeePO po : insuranceArchivesEmployeePOS) { + List otherList = otherSchemeMapper.getOtherByEmployeeIdAndPayOrg(po); + allList.addAll(otherList); + } + return allList; + } finally { + sqlSession.close(); + } + } + /** * 新增 @@ -556,8 +616,12 @@ public class SIArchivesBiz { InsuranceArchivesOtherSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesOtherSaveParam.class); SalaryAssert.notNull("员工id为空", param, param.getEmployeeId()); -// otherSchemeMapper.batchDeleteByEmployeeIds(Collections.singletonList(param.getEmployeeId())); - List oldOtherInfoList = otherSchemeMapper.getOtherByEmployeeId(Collections.singletonList(param.getEmployeeId())); + +// List oldOtherInfoList = otherSchemeMapper.getOtherByEmployeeId(Collections.singletonList(param.getEmployeeId())); + List oldOtherInfoList = otherSchemeMapper.getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); if (oldOtherInfoList.size() == 1) { InsuranceArchivesOtherSchemePO oldOtherInfo = oldOtherInfoList.get(0); InsuranceArchivesOtherSchemePO updateOtherInfo = @@ -599,8 +663,12 @@ public class SIArchivesBiz { FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); InsuranceArchivesFundSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesFundSaveParam.class); SalaryAssert.notNull("员工id为空", param, param.getEmployeeId()); -// fundSchemeMapper.batchDeleteByEmployeeIds(Collections.singletonList(param.getEmployeeId())); - List oldFundInfoList = fundSchemeMapper.getFundByEmployeeId(Collections.singletonList(param.getEmployeeId())); + +// List oldFundInfoList = fundSchemeMapper.getFundByEmployeeId(Collections.singletonList(param.getEmployeeId())); + List oldFundInfoList = fundSchemeMapper.getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); if (oldFundInfoList.size() == 1) { InsuranceArchivesFundSchemePO oldFundInfo = oldFundInfoList.get(0); InsuranceArchivesFundSchemePO updateFundInfo = InsuranceArchivesFundSchemePO.builder() @@ -651,7 +719,11 @@ public class SIArchivesBiz { // socialSchemeMapper.batchDeleteByEmployeeIds(Collections.singletonList(param.getEmployeeId())); //查询已有数据 - List oldSocialInfoList = socialSchemeMapper.getSocialByEmployeeId(Collections.singletonList(param.getEmployeeId())); +// List oldSocialInfoList = socialSchemeMapper.getSocialByEmployeeId(Collections.singletonList(param.getEmployeeId())); + List oldSocialInfoList = socialSchemeMapper.getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); //组装新数据 if (oldSocialInfoList.size() == 1) { InsuranceArchivesSocialSchemePO oldSocialInfo = oldSocialInfoList.get(0); @@ -866,6 +938,8 @@ public class SIArchivesBiz { public Map> buildColumnTitle(List insuranceArchivesEmployeePOS, long operateId) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); Map> result = new HashMap<>(); + + insuranceArchivesEmployeePOS = insuranceArchivesEmployeePOS.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(InsuranceArchivesEmployeePO::getEmployeeId))), ArrayList::new)); try { SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); @@ -979,20 +1053,20 @@ public class SIArchivesBiz { OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); InsuranceSchemeMapper insuranceSchemeMapper = sqlSession.getMapper(InsuranceSchemeMapper.class); - List employeeIds = insuranceArchivesEmployeePOS.stream().map(InsuranceArchivesEmployeePO::getEmployeeId).collect(Collectors.toList()); - Map socialSchemePOMap = InsuranceArchivesSocialSchemePOEncrypt.decryptList(this.getSocialByEmployeeIds(employeeIds)) - .stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getEmployeeId, Function.identity())); +// List employeeIds = insuranceArchivesEmployeePOS.stream().map(InsuranceArchivesEmployeePO::getEmployeeId).collect(Collectors.toList()); + Map socialSchemePOMap = InsuranceArchivesSocialSchemePOEncrypt.decryptList(this.getSocialByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS)) + .stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getId, Function.identity())); - Map fundSchemePOMap = InsuranceArchivesFundSchemePOEncrypt.decryptList(this.getFundByEmployeeIds(employeeIds)) - .stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getEmployeeId, Function.identity())); - List otherByEmployeeList = this.getOtherByEmployeeIds(employeeIds); + Map fundSchemePOMap = InsuranceArchivesFundSchemePOEncrypt.decryptList(this.getFundByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS)) + .stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getId, Function.identity())); + List otherByEmployeeList = this.getOtherByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS); InsuranceArchivesOtherSchemePOEncrypt.decryptList(otherByEmployeeList); Map otherSchemePOMap = otherByEmployeeList - .stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getEmployeeId, Function.identity())); + .stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getId, Function.identity())); insuranceArchivesEmployeePOS.forEach(item -> { - InsuranceArchivesSocialSchemePO socialItem = socialSchemePOMap.get(item.getEmployeeId()); - InsuranceArchivesFundSchemePO fundItem = fundSchemePOMap.get(item.getEmployeeId()); - InsuranceArchivesOtherSchemePO otherItem = otherSchemePOMap.get(item.getEmployeeId()); + InsuranceArchivesSocialSchemePO socialItem = socialSchemePOMap.get(item.getSocialId()); + InsuranceArchivesFundSchemePO fundItem = fundSchemePOMap.get(item.getFundId()); + InsuranceArchivesOtherSchemePO otherItem = otherSchemePOMap.get(item.getOtherId()); Map map = new HashMap<>(); map.put("employeeName", item.getUserName()); map.put("paymentOrganizationName", longTaxAgentPOMap.get(item.getPaymentOrganization()) != null ? longTaxAgentPOMap.get(item.getPaymentOrganization()).getName() : ""); @@ -1006,6 +1080,7 @@ public class SIArchivesBiz { map.put("otherSchemeId", item.getOtherSchemeId()); map.put("status", item.getUserStatus() != null ? UserStatusEnum.values()[item.getUserStatus()].getDefaultLabel() : ""); map.put("baseInfo", item.getBaseInfoId()); + map.put("paymentOrganization", item.getPaymentOrganization()); if (socialItem != null) { map.put("socialName", insuranceSchemeMapper.querySchemeName(socialItem.getSocialSchemeId())); Map socialJson = JSON.parseObject(socialItem.getSocialPaymentBaseString(), new TypeReference>() { @@ -1207,23 +1282,32 @@ public class SIArchivesBiz { * @param ids 员工id集合 * @return map */ - public Map buildBatchAccount(List ids) { + public Map buildBatchAccount(List ids, Long paymentOrganization) { if (CollectionUtils.isEmpty(ids)) { return new HashMap<>(); } + //设置获取社保/公积金/其他福利档案方法的入参 + List insuranceArchivesEmployeePOS = new ArrayList<>(); + for (Long employeeId : ids) { + insuranceArchivesEmployeePOS.add(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + } + Map result = new HashMap<>(); Map socialMap = new HashMap<>(); Map funMap = new HashMap<>(); Map otherMap = new HashMap<>(); - List socialPOS = InsuranceArchivesSocialSchemePOEncrypt.decryptList(this.getSocialByEmployeeIds(ids)); + List socialPOS = InsuranceArchivesSocialSchemePOEncrypt.decryptList(this.getSocialByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS)); if (CollectionUtils.isNotEmpty(socialPOS)) { socialMap = socialPOS.stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getEmployeeId, Function.identity())); } - List fundPOS = InsuranceArchivesFundSchemePOEncrypt.decryptList(this.getFundByEmployeeIds(ids)); + List fundPOS = InsuranceArchivesFundSchemePOEncrypt.decryptList(this.getFundByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS)); if (CollectionUtils.isNotEmpty(fundPOS)) { funMap = fundPOS.stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getEmployeeId, Function.identity())); } - List otherPOS = this.getOtherByEmployeeIds(ids); + List otherPOS = this.getOtherByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS); InsuranceArchivesOtherSchemePOEncrypt.decryptList(otherPOS); if (CollectionUtils.isNotEmpty(otherPOS)) { otherMap = otherPOS.stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getEmployeeId, Function.identity())); diff --git a/src/com/engine/salary/entity/siaccount/bo/InsuranceComparisonResultBO.java b/src/com/engine/salary/entity/siaccount/bo/InsuranceComparisonResultBO.java index 0e145342c..d6f6ab501 100644 --- a/src/com/engine/salary/entity/siaccount/bo/InsuranceComparisonResultBO.java +++ b/src/com/engine/salary/entity/siaccount/bo/InsuranceComparisonResultBO.java @@ -207,12 +207,12 @@ public class InsuranceComparisonResultBO { Map temp = Maps.newHashMap(); if (accountMap != null && accountMap.get(welfare.getId().toString()) != null) { - temp.put("acctResultValue", accountMap.get(welfare.getId().toString())); + temp.put("acctResultValue", dealNull(accountMap.get(welfare.getId().toString()))); } else { temp.put("acctResultValue", ""); } if (excelAccountMap != null && excelAccountMap.get(welfare.getId().toString()) != null) { - temp.put("excelResultValue", excelAccountMap.get(welfare.getId().toString())); + temp.put("excelResultValue", dealNull(excelAccountMap.get(welfare.getId().toString()))); }else { temp.put("excelResultValue", ""); } diff --git a/src/com/engine/salary/entity/siaccount/param/InspectAccountParam.java b/src/com/engine/salary/entity/siaccount/param/InspectAccountParam.java index 933625609..d52bcd056 100644 --- a/src/com/engine/salary/entity/siaccount/param/InspectAccountParam.java +++ b/src/com/engine/salary/entity/siaccount/param/InspectAccountParam.java @@ -27,4 +27,6 @@ public class InspectAccountParam { //账单月份") private String billMonth; + + private Long paymentOrganization; } diff --git a/src/com/engine/salary/entity/siarchives/bo/InsuranceArchivesBaseInfoBO.java b/src/com/engine/salary/entity/siarchives/bo/InsuranceArchivesBaseInfoBO.java index ef62a2a34..f5cd11ee4 100644 --- a/src/com/engine/salary/entity/siarchives/bo/InsuranceArchivesBaseInfoBO.java +++ b/src/com/engine/salary/entity/siarchives/bo/InsuranceArchivesBaseInfoBO.java @@ -55,20 +55,20 @@ public class InsuranceArchivesBaseInfoBO { Map insuranceArchivesBaseInfoListMap = SalaryEntityUtil.convert2Map(insuranceArchivesBaseInfoList, k -> k.getPaymentOrganization() + "-" + k.getEmployeeId()); taxAgentEmpChanges.forEach(change -> { - //以人员id筛选出侧面比较的档案数据,避免存在当前个税扣缴义务人外的该人员档案数据 - List moreBaseInfos = insuranceArchivesBaseInfoList.stream().filter(f -> f.getEmployeeId().equals(change.getEmployeeId())).collect(Collectors.toList()); +// //以人员id筛选出侧面比较的档案数据,避免存在当前个税扣缴义务人外的该人员档案数据 +// List moreBaseInfos = insuranceArchivesBaseInfoList.stream().filter(f -> f.getEmployeeId().equals(change.getEmployeeId())).collect(Collectors.toList()); //以个税扣缴义务人和人员id为条件筛选当前数据直接对比的档案数据 InsuranceArchivesBaseInfoPO insuranceBaseInfo = insuranceArchivesBaseInfoListMap.get(change.getTaxAgentId() + "-" + change.getEmployeeId()); // 如果是新增 说明:如果没有档案,则新增,如果有档案而且是停止缴纳,就转移到待增员中,以个税扣缴义务人和人员id判断唯一 if (change.getChangeType() == TaxAgentEmpChangeTypeEnum.ADD.getValue()) { - if (insuranceBaseInfo != null && moreBaseInfos.size() == 1) { + if (insuranceBaseInfo != null) { // 停止缴纳->待增员 if (insuranceBaseInfo.getRunStatus().equals(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue()) || insuranceBaseInfo.getRunStatus().equals(EmployeeStatusEnum.STOP_PAYMENT_FROM_ADD.getValue())) { insuranceBaseInfo.setRunStatus(EmployeeStatusEnum.STAY_ADD.getValue()); insuranceBaseInfo.setUpdateTime(now); baseInfoUpdateTodoList.add(insuranceBaseInfo); } - } else if (insuranceBaseInfo == null && moreBaseInfos.size() == 0) { + } else { //新增社保、公积金、其他福利档案 // 新增基础信息 baseInfoAddTodoList.add(InsuranceArchivesBaseInfoPO.builder() @@ -85,7 +85,7 @@ public class InsuranceArchivesBaseInfoBO { } // 如果是删除 说明:如果有档案并且是在缴纳中才处理,没档案不用管 } else if (change.getChangeType() == TaxAgentEmpChangeTypeEnum.DEL.getValue()) { - if (insuranceBaseInfo != null && moreBaseInfos.size() == 1) { + if (insuranceBaseInfo != null) { if (insuranceBaseInfo.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue())) { // 正在缴纳->待减员 insuranceBaseInfo.setRunStatus(EmployeeStatusEnum.STAY_DEL.getValue()); diff --git a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesEmployeePO.java b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesEmployeePO.java index 170e41bde..42e58dfc9 100644 --- a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesEmployeePO.java +++ b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesEmployeePO.java @@ -53,4 +53,12 @@ public class InsuranceArchivesEmployeePO { private Long otherSchemeId; private Long baseInfoId; + /** + * 社保、公积金、其他福利档案id + */ + private Long socialId; + + private Long fundId; + + private Long otherId; } diff --git a/src/com/engine/salary/mapper/siarchives/FundSchemeMapper.java b/src/com/engine/salary/mapper/siarchives/FundSchemeMapper.java index f55930382..cfee53a1c 100644 --- a/src/com/engine/salary/mapper/siarchives/FundSchemeMapper.java +++ b/src/com/engine/salary/mapper/siarchives/FundSchemeMapper.java @@ -1,5 +1,6 @@ package com.engine.salary.mapper.siarchives; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO; import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO; import org.apache.ibatis.annotations.Param; @@ -22,6 +23,14 @@ public interface FundSchemeMapper { */ List getFundByEmployeeId(@Param("employeeIds")List employeeId); + /** + * 根据人员id和个税扣缴人id获取记录 + * @param insuranceArchivesEmployeePO + * @return + */ + List getFundByEmployeeIdAndPayOrg(@Param("param") InsuranceArchivesEmployeePO insuranceArchivesEmployeePO); + + /** * 根据id获取 * @param ids @@ -35,6 +44,11 @@ public interface FundSchemeMapper { */ void batchDeleteByEmployeeIds(@Param("employeeIds") Collection singletonList); + /** + * 根据人员id和个税扣缴义务人删除档案 + * @param insuranceArchivesFundSchemePO + */ + void deleteByEmployeeIdAndPayOrg(@Param("param") InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO); /** * 批量保存 * @param singletonList diff --git a/src/com/engine/salary/mapper/siarchives/FundSchemeMapper.xml b/src/com/engine/salary/mapper/siarchives/FundSchemeMapper.xml index db9f435af..00d4e32f9 100644 --- a/src/com/engine/salary/mapper/siarchives/FundSchemeMapper.xml +++ b/src/com/engine/salary/mapper/siarchives/FundSchemeMapper.xml @@ -58,6 +58,16 @@ + + + SELECT @@ -169,17 +178,17 @@ SELECT FROM hrsa_insurance_base_info t - LEFT JOIN( SELECT social.employee_id, social.social_end_time FROM hrsa_social_archives social WHERE social.delete_type = 0 )social ON t.employee_id = social.employee_id - LEFT JOIN( SELECT fund.employee_id, fund.fund_end_time FROM hrsa_fund_archives fund WHERE fund.delete_type = 0 )fund ON t.employee_id = fund.employee_id - LEFT JOIN( SELECT other.employee_id, other.other_end_time FROM hrsa_other_archives other WHERE other.delete_type = 0 )other ON t.employee_id = other.employee_id + LEFT JOIN( SELECT social.payment_organization, social.employee_id, social.social_end_time FROM hrsa_social_archives social WHERE social.delete_type = 0 )social ON t.employee_id = social.employee_id AND t.payment_organization = social.payment_organization + LEFT JOIN( SELECT fund.payment_organization, fund.employee_id, fund.fund_end_time FROM hrsa_fund_archives fund WHERE fund.delete_type = 0 )fund ON t.employee_id = fund.employee_id AND t.payment_organization = fund.payment_organization + LEFT JOIN( SELECT other.payment_organization, other.employee_id, other.other_end_time FROM hrsa_other_archives other WHERE other.delete_type = 0 )other ON t.employee_id = other.employee_id AND t.payment_organization = other.payment_organization WHERE t.delete_type = 0 AND t.run_status = '3' AND ( - (social.social_end_time is not null and social.social_end_time ]]> '' and social.social_end_time ]]> #{today}) + (social.social_end_time is not null and social.social_end_time ]]> ' ' and social.social_end_time ]]> #{today}) OR - (fund.fund_end_time is not null and fund.fund_end_time ]]> '' and fund.fund_end_time ]]> #{today}) + (fund.fund_end_time is not null and fund.fund_end_time ]]> ' ' and fund.fund_end_time ]]> #{today}) OR - (other.other_end_time is not null and other.other_end_time ]]> '' and other.other_end_time ]]> #{today}) + (other.other_end_time is not null and other.other_end_time ]]> ' ' and other.other_end_time ]]> #{today}) ) @@ -187,14 +196,14 @@ SELECT FROM hrsa_insurance_base_info t - LEFT JOIN( SELECT social.employee_id, social.social_end_time FROM hrsa_social_archives social WHERE social.delete_type = 0 )social ON t.employee_id = social.employee_id - LEFT JOIN( SELECT fund.employee_id, fund.fund_end_time FROM hrsa_fund_archives fund WHERE fund.delete_type = 0 )fund ON t.employee_id = fund.employee_id - LEFT JOIN( SELECT other.employee_id, other.other_end_time FROM hrsa_other_archives other WHERE other.delete_type = 0 )other ON t.employee_id = other.employee_id + LEFT JOIN( SELECT social.payment_organization, social.employee_id, social.social_end_time FROM hrsa_social_archives social WHERE social.delete_type = 0 )social ON t.employee_id = social.employee_id AND t.payment_organization = social.payment_organization + LEFT JOIN( SELECT fund.payment_organization, fund.employee_id, fund.fund_end_time FROM hrsa_fund_archives fund WHERE fund.delete_type = 0 )fund ON t.employee_id = fund.employee_id AND t.payment_organization = fund.payment_organization + LEFT JOIN( SELECT other.payment_organization, other.employee_id, other.other_end_time FROM hrsa_other_archives other WHERE other.delete_type = 0 )other ON t.employee_id = other.employee_id AND t.payment_organization = other.payment_organization WHERE t.delete_type = 0 AND t.run_status = '2' - AND social.social_end_time is not null and social.social_end_time ]]> '' and social.social_end_time #{today} - AND fund.fund_end_time is not null and fund.fund_end_time ]]> '' and fund.fund_end_time #{today} - AND other.other_end_time is not null and other.other_end_time ]]> '' and other.other_end_time #{today} + AND social.social_end_time is not null and social.social_end_time ]]> ' ' and social.social_end_time #{today} + AND fund.fund_end_time is not null and fund.fund_end_time ]]> ' ' and fund.fund_end_time #{today} + AND other.other_end_time is not null and other.other_end_time ]]> ' ' and other.other_end_time #{today} + + + + + +