From ecfa6a46047b91b0f0c30de85ddec0b3c8577a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Mon, 2 Sep 2024 17:36:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=A8=E6=89=A3=E7=BC=B4=E4=B9=89=E5=8A=A1?= =?UTF-8?q?=E4=BA=BA=E6=A0=B8=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wiki/扩展功能/hrmSalaryCustom.properties | 3 +- .../salaryacct/bo/SalaryAcctResultBO.java | 118 ++++++++++-------- .../salaryarchive/bo/SalaryArchiveBO.java | 69 ---------- .../entity/salarysob/po/SalarySobPO.java | 6 +- .../mapper/salarysob/SalarySobMapper.java | 1 + .../mapper/salarysob/SalarySobMapper.xml | 16 +++ .../salary/service/AddUpDeductionService.java | 2 +- .../salary/service/OtherDeductionService.java | 2 +- .../salary/service/SalaryArchiveService.java | 4 +- .../salary/service/SalarySobService.java | 4 +- .../impl/AddUpDeductionServiceImpl.java | 8 +- .../impl/AttendQuoteDataServiceImpl.java | 8 +- .../impl/OtherDeductionServiceImpl.java | 4 +- .../impl/SalaryAcctCalculateServiceImpl.java | 11 +- .../impl/SalaryAcctEmployeeServiceImpl.java | 34 ++--- .../impl/SalaryArchiveServiceImpl.java | 12 +- .../service/impl/SalarySobServiceImpl.java | 10 +- 17 files changed, 142 insertions(+), 170 deletions(-) diff --git a/resource/wiki/扩展功能/hrmSalaryCustom.properties b/resource/wiki/扩展功能/hrmSalaryCustom.properties index 6294cc5c3..bde8d4ce1 100644 --- a/resource/wiki/扩展功能/hrmSalaryCustom.properties +++ b/resource/wiki/扩展功能/hrmSalaryCustom.properties @@ -1 +1,2 @@ -formulaRunOvertimeThreshold= \ No newline at end of file +formulaRunOvertimeThreshold=100 +threadNumber=10 \ No newline at end of file diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultBO.java index ef1dcca05..f3cf66dba 100644 --- a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultBO.java +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultBO.java @@ -273,65 +273,73 @@ public class SalaryAcctResultBO { } SalaryI18nUtil.i18nList(salaryAcctEmployees); Map employeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId); - Map> acctResultMap = SalaryEntityUtil.group2Map(salaryAccountingResults, SalaryAcctResultPO::getEmployeeId); Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName); - return salaryAcctEmployees.stream().map(e -> { - Map resultValueMap = SalaryEntityUtil.convert2Map(acctResultMap.getOrDefault(e.getEmployeeId(), Collections.emptyList()), - SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue); - // 薪资项目的值 - Map map = SalaryEntityUtil.convert2Map(salaryItems, o -> "" + o.getId(), o -> resultValueMap.getOrDefault(o.getId(), StringUtils.EMPTY)); - // 薪资项目的字段类型(前端依据这个判断是否需要展示千分位) - Map dataTypeMap = SalaryEntityUtil.convert2Map(salaryItems, salaryItemPO -> salaryItemPO.getId() + DATA_TYPE_SUFFIX, SalaryItemPO::getDataType); - map.putAll(dataTypeMap); - // 人员信息字段的值 - Map fieldValueMap = SalaryAcctFormulaBO.convert2FormulaEmployee(employeeMap.get(e.getEmployeeId()), e, true); - for (SalarySobEmpFieldPO salarySobEmpField : salarySobEmpFields) { - // 员工信息字段的字段类型 - if (dynamicEmpInfo) { - map.put(salarySobEmpField.getFieldCode(), fieldValueMap.get(salarySobEmpField.getFieldCode())); - } else { - if ("departmentName".equals(salarySobEmpField.getFieldCode())) { - map.put("departmentName", e.getDepartmentName()); - } else if ("departmentId".equals(salarySobEmpField.getFieldCode())) { - map.put("departmentId", e.getDepartmentId()); - } else if ("subcompanyName".equals(salarySobEmpField.getFieldCode())) { - map.put("subcompanyName", e.getSubcompanyName()); - } else if ("jobcall".equals(salarySobEmpField.getFieldCode())) { - map.put("jobcall", e.getJobcall()); - } else if ("jobcallId".equals(salarySobEmpField.getFieldCode())) { - map.put("jobcallId", e.getJobcallId()); - } else if ("jobtitleName".equals(salarySobEmpField.getFieldCode())) { - map.put("jobtitleName", e.getJobtitleName()); - } else if ("jobtitleId".equals(salarySobEmpField.getFieldCode())) { - map.put("jobtitleId", e.getJobtitleId()); - } else if ("status".equals(salarySobEmpField.getFieldCode())) { - map.put("status", e.getStatus()); - } else if ("statusName".equals(salarySobEmpField.getFieldCode())) { - map.put("statusName", UserStatusEnum.getDefaultLabelByValue(new Integer(Util.null2s(e.getStatus(), "1")))); - } else { + Map> taxAcctEmpsMap = SalaryEntityUtil.group2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getTaxAgentId); + Map> taxAcctResultMap = SalaryEntityUtil.group2Map(salaryAccountingResults, SalaryAcctResultPO::getTaxAgentId); + + List> result = new ArrayList<>(); + for (Long taxAgentId : taxAcctEmpsMap.keySet()) { + Map> acctResultMap = SalaryEntityUtil.group2Map(taxAcctResultMap.get(taxAgentId), SalaryAcctResultPO::getEmployeeId); + List> collect = taxAcctEmpsMap.get(taxAgentId).stream().map(e -> { + Map resultValueMap = SalaryEntityUtil.convert2Map(acctResultMap.getOrDefault(e.getEmployeeId(), Collections.emptyList()), + SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue); + // 薪资项目的值 + Map map = SalaryEntityUtil.convert2Map(salaryItems, o -> "" + o.getId(), o -> resultValueMap.getOrDefault(o.getId(), StringUtils.EMPTY)); + // 薪资项目的字段类型(前端依据这个判断是否需要展示千分位) + Map dataTypeMap = SalaryEntityUtil.convert2Map(salaryItems, salaryItemPO -> salaryItemPO.getId() + DATA_TYPE_SUFFIX, SalaryItemPO::getDataType); + map.putAll(dataTypeMap); + // 人员信息字段的值 + Map fieldValueMap = SalaryAcctFormulaBO.convert2FormulaEmployee(employeeMap.get(e.getEmployeeId()), e, true); + for (SalarySobEmpFieldPO salarySobEmpField : salarySobEmpFields) { + // 员工信息字段的字段类型 + if (dynamicEmpInfo) { map.put(salarySobEmpField.getFieldCode(), fieldValueMap.get(salarySobEmpField.getFieldCode())); + } else { + if ("departmentName".equals(salarySobEmpField.getFieldCode())) { + map.put("departmentName", e.getDepartmentName()); + } else if ("departmentId".equals(salarySobEmpField.getFieldCode())) { + map.put("departmentId", e.getDepartmentId()); + } else if ("subcompanyName".equals(salarySobEmpField.getFieldCode())) { + map.put("subcompanyName", e.getSubcompanyName()); + } else if ("jobcall".equals(salarySobEmpField.getFieldCode())) { + map.put("jobcall", e.getJobcall()); + } else if ("jobcallId".equals(salarySobEmpField.getFieldCode())) { + map.put("jobcallId", e.getJobcallId()); + } else if ("jobtitleName".equals(salarySobEmpField.getFieldCode())) { + map.put("jobtitleName", e.getJobtitleName()); + } else if ("jobtitleId".equals(salarySobEmpField.getFieldCode())) { + map.put("jobtitleId", e.getJobtitleId()); + } else if ("status".equals(salarySobEmpField.getFieldCode())) { + map.put("status", e.getStatus()); + } else if ("statusName".equals(salarySobEmpField.getFieldCode())) { + map.put("statusName", UserStatusEnum.getDefaultLabelByValue(new Integer(Util.null2s(e.getStatus(), "1")))); + } else { + map.put(salarySobEmpField.getFieldCode(), fieldValueMap.get(salarySobEmpField.getFieldCode())); + } } + map.put(salarySobEmpField.getFieldCode() + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); } - map.put(salarySobEmpField.getFieldCode() + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); - } - // 主键id - map.put("id", e.getId()); - //锁定状态 - map.put("lockStatus", LockStatusEnum.getByValue(e.getLockStatus()).getDefaultLabel()); - //人员id - map.put("employeeId", e.getEmployeeId()); - // 个税扣缴义务人 - String taxAgentName = taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY); - map.put("taxAgentName", taxAgentName); - // 是否属于"合并计税"的标记 - map.put("consolidatedTaxation", StringUtils.isNotEmpty(taxAgentName) && consolidatedTaxSalaryAcctEmpIds.contains(e.getId())); - // 个税扣缴义务人的字段类型 - map.put("taxAgentName" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); - // 公式详情 - customParameters.putAll(customBackCalcParameters); - map.put("customParameters", customParameters); - return map; - }).collect(Collectors.toList()); + // 主键id + map.put("id", e.getId()); + //锁定状态 + map.put("lockStatus", LockStatusEnum.getByValue(e.getLockStatus()).getDefaultLabel()); + //人员id + map.put("employeeId", e.getEmployeeId()); + // 个税扣缴义务人 + String taxAgentName = taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY); + map.put("taxAgentName", taxAgentName); + // 是否属于"合并计税"的标记 + map.put("consolidatedTaxation", StringUtils.isNotEmpty(taxAgentName) && consolidatedTaxSalaryAcctEmpIds.contains(e.getId())); + // 个税扣缴义务人的字段类型 + map.put("taxAgentName" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); + // 公式详情 + customParameters.putAll(customBackCalcParameters); + map.put("customParameters", customParameters); + return map; + }).collect(Collectors.toList()); + result.addAll(collect); + } + return result; } /** diff --git a/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveBO.java b/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveBO.java index fabbfd1b0..2fa4ac05f 100644 --- a/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveBO.java +++ b/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveBO.java @@ -106,75 +106,6 @@ public class SalaryArchiveBO { LocalDateRange localDateRange, List allEmployeeIds, boolean isOnlyTaxAgent) { -// // 开始日期 -// Date start = localDateRange.getFromDate(); -// // 结束日期 -// Date end = localDateRange.getEndDate(); -// -// List list = new ArrayList<>(); -// allEmployeeIds.forEach(e -> { -// // 同一个人的档案数据 -// List salaryArchives = salaryArchiveList.stream().filter(f -> f.getEmployeeId().equals(e)).collect(Collectors.toList()); -// List salaryArchiveIds = salaryArchives.stream().map(SalaryArchivePO::getId).collect(Collectors.toList()); -// // 同一个人的薪资项目调整历史数据 -// List salaryArchiveItems = salaryArchiveItemDataList.stream().filter(d -> salaryArchiveIds.contains(d.getSalaryArchiveId())).collect(Collectors.toList()); -// List salaryArchiveItemIds = salaryArchiveItems.stream().map(SalaryArchiveItemPO::getSalaryItemId).distinct().collect(Collectors.toList()); -// -// SalaryArchiveDataDTO salaryArchiveData = new SalaryArchiveDataDTO(); -// salaryArchiveData.setEmployeeId(e); -// List taxAgents = new ArrayList<>(); -// // 按个税扣缴义务人生效日期时间段切割 -// for (SalaryArchivePO salaryArchive : salaryArchives) { -// Date fromDate = salaryArchive.getPayStartDate(); -// Date endDate = salaryArchive.getPayEndDate(); -// // 起始发薪日不为空,且不能比结束日期晚,最后发薪日可空可不空,但是如果不为空,就不能比开始日期早,且起始发薪日不能晚于最后发薪日 -// boolean isEnable = fromDate != null && !fromDate.after(end) && (endDate == null || (!fromDate.after(endDate) && !endDate.before(start))); -// if (isEnable) { -// SalaryArchiveTaxAgentDataDTO taxAgent = new SalaryArchiveTaxAgentDataDTO(); -// taxAgent.setTaxAgentId(salaryArchive.getTaxAgentId()); -//// taxAgent.setIncomeCategory(salaryArchive.getIncomeCategory()); -// taxAgent.setEffectiveDateRange(LocalDateRange.builder().fromDate((fromDate.before(start) ? start : fromDate)).endDate(endDate == null || endDate.after(end) ? end : endDate).build()); -// // 薪资项目数据按个税扣缴义务人切割 -// if (!isOnlyTaxAgent) { -// // 开始日期 -// Date startItem = taxAgent.getEffectiveDateRange().getFromDate(); -// // 结束日期 -// Date endItem = taxAgent.getEffectiveDateRange().getEndDate(); -// Date endTempItem = endItem; -// List salaryItemValues = new ArrayList<>(); -// for (Long salaryArchiveItemId : salaryArchiveItemIds) { -// for (SalaryArchiveItemPO salaryArchiveItem : salaryArchiveItems) { -// if (!salaryArchiveItemId.equals(salaryArchiveItem.getSalaryItemId()) || !salaryArchiveItem.getSalaryArchiveId().equals(salaryArchive.getId())) { -// continue; -// } -// Date fromDateItem = salaryArchiveItem.getEffectiveTime(); -// if (fromDateItem.after(endTempItem) || (!endTempItem.after(startItem) && !endTempItem.equals(startItem))) { -// continue; -// } -// SalaryArchiveItemDataDTO salaryArchiveItemData = new SalaryArchiveItemDataDTO(); -// salaryArchiveItemData.setEffectiveDateRange(LocalDateRange.builder().fromDate((fromDateItem.before(startItem) ? startItem : fromDateItem)).endDate(endTempItem).build()); -// //fixme 排除1号调薪,之前的历史周期为2022-01-01-2022-01-01这种情况 -// if (!salaryArchiveItemData.getEffectiveDateRange().getFromDate().before(salaryArchiveItemData.getEffectiveDateRange().getEndDate())) { -// continue; -// } -// salaryArchiveItemData.setSalaryItemId(salaryArchiveItem.getSalaryItemId()); -// salaryArchiveItemData.setValue(salaryArchiveItem.getItemValue()); -// salaryItemValues.add(salaryArchiveItemData); -// endTempItem = fromDateItem; -// } -// endTempItem = endItem; -// } -// taxAgent.setSalaryItemValues(salaryItemValues); -// } -// taxAgents.add(taxAgent); -// } -// } -// salaryArchiveData.setTaxAgents(taxAgents); -// list.add(salaryArchiveData); -// }); -// -// return list; - // 开始日期 Date start = localDateRange.getFromDate(); diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobPO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobPO.java index 89a17bd77..fd93761fb 100644 --- a/src/com/engine/salary/entity/salarysob/po/SalarySobPO.java +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobPO.java @@ -15,6 +15,7 @@ import lombok.experimental.Accessors; import java.util.Collection; import java.util.Date; +import java.util.List; import java.util.Set; /** @@ -54,8 +55,11 @@ public class SalarySobPO { @ElogTransform( name="个税扣缴义务人id" ) @XStreamAlias("taxAgentId") @XStreamAsAttribute + @Deprecated private Long taxAgentId; + List taxAgentIds; + /** * 应税项目。1:正常工资薪金所得 */ @@ -176,7 +180,7 @@ public class SalarySobPO { private String tenantKey; Collection ids; - Collection taxAgentIds; + private Set opts; diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobMapper.java index 999c805d1..6d31899b0 100644 --- a/src/com/engine/salary/mapper/salarysob/SalarySobMapper.java +++ b/src/com/engine/salary/mapper/salarysob/SalarySobMapper.java @@ -54,4 +54,5 @@ public interface SalarySobMapper { List listByName(SalarySobPO build); + SalarySobPO getByIdWithTax(Long id); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobMapper.xml index 59f40120d..ecc2e3a1b 100644 --- a/src/com/engine/salary/mapper/salarysob/SalarySobMapper.xml +++ b/src/com/engine/salary/mapper/salarysob/SalarySobMapper.xml @@ -508,6 +508,22 @@ and name = #{name} + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/service/AddUpDeductionService.java b/src/com/engine/salary/service/AddUpDeductionService.java index e80a3e53d..ef3b259ba 100644 --- a/src/com/engine/salary/service/AddUpDeductionService.java +++ b/src/com/engine/salary/service/AddUpDeductionService.java @@ -98,7 +98,7 @@ public interface AddUpDeductionService { * @param employeeIds * @return */ - List getAddUpDeductionList(YearMonth declareMonth, List employeeIds, Long taxAgentId); + List getAddUpDeductionList(YearMonth declareMonth, List employeeIds, List taxAgentIds); /** * 根据年月获取已核算数据 diff --git a/src/com/engine/salary/service/OtherDeductionService.java b/src/com/engine/salary/service/OtherDeductionService.java index e77c70995..dbe8de31a 100644 --- a/src/com/engine/salary/service/OtherDeductionService.java +++ b/src/com/engine/salary/service/OtherDeductionService.java @@ -84,7 +84,7 @@ public interface OtherDeductionService { * @param employeeIds * @return */ - List getOtherDeductionList(YearMonth declareMonth, List employeeIds, Long taxAgentId); + List getOtherDeductionList(YearMonth declareMonth, List employeeIds, List taxAgentIds); /** * 编辑数据 diff --git a/src/com/engine/salary/service/SalaryArchiveService.java b/src/com/engine/salary/service/SalaryArchiveService.java index 5ab2dac29..e86655fd6 100644 --- a/src/com/engine/salary/service/SalaryArchiveService.java +++ b/src/com/engine/salary/service/SalaryArchiveService.java @@ -114,7 +114,7 @@ public interface SalaryArchiveService { * @param employeeIds 为空则返回所有人的 * @return */ - List getSalaryArchiveData(LocalDateRange localDateRange, Collection employeeIds, Long taxAgentId); + List getSalaryArchiveData(LocalDateRange localDateRange, Collection employeeIds, List taxAgentIds); /** * 根据日期范围与人员id获取薪资档案-个税扣缴义务人数据 @@ -123,7 +123,7 @@ public interface SalaryArchiveService { * @param employeeIds 为空则返回所有人的 * @return */ - List getSalaryArchiveTaxAgentData(LocalDateRange localDateRange, Collection employeeIds, Long taxAgentId); + List getSalaryArchiveTaxAgentData(LocalDateRange localDateRange, Collection employeeIds, List taxAgentIds); /** * 预览 diff --git a/src/com/engine/salary/service/SalarySobService.java b/src/com/engine/salary/service/SalarySobService.java index 9cbb47fac..4f0523586 100644 --- a/src/com/engine/salary/service/SalarySobService.java +++ b/src/com/engine/salary/service/SalarySobService.java @@ -30,6 +30,8 @@ public interface SalarySobService { */ SalarySobPO getById(Long id); + SalarySobPO getByIdWithTax(Long id); + /** * 根据主键id查询薪资账套 * @@ -154,7 +156,7 @@ public interface SalarySobService { * @param taxAgentIds * @return */ - List listByTaxAgentIds(Collection taxAgentIds); + List listByTaxAgentIds(List taxAgentIds); List getConfig(Long taxAgentId); diff --git a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java index d453b6c96..6a7e15884 100644 --- a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java @@ -913,9 +913,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction } private Map> getEmpInfoByYearMonth(TaxAgentPO taxAgent, List employeePOs, YearMonth lastMonth) { - List addUpDeductionList = getAddUpDeductionList(lastMonth, - employeePOs.stream().map(SpecialAddDeductionPO::getEmployeeId).collect(Collectors.toList()), - taxAgent.getId()); + List addUpDeductionList = getAddUpDeductionList(lastMonth, employeePOs.stream().map(SpecialAddDeductionPO::getEmployeeId).collect(Collectors.toList()), Collections.singletonList(taxAgent.getId())); return addUpDeductionList.stream() .filter(addUpDeduction -> taxAgent.getId().equals(addUpDeduction.getTaxAgentId())) .collect(Collectors.groupingBy(AddUpDeduction::getEmployeeId)); @@ -1127,12 +1125,12 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction @Override - public List getAddUpDeductionList(YearMonth declareMonth, List employeeIds, Long taxAgentId) { + public List getAddUpDeductionList(YearMonth declareMonth, List employeeIds, List taxAgentIds) { AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz(); if (declareMonth == null) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100342, "参数有误:申报月份、租户key必传")); } - return addUpDeductionBiz.listSome(AddUpDeduction.builder().declareMonth(SalaryDateUtil.toDateStartOfMonth(declareMonth)).employeeIds(employeeIds).taxAgentId(taxAgentId).build()); + return addUpDeductionBiz.listSome(AddUpDeduction.builder().declareMonth(SalaryDateUtil.toDateStartOfMonth(declareMonth)).employeeIds(employeeIds).taxAgentIds(taxAgentIds).build()); } @Override diff --git a/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java b/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java index 1771b6c09..da369b9ef 100644 --- a/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java +++ b/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java @@ -352,7 +352,7 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa for (Long salarySobId : salarySobIds) { // 获取薪资账套 SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salarySobId, YearMonth.of(year, month)); - SalarySobPO salarySobPO = getSalarySobService(user).getById(salarySobId); + SalarySobPO salarySobPO = getSalarySobService(user).getByIdWithTax(salarySobId); // 根据薪资账套查询人员 List salaryEmployees = getSalaryEmployeeService(user).listBySalarySobId(salarySobId); @@ -360,17 +360,17 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa errorMsg = errorMsg + "【" + salarySobPO.getName() + "】薪资账套没有人员; "; } else { // 根据薪资账套查询薪资周期 - Long taxAgentId = salarySobPO.getTaxAgentId(); + List taxAgentIds = salarySobPO.getTaxAgentIds(); // 查询薪资档案,获取人员的个税扣缴义务人 List employeeIds = SalaryEntityUtil.properties(salaryEmployees, DataCollectionEmployee::getEmployeeId, Collectors.toList()); - List salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentId); + List salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds); // 转换成薪资核算人员po Date salaryDate = SalaryDateUtil.dateStrToLocalTime(salaryYearMonth + "-01"); List salaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2Employee(salaryEmployees, SalaryAcctRecordPO.builder().salarySobId(salarySobId).salaryMonth(salaryDate).build(), salaryArchiveDataDTOS, (long) user.getUID()); //过滤掉不属于当前账套扣缴义务人的人员 - employeeIds = salaryAcctEmployeePOS.stream().filter(po -> Objects.equals(taxAgentId, po.getTaxAgentId())).map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toList()); + employeeIds = salaryAcctEmployeePOS.stream().filter(po -> taxAgentIds.contains(po.getTaxAgentId())).map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toList()); // 4.获取考勤模块数据 diff --git a/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java index 8347f1045..d376e4af9 100644 --- a/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java @@ -636,12 +636,12 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction @Override - public List getOtherDeductionList(YearMonth declareMonth, List employeeIds, Long taxAgentId) { + public List getOtherDeductionList(YearMonth declareMonth, List employeeIds, List taxAgentIds) { if (declareMonth == null) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100342, "参数有误:申报月份必传")); } OtherDeductionBiz OtherDeductionBiz = new OtherDeductionBiz(); - return OtherDeductionBiz.listSome(OtherDeductionPO.builder().declareMonth(SalaryDateUtil.toDateStartOfMonth(declareMonth)).employeeIds(employeeIds).taxAgentId(taxAgentId).build()); + return OtherDeductionBiz.listSome(OtherDeductionPO.builder().declareMonth(SalaryDateUtil.toDateStartOfMonth(declareMonth)).employeeIds(employeeIds).taxAgentIds(taxAgentIds).build()); } @Override diff --git a/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java index 09927a388..34fd21ee0 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java @@ -121,11 +121,11 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc List employeeIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getSalaryAcctEmployeePOS(), SalaryAcctEmployeePO::getEmployeeId, Collectors.toList()); List simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); SalarySobCycleDTO salarySobCycleDTO = salaryAcctCalculateBO.getSalarySobCycleDTO(); - Long taxAgentId = salaryAcctCalculateBO.getSalarySobPO().getTaxAgentId(); + List taxAgentIds = salaryAcctCalculateBO.getSalarySobPO().getTaxAgentIds(); sw.stop(); // 2、查询薪资档案的数据 sw.start("查询薪资档案的数据"); - List salaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentId); + List salaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds); sw.stop(); // 3、查询往期累计情况(查询的是上个税款所属期的的累计情况) sw.start("查询往期累计情况"); @@ -139,15 +139,16 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc sw.stop(); // 4、查询累计专项附加扣除 sw.start("查询累计专项附加扣除"); - List addUpDeductionPOS = getAddUpDeductionService(user).getAddUpDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds, taxAgentId); + List addUpDeductionPOS = getAddUpDeductionService(user).getAddUpDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds, taxAgentIds); sw.stop(); // 5、查询其他免税扣除 sw.start("查询其他免税扣除"); - List otherDeductionPOS = getOtherDeductionService(user).getOtherDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds, taxAgentId); + List otherDeductionPOS = getOtherDeductionService(user).getOtherDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds, taxAgentIds); sw.stop(); //6、查询社保福利 sw.start("查询社保福利"); - List> welfareData = getSIAccountService(user).welfareData(salarySobCycleDTO.getSocialSecurityCycle().toString(), employeeIds, taxAgentId); + //getSIAccountService(user).welfareData(salarySobCycleDTO.getSocialSecurityCycle().toString(), employeeIds, taxAgentIds) + List> welfareData = new ArrayList<>(); sw.stop(); // 7、查询考勤数据 sw.start("查询考勤数据"); diff --git a/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java index 621b2b068..c183b043d 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java @@ -5,9 +5,9 @@ import cn.hutool.core.date.DateUtil; import com.api.formmode.mybatis.util.SqlProxyHandle; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; import com.engine.salary.config.SalaryElogConfig; import com.engine.salary.constant.SalaryDefaultTenantConstant; -import com.engine.hrmelog.entity.dto.LoggerContext; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.salaryacct.bo.SalaryAcctEmployeeBO; import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeCountDTO; @@ -23,6 +23,7 @@ import com.engine.salary.enums.salaryaccounting.LockStatusEnum; import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.salaryacct.SalaryAcctEmployeeMapper; +import com.engine.salary.mapper.salarysob.SobTaxLinkMapper; import com.engine.salary.mapper.sys.SalarySysConfMapper; import com.engine.salary.report.entity.param.SalaryStatisticsReportDataQueryParam; import com.engine.salary.service.*; @@ -62,6 +63,10 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct return MapperProxyFactory.getProxy(SalaryAcctEmployeeMapper.class); } + private SobTaxLinkMapper getSobTaxLinkMapper() { + return MapperProxyFactory.getProxy(SobTaxLinkMapper.class); + } + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); } @@ -397,22 +402,22 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct // 根据薪资账套查询薪资周期 SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth())); //获取核算的扣缴义务人 - SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + SalarySobPO salarySobPO = getSalarySobService(user).getByIdWithTax(salaryAcctRecordPO.getSalarySobId()); if (Objects.isNull(salarySobPO)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "薪资账套不存在或已被删除")); } - Long taxAgentId = salarySobPO.getTaxAgentId(); + List taxAgentIds = salarySobPO.getTaxAgentIds(); List employees = getSalaryEmployeeService(user).getEmployeeByIdsAll((List) saveParam.getEmployeeIds()); // 查询薪资档案 - List salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), saveParam.getEmployeeIds(), taxAgentId); + List salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), saveParam.getEmployeeIds(), taxAgentIds); // 转换成薪资核算人员po List salaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2Employee(employees, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID()); //过滤不是扣缴义务人下的人员 - salaryAcctEmployeePOS = salaryAcctEmployeePOS.stream().filter(ps -> Objects.equals(taxAgentId, ps.getTaxAgentId())).collect(Collectors.toList()); + salaryAcctEmployeePOS = salaryAcctEmployeePOS.stream().filter(ps -> taxAgentIds.contains(ps.getTaxAgentId())).collect(Collectors.toList()); // 保存薪资核算人员 if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "个税扣缴义务人下无该人员档案信息或薪资缴纳日期不在薪资周期内")); @@ -524,20 +529,17 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct //查询账套对应的扣缴义务人 - SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); - Long taxAgentId = salarySobPO.getTaxAgentId(); -// //过滤扣税扣缴义务人不包含的人员 -// Collection employeeIdsInTaxAgent = getTaxAgentService(user).listEmployeeIdsInTaxAgent(taxAgentId); -// salaryEmployees = salaryEmployees.stream().filter(salaryEmployee -> employeeIdsInTaxAgent.contains(salaryEmployee.getEmployeeId())).collect(Collectors.toList()); + SalarySobPO salarySobPO = getSalarySobService(user).getByIdWithTax(salaryAcctRecordPO.getSalarySobId()); + List taxAgentIds = salarySobPO.getTaxAgentIds(); // 查询薪资档案,获取人员的个税扣缴义务人 List employeeIds = SalaryEntityUtil.properties(salaryEmployees, DataCollectionEmployee::getEmployeeId, Collectors.toList()); - List salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentId); + List salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds); // 转换成薪资核算人员po List salaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2Employee(salaryEmployees, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID()); //过滤掉不属于当前账套扣缴义务人的人员 - salaryAcctEmployeePOS = salaryAcctEmployeePOS.stream().filter(po -> Objects.equals(taxAgentId, po.getTaxAgentId())).collect(Collectors.toList()); + salaryAcctEmployeePOS = salaryAcctEmployeePOS.stream().filter(po -> taxAgentIds.contains(po.getTaxAgentId())).collect(Collectors.toList()); // 保存薪资核算人员 if (CollectionUtils.isNotEmpty(salaryAcctEmployeePOS)) { @@ -559,18 +561,18 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); } //查询账套对应的扣缴义务人 - SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + SalarySobPO salarySobPO = getSalarySobService(user).getByIdWithTax(salaryAcctRecordPO.getSalarySobId()); //过滤掉不属于当前账套扣缴义务人的人员 - Long taxAgentId = salarySobPO.getTaxAgentId(); + List taxAgentIds = salarySobPO.getTaxAgentIds(); // 查询薪资核算记录所用的帐套的薪资周期 SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth())); // 查询薪资档案,获取人员的个税扣缴义务人 - List salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentId); + List salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds); List employees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); // 转换成薪资核算人员po List newSalaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2Employee(employees, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID()); - newSalaryAcctEmployeePOS = newSalaryAcctEmployeePOS.stream().filter(po -> Objects.equals(taxAgentId, po.getTaxAgentId())).collect(Collectors.toList()); + newSalaryAcctEmployeePOS = newSalaryAcctEmployeePOS.stream().filter(po ->taxAgentIds.contains(po.getTaxAgentId())).collect(Collectors.toList()); // 删除以前的薪资核算人员 getSalaryAcctEmployeeMapper().deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId)); // 插入新的薪资核算人员 diff --git a/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java b/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java index d315b44b2..665ce3a76 100644 --- a/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java @@ -818,13 +818,13 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe } @Override - public List getSalaryArchiveData(LocalDateRange localDateRange, Collection employeeIds, Long taxAgentId) { - return getSalaryArchiveData(localDateRange, employeeIds, taxAgentId, Boolean.FALSE); + public List getSalaryArchiveData(LocalDateRange localDateRange, Collection employeeIds, List taxAgentIds) { + return getSalaryArchiveData(localDateRange, employeeIds, taxAgentIds, Boolean.FALSE); } @Override - public List getSalaryArchiveTaxAgentData(LocalDateRange localDateRange, Collection employeeIds, Long taxAgentId) { - return getSalaryArchiveData(localDateRange, employeeIds, taxAgentId, Boolean.TRUE); + public List getSalaryArchiveTaxAgentData(LocalDateRange localDateRange, Collection employeeIds, List taxAgentIds) { + return getSalaryArchiveData(localDateRange, employeeIds, taxAgentIds, Boolean.TRUE); } /** @@ -835,7 +835,7 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe * @param isOnlyTaxAgent * @return */ - private List getSalaryArchiveData(LocalDateRange localDateRange, Collection employeeIds, Long taxAgentId, boolean isOnlyTaxAgent) { + private List getSalaryArchiveData(LocalDateRange localDateRange, Collection employeeIds, List taxAgentIds, boolean isOnlyTaxAgent) { // 获取核算人员规则 List statusList = Collections.emptyList(); SalarySysConfPO employeeRule = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_ACCT_EMPLOYEE_RULE); @@ -848,7 +848,7 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe statusList = Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue()); } // 获取薪资档案数据 - List salaryArchiveList = listSome(SalaryArchivePO.builder().runStatusList(statusList).employeeIds(employeeIds).taxAgentId(taxAgentId).build()); + List salaryArchiveList = listSome(SalaryArchivePO.builder().runStatusList(statusList).employeeIds(employeeIds).taxAgentIds(taxAgentIds).build()); List allEmployeeIds = salaryArchiveList.stream().map(SalaryArchivePO::getEmployeeId).distinct().collect(Collectors.toList()); // 获取所有可被引用的薪资项目 diff --git a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java index d132cb7ff..064128c2a 100644 --- a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java @@ -179,6 +179,14 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { return salarySobMapper.getById(id); } + @Override + public SalarySobPO getByIdWithTax(Long id) { + SalarySobPO sobPO = getSalarySobMapper().getById(id); + List sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().sobId(id).build()); + sobPO.setTaxAgentIds(sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList())); + return sobPO; + } + @Override public List listByIds(Collection ids) { if (CollectionUtils.isEmpty(ids)) { @@ -861,7 +869,7 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { } @Override - public List listByTaxAgentIds(Collection taxAgentIds) { + public List listByTaxAgentIds(List taxAgentIds) { if (CollectionUtils.isEmpty(taxAgentIds)) { return new ArrayList<>(); }