From fac31d4898c587e9e333474ac9e20ac54841a675 Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Tue, 26 Aug 2025 15:13:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=B1=E5=9C=B3=E5=85=89=E8=BE=BE=E9=A1=BA?= =?UTF-8?q?=E6=92=A4=E5=9B=9E=E9=83=A8=E5=88=86=E5=B7=A5=E8=B5=84=E5=8D=95?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/salarybill/SalarySendMapper.xml | 2 +- .../service/impl/SalarySendServiceImpl.java | 55 ++++++++++++------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/com/engine/salary/mapper/salarybill/SalarySendMapper.xml b/src/com/engine/salary/mapper/salarybill/SalarySendMapper.xml index e3d729fd4..a97e91e6c 100644 --- a/src/com/engine/salary/mapper/salarybill/SalarySendMapper.xml +++ b/src/com/engine/salary/mapper/salarybill/SalarySendMapper.xml @@ -218,7 +218,7 @@ AND send_status = #{sendStatus} - AND salary_acct_type = #{salaryAcctTypec} + AND salary_acct_type = #{salaryAcctType} AND creator = #{creator} diff --git a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java index af9f51f1e..ed126d32a 100644 --- a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java @@ -247,6 +247,9 @@ public class SalarySendServiceImpl extends Service implements SalarySendService if (CollectionUtils.isEmpty(acctRecords)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100498, "核算记录不存在")); } + SalaryAcctRecordPO salaryAcctRecord = acctRecords.get(0); + // 工资单模板类型:0,正常核算,1是回算,todo 后续可能还有别的算,需要改这里 + Integer templateType = salaryAcctRecord.getBackCalcStatus(); List salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(Collections.singletonList(salaryAccountingId)); @@ -288,12 +291,20 @@ public class SalarySendServiceImpl extends Service implements SalarySendService .collect(Collectors.toSet()); salaryAcctEmployees = salaryAcctEmployees.stream().filter(se -> salaryAcctEmployeeIds.contains(se.getId())).collect(Collectors.toList()); } - // 将未冻结的给冻结掉 if (salarySend != null) { salarySend.setSendStatus(NumberUtils.INTEGER_ONE); mapper.updateById(salarySend); } + sendPO = new SalarySendPO(); + sendPO.setDeleteType(0); + sendPO.setSalaryAccountingId(salaryAccountingId); + sendPO.setSalaryAcctType(templateType); + List salarySendPOS = mapper.listSome(sendPO); + if (CollectionUtils.isNotEmpty(salarySendPOS)) { + // throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100499, "工资单已生成过,不可再重复生成")); + return ""; + } // 2.正常核算 } else { SalarySendPO sendPO = new SalarySendPO(); @@ -301,15 +312,14 @@ public class SalarySendServiceImpl extends Service implements SalarySendService sendPO.setSalaryAccountingId(salaryAccountingId); List salarySends = mapper.listSome(sendPO); if (CollectionUtils.isNotEmpty(salarySends)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100499, "工资单已生成过,不可再重复生成")); + // throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100499, "工资单已生成过,不可再重复生成")); + return ""; } } Long salarySendId = IdGenerator.generate(); - SalaryAcctRecordPO salaryAcctRecord = acctRecords.get(0); - // 工资单模板类型:0,正常核算,1是回算,todo 后续可能还有别的算,需要改这里 - Integer templateType = salaryAcctRecord.getBackCalcStatus(); + // 构建工资单发放数据 List salarySendInfos = salaryAcctEmployees.stream().map(m -> @@ -407,24 +417,27 @@ public class SalarySendServiceImpl extends Service implements SalarySendService .sendStatus(SalarySendStatusEnum.ALREADYSEND.getValue()) .salaryAcctType(NumberUtils.INTEGER_ZERO).build(); List salarySendInfos = getSalarySendInfoMapper().listSome(sendInfo); - if ((salarySend.getSendNum() > 0 || CollectionUtils.isNotEmpty(salarySendInfos)) && Objects.equals(salarySend.getSalaryAcctType(), NumberUtils.INTEGER_ONE)) { + if ((salarySend.getSendNum() > 0 || CollectionUtils.isNotEmpty(salarySendInfos)) && Objects.equals(salarySend.getSalaryAcctType(), NumberUtils.INTEGER_ONE) && salarySend.getSendNum().equals(salarySend.getSendTotal())) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100507, "补发工资单已经发放,不可进行回算")); - } else if (salarySend.getSendNum() > 0 || CollectionUtils.isNotEmpty(salarySendInfos)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100507, "工资单已经发放,不可撤销,可以进行回算")); + } else if (salarySend.getSendNum() > 0 && salarySend.getSendNum().equals(salarySend.getSendTotal())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100507, "工资单已经全部发放,不可撤销,请先撤回至少一条工资单")); + } + // 所有工资单都被撤回 + if (salarySend.getSendNum() == 0 || CollectionUtils.isEmpty(salarySendInfos)) { + // 删除工资单 + SalarySendPO salarySendPO = SalarySendPO.builder() + .id(salarySend.getId()) + .sendNum(0) + .deleteType(1) + .build(); + getSalarySendMapper().updateIgnoreNull(salarySendPO); + // 删除工资单发放 + SalarySendInfoPO infoPO = SalarySendInfoPO.builder() + .salarySendId(salarySend.getId()) + .deleteType(1) + .build(); + getSalarySendInfoMapper().updateGrantWithdraw(infoPO, salarySend.getId(), null, null); } - // 删除工资单 - SalarySendPO salarySendPO = SalarySendPO.builder() - .id(salarySend.getId()) - .sendNum(0) - .deleteType(1) - .build(); - getSalarySendMapper().updateIgnoreNull(salarySendPO); - // 删除工资单发放 - SalarySendInfoPO infoPO = SalarySendInfoPO.builder() - .salarySendId(salarySend.getId()) - .deleteType(1) - .build(); - getSalarySendInfoMapper().updateGrantWithdraw(infoPO, salarySend.getId(), null, null); }