diff --git a/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java b/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java index a4ce08bb3..21dad30c7 100644 --- a/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java +++ b/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java @@ -120,6 +120,9 @@ public class DataCollectionEmployee { //是否外部人员 private boolean extEmp; + // 安全级别 + private Integer seclevel; + /** * 扩展数据 */ diff --git a/src/com/engine/salary/entity/salaryacct/dto/HtSbqsListDTO.java b/src/com/engine/salary/entity/salaryacct/dto/HtSbqsListDTO.java new file mode 100644 index 000000000..d8ad26fb7 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/HtSbqsListDTO.java @@ -0,0 +1,46 @@ +package com.engine.salary.entity.salaryacct.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @ClassName HtSbqsListDTO + * @date 2024/10/29 15:45 + * @description 汇通社保请示流程 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class HtSbqsListDTO { + + // 保险类型id + private Long insuranceId; + + // 保险类型名称 + private String bxlx; + + // 上期缴纳人数 + private Integer sqjnrs; + + // 增加人数 + private Integer zjrs; + + // 减少人数 + private Integer jsrs; + + // 本期人数 + private Integer bqrs; + + // 个人缴纳金额 + private Double grjnje; + + // 单位缴纳金额 + private Double dwjnje; + + // 缴纳总额 + private Double jnze; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/HtjsApprovalParam.java b/src/com/engine/salary/entity/salaryacct/param/HtjsApprovalParam.java index 9d03c1e7d..b92863a21 100644 --- a/src/com/engine/salary/entity/salaryacct/param/HtjsApprovalParam.java +++ b/src/com/engine/salary/entity/salaryacct/param/HtjsApprovalParam.java @@ -1,12 +1,14 @@ package com.engine.salary.entity.salaryacct.param; import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.entity.salaryacct.dto.HtXcssItemDTO; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.util.Date; +import java.util.List; /** * @ClassName HtjsApprovalParam @@ -29,5 +31,9 @@ public class HtjsApprovalParam extends BaseQueryParam { // 单位id Long subcompanyId; + Long schemeId; + + List htXcssItemDTOList; + } diff --git a/src/com/engine/salary/mapper/datacollection/EmployMapper.xml b/src/com/engine/salary/mapper/datacollection/EmployMapper.xml index ae903a6a7..c0ee7621b 100644 --- a/src/com/engine/salary/mapper/datacollection/EmployMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/EmployMapper.xml @@ -78,7 +78,8 @@ e.certificatenum as idNo, e.enddate as dismissdate, e.workyear, - e.companyworkyear + e.companyworkyear, + e.SECLEVEL from hrmresource e left join hrmdepartment d on e.departmentid = d.id left join hrmjobtitles c on e.jobtitle = c.id diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java index 2a05a0c72..040270cd9 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java @@ -89,6 +89,8 @@ public interface InsuranceAccountDetailMapper { List queryList(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization, @Param("employeeIds") Collection employeeIds); + List queryList4Ht(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization, @Param("socialSchemeId") Long socialSchemeId, @Param("fundSchemeId") Long fundSchemeId, @Param("otherSchemeId") Long otherSchemeId); + /** * 查询正常缴纳数据 * @param billMonth 账单月份 diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml index 977fb9edd..4da7f50e3 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml @@ -1475,4 +1475,29 @@ AND t.payment_organization = #{paymentOrganization} AND t.employee_id = #{employeeId} + + \ No newline at end of file diff --git a/src/com/engine/salary/service/SIAccountService.java b/src/com/engine/salary/service/SIAccountService.java index bd95388a2..41f23580d 100644 --- a/src/com/engine/salary/service/SIAccountService.java +++ b/src/com/engine/salary/service/SIAccountService.java @@ -1,5 +1,6 @@ package com.engine.salary.service; +import com.engine.salary.entity.salaryacct.dto.HtSbqsListDTO; import com.engine.salary.entity.siaccount.dto.InsuranceAccountTabDTO; import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO; import com.engine.salary.entity.siaccount.param.*; @@ -209,6 +210,8 @@ public interface SIAccountService { */ List> welfareData(String billMonth, List employeeIds,Long taxAgentId); + List welfareData4Htjs(String billMonth, Long socialSchemeId, Long fundSchemeId, Long otherSchemeId); + /** * 给套账提供字段名对应字段释义 * diff --git a/src/com/engine/salary/service/SISchemeService.java b/src/com/engine/salary/service/SISchemeService.java index 86eb024ee..e0a5a45b1 100644 --- a/src/com/engine/salary/service/SISchemeService.java +++ b/src/com/engine/salary/service/SISchemeService.java @@ -4,11 +4,13 @@ import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; import com.engine.salary.entity.siarchives.param.SIArchiveImportParam; import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDetailDTO; import com.engine.salary.entity.sischeme.dto.InsuranceSchemeListDTO; import com.engine.salary.entity.sischeme.param.InsuranceSchemeDetailUpdateParam; import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam; import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; import com.engine.salary.util.page.PageInfo; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -82,5 +84,7 @@ public interface SISchemeService { */ List updateSchemeDetail(List schemeDetailList); + List getSchemeDetailFormDTO(WelfareTypeEnum welfareTypeEnum, Long id); + List listAll(); } diff --git a/src/com/engine/salary/service/SalaryAcctEmployeeService.java b/src/com/engine/salary/service/SalaryAcctEmployeeService.java index f2647df1b..6fbd00807 100644 --- a/src/com/engine/salary/service/SalaryAcctEmployeeService.java +++ b/src/com/engine/salary/service/SalaryAcctEmployeeService.java @@ -60,7 +60,7 @@ public interface SalaryAcctEmployeeService { * @param salaryAcctRecordIds 薪资核算记录id * @return */ - List listBySalaryAcctRecordIds(Collection salaryAcctRecordIds); + List listBySalaryAcctRecordIds(List salaryAcctRecordIds); /** * 根据薪资核算记录id、个税扣缴义务人id查询薪资核算人员 diff --git a/src/com/engine/salary/service/SalaryAcctResultService.java b/src/com/engine/salary/service/SalaryAcctResultService.java index 5846b4bb4..986d6fc6d 100644 --- a/src/com/engine/salary/service/SalaryAcctResultService.java +++ b/src/com/engine/salary/service/SalaryAcctResultService.java @@ -2,6 +2,7 @@ package com.engine.salary.service; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO; +import com.engine.salary.entity.salaryacct.dto.HtSbqsListDTO; import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO; import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultListColumnDTO; import com.engine.salary.entity.salaryacct.param.*; @@ -221,4 +222,8 @@ public interface SalaryAcctResultService { Map htjsXcssList(HtjsApprovalParam param); Map htjsXcssDataDetail(HtjsApprovalParam param); + + Map htjsXczfsqList(HtjsApprovalParam param); + + List htjsSbqsList(HtjsApprovalParam param); } diff --git a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java index d453b6c96..457b6c7fd 100644 --- a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java @@ -1271,7 +1271,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction boolean isAccounted = e.getStatus() > SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue(); if (isAccounted) { // list.addAll(getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecords.get(0).getId()))); - list.addAll(getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(Collections.singleton(e.getId()))); + list.addAll(getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(Collections.singletonList(e.getId()))); } }); @@ -1292,7 +1292,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction boolean isAccounted = e.getStatus() > SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue(); if (isAccounted) { // list.addAll(getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecords.get(0).getId()))); - list.addAll(getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(Collections.singleton(e.getId()))); + list.addAll(getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(Collections.singletonList(e.getId()))); } }); diff --git a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java index f85238077..9537cd41f 100644 --- a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java @@ -22,6 +22,7 @@ import com.engine.salary.constant.SalaryItemConstant; import com.engine.salary.encrypt.EncryptUtil; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.progress.ProgressDTO; +import com.engine.salary.entity.salaryacct.dto.HtSbqsListDTO; import com.engine.salary.entity.siaccount.bo.InsuranceAccountBO; import com.engine.salary.entity.siaccount.dto.*; import com.engine.salary.entity.siaccount.param.*; @@ -30,6 +31,7 @@ import com.engine.salary.entity.siarchives.po.*; import com.engine.salary.entity.sicategory.po.ICategoryPO; import com.engine.salary.entity.siexport.param.InsuranceExportParam; import com.engine.salary.entity.siexport.po.AccountExportPO; +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDetailDTO; import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; import com.engine.salary.entity.taxagent.po.TaxAgentPO; @@ -88,6 +90,7 @@ import weaver.hrm.User; import java.io.InputStream; import java.math.BigDecimal; import java.text.SimpleDateFormat; +import java.time.LocalDate; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -241,6 +244,10 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { return MapperProxyFactory.getProxy(EmployMapper.class); } + private SISchemeService getSiSchemeService() { + return ServiceUtil.getService(SISchemeServiceImpl.class, user); + } + @Override public Map listPage(InsuranceAccountBatchParam queryParam) { Long employeeId = (long) user.getUID(); @@ -1213,6 +1220,104 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { return result; } + /** + * 汇通建设 二开 + * @param billMonth + * @return + */ + @Override + public List welfareData4Htjs(String billMonth, Long socialSchemeId, Long fundSchemeId, Long otherSchemeId) { + // 获取所有个税扣缴义务人 + List taxAgentList = getTaxAgentService(user).listAll(); + List insuranceAccountDetailPOS = new ArrayList<>(); + for (TaxAgentPO taxAgent : taxAgentList) { + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(billMonth, taxAgent.getId()); + insuranceAccountBatchPO = encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + if (insuranceAccountBatchPO == null || Objects.equals(BillStatusEnum.NOT_ARCHIVED.getValue(), insuranceAccountBatchPO.getBillStatus())) { + continue; + } + insuranceAccountDetailPOS.addAll(getInsuranceAccountDetailMapper().queryList4Ht(billMonth, taxAgent.getId(), socialSchemeId, fundSchemeId, otherSchemeId)); + } + + //退差数据不参与薪资核算 + insuranceAccountDetailPOS = insuranceAccountDetailPOS.stream() + .filter(f -> f.getPaymentStatus().equals(PaymentStatusEnum.COMMON.getValue()) + || f.getPaymentStatus().equals(PaymentStatusEnum.REPAIR.getValue()) + || f.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue()) ) + .collect(Collectors.toList()); + Map resultMap = buildInsuranceApproInfo4Ht(insuranceAccountDetailPOS); + Map perValueMap = (Map)resultMap.getOrDefault("perValueMap", Collections.emptyMap()); + Map comValueMap = (Map)resultMap.getOrDefault("comValueMap", Collections.emptyMap()); + Map> empMap = (Map>)resultMap.getOrDefault("empMap", Collections.emptyMap()); + + // 获取上期社保数据 + List lastInsuranceAccountDetailPOS = new ArrayList<>(); + for (TaxAgentPO taxAgent : taxAgentList) { + + LocalDate localDate = SalaryDateUtil.dateToLocalDate(SalaryDateUtil.dateStrToLocalYearMonth(billMonth)); + String lastMonth = SalaryDateUtil.getFormatYearMonth(localDate.minusMonths(1)); + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(lastMonth, taxAgent.getId()); + insuranceAccountBatchPO = encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + if (insuranceAccountBatchPO == null || Objects.equals(BillStatusEnum.NOT_ARCHIVED.getValue(), insuranceAccountBatchPO.getBillStatus())) { + continue; + } + lastInsuranceAccountDetailPOS.addAll(getInsuranceAccountDetailMapper().queryList4Ht(lastMonth, taxAgent.getId(), socialSchemeId, fundSchemeId, otherSchemeId)); + } + + //退差数据不参与薪资核算 + lastInsuranceAccountDetailPOS = lastInsuranceAccountDetailPOS.stream() + .filter(f -> f.getPaymentStatus().equals(PaymentStatusEnum.COMMON.getValue()) + || f.getPaymentStatus().equals(PaymentStatusEnum.REPAIR.getValue()) + || f.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue()) ) + .collect(Collectors.toList()); + Map lastResultMap = buildInsuranceApproInfo4Ht(lastInsuranceAccountDetailPOS); + Map> lastEmpMap = (Map>)lastResultMap.getOrDefault("empMap", Collections.emptyMap()); + + + // 查询社保方案信息 + List insuranceSchemeDetailDTOList = Collections.emptyList(); + if (socialSchemeId != null) { + insuranceSchemeDetailDTOList = getSiSchemeService().getSchemeDetailFormDTO(WelfareTypeEnum.SOCIAL_SECURITY, socialSchemeId); + } else if (fundSchemeId != null) { + insuranceSchemeDetailDTOList = getSiSchemeService().getSchemeDetailFormDTO(WelfareTypeEnum.ACCUMULATION_FUND, fundSchemeId); + } else if (otherSchemeId != null) { + insuranceSchemeDetailDTOList = getSiSchemeService().getSchemeDetailFormDTO(WelfareTypeEnum.OTHER, otherSchemeId); + } + + // 获取所有开启缴纳的福利项 + insuranceSchemeDetailDTOList = insuranceSchemeDetailDTOList.stream() + .filter(dto -> dto.getIsPayment() == null || dto.getIsPayment() == true) + .collect(Collectors.toMap(InsuranceSchemeDetailDTO::getInsuranceId, Function.identity(), (a, b) -> a)) + .values() + .stream().collect(Collectors.toList()); + List htSbqsListDTOS = new ArrayList(); + for (InsuranceSchemeDetailDTO dto : insuranceSchemeDetailDTOList) { + List empList = empMap.getOrDefault(dto.getInsuranceId().toString(), Collections.emptyList()); + empList = empList.stream().distinct().collect(Collectors.toList()); + Object perPaymentObj = perValueMap.get(dto.getInsuranceId().toString()); + BigDecimal perPayment = perPaymentObj != null && NumberUtils.isNumber(perPaymentObj.toString()) ? new BigDecimal(perPaymentObj.toString()) : BigDecimal.ZERO; + Object comPaymentObj = comValueMap.get(dto.getInsuranceId().toString()); + BigDecimal comPayment = comPaymentObj != null && NumberUtils.isNumber(comPaymentObj.toString()) ? new BigDecimal(comPaymentObj.toString()) : BigDecimal.ZERO; + // 获取上期人数 + List lastEmpList = lastEmpMap.getOrDefault(dto.getInsuranceId().toString(), Collections.emptyList()); + lastEmpList = lastEmpList.stream().distinct().collect(Collectors.toList()); + HtSbqsListDTO build = HtSbqsListDTO.builder() + .insuranceId(dto.getInsuranceId()) + .bxlx(dto.getInsuranceName()) + .sqjnrs(lastEmpList.size()) + .zjrs(lastEmpList.size() < empList.size() ? empList.size() - lastEmpList.size() : 0) + .jsrs(lastEmpList.size() > empList.size() ? lastEmpList.size() - empList.size() : 0) + .bqrs(empList.size()) + .grjnje(perPayment.doubleValue()) + .dwjnje(comPayment.doubleValue()) + .jnze(perPayment.add(comPayment).doubleValue()) + .build(); + htSbqsListDTOS.add(build); + } + + return htSbqsListDTOS; + } + @Override public Map welfareColumns() { List listAll = getICategoryMapper().listAll().stream().filter(f -> f.getIsUse().equals(IsUseEnum.START.getValue())).collect(Collectors.toList()); @@ -1532,6 +1637,279 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { } + public Map buildInsuranceApproInfo4Ht(List list) { + // List newList = new ArrayList<>(); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyMap(); + } + Map> employeeMap = list.stream().filter(item -> item.getEmployeeId() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getEmployeeId)); + + Map perSumValueMap = new HashMap<>(); + Map comSumValueMap = new HashMap<>(); + Map> payedEmpMap = new HashMap<>(); + for (Map.Entry> entry : employeeMap.entrySet()) { + Long k = entry.getKey(); + List v = entry.getValue(); + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + insuranceAccountDetailPO.setEmployeeId(k); + // Map socialPerMap = new HashMap<>(); + // Map fundPerMap = new HashMap<>(); + // Map otherPerMap = new HashMap<>(); + // Map socialComMap = new HashMap<>(); + // Map fundComMap = new HashMap<>(); + // Map otherComMap = new HashMap<>(); + // BigDecimal socialPer = new BigDecimal("0"); + // BigDecimal socialCom = new BigDecimal("0"); + // BigDecimal fundPer = new BigDecimal("0"); + // BigDecimal fundCom = new BigDecimal("0"); + // BigDecimal otherPer = new BigDecimal("0"); + // BigDecimal otherCom = new BigDecimal("0"); + // BigDecimal perSum = new BigDecimal("0"); + // BigDecimal comSum = new BigDecimal("0"); + for (InsuranceAccountDetailPO item : v) { + encryptUtil.decrypt(item, InsuranceAccountDetailPO.class); + insuranceAccountDetailPO.setId(item.getId()); + insuranceAccountDetailPO.setSocialPaymentBaseString(item.getSocialPaymentBaseString()); + insuranceAccountDetailPO.setFundPaymentBaseString(item.getFundPaymentBaseString()); + insuranceAccountDetailPO.setOtherPaymentBaseString(item.getOtherPaymentBaseString()); + // BigDecimal socialPerSum = StringUtils.isBlank(item.getSocialPerSum()) ? new BigDecimal("0") : new BigDecimal(item.getSocialPerSum()); + // BigDecimal socialComSum = StringUtils.isBlank(item.getSocialComSum()) ? new BigDecimal("0") : new BigDecimal(item.getSocialComSum()); + // BigDecimal fundPerSum = StringUtils.isBlank(item.getFundPerSum()) ? new BigDecimal("0") : new BigDecimal(item.getFundPerSum()); + // BigDecimal fundComSum = StringUtils.isBlank(item.getFundComSum()) ? new BigDecimal("0") : new BigDecimal(item.getFundComSum()); + // BigDecimal otherPerSum = StringUtils.isBlank(item.getOtherPerSum()) ? new BigDecimal("0") : new BigDecimal(item.getOtherPerSum()); + // BigDecimal otherComSum = StringUtils.isBlank(item.getOtherComSum()) ? new BigDecimal("0") : new BigDecimal(item.getOtherComSum()); + // BigDecimal perSumItem = StringUtils.isBlank(item.getPerSum()) ? new BigDecimal("0") : new BigDecimal(item.getPerSum()); + // BigDecimal comSumItem = StringUtils.isBlank(item.getComSum()) ? new BigDecimal("0") : new BigDecimal(item.getComSum()); + // socialPer = socialPer.add(socialPerSum); + // socialCom = socialCom.add(socialComSum); + // fundPer = fundPer.add(fundPerSum); + // fundCom = fundCom.add(fundComSum); + // otherPer = otherPer.add(otherPerSum); + // otherCom = otherCom.add(otherComSum); + // perSum = perSum.add(perSumItem); + // comSum = comSum.add(comSumItem); + if (StringUtils.isNotBlank(item.getSocialPerJson())) { + Map socialJson = JSON.parseObject(item.getSocialPerJson(), new HashMap().getClass()); + if (socialJson != null) { + socialJson.forEach((insuranceId, num) -> { + // if (socialPerMap.get(insuranceId) == null) { + // socialPerMap.put(insuranceId, num); + // } else { + // String oldNum = socialPerMap.get(insuranceId); + // BigDecimal insuanceNum = new BigDecimal("0"); + // BigDecimal oldDecimal = new BigDecimal(oldNum); + // BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + // insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + // socialPerMap.put(insuranceId, insuanceNum.toPlainString()); + // } + + if (perSumValueMap.get(insuranceId) == null) { + perSumValueMap.put(insuranceId, num); + } else { + String oldNum = perSumValueMap.get(insuranceId); + BigDecimal insuanceNum = new BigDecimal("0"); + BigDecimal oldDecimal = new BigDecimal(oldNum); + BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + perSumValueMap.put(insuranceId, insuanceNum.toPlainString()); + } + if (StringUtils.isNotBlank(num) && NumberUtils.isNumber(num) && new BigDecimal(num).compareTo(BigDecimal.ZERO) != 0) { + List empList = payedEmpMap.computeIfAbsent(insuranceId, i -> new ArrayList()); + empList.add(item.getEmployeeId()); + } + }); + } + + } + if (StringUtils.isNotBlank(item.getSocialComJson())) { + Map socialJson = JSON.parseObject(item.getSocialComJson(), new HashMap().getClass()); + if (socialJson != null) { + socialJson.forEach((insuranceId, num) -> { + // if (socialComMap.get(insuranceId) == null) { + // socialComMap.put(insuranceId, num); + // } else { + // String oldNum = socialComMap.get(insuranceId); + // BigDecimal insuanceNum = new BigDecimal("0"); + // BigDecimal oldDecimal = new BigDecimal(oldNum); + // BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + // insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + // socialComMap.put(insuranceId, insuanceNum.toPlainString()); + // } + if (comSumValueMap.get(insuranceId) == null) { + comSumValueMap.put(insuranceId, num); + } else { + String oldNum = comSumValueMap.get(insuranceId); + BigDecimal insuanceNum = new BigDecimal("0"); + BigDecimal oldDecimal = new BigDecimal(oldNum); + BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + comSumValueMap.put(insuranceId, insuanceNum.toPlainString()); + } + if (StringUtils.isNotBlank(num) && NumberUtils.isNumber(num) && new BigDecimal(num).compareTo(BigDecimal.ZERO) != 0) { + List empList = payedEmpMap.computeIfAbsent(insuranceId, i -> new ArrayList()); + empList.add(item.getEmployeeId()); + } + }); + } + + } + if (StringUtils.isNotBlank(item.getFundPerJson())) { + Map fundJson = JSON.parseObject(item.getFundPerJson(), new HashMap().getClass()); + if (fundJson != null) { + fundJson.forEach((insuranceId, num) -> { + // if (fundPerMap.get(insuranceId) == null) { + // fundPerMap.put(insuranceId, num); + // } else { + // String oldNum = fundPerMap.get(insuranceId); + // BigDecimal insuanceNum = new BigDecimal("0"); + // BigDecimal oldDecimal = new BigDecimal(oldNum); + // BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + // insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + // fundPerMap.put(insuranceId, insuanceNum.toPlainString()); + // } + + if (perSumValueMap.get(insuranceId) == null) { + perSumValueMap.put(insuranceId, num); + } else { + String oldNum = perSumValueMap.get(insuranceId); + BigDecimal insuanceNum = new BigDecimal("0"); + BigDecimal oldDecimal = new BigDecimal(oldNum); + BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + perSumValueMap.put(insuranceId, insuanceNum.toPlainString()); + } + if (StringUtils.isNotBlank(num) && NumberUtils.isNumber(num) && new BigDecimal(num).compareTo(BigDecimal.ZERO) != 0) { + List empList = payedEmpMap.computeIfAbsent(insuranceId, i -> new ArrayList()); + empList.add(item.getEmployeeId()); + } + }); + } + + } + if (StringUtils.isNotBlank(item.getFundComJson())) { + Map fundJson = JSON.parseObject(item.getFundComJson(), new HashMap().getClass()); + if (fundJson != null) { + fundJson.forEach((insuranceId, num) -> { + // if (fundComMap.get(insuranceId) == null) { + // fundComMap.put(insuranceId, num); + // } else { + // String oldNum = fundComMap.get(insuranceId); + // BigDecimal insuanceNum = new BigDecimal("0"); + // BigDecimal oldDecimal = new BigDecimal(oldNum); + // BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + // insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + // fundComMap.put(insuranceId, insuanceNum.toPlainString()); + // } + + if (comSumValueMap.get(insuranceId) == null) { + comSumValueMap.put(insuranceId, num); + } else { + String oldNum = comSumValueMap.get(insuranceId); + BigDecimal insuanceNum = new BigDecimal("0"); + BigDecimal oldDecimal = new BigDecimal(oldNum); + BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + comSumValueMap.put(insuranceId, insuanceNum.toPlainString()); + } + if (StringUtils.isNotBlank(num) && NumberUtils.isNumber(num) && new BigDecimal(num).compareTo(BigDecimal.ZERO) != 0) { + List empList = payedEmpMap.computeIfAbsent(insuranceId, i -> new ArrayList()); + empList.add(item.getEmployeeId()); + } + }); + } + + } + if (StringUtils.isNotBlank(item.getOtherPerJson())) { + Map otherJson = JSON.parseObject(item.getOtherPerJson(), new HashMap().getClass()); + if (otherJson != null) { + otherJson.forEach((insuranceId, num) -> { + // if (otherPerMap.get(insuranceId) == null) { + // otherPerMap.put(insuranceId, num); + // } else { + // String oldNum = otherPerMap.get(insuranceId); + // BigDecimal insuanceNum = new BigDecimal("0"); + // BigDecimal oldDecimal = new BigDecimal(oldNum); + // BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + // insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + // otherPerMap.put(insuranceId, insuanceNum.toPlainString()); + // } + + if (perSumValueMap.get(insuranceId) == null) { + perSumValueMap.put(insuranceId, num); + } else { + String oldNum = perSumValueMap.get(insuranceId); + BigDecimal insuanceNum = new BigDecimal("0"); + BigDecimal oldDecimal = new BigDecimal(oldNum); + BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + perSumValueMap.put(insuranceId, insuanceNum.toPlainString()); + } + if (StringUtils.isNotBlank(num) && NumberUtils.isNumber(num) && new BigDecimal(num).compareTo(BigDecimal.ZERO) != 0) { + List empList = payedEmpMap.computeIfAbsent(insuranceId, i -> new ArrayList()); + empList.add(item.getEmployeeId()); + } + }); + } + + } + if (StringUtils.isNotBlank(item.getOtherComJson())) { + Map otherJson = JSON.parseObject(item.getOtherComJson(), new HashMap().getClass()); + if (otherJson != null) { + otherJson.forEach((insuranceId, num) -> { + // if (otherComMap.get(insuranceId) == null) { + // otherComMap.put(insuranceId, num); + // } else { + // String oldNum = otherComMap.get(insuranceId); + // BigDecimal insuanceNum = new BigDecimal("0"); + // BigDecimal oldDecimal = new BigDecimal(oldNum); + // BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + // insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + // otherComMap.put(insuranceId, insuanceNum.toPlainString()); + // } + + if (comSumValueMap.get(insuranceId) == null) { + comSumValueMap.put(insuranceId, num); + } else { + String oldNum = comSumValueMap.get(insuranceId); + BigDecimal insuanceNum = new BigDecimal("0"); + BigDecimal oldDecimal = new BigDecimal(oldNum); + BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + comSumValueMap.put(insuranceId, insuanceNum.toPlainString()); + } + if (StringUtils.isNotBlank(num) && NumberUtils.isNumber(num) && new BigDecimal(num).compareTo(BigDecimal.ZERO) != 0) { + List empList = payedEmpMap.computeIfAbsent(insuranceId, i -> new ArrayList()); + empList.add(item.getEmployeeId()); + } + }); + } + + } + } + // insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerMap)); + // insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(socialComMap)); + // insuranceAccountDetailPO.setFundPerJson(JSON.toJSONString(fundPerMap)); + // insuranceAccountDetailPO.setFundComJson(JSON.toJSONString(fundComMap)); + // insuranceAccountDetailPO.setOtherPerJson(JSON.toJSONString(otherPerMap)); + // insuranceAccountDetailPO.setOtherComJson(JSON.toJSONString(otherComMap)); + // insuranceAccountDetailPO.setSocialPerSum(socialPer.toPlainString()); + // insuranceAccountDetailPO.setSocialComSum(socialCom.toPlainString()); + // insuranceAccountDetailPO.setFundPerSum(fundPer.toPlainString()); + // insuranceAccountDetailPO.setFundComSum(fundCom.toPlainString()); + // insuranceAccountDetailPO.setOtherPerSum(otherPer.toPlainString()); + // insuranceAccountDetailPO.setOtherComSum(otherCom.toPlainString()); + // insuranceAccountDetailPO.setPerSum(perSum.toPlainString()); + // insuranceAccountDetailPO.setComSum(comSum.toPlainString()); + // newList.add(insuranceAccountDetailPO); + } + Map resultMap = new HashMap<>(); + resultMap.put("perValueMap", perSumValueMap); + resultMap.put("comValueMap", comSumValueMap); + resultMap.put("empMap", payedEmpMap); + return resultMap; + } + @Override public List allInspects(Collection ids, String billMonth) { // InsuranceAccountInspectMapper siAccountInspectMapper = MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class); diff --git a/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java index ee7588545..d17d9e95d 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.cache.SalaryCacheKey; +import com.engine.salary.common.LocalDateRange; import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.constant.SalaryFormulaFieldConstant; import com.engine.salary.entity.datacollection.AddUpDeduction; @@ -23,10 +24,13 @@ import com.engine.salary.entity.salaryitem.po.SalaryItemPO; import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum; import com.engine.salary.formlua.entity.standard.ExcelResult; import com.engine.salary.service.*; import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; +import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; @@ -38,6 +42,8 @@ import weaver.general.BaseBean; import weaver.general.Util; import weaver.hrm.User; +import java.math.BigDecimal; +import java.time.LocalDate; import java.time.Month; import java.util.*; import java.util.stream.Collectors; @@ -113,6 +119,15 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc return ServiceUtil.getService(VariableArchiveServiceImpl.class, user); } + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + @Override public void calculate(SalaryAcctCalculateBO salaryAcctCalculateBO, DataCollectionEmployee simpleEmployee, List salarySobBackItems) { log.info("开始核算V3 {}", salaryAcctCalculateBO); @@ -191,6 +206,23 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, salaryArchiveData, addUpSituationPOS, addUpDeductionPOS, otherDeductionPOS, welfareData, attendQuoteDataDTOS, salaryAcctResultPOS, variableArchiveList); Map> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO); sw.stop(); + + // 11、汇通二开数据处理 + // 获取汇通建设薪资项目id + BaseBean baseBean = new BaseBean(); + // 绩效预发金额 + Long jxyfSalaryItemId = NumberUtils.isCreatable(baseBean.getPropValue("htjsSalaryApproval", "jxyfje_salary_item_id")) ? Long.valueOf(baseBean.getPropValue("htjsSalaryApproval", "jxyfje_salary_item_id")) : 0L; + // 上季度结余绩效工资 + Long sjdjyjxgzSalaryItemId = NumberUtils.isCreatable(baseBean.getPropValue("htjsSalaryApproval", "sjdjyjxgz_salary_item_id")) ? Long.valueOf(baseBean.getPropValue("htjsSalaryApproval", "sjdjyjxgz_salary_item_id")) : 0L; + // 绩效差额 + Long jxceSalaryItemId = NumberUtils.isCreatable(baseBean.getPropValue("htjsSalaryApproval", "jxce_salary_item_id")) ? Long.valueOf(baseBean.getPropValue("htjsSalaryApproval", "jxce_salary_item_id")) : 0L; + // 获取二开薪资项目需要排除的员工id + List htjsExcludeEmpIds = Arrays.stream(baseBean.getPropValue("htjsSalaryApproval", "salary_acct_exclued_emp_ids").split(",")).filter(NumberUtils::isCreatable).map(Long::valueOf).collect(Collectors.toList()); + // 获取上季度预发绩效数据 + Map lastQuarterJxMap = getLastQuarterJxData(salaryAcctCalculateBO.getSalaryAcctRecordPO(), salaryAcctCalculateBO.getSalarySobPO(), simpleEmployees, jxyfSalaryItemId, htjsExcludeEmpIds); + // 获取绩效查额数据(乘以绩效分值前的值) + Map jxceMap = getJxceData(salaryAcctCalculateBO.getSalaryAcctRecordPO(), salaryAcctCalculateBO.getSalarySobPO(), simpleEmployees, jxyfSalaryItemId, htjsExcludeEmpIds); + sw.start("数据结构准备"); // 本次薪资核算所用的薪资账套下的薪资项目 Map salaryItemIdKeySalarySobItemPOMap = SalaryEntityUtil.convert2Map(salaryAcctCalculateBO.getSalarySobItemPOS(), SalarySobItemPO::getSalaryItemId); @@ -266,6 +298,25 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc String key = SalaryFormulaReferenceEnum.SALARY_ARCHIVES.getValue() + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + salaryItemPO.getCode(); resultValue = formulaVarValueMap.getOrDefault(key, StringUtils.EMPTY); } + + // 处理汇通二开的2个薪资项目 + // 上季度结余绩效工资 + if (salaryItemId.equals(sjdjyjxgzSalaryItemId)) { + if (htjsExcludeEmpIds.contains(salaryAcctEmployeePO.getEmployeeId())) { + resultValue = "0"; + } else { + resultValue = lastQuarterJxMap.getOrDefault(salaryAcctEmployeePO.getEmployeeId(), new BigDecimal(0)).divide(new BigDecimal(3), 10, BigDecimal.ROUND_HALF_UP).toString(); + } + } + // 绩效差额 + if (salaryItemId.equals(jxceSalaryItemId)) { + if (htjsExcludeEmpIds.contains(salaryAcctEmployeePO.getEmployeeId())) { + resultValue = "0"; + } else { + BigDecimal jxfz = NumberUtils.isCreatable(resultValue) ? new BigDecimal(resultValue) : new BigDecimal(0); + resultValue = jxceMap.getOrDefault(salaryAcctEmployeePO.getEmployeeId(), new BigDecimal(0)).multiply(jxfz).toString(); + } + } // 处理合并计税 resultValue = handleConsolidatedTax(resultValue, salaryItemPO, salaryAcctCalculateBO, otherSalaryAcctEmployeePOMap.get(salaryAcctEmployeePO.getEmployeeId() + "_" + salaryAcctEmployeePO.getTaxAgentId()), otherSalaryAcctResultPOMap.get(salaryAcctEmployeePO.getEmployeeId() + "_" + salaryAcctEmployeePO.getTaxAgentId())); @@ -329,6 +380,131 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc } } + + /** + * 汇通建设 - 获取上季度预发绩效 + * @param salaryAcctRecordPO + * @param jxyfSalaryItemId + * @return + */ + private Map getLastQuarterJxData(SalaryAcctRecordPO salaryAcctRecordPO, SalarySobPO salarySob, List simpleEmployees, Long jxyfSalaryItemId, List htjsExcludeEmpIds) { + // 根据薪资所属月获取上季度月份 + LocalDateRange lastQuarterRange = SalaryDateUtil.getLastQuarterRange(salaryAcctRecordPO.getSalaryMonth()); + // 获取义务人下所有账套 + List salarySobPOS = getSalarySobService(user).listByTaxAgentId(salarySob.getTaxAgentId()); + Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); + List salaryAcctRecordPOS = getSalaryAcctRecordService(user).listBySalarySobIdsAndSalaryMonth(salarySobIds, lastQuarterRange); + // 过滤未归档的核算记录 + salaryAcctRecordPOS = salaryAcctRecordPOS.stream().filter(record -> record.getStatus() > SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()).collect(Collectors.toList()); + Set salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); + // 查询薪资核算结果 + List resultPOList = getSalaryAcctResultService(user).listBySalaryAcctRecordIdsAndSalaryItemIds(salaryAcctRecordIds, Collections.singletonList(jxyfSalaryItemId)); + // 只取安全级别70以下的,不含70 + List empIds = simpleEmployees.stream() + .filter(emp -> emp.getSeclevel() != null && emp.getSeclevel().compareTo(new Integer(70)) == -1 && !htjsExcludeEmpIds.contains(emp.getEmployeeId())) + .map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList()); + resultPOList = resultPOList.stream().filter(result -> empIds.contains(result.getEmployeeId())).collect(Collectors.toList()); + // 根据人员汇总 + Map> valueMap = SalaryEntityUtil.group2Map(resultPOList, SalaryAcctResultPO::getEmployeeId); + Map resultMap = new HashMap<>(); + for (Map.Entry> entry : valueMap.entrySet()) { + BigDecimal sumValue = entry.getValue().stream().map(SalaryAcctResultPO::getResultValue).filter(NumberUtils::isCreatable).map(BigDecimal::new).reduce(new BigDecimal(0), BigDecimal::add); + resultMap.put(entry.getKey(), sumValue); + } + return resultMap; + } + + /** + * 汇通建设 - 获取绩效差额数据 + * @param salaryAcctRecordPO + * @param jxyfSalaryItemId + * @return + */ + private Map getJxceData(SalaryAcctRecordPO salaryAcctRecordPO, SalarySobPO salarySob, List employeeList, Long jxyfSalaryItemId, List htjsExcludeEmpIds) { + LocalDate salaryMonth = SalaryDateUtil.dateToLocalDate(salaryAcctRecordPO.getSalaryMonth()); + Map resultMap = new HashMap<>(); + // 如果是1或者7月需要取计算绩效差额 + if (salaryMonth.getMonthValue() == 1 || salaryMonth.getMonthValue() == 7) { + // 区分安全级别为70以下和 70及以上 + // List managerEmpIdList = new ArrayList<>(); + List normalEmpIdList = new ArrayList<>(); + employeeList.stream().forEach(emp -> { + if (emp.getSeclevel() != null && emp.getSeclevel().compareTo(new Integer(70)) == -1 && !htjsExcludeEmpIds.contains(emp.getEmployeeId())) { + normalEmpIdList.add(emp.getEmployeeId()); + } + }); + // 获取义务人下所有账套 + List salarySobPOS = getSalarySobService(user).listByTaxAgentId(salarySob.getTaxAgentId()); + Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); + // 3个时间范围 + LocalDate salaryMonthLocalDate = SalaryDateUtil.dateToLocalDate(salaryAcctRecordPO.getSalaryMonth()); + LocalDate lastYearLocalDate = salaryMonthLocalDate.minusYears(1); + LocalDate fistMonthOfLastYear = lastYearLocalDate.withMonth(1).withDayOfMonth(1); + LocalDate lastMonthOfLastYear = lastYearLocalDate.withMonth(12).withDayOfMonth(1); + // LocalDateRange lastYearRange = LocalDateRange.builder().fromDate(SalaryDateUtil.localDateToDate(fistMonthOfLastYear)).endDate(SalaryDateUtil.localDateToDate(lastMonthOfLastYear)).build(); + LocalDateRange lastYearHalfYearRange = LocalDateRange.builder().fromDate(SalaryDateUtil.localDateToDate(fistMonthOfLastYear.withMonth(7))).endDate(SalaryDateUtil.localDateToDate(lastMonthOfLastYear)).build(); + LocalDateRange thisYearHalfYearRange = LocalDateRange.builder().fromDate(SalaryDateUtil.localDateToDate(salaryMonthLocalDate.withMonth(1).withDayOfMonth(1))).endDate(SalaryDateUtil.localDateToDate(salaryMonthLocalDate.withMonth(6).withDayOfMonth(1))).build(); + + if(salaryMonth.getMonthValue() == 1) { + // // 处理安全级别为70及以上的 + // // 1月份取上年绩效预发金额合计/0.4*绩效分值 + // List salaryAcctRecordPOS = getSalaryAcctRecordService(user).listBySalarySobIdsAndSalaryMonth(salarySobIds, lastYearRange); + // // 过滤未归档的核算记录 + // salaryAcctRecordPOS = salaryAcctRecordPOS.stream().filter(record -> record.getStatus() > SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()).collect(Collectors.toList()); + // Set salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); + // List salaryAcctEmployeePOList = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIdsAndEmployeeIds(salaryAcctRecordIds, managerEmpIdList); + // List salaryAcctEmpIds = SalaryEntityUtil.properties(salaryAcctEmployeePOList, SalaryAcctEmployeePO::getId, Collectors.toList()); + // // 查询薪资核算结果 + // List resultPOList = getSalaryAcctResultService(user).listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, Collections.singletonList(jxyfSalaryItemId)); + // // 根据人员汇总 + // Map> valueMap = SalaryEntityUtil.group2Map(resultPOList, SalaryAcctResultPO::getEmployeeId, SalaryAcctResultPO::getResultValue); + // BigDecimal base = BigDecimal.valueOf(0.4); + // for (Map.Entry> entry : valueMap.entrySet()) { + // BigDecimal sumValue = entry.getValue().stream().filter(NumberUtils::isCreatable).map(BigDecimal::new).reduce(new BigDecimal(0), BigDecimal::add); + // resultMap.put(entry.getKey(), sumValue.divide(base,10, BigDecimal.ROUND_HALF_UP)); + // } + + // 处理安全级别为70以下的 + // 1月份差额取去年7-12绩效预发金额合计*2*绩效分值 + List salaryAcctRecordPOS = getSalaryAcctRecordService(user).listBySalarySobIdsAndSalaryMonth(salarySobIds, lastYearHalfYearRange); + // 过滤未归档的核算记录 + salaryAcctRecordPOS = salaryAcctRecordPOS.stream().filter(record -> record.getStatus() > SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()).collect(Collectors.toList()); + Set salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); + List salaryAcctEmployeePOList = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIdsAndEmployeeIds(salaryAcctRecordIds, normalEmpIdList); + List salaryAcctEmpIds = SalaryEntityUtil.properties(salaryAcctEmployeePOList, SalaryAcctEmployeePO::getId, Collectors.toList()); + // 查询薪资核算结果 + List resultPOList = getSalaryAcctResultService(user).listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, Collections.singletonList(jxyfSalaryItemId)); + // 根据人员汇总 + Map> valueMap = SalaryEntityUtil.group2Map(resultPOList, SalaryAcctResultPO::getEmployeeId); + BigDecimal base = BigDecimal.valueOf(2); + for (Map.Entry> entry : valueMap.entrySet()) { + BigDecimal sumValue = entry.getValue().stream().map(SalaryAcctResultPO::getResultValue).filter(NumberUtils::isCreatable).map(BigDecimal::new).reduce(new BigDecimal(0), BigDecimal::add); + resultMap.put(entry.getKey(), sumValue.multiply(base)); + } + } + + if (salaryMonth.getMonthValue() == 7){ + // 7月份差额取1-6月绩效预发金额合计*2*绩效分值 + List salaryAcctRecordPOS = getSalaryAcctRecordService(user).listBySalarySobIdsAndSalaryMonth(salarySobIds, thisYearHalfYearRange); + // 过滤未归档的核算记录 + salaryAcctRecordPOS = salaryAcctRecordPOS.stream().filter(record -> record.getStatus() > SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()).collect(Collectors.toList()); + Set salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); + List salaryAcctEmployeePOList = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIdsAndEmployeeIds(salaryAcctRecordIds, normalEmpIdList); + List salaryAcctEmpIds = SalaryEntityUtil.properties(salaryAcctEmployeePOList, SalaryAcctEmployeePO::getId, Collectors.toList()); + // 查询薪资核算结果 + List resultPOList = getSalaryAcctResultService(user).listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, Collections.singletonList(jxyfSalaryItemId)); + // 根据人员汇总 + Map> valueMap = SalaryEntityUtil.group2Map(resultPOList, SalaryAcctResultPO::getEmployeeId); + BigDecimal base = BigDecimal.valueOf(2); + for (Map.Entry> entry : valueMap.entrySet()) { + BigDecimal sumValue = entry.getValue().stream().map(SalaryAcctResultPO::getResultValue).filter(NumberUtils::isCreatable).map(BigDecimal::new).reduce(new BigDecimal(0), BigDecimal::add); + resultMap.put(entry.getKey(), sumValue.multiply(base)); + } + } + } + return resultMap; + } + /** * 运行公式 * diff --git a/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java index ee0ddc70a..4cfb2b1a2 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java @@ -143,8 +143,16 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct } @Override - public List listBySalaryAcctRecordIds(Collection salaryAcctRecordIds) { - return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordIds(salaryAcctRecordIds).build()); + public List listBySalaryAcctRecordIds(List salaryAcctRecordIds) { + if (CollectionUtils.isEmpty(salaryAcctRecordIds)) { + return Collections.emptyList(); + } + List> partition = Lists.partition(salaryAcctRecordIds, 500); + List resultList = new ArrayList<>(); + partition.forEach(part -> { + resultList.addAll(getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordIds(part).build())); + }); + return resultList; } @Override @@ -298,7 +306,7 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct } Set lastMonthSalaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); // 上个月的核算人员 - List lastMonthSalaryAcctEmployeePOS = listBySalaryAcctRecordIds(lastMonthSalaryAcctRecordIds); + List lastMonthSalaryAcctEmployeePOS = listBySalaryAcctRecordIds(lastMonthSalaryAcctRecordIds.stream().collect(Collectors.toList())); Map lastMonthSalaryAcctEmployeePOMap = SalaryEntityUtil.convert2Map(lastMonthSalaryAcctEmployeePOS, salaryAcctEmployeePO -> salaryAcctEmployeePO.getEmployeeId() + "-" + salaryAcctEmployeePO.getTaxAgentId()); // 本月的核算人员 List salaryAcctEmployeePOS = listByParam(queryParam); @@ -323,7 +331,7 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct } Set lastMonthSalaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); // 上个月的核算人员 - List lastMonthSalaryAcctEmployeePOS = listBySalaryAcctRecordIds(lastMonthSalaryAcctRecordIds); + List lastMonthSalaryAcctEmployeePOS = listBySalaryAcctRecordIds(lastMonthSalaryAcctRecordIds.stream().collect(Collectors.toList())); Map lastMonthSalaryAcctEmployeePOMap = SalaryEntityUtil.convert2Map(lastMonthSalaryAcctEmployeePOS, salaryAcctEmployeePO -> salaryAcctEmployeePO.getEmployeeId() + "-" + salaryAcctEmployeePO.getTaxAgentId()); // 本月的核算人员 List salaryAcctEmployeePOS = listByParam(queryParam); diff --git a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java index 2a75368dc..06900ac2f 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java @@ -719,7 +719,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe List salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(id); // 查询其他核算记录中的薪资核算人员 Set otherSalaryAcctRecordIds = SalaryEntityUtil.properties(otherSalaryAcctRecordPOS, SalaryAcctRecordPO::getId); - List otherSalaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(otherSalaryAcctRecordIds); + List otherSalaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(otherSalaryAcctRecordIds.stream().collect(Collectors.toList())); // 有其他核算记录,需要进一步判断本次核算的人员中是否存在合并计税 Set keySet = SalaryEntityUtil.properties(otherSalaryAcctEmployeePOS, salaryAcctEmployeePO -> salaryAcctEmployeePO.getEmployeeId() + "-" + salaryAcctEmployeePO.getTaxAgentId()); boolean hasConsolidatedTax = salaryAcctEmployeePOS.stream().anyMatch(salaryAcctEmployeePO -> keySet.contains(salaryAcctEmployeePO.getEmployeeId() + "-" + salaryAcctEmployeePO.getTaxAgentId())); diff --git a/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java index f99f7ac58..a572839a9 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java @@ -1,6 +1,5 @@ package com.engine.salary.service.impl; -import com.alibaba.fastjson.JSON; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.hrmelog.entity.dto.LoggerContext; @@ -27,6 +26,7 @@ import com.engine.salary.entity.salaryformula.ExpressFormula; import com.engine.salary.entity.salaryitem.po.SalaryItemPO; import com.engine.salary.entity.salarysob.dto.*; import com.engine.salary.entity.salarysob.po.*; +import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; import com.engine.salary.entity.taxagent.po.TaxAgentAdminPO; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.enums.OperateTypeEnum; @@ -37,8 +37,10 @@ import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; import com.engine.salary.enums.salaryaccounting.SalaryAcctResultDataSourceEnum; import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.salaryacct.SalaryAcctResultMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper; import com.engine.salary.report.service.SalaryStatisticsReportService; import com.engine.salary.report.service.impl.SalaryStatisticsReportServiceImpl; import com.engine.salary.service.*; @@ -70,7 +72,6 @@ import weaver.general.BaseBean; import weaver.general.Util; import weaver.hrm.User; -import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.util.*; import java.util.concurrent.BlockingDeque; @@ -202,6 +203,10 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe return ServiceUtil.getService(SalaryAcctSobConfigServiceImpl.class, user); } + private InsuranceSchemeMapper getInsuranceSchemeMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeMapper.class); + } + @Override public List listBySalaryAcctRecordIds(Collection salaryAcctRecordIds) { if (CollectionUtils.isEmpty(salaryAcctRecordIds)) { @@ -1262,20 +1267,12 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe List salaryAcctEmpIds = salaryAcctEmployeePOList.stream().map(SalaryAcctEmployeePO::getId).collect(Collectors.toList()); List empIds = salaryAcctEmployeePOList.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); List employeeList = getSalaryEmployeeService(user).listByIds(empIds); - // 获取需要查询的薪资项目 - BaseBean baseBean = new BaseBean(); - String xcssConfig = baseBean.getPropValue("htjsSalaryApproval", "xcss_config"); - try { - xcssConfig = new String(xcssConfig.getBytes("ISO-8859-1"), "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - List htXcssItemDTOList = JSON.parseArray(xcssConfig, HtXcssItemDTO.class); + Map salaryItemNameMap = SalaryEntityUtil.convert2Map(getSalaryItemService(user).listAll(), SalaryItemPO::getName, SalaryItemPO::getId); - for(HtXcssItemDTO dto : htXcssItemDTOList) { + for(HtXcssItemDTO dto : param.getHtXcssItemDTOList()) { dto.setSalaryItemId(salaryItemNameMap.getOrDefault(dto.getSalaryItemName(), 0L)); } - List salaryItemIds = htXcssItemDTOList.stream().map(HtXcssItemDTO::getSalaryItemId).filter(salaryItemId -> salaryItemId != null && (!salaryItemId.equals(0L))).collect(Collectors.toList()); + List salaryItemIds = param.getHtXcssItemDTOList().stream().map(HtXcssItemDTO::getSalaryItemId).filter(salaryItemId -> salaryItemId != null && (!salaryItemId.equals(0L))).collect(Collectors.toList()); List acctResultList = listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, salaryItemIds); List salaryItemList = getSalaryItemService(user).listByIds(salaryItemIds); List taxAgentList = getTaxAgentService(user).listAll(); @@ -1295,7 +1292,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe resultMap = sortedMap; List> list = resultMap.values().stream().collect(Collectors.toList()); // 表头信息 - List columns = htXcssItemDTOList.stream().map(itemDTO -> { + List columns = param.getHtXcssItemDTOList().stream().map(itemDTO -> { return HtjsApprovalColumn.builder() .fieldName(itemDTO.getFieldName()) .salaryItemId(Util.null2String(itemDTO.getSalaryItemId())) @@ -1329,21 +1326,14 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe // 分页 PageInfo salaryAcctEmployeePageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), salaryAcctEmployeePOList, SalaryAcctEmployeePO.class); - // 获取需要查询的薪资项目 - BaseBean baseBean = new BaseBean(); - String xcssConfig = baseBean.getPropValue("htjsSalaryApproval", "xcss_config"); - try { - xcssConfig = new String(xcssConfig.getBytes("ISO-8859-1"), "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - List htXcssItemDTOList = JSON.parseArray(xcssConfig, HtXcssItemDTO.class); + Map salaryItemNameMap = SalaryEntityUtil.convert2Map(getSalaryItemService(user).listAll(), SalaryItemPO::getName, SalaryItemPO::getId); - for(HtXcssItemDTO dto : htXcssItemDTOList) { + for(HtXcssItemDTO dto : param.getHtXcssItemDTOList()) { dto.setSalaryItemId(salaryItemNameMap.getOrDefault(dto.getSalaryItemName(), 0L)); } - List salaryItemIds = htXcssItemDTOList.stream().map(HtXcssItemDTO::getSalaryItemId).filter(salaryItemId -> salaryItemId != null && (!salaryItemId.equals(0L))).collect(Collectors.toList()); + List salaryItemIds = param.getHtXcssItemDTOList().stream().map(HtXcssItemDTO::getSalaryItemId).filter(salaryItemId -> salaryItemId != null && (!salaryItemId.equals(0L))).collect(Collectors.toList()); List salaryItemList = getSalaryItemService(user).listByIds(salaryItemIds); + Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItemList, SalaryItemPO::getId); List> valueList = htjsListBySalaryAcctEmployees(salaryAcctEmployeePageInfo.getList(), salaryItemIds); // 薪资核算结果的分页结果 PageInfo> pageInfo = new PageInfo<>(); @@ -1355,15 +1345,18 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe // 表头 List columns = Lists.newArrayList(); // 员工信息字段 - columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption("个税扣缴义务人", 0), "个税扣缴义务人", "taxAgentname")); + columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption("个税扣缴义务人", 0), "个税扣缴义务人", "taxAgentName")); columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption("姓名", 0), "姓名", "username")); + columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption("分部", 0), "分部", "subcompanyName")); columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption("部门", 0), "部门", "departmentName")); columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption("状态", 0), "状态", "statusName")); // 薪资项目 - for (SalaryItemPO salaryItemPO : salaryItemList) { - columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salaryItemPO.getName(), salaryItemPO.getWidth()), salaryItemPO.getName(), "" + salaryItemPO.getId(), LockStatusEnum.UNLOCK.getDefaultLabel())); - + for (Long salaryItemId : salaryItemIds) { + SalaryItemPO salaryItemPO = salaryItemMap.get(salaryItemId); + if (salaryItemPO != null) { + columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salaryItemPO.getName(), salaryItemPO.getWidth()), salaryItemPO.getName(), "" + salaryItemPO.getId(), LockStatusEnum.UNLOCK.getDefaultLabel())); + } } result.put("pageInfo", pageInfo); result.put("columns", columns); @@ -1393,7 +1386,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe String[] split = entrySet.getKey().split("_split"); itemSum.put("subCompanyName", split.length > 1 ? split[1] : ""); itemSum.put("empNums", entrySet.getValue().size()); - itemSum.put("subcompanyId", CollectionUtils.isEmpty(value) ? "" : value.get(0).get("subcompanyId") == null ? "0" : value.get(0).get("subcompanyId")); + itemSum.put("subCompanyId", CollectionUtils.isEmpty(value) ? "" : value.get(0).get("subcompanyId") == null ? "0" : value.get(0).get("subcompanyId")); result.put(entrySet.getKey(), itemSum); } return result; @@ -1408,6 +1401,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe List salarySobEmpFieldPOS = new ArrayList<>(); salarySobEmpFieldPOS.add(SalarySobEmpFieldPO.builder().fieldCode("taxAgentName").build()); salarySobEmpFieldPOS.add(SalarySobEmpFieldPO.builder().fieldCode("username").build()); + salarySobEmpFieldPOS.add(SalarySobEmpFieldPO.builder().fieldCode("subcompanyName").build()); salarySobEmpFieldPOS.add(SalarySobEmpFieldPO.builder().fieldCode("departmentName").build()); salarySobEmpFieldPOS.add(SalarySobEmpFieldPO.builder().fieldCode("statusName").build()); List salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds); @@ -1429,7 +1423,80 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe return SalaryAcctResultBO.buildTableData4Ht(salaryItemPOS, salarySobEmpFieldPOS, simpleEmployees, salaryAcctEmployeePOS, salaryAcctResultPOS, taxAgentPOS, false); } + @Override + public Map htjsXczfsqList(HtjsApprovalParam param) { + if (StringUtils.isBlank(param.getSalaryMonth()) || param.getSubcompanyId() == null) { + throw new SalaryRunTimeException("参数错误"); + } + // 明细数据 + Map dataList = htjsXcssList(param); + // 获取累计数据 + BaseBean baseBean = new BaseBean(); + String itemId = baseBean.getPropValue("htjsSalaryApproval", "xczf_sum_item_id"); + BigDecimal totalValueLastMonth = new BigDecimal(0); + BigDecimal totalValue = new BigDecimal(0); + if (NumberUtils.isCreatable(itemId)) { + SalaryItemPO salaryItemPO = getSalaryItemService(user).getById(Long.valueOf(itemId)); + // 获取截至本月上一个月的核算记录 + Date lastMonthDate = SalaryDateUtil.localDateToDate(SalaryDateUtil.dateToLocalDate(param.getSalaryMonthDate()).plusMonths(-1)); + List salaryAcctRecordPOS = getSalaryAcctRecordService(user).listBySalaryMonth(LocalDateRange.builder().endDate(lastMonthDate).build()); + salaryAcctRecordPOS = salaryAcctRecordPOS.stream().filter(record -> record.getStatus() > SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()).collect(Collectors.toList()); + // 获取薪资核算人员 + List salaryAcctRecordIds = salaryAcctRecordPOS.stream().map(SalaryAcctRecordPO::getId).collect(Collectors.toList()); + List salaryAcctEmployeeList = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(salaryAcctRecordIds); + // 过滤单位 + salaryAcctEmployeeList = salaryAcctEmployeeList.stream().filter(acctEmp -> acctEmp.getSubcompanyId() != null && param.getSubcompanyId().equals(acctEmp.getSubcompanyId())).collect(Collectors.toList()); + List salaryAcctEmpIds = SalaryEntityUtil.properties(salaryAcctEmployeeList, SalaryAcctEmployeePO::getId, Collectors.toList()); + // 获取薪资核算结果 + List resultPOList = listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, Collections.singletonList(salaryItemPO.getId())); + totalValueLastMonth = resultPOList.stream() + .map(SalaryAcctResultPO::getResultValue) + .filter(NumberUtils::isCreatable) + .map(BigDecimal::new) + .reduce(BigDecimal.ZERO, BigDecimal::add); + // 获取本月的数据 + salaryAcctRecordPOS = getSalaryAcctRecordService(user).listBySalaryMonth(LocalDateRange.builder().fromDate(param.getSalaryMonthDate()).endDate(param.getSalaryMonthDate()).build()); + salaryAcctRecordPOS = salaryAcctRecordPOS.stream().filter(record -> record.getStatus() > SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()).collect(Collectors.toList()); + // 获取薪资核算人员 + salaryAcctRecordIds = salaryAcctRecordPOS.stream().map(SalaryAcctRecordPO::getId).collect(Collectors.toList()); + salaryAcctEmployeeList = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(salaryAcctRecordIds); + // 过滤单位 + salaryAcctEmployeeList = salaryAcctEmployeeList.stream().filter(acctEmp -> acctEmp.getSubcompanyId() != null && param.getSubcompanyId().equals(acctEmp.getSubcompanyId())).collect(Collectors.toList()); + salaryAcctEmpIds = SalaryEntityUtil.properties(salaryAcctEmployeeList, SalaryAcctEmployeePO::getId, Collectors.toList()); + // 获取薪资核算结果 + resultPOList = listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, Collections.singletonList(salaryItemPO.getId())); + BigDecimal thisMonthValue = resultPOList.stream() + .map(SalaryAcctResultPO::getResultValue) + .filter(NumberUtils::isCreatable) + .map(BigDecimal::new) + .reduce(BigDecimal.ZERO, BigDecimal::add); + totalValue = totalValueLastMonth.add(thisMonthValue); + } + Map resultMap = new HashMap<>(); + resultMap.put("columns", dataList.get("columns")); + resultMap.put("data", dataList.get("data")); + resultMap.put("ljjhzf",totalValue); + resultMap.put("ljyzf", totalValueLastMonth); + return resultMap; + } - + @Override + public List htjsSbqsList(HtjsApprovalParam param) { + if (param.getSchemeId() == null || StringUtils.isBlank(param.getSalaryMonth())) { + return Collections.emptyList(); + } + InsuranceSchemePO insuranceSchemePO = getInsuranceSchemeMapper().getById(param.getSchemeId()); + if (insuranceSchemePO == null) { + throw new SalaryRunTimeException("社保福利方案不存在或已被删除"); + } + Integer welfareType = insuranceSchemePO.getWelfareType(); + if (welfareType.equals(WelfareTypeEnum.SOCIAL_SECURITY.getValue())) { + return getSIAccountService(user).welfareData4Htjs(param.getSalaryMonth(), param.getSchemeId(), null, null); + } else if (welfareType.equals(WelfareTypeEnum.ACCUMULATION_FUND.getValue())) { + return getSIAccountService(user).welfareData4Htjs(param.getSalaryMonth(), null, param.getSchemeId(), null); + } else { + return getSIAccountService(user).welfareData4Htjs(param.getSalaryMonth(), null, null, param.getSchemeId()); + } + } } \ No newline at end of file diff --git a/src/com/engine/salary/util/SalaryDateUtil.java b/src/com/engine/salary/util/SalaryDateUtil.java index 09983dd1f..391afd561 100644 --- a/src/com/engine/salary/util/SalaryDateUtil.java +++ b/src/com/engine/salary/util/SalaryDateUtil.java @@ -14,6 +14,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.*; import java.time.format.DateTimeFormatter; +import java.time.temporal.TemporalAdjusters; import java.util.Calendar; import java.util.Date; import java.util.Objects; @@ -604,6 +605,20 @@ public class SalaryDateUtil { LocalDate localDate = SalaryDateUtil.dateToLocalDate(date).plusMonths(i); return SalaryDateUtil.localDateToDate(localDate); } + + /** + * 获取上一季度日期范围 + * @param salaryMonth + * @return + */ + public static LocalDateRange getLastQuarterRange(Date salaryMonth) { + LocalDate today = SalaryDateUtil.dateToLocalDate(salaryMonth); + LocalDate firstDayOfThisQuarter = today.with(TemporalAdjusters.firstDayOfNextMonth()) + .minusMonths(today.getMonthValue() % 3 == 0 ? 3 : today.getMonthValue() % 3); + LocalDate firstDayOfLastQuarter = firstDayOfThisQuarter.minusMonths(3); + LocalDate lastDayOfLastQuarter = firstDayOfLastQuarter.plusMonths(3).minusDays(1); + return LocalDateRange.builder().fromDate(localDateToDate(firstDayOfLastQuarter)).endDate(localDateToDate(lastDayOfLastQuarter)).build(); + } } diff --git a/src/com/engine/salary/web/SalaryAcctController.java b/src/com/engine/salary/web/SalaryAcctController.java index d436f337a..e88365e5b 100644 --- a/src/com/engine/salary/web/SalaryAcctController.java +++ b/src/com/engine/salary/web/SalaryAcctController.java @@ -960,5 +960,52 @@ public class SalaryAcctController { User user = HrmUserVarify.getUser(request, response); return new ResponseResult>(user).run(getSalaryAcctResultWrapper(user)::htjsXcssDataDetail, param); } + + + + /** + * 薪酬支付申请list + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/htjs/xczfsqList") + @Produces(MediaType.APPLICATION_JSON) + public String htjsXczfsqList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody HtjsApprovalParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryAcctResultWrapper(user)::htjsXczfsqList, param); + } + + /** + * 薪酬支付申请 数据穿透 + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/htjs/xczfsqDataDetail") + @Produces(MediaType.APPLICATION_JSON) + public String htjsXczfsqDataDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody HtjsApprovalParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryAcctResultWrapper(user)::htjsXczfsqDataDetail, param); + } + + /** + * 薪酬支付申请list + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/htjs/sbqsList") + @Produces(MediaType.APPLICATION_JSON) + public String htjsSbqsList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody HtjsApprovalParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryAcctResultWrapper(user)::htjsSbqsList, param); + } /**********************************汇通建设送薪审批 end*********************************/ } diff --git a/src/com/engine/salary/wrapper/SalaryAcctResultWrapper.java b/src/com/engine/salary/wrapper/SalaryAcctResultWrapper.java index 2f8707a1d..460966616 100644 --- a/src/com/engine/salary/wrapper/SalaryAcctResultWrapper.java +++ b/src/com/engine/salary/wrapper/SalaryAcctResultWrapper.java @@ -1,14 +1,13 @@ package com.engine.salary.wrapper; +import com.alibaba.fastjson.JSON; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.cache.SalaryCacheKey; import com.engine.salary.component.WeaTableColumnGroup; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.progress.ProgressDTO; -import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO; -import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO; -import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultListColumnDTO; +import com.engine.salary.entity.salaryacct.dto.*; import com.engine.salary.entity.salaryacct.param.*; import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; import com.engine.salary.exception.SalaryRunTimeException; @@ -23,8 +22,10 @@ import com.engine.salary.wrapper.proxy.SalaryAcctResultWrapperProxy; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.math.NumberUtils; import org.apache.commons.lang3.StringUtils; +import weaver.general.BaseBean; import weaver.hrm.User; +import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.util.*; @@ -267,14 +268,81 @@ public class SalaryAcctResultWrapper extends Service implements SalaryAcctResult getSalaryAcctResultService(user).batchUpdate(param); } + /** + * 薪酬送审列表 + * @param param + * @return + */ public Map htjsXcssList(HtjsApprovalParam param) { + // 获取需要查询的薪资项目 + BaseBean baseBean = new BaseBean(); + String xcssConfig = baseBean.getPropValue("htjsSalaryApproval", "xcss_config"); + try { + xcssConfig = new String(xcssConfig.getBytes("ISO-8859-1"), "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + List htXcssItemDTOList = JSON.parseArray(xcssConfig, HtXcssItemDTO.class); + param.setHtXcssItemDTOList(htXcssItemDTOList); return getSalaryAcctResultService(user).htjsXcssList(param); } + /** + * 薪酬送审数据穿透 + * @param param + * @return + */ public Map htjsXcssDataDetail(HtjsApprovalParam param) { + // 获取需要查询的薪资项目 + BaseBean baseBean = new BaseBean(); + String xcssConfig = baseBean.getPropValue("htjsSalaryApproval", "xcss_config"); + try { + xcssConfig = new String(xcssConfig.getBytes("ISO-8859-1"), "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + List htXcssItemDTOList = JSON.parseArray(xcssConfig, HtXcssItemDTO.class); + param.setHtXcssItemDTOList(htXcssItemDTOList); return getSalaryAcctResultService(user).htjsXcssDataDetail(param); } + /** + * 薪酬支付申请list + * @param param + * @return + */ + public Map htjsXczfsqList(HtjsApprovalParam param) { + // 获取需要查询的薪资项目 + BaseBean baseBean = new BaseBean(); + String xcssConfig = baseBean.getPropValue("htjsSalaryApproval", "xczf_config"); + try { + xcssConfig = new String(xcssConfig.getBytes("ISO-8859-1"), "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + List htXcssItemDTOList = JSON.parseArray(xcssConfig, HtXcssItemDTO.class); + param.setHtXcssItemDTOList(htXcssItemDTOList); + return getSalaryAcctResultService(user).htjsXczfsqList(param); + } + + public Map htjsXczfsqDataDetail(HtjsApprovalParam param) { + // 获取需要查询的薪资项目 + BaseBean baseBean = new BaseBean(); + String xcssConfig = baseBean.getPropValue("htjsSalaryApproval", "xczf_config"); + try { + xcssConfig = new String(xcssConfig.getBytes("ISO-8859-1"), "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + List htXcssItemDTOList = JSON.parseArray(xcssConfig, HtXcssItemDTO.class); + param.setHtXcssItemDTOList(htXcssItemDTOList); + return getSalaryAcctResultService(user).htjsXcssDataDetail(param); + } + + public List htjsSbqsList(HtjsApprovalParam param) { + return getSalaryAcctResultService(user).htjsSbqsList(param); + } + /** * 薪资核算-校验 *