diff --git a/src/com/engine/salary/service/impl/RecordsBuildServiceImpl.java b/src/com/engine/salary/service/impl/RecordsBuildServiceImpl.java index 0c27fecea..c32c2c001 100644 --- a/src/com/engine/salary/service/impl/RecordsBuildServiceImpl.java +++ b/src/com/engine/salary/service/impl/RecordsBuildServiceImpl.java @@ -28,6 +28,7 @@ import com.engine.salary.util.SalaryEnumUtil; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.db.MapperProxyFactory; import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import weaver.hrm.User; @@ -44,6 +45,7 @@ import java.util.stream.Collectors; * @Date 2022/4/11 * @Version V1.0 **/ +@Slf4j public class RecordsBuildServiceImpl extends Service implements RecordsBuildService { private EmployMapper getEmployMapper() { @@ -92,230 +94,236 @@ public class RecordsBuildServiceImpl extends Service implements RecordsBuildServ Map collect = employeeByIds.stream().collect(Collectors.toMap(DataCollectionEmployee::getEmployeeId, Function.identity())); list.forEach(item -> { Map record = new HashMap<>(); - DataCollectionEmployee simpleEmployee = collect.get(item.getEmployeeId()); - UserStatusEnum userStatusEnum = UserStatusEnum.parseByValue(Integer.parseInt(simpleEmployee.getStatus())); + try { + DataCollectionEmployee simpleEmployee = collect.get(item.getEmployeeId()); + UserStatusEnum userStatusEnum = UserStatusEnum.parseByValue(Integer.parseInt(simpleEmployee.getStatus())); - record.put("id", item.getId()); - record.put("employeeId", item.getEmployeeId()); - record.put("billMonth", item.getBillMonth()); - record.put("billStatus", SalaryEnumUtil.enumMatchByValue(item.getBillStatus(), BillStatusEnum.values(), BillStatusEnum.class)); - record.put("userName", simpleEmployee.getUsername()); - record.put("department", simpleEmployee.getDepartmentName()); - record.put("supplementaryMonth", item.getSupplementaryMonth()); - record.put("mobile", simpleEmployee.getMobile()); + record.put("id", item.getId()); + record.put("employeeId", item.getEmployeeId()); + record.put("billMonth", item.getBillMonth()); + record.put("billStatus", SalaryEnumUtil.enumMatchByValue(item.getBillStatus(), BillStatusEnum.values(), BillStatusEnum.class)); + record.put("userName", simpleEmployee.getUsername()); + record.put("department", simpleEmployee.getDepartmentName()); + record.put("supplementaryMonth", item.getSupplementaryMonth()); + record.put("mobile", simpleEmployee.getMobile()); // record.put("employeeStatus", simpleEmployee.getStatus() != null ? UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(simpleEmployee.getStatus())) : ""); - record.put("employeeStatus", simpleEmployee.getStatus() != null ? SalaryI18nUtil.getI18nLabel(user.getLanguage(), userStatusEnum.getLabelId(), userStatusEnum.getDefaultLabel()) : ""); - ResourceFromEnum from = SalaryEnumUtil.enumMatchByValue(item.getResourceFrom(), ResourceFromEnum.values(), ResourceFromEnum.class); - record.put("workcode", StringUtils.isBlank(simpleEmployee.getWorkcode()) ? "" : simpleEmployee.getWorkcode()); - record.put("sourceFrom", SalaryI18nUtil.getI18nLabel(user.getLanguage(),from.getLabelId(), from.getDefaultLabel())); - record.put("socialPayOrg", paymentMap.get(item.getSocialPayOrg()) == null ? "" : paymentMap.get(item.getSocialPayOrg()).getName()); - record.put("socialAccount", item.getSocialAccount()); + record.put("employeeStatus", simpleEmployee.getStatus() != null ? SalaryI18nUtil.getI18nLabel(user.getLanguage(), userStatusEnum.getLabelId(), userStatusEnum.getDefaultLabel()) : ""); + ResourceFromEnum from = SalaryEnumUtil.enumMatchByValue(item.getResourceFrom(), ResourceFromEnum.values(), ResourceFromEnum.class); + record.put("workcode", StringUtils.isBlank(simpleEmployee.getWorkcode()) ? "" : simpleEmployee.getWorkcode()); + record.put("sourceFrom", SalaryI18nUtil.getI18nLabel(user.getLanguage(),from.getLabelId(), from.getDefaultLabel())); + record.put("socialPayOrg", paymentMap.get(item.getSocialPayOrg()) == null ? "" : paymentMap.get(item.getSocialPayOrg()).getName()); + record.put("socialAccount", item.getSocialAccount()); - record.put("socialSchemeName", getInsuranceSchemeMapper().querySchemeName(item.getSocialSchemeId())); - if (StringUtils.isNotEmpty(item.getSocialPaymentBaseString()) || StringUtils.isNotEmpty(item.getSocialPaymentComBaseString())) { - Map socialJson = JSON.parseObject(item.getSocialPaymentBaseString(), new HashMap().getClass()); + record.put("socialSchemeName", getInsuranceSchemeMapper().querySchemeName(item.getSocialSchemeId())); + if (StringUtils.isNotEmpty(item.getSocialPaymentBaseString()) || StringUtils.isNotEmpty(item.getSocialPaymentComBaseString())) { + Map socialJson = JSON.parseObject(item.getSocialPaymentBaseString(), new HashMap().getClass()); // if(socialJson!=null){ // socialJson.forEach((k, v) -> { // record.put(k + "socialBase", (String) v); // }); // } - if (welBaseDiffSign) { - if (socialJson != null) { - //查询该福利方案下开启缴纳的福利项 + if (welBaseDiffSign) { + if (socialJson != null) { + //查询该福利方案下开启缴纳的福利项 // List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); - List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); - socialJson.forEach((k, v) -> { - if (insuranceIdList.contains(Long.valueOf(k))) { - record.put(k + "socialPerBase", v); - } + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + socialJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "socialPerBase", v); + } + }); + } + Map socialComJson = JSON.parseObject(item.getSocialPaymentComBaseString(), new TypeReference>() { }); - } - Map socialComJson = JSON.parseObject(item.getSocialPaymentComBaseString(), new TypeReference>() { - }); - if (socialComJson != null) { - //查询该福利方案下开启缴纳的福利项 + if (socialComJson != null) { + //查询该福利方案下开启缴纳的福利项 // List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); - List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); - socialComJson.forEach((k, v) -> { - if (insuranceIdList.contains(Long.valueOf(k))) { - record.put(k + "socialComBase", v); - } - }); - } - } else { - if (socialJson != null) { - //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + socialComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "socialComBase", v); + } + }); + } + } else { + if (socialJson != null) { + //查询该福利方案下开启缴纳的福利项 // List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId()); - List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId()); - socialJson.forEach((k, v) -> { - if (insuranceIdList.contains(Long.valueOf(k))) { - record.put(k + "socialBase", v); - } - }); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId()); + socialJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "socialBase", v); + } + }); + } } } - } - record.put("fundPayOrg", item.getFundPayOrg() == null ? "" : (paymentMap.getOrDefault(item.getFundPayOrg(),TaxAgentPO.builder().build())).getName()); - record.put("fundAccount", item.getFundAccount()); - record.put("fundSchemeName", getInsuranceSchemeMapper().querySchemeName(item.getFundSchemeId())); - record.put("supplementFundAccount", item.getSupplementFundAccount()); - if (StringUtils.isNotEmpty(item.getFundPaymentBaseString()) || StringUtils.isNotEmpty(item.getFundPaymentComBaseString())) { - Map fundJson = JSON.parseObject(item.getFundPaymentBaseString(), new HashMap().getClass()); + record.put("fundPayOrg", item.getFundPayOrg() == null ? "" : (paymentMap.getOrDefault(item.getFundPayOrg(),TaxAgentPO.builder().build())).getName()); + record.put("fundAccount", item.getFundAccount()); + record.put("fundSchemeName", getInsuranceSchemeMapper().querySchemeName(item.getFundSchemeId())); + record.put("supplementFundAccount", item.getSupplementFundAccount()); + if (StringUtils.isNotEmpty(item.getFundPaymentBaseString()) || StringUtils.isNotEmpty(item.getFundPaymentComBaseString())) { + Map fundJson = JSON.parseObject(item.getFundPaymentBaseString(), new HashMap().getClass()); // if(fundJson!=null){ // fundJson.forEach((k, v) -> { // record.put(k + "fundBase", (String) v); // }); // } - if (welBaseDiffSign) { - if (fundJson != null) { - //查询该福利方案下开启缴纳的福利项 + if (welBaseDiffSign) { + if (fundJson != null) { + //查询该福利方案下开启缴纳的福利项 // List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); - List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); - fundJson.forEach((k, v) -> { - if (insuranceIdList.contains(Long.valueOf(k))) { - record.put(k + "fundPerBase", v); - } + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + fundJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "fundPerBase", v); + } + }); + } + Map fundComJson = JSON.parseObject(item.getFundPaymentComBaseString(), new TypeReference>() { }); - } - Map fundComJson = JSON.parseObject(item.getFundPaymentComBaseString(), new TypeReference>() { - }); - if (fundComJson != null) { - //查询该福利方案下开启缴纳的福利项 + if (fundComJson != null) { + //查询该福利方案下开启缴纳的福利项 // List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); - List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); - fundComJson.forEach((k, v) -> { - if (insuranceIdList.contains(Long.valueOf(k))) { - record.put(k + "fundComBase", v); - } - }); - } - } else { - if (fundJson != null) { - //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + fundComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "fundComBase", v); + } + }); + } + } else { + if (fundJson != null) { + //查询该福利方案下开启缴纳的福利项 // List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId()); - List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId()); - fundJson.forEach((k, v) -> { - if (insuranceIdList.contains(Long.valueOf(k))) { - record.put(k + "fundBase", v); - } - }); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId()); + fundJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "fundBase", v); + } + }); + } } } - } - record.put("otherPayOrg", item.getOtherPayOrg() == null ? "" : (paymentMap.getOrDefault(item.getOtherPayOrg(),TaxAgentPO.builder().build())).getName()); - record.put("otherSchemeName", getInsuranceSchemeMapper().querySchemeName(item.getOtherSchemeId())); - if (StringUtils.isNotEmpty(item.getOtherPaymentBaseString()) || StringUtils.isNotEmpty(item.getOtherPaymentComBaseString())) { - Map otherJson = JSON.parseObject(item.getOtherPaymentBaseString(), new HashMap().getClass()); + record.put("otherPayOrg", item.getOtherPayOrg() == null ? "" : (paymentMap.getOrDefault(item.getOtherPayOrg(),TaxAgentPO.builder().build())).getName()); + record.put("otherSchemeName", getInsuranceSchemeMapper().querySchemeName(item.getOtherSchemeId())); + if (StringUtils.isNotEmpty(item.getOtherPaymentBaseString()) || StringUtils.isNotEmpty(item.getOtherPaymentComBaseString())) { + Map otherJson = JSON.parseObject(item.getOtherPaymentBaseString(), new HashMap().getClass()); // if(otherJson!=null){ // otherJson.forEach((k, v) -> { // record.put(k + "otherBase", (String) v); // }); // } - if (welBaseDiffSign) { - if (otherJson != null) { - //查询该福利方案下开启缴纳的福利项 + if (welBaseDiffSign) { + if (otherJson != null) { + //查询该福利方案下开启缴纳的福利项 // List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); - List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); - otherJson.forEach((k, v) -> { - if (insuranceIdList.contains(Long.valueOf(k))) { - record.put(k + "otherPerBase", v); - } + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + otherJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "otherPerBase", v); + } + }); + } + Map otherComJson = JSON.parseObject(item.getOtherPaymentComBaseString(), new TypeReference>() { }); - } - Map otherComJson = JSON.parseObject(item.getOtherPaymentComBaseString(), new TypeReference>() { - }); - if (otherComJson != null) { - //查询该福利方案下开启缴纳的福利项 + if (otherComJson != null) { + //查询该福利方案下开启缴纳的福利项 // List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); - List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); - otherComJson.forEach((k, v) -> { - if (insuranceIdList.contains(Long.valueOf(k))) { - record.put(k + "otherComBase", v); - } - }); - } - } else { - if (otherJson != null) { - //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + otherComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "otherComBase", v); + } + }); + } + } else { + if (otherJson != null) { + //查询该福利方案下开启缴纳的福利项 // List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId()); - List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId()); - otherJson.forEach((k, v) -> { - if (insuranceIdList.contains(Long.valueOf(k))) { - record.put(k + "otherBase", v); - } - }); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId()); + otherJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "otherBase", v); + } + }); + } } } - } - if (StringUtils.isNotEmpty(item.getSocialPerJson())) { - Map socialJson = JSON.parseObject(item.getSocialPerJson(), new HashMap().getClass()); - if(socialJson!=null){ - socialJson.forEach((k, v) -> { - record.put(k + "socialPer", (String) v); - }); - } + if (StringUtils.isNotEmpty(item.getSocialPerJson())) { + Map socialJson = JSON.parseObject(item.getSocialPerJson(), new HashMap().getClass()); + if(socialJson!=null){ + socialJson.forEach((k, v) -> { + record.put(k + "socialPer", (String) v); + }); + } - } - record.put("socialPerSum", item.getSocialPerSum()); - if (StringUtils.isNotEmpty(item.getFundPerJson())) { - Map fundPerJson = JSON.parseObject(item.getFundPerJson(), new HashMap().getClass()); - if(fundPerJson!=null){ - fundPerJson.forEach((k, v) -> { - record.put(k + "fundPer", (String) v); - }); } + record.put("socialPerSum", item.getSocialPerSum()); + if (StringUtils.isNotEmpty(item.getFundPerJson())) { + Map fundPerJson = JSON.parseObject(item.getFundPerJson(), new HashMap().getClass()); + if(fundPerJson!=null){ + fundPerJson.forEach((k, v) -> { + record.put(k + "fundPer", (String) v); + }); + } - } - record.put("fundPerSum", item.getFundPerSum()); - if (StringUtils.isNotEmpty(item.getOtherPerJson())) { - Map fundPerJson = JSON.parseObject(item.getOtherPerJson(), new HashMap().getClass()); - if(fundPerJson!=null){ - fundPerJson.forEach((k, v) -> { - record.put(k + "otherPer", (String) v); - }); } + record.put("fundPerSum", item.getFundPerSum()); + if (StringUtils.isNotEmpty(item.getOtherPerJson())) { + Map fundPerJson = JSON.parseObject(item.getOtherPerJson(), new HashMap().getClass()); + if(fundPerJson!=null){ + fundPerJson.forEach((k, v) -> { + record.put(k + "otherPer", (String) v); + }); + } - } - record.put("otherPerSum", item.getOtherPerSum()); - record.put("perSum", item.getPerSum()); - if (StringUtils.isNotEmpty(item.getSocialComJson())) { - Map fundPerJson = JSON.parseObject(item.getSocialComJson(), new HashMap().getClass()); - if(fundPerJson!=null){ + } + record.put("otherPerSum", item.getOtherPerSum()); + record.put("perSum", item.getPerSum()); + if (StringUtils.isNotEmpty(item.getSocialComJson())) { + Map fundPerJson = JSON.parseObject(item.getSocialComJson(), new HashMap().getClass()); + if(fundPerJson!=null){ + fundPerJson.forEach((k, v) -> { + record.put(k + "socialCom", (String) v); + }); + } fundPerJson.forEach((k, v) -> { record.put(k + "socialCom", (String) v); }); } - fundPerJson.forEach((k, v) -> { - record.put(k + "socialCom", (String) v); - }); - } - record.put("socialComSum", item.getSocialComSum()); - if (StringUtils.isNotEmpty(item.getFundComJson())) { - Map fundPerJson = JSON.parseObject(item.getFundComJson(), new HashMap().getClass()); - if(fundPerJson!=null){ - fundPerJson.forEach((k, v) -> { - record.put(k + "fundCom", (String) v); - }); - } + record.put("socialComSum", item.getSocialComSum()); + if (StringUtils.isNotEmpty(item.getFundComJson())) { + Map fundPerJson = JSON.parseObject(item.getFundComJson(), new HashMap().getClass()); + if(fundPerJson!=null){ + fundPerJson.forEach((k, v) -> { + record.put(k + "fundCom", (String) v); + }); + } - } - record.put("fundComSum", item.getFundComSum()); - if (StringUtils.isNotEmpty(item.getOtherComJson())) { - Map fundPerJson = JSON.parseObject(item.getOtherComJson(), new HashMap().getClass()); - if(fundPerJson!=null){ - fundPerJson.forEach((k, v) -> { - record.put(k + "otherCom", (String) v); - }); } + record.put("fundComSum", item.getFundComSum()); + if (StringUtils.isNotEmpty(item.getOtherComJson())) { + Map fundPerJson = JSON.parseObject(item.getOtherComJson(), new HashMap().getClass()); + if(fundPerJson!=null){ + fundPerJson.forEach((k, v) -> { + record.put(k + "otherCom", (String) v); + }); + } + } + record.put("otherComSum", item.getOtherComSum()); + record.put("comSum", item.getComSum()); + record.put("socialSum", item.getSocialSum()); + record.put("fundSum", item.getFundSum()); + record.put("otherSum", item.getOtherSum()); + record.put("total", item.getTotal()); + result.add(record); + }catch (Exception e){ + DataCollectionEmployee simpleEmployee = collect.get(item.getEmployeeId()); + log.error("SIExportServiceImpl.buildCommonRecords item {} simpleEmployee {}",item,simpleEmployee); + throw e; } - record.put("otherComSum", item.getOtherComSum()); - record.put("comSum", item.getComSum()); - record.put("socialSum", item.getSocialSum()); - record.put("fundSum", item.getFundSum()); - record.put("otherSum", item.getOtherSum()); - record.put("total", item.getTotal()); - result.add(record); }); return result; }