From 0b90f4890ec9d0db5c4bd32384faa6acfed283bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Tue, 3 Sep 2024 14:30:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E8=B5=84=E5=8D=95=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B7=A8=E6=89=A3=E7=BC=B4=E4=B9=89=E5=8A=A1=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/SalarySendDetailListDTO.java | 1 + .../mapper/salarysob/SalarySobMapper.java | 3 +- .../mapper/salarysob/SalarySobMapper.xml | 15 +----- .../service/impl/SalarySendServiceImpl.java | 51 ++++++++++--------- .../service/impl/SalarySobServiceImpl.java | 33 ++++++++---- 5 files changed, 54 insertions(+), 49 deletions(-) diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalarySendDetailListDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalarySendDetailListDTO.java index 4e87a6ad8..ae647ab04 100644 --- a/src/com/engine/salary/entity/salaryBill/dto/SalarySendDetailListDTO.java +++ b/src/com/engine/salary/entity/salaryBill/dto/SalarySendDetailListDTO.java @@ -44,6 +44,7 @@ public class SalarySendDetailListDTO { // 个税扣缴义务人") private String taxAgent; + private Long taxAgentId; // 部门") @I18n diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobMapper.java index 6d31899b0..71ee8abe5 100644 --- a/src/com/engine/salary/mapper/salarysob/SalarySobMapper.java +++ b/src/com/engine/salary/mapper/salarysob/SalarySobMapper.java @@ -54,5 +54,6 @@ public interface SalarySobMapper { List listByName(SalarySobPO build); - SalarySobPO getByIdWithTax(Long id); + + List listByTaxAgentId(Long taxAgentId); } \ 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 ecc2e3a1b..cd2a20ba8 100644 --- a/src/com/engine/salary/mapper/salarysob/SalarySobMapper.xml +++ b/src/com/engine/salary/mapper/salarysob/SalarySobMapper.xml @@ -508,22 +508,11 @@ and name = #{name} - - - - - - - - - - SELECT - , l.tax_agent_id FROM hrsa_salary_sob t - left join hrsa_sob_tax_link l on t.id=l.sob_id and t.delete_type=0 and l.delete_type=0 - WHERE t.id = #{id} + WHERE t.delete_type = 0 and t.id = (select sob_id from hrsa_sob_tax_link where delete_type=0 and tax_agent_id=#{taxAgentId}) \ No newline at end of file diff --git a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java index 30019d8fc..c4df714b2 100644 --- a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java @@ -245,9 +245,9 @@ public class SalarySendServiceImpl extends Service implements SalarySendService List salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(Collections.singletonList(salaryAccountingId)); - // 根据人员id去重 - salaryAcctEmployees = salaryAcctEmployees.stream() - .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SalaryAcctEmployeePO::getEmployeeId))), ArrayList::new)); +// // 根据人员id去重 +// salaryAcctEmployees = salaryAcctEmployees.stream() +// .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SalaryAcctEmployeePO::getEmployeeId))), ArrayList::new)); // 1.回算:如果是回算,todo 要等原始核算发完或者上一个回算记录发完才行,目前最多只有一个回算记录 if (Objects.equals(acctRecords.get(0).getBackCalcStatus(), (NumberUtils.INTEGER_ONE))) { @@ -555,7 +555,12 @@ public class SalarySendServiceImpl extends Service implements SalarySendService // 获取薪资项目数据 Long salaryAcctRecordId = salarySendInfo.getSalaryAcctRecordId(); - List salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordId(salaryAcctRecordId).employeeId(currentEmployeeId).build()); + SalaryAcctResultPO build = SalaryAcctResultPO.builder() + .salaryAcctRecordId(salaryAcctRecordId) + .taxAgentId(salarySendInfo.getTaxAgentId()) + .employeeId(currentEmployeeId) + .build(); + List salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(build); if (CollUtil.isEmpty(salaryAcctResultPOS)) { throw new SalaryRunTimeException("薪资核算结果不存在!"); } @@ -691,7 +696,6 @@ public class SalarySendServiceImpl extends Service implements SalarySendService } - private Date getLimitMonth() { //工资单时效性 salaryBillViewingLimitSetting salaryBillViewingLimitSetting = getSalaryBillBaseSetService(user).getSalaryBillViewingLimitSetting(); @@ -933,7 +937,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService .jobtitleName(simpleEmployee.getJobtitleName()) .jobtitleId(simpleEmployee.getJobtitleId()) .status(simpleEmployee.getStatus() == null ? "" : simpleEmployee.getStatus()) - .statusName(simpleEmployee.getStatus() == null ? "" : UserStatusEnum.parseByValue(new Integer(Util.null2s(simpleEmployee.getStatus(),"1"))).getDefaultLabel()) + .statusName(simpleEmployee.getStatus() == null ? "" : UserStatusEnum.parseByValue(new Integer(Util.null2s(simpleEmployee.getStatus(), "1"))).getDefaultLabel()) .telephone(StringUtils.isEmpty(simpleEmployee.getTelephone()) ? "" : simpleEmployee.getTelephone()) .username(StringUtils.isEmpty(simpleEmployee.getUsername()) ? "" : simpleEmployee.getUsername()) .workcode(StringUtils.isEmpty(simpleEmployee.getWorkcode()) ? "" : simpleEmployee.getWorkcode()) @@ -974,16 +978,12 @@ public class SalarySendServiceImpl extends Service implements SalarySendService if (CollectionUtils.isEmpty(list)) { return listMaps; } - // 获取薪资项目数据 -// List salaryAccountingResults = new LambdaQueryChainWrapper<>(salaryAcctResultMapper) -// .eq(SalaryAcctResultPO::getDeleteType, 0) -// .eq(SalaryAcctResultPO::getSalaryAcctRecordId, salaryAccountingId).list(); - SalaryAcctResultPO po = new SalaryAcctResultPO(); - po.setDeleteType(0); - po.setSalaryAcctRecordId(salaryAccountingId); - po.setEmployeeIds(list.stream().map(SalarySendDetailListDTO::getEmployeeId).collect(Collectors.toList())); - List salaryAccountingResults = getSalaryAcctResultMapper().listSome(po); + SalaryAcctResultPO build = SalaryAcctResultPO.builder() + .salaryAcctRecordId(salaryAccountingId) + .employeeIds(list.stream().map(SalarySendDetailListDTO::getEmployeeId).collect(Collectors.toList())) + .build(); + List salaryAccountingResults = getSalaryAcctResultMapper().listSome(build); encryptUtil.decryptList(salaryAccountingResults, SalaryAcctResultPO.class); // 动态列 List employeeList = getExtEmpService(user).listEmployee(); @@ -1009,7 +1009,10 @@ public class SalarySendServiceImpl extends Service implements SalarySendService map.put("email", Objects.equals(employeeType, 1) ? extEmp.getEmail() : e.getEmail()); salaryItems.forEach(i -> { Optional optional = salaryAccountingResults.stream() - .filter(r -> r.getEmployeeId().equals(e.getEmployeeId()) && r.getSalaryItemId().equals(Long.valueOf(i.getSalaryItemId()))).findFirst(); + .filter(r -> r.getTaxAgentId().equals(e.getTaxAgentId()) + && r.getEmployeeId().equals(e.getEmployeeId()) + && r.getSalaryItemId().equals(Long.valueOf(i.getSalaryItemId()))) + .findFirst(); map.put(i.getSalaryItemId() + SalaryItemConstant.DYNAMIC_SUFFIX, optional.isPresent() ? optional.get().getResultValue() : ""); }); @@ -1578,7 +1581,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService header.add(SalaryI18nUtil.getI18nLabel(86317, "工号")); Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, dto -> dto.getSalaryItemId() + SalaryConstant.DYNAMIC_SUFFIX); List sortedSalaryItems = new ArrayList<>(); - for(String column : queryParam.getColumns()) { + for (String column : queryParam.getColumns()) { if (column.contains(SalaryConstant.DYNAMIC_SUFFIX)) { SalaryTemplateSalaryItemListDTO salaryTemplateSalaryItemListDTO = salaryItemMap.get(column); if (salaryTemplateSalaryItemListDTO != null) { @@ -1660,13 +1663,6 @@ public class SalarySendServiceImpl extends Service implements SalarySendService mapper.batchHandleSalaryAcctTypeHistory(); } -// -// @BatchExportHandler("exportSalarySendDetail") -// public void salarySendDetailExportHandler() { -// BatchCallbackMessage message = BatchExportContext.getBatchCallbackMessage(); -// System.out.println("接受到导出的结果" + JSONObject.toJSONString(message)); -// } - @Override public Map sumRow(SalarySendInfoQueryParam param) { @@ -1876,7 +1872,12 @@ public class SalarySendServiceImpl extends Service implements SalarySendService // 判断是否是补发 boolean isReplenish = NumberUtils.INTEGER_ONE.equals(salarySendInfo.getSalaryAcctType()); - List salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordId(salarySendInfo.getSalaryAcctRecordId()).employeeId(recipient).build()); + SalaryAcctResultPO build = SalaryAcctResultPO.builder() + .salaryAcctRecordId(salarySendInfo.getSalaryAcctRecordId()) + .taxAgentId(salarySendInfo.getTaxAgentId()) + .employeeId(recipient) + .build(); + List salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(build); if (CollUtil.isEmpty(salaryAcctResultPOS)) { throw new SalaryRunTimeException("薪资核算结果不存在!"); } diff --git a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java index 3540c7151..09f3ac3b8 100644 --- a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java @@ -183,7 +183,25 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { 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())); + List taxAgentIds = sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList()); + //处理历史数据 + if (CollectionUtil.isEmpty(taxAgentIds)) { + SobTaxLinkPO taxLinkPO = SobTaxLinkPO.builder() + .id(IdGenerator.generate()) + .taxAgentId(sobPO.getTaxAgentId()) + .sobId(sobPO.getId()) + .creator((long) user.getUID()) + .createTime(new Date()) + .updateTime(new Date()) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getSobTaxLinkMapper().insertIgnoreNull(taxLinkPO); + + taxAgentIds.add(sobPO.getTaxAgentId()); + } + + sobPO.setTaxAgentIds(taxAgentIds); return sobPO; } @@ -197,13 +215,7 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { @Override public List listByIdsWithTax(Collection ids) { - List collect = ids.stream().map(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; - }).collect(Collectors.toList()); - return collect; + return ids.stream().map(this::getByIdWithTax).collect(Collectors.toList()); } @Override @@ -257,7 +269,7 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { @Override public List listByTaxAgentId(Long taxAgentId) { - return salarySobMapper.listSome(SalarySobPO.builder().disable(NumberUtils.INTEGER_ZERO).taxAgentId(taxAgentId).build()); + return getSalarySobMapper().listByTaxAgentId(taxAgentId); } @Override @@ -1077,7 +1089,8 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { } if (param.getTaxAgentId() != null) { - sobPO.setTaxAgentId(param.getTaxAgentId()); + List sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentId(param.getTaxAgentId()).build()); + sobPO.setIds(SalaryEntityUtil.properties(sobTaxLinkPOS, SobTaxLinkPO::getSobId)); } return getSalarySobMapper().listSome(sobPO); }