From 3003d0fadbc87e7a5886c485a2e84e08caee4963 Mon Sep 17 00:00:00 2001 From: MustangDeng <670124965@qq.com> Date: Thu, 21 Apr 2022 16:45:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90=E5=B7=A5=E8=B5=84=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/salary/biz/SalarySendBiz.java | 10 ++ .../engine/salary/biz/SalarySendInfoBiz.java | 11 ++ .../salarybill/SalarySendInfoMapper.java | 3 +- .../mapper/salarybill/SalarySendMapper.java | 2 + .../mapper/salarybill/SalarySendMapper.xml | 94 +++++++++++- .../salary/service/SalarySendService.java | 3 +- .../impl/SalaryAcctRecordServiceImpl.java | 13 +- .../service/impl/SalarySendServiceImpl.java | 142 +++++++++--------- 8 files changed, 193 insertions(+), 85 deletions(-) diff --git a/src/com/engine/salary/biz/SalarySendBiz.java b/src/com/engine/salary/biz/SalarySendBiz.java index 312b8b1df..0b6219985 100644 --- a/src/com/engine/salary/biz/SalarySendBiz.java +++ b/src/com/engine/salary/biz/SalarySendBiz.java @@ -86,4 +86,14 @@ public class SalarySendBiz { } } + public void insert(SalarySendPO salarySend) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendMapper mapper = sqlSession.getMapper(SalarySendMapper.class); + mapper.insertIgnoreNull(salarySend); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } } diff --git a/src/com/engine/salary/biz/SalarySendInfoBiz.java b/src/com/engine/salary/biz/SalarySendInfoBiz.java index 43b342efa..2b036c1db 100644 --- a/src/com/engine/salary/biz/SalarySendInfoBiz.java +++ b/src/com/engine/salary/biz/SalarySendInfoBiz.java @@ -104,4 +104,15 @@ public class SalarySendInfoBiz { sqlSession.close(); } } + + public void batchInsert(List salarySendInfos) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendInfoMapper mapper = sqlSession.getMapper(SalarySendInfoMapper.class); + mapper.batchInsert(salarySendInfos); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } } diff --git a/src/com/engine/salary/mapper/salarybill/SalarySendInfoMapper.java b/src/com/engine/salary/mapper/salarybill/SalarySendInfoMapper.java index 2bea5e956..7712cc391 100644 --- a/src/com/engine/salary/mapper/salarybill/SalarySendInfoMapper.java +++ b/src/com/engine/salary/mapper/salarybill/SalarySendInfoMapper.java @@ -64,9 +64,8 @@ public interface SalarySendInfoMapper { /** * 批量插入工资单信息记录 * @param pos - * @param currentTenantKey */ - void batchInsert(@Param("collection") List pos, String currentTenantKey); + void batchInsert(@Param("collection") List pos); /** * 发放、撤回工资单 diff --git a/src/com/engine/salary/mapper/salarybill/SalarySendMapper.java b/src/com/engine/salary/mapper/salarybill/SalarySendMapper.java index 6c02fd968..4abfaa448 100644 --- a/src/com/engine/salary/mapper/salarybill/SalarySendMapper.java +++ b/src/com/engine/salary/mapper/salarybill/SalarySendMapper.java @@ -55,4 +55,6 @@ public interface SalarySendMapper { * @return */ List listSome(SalarySendPO params); + + void insertIgnoreNull(SalarySendPO salarySend); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarybill/SalarySendMapper.xml b/src/com/engine/salary/mapper/salarybill/SalarySendMapper.xml index 55b2fa99e..2ae345cea 100644 --- a/src/com/engine/salary/mapper/salarybill/SalarySendMapper.xml +++ b/src/com/engine/salary/mapper/salarybill/SalarySendMapper.xml @@ -164,9 +164,9 @@ AND salary_accounting_id = #{salaryAccountingId} - - AND salary_acct_record_id = #{salaryAcctRecordId} - + + + AND salary_sob_id = #{salarySobId} @@ -198,5 +198,93 @@ + + + INSERT INTO hrsa_salary_send + + + id, + + + salary_month, + + + salary_accounting_id, + + + salary_sob_id, + + + send_num, + + + send_total, + + + last_send_time, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + + #{id}, + + + #{salaryMonth}, + + + #{salaryAccountingId}, + + + #{salarySobId}, + + + #{sendNum}, + + + #{sendTotal}, + + + #{lastSendTime}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/service/SalarySendService.java b/src/com/engine/salary/service/SalarySendService.java index a91e65e1f..a2529c00e 100644 --- a/src/com/engine/salary/service/SalarySendService.java +++ b/src/com/engine/salary/service/SalarySendService.java @@ -28,10 +28,9 @@ public interface SalarySendService { /** * 薪资核算-归档生成工资单 * @param salaryAccountingId - * @param currentTenantKey * @return */ -// Map generateSalaryBill(Long salaryAccountingId, Long currentEmployeeId, String currentTenantKey); + String generateSalaryBill(Long salaryAccountingId); /** * 薪资核算-归档撤销工资单 diff --git a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java index 884d2adff..7f3bd99f9 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java @@ -15,10 +15,7 @@ import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; import com.engine.salary.enums.salarysob.IncomeCategoryEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper; -import com.engine.salary.service.SalaryAcctEmployeeService; -import com.engine.salary.service.SalaryAcctRecordService; -import com.engine.salary.service.SalaryAcctResultService; -import com.engine.salary.service.SalarySobService; +import com.engine.salary.service.*; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryI18nUtil; @@ -64,6 +61,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe return (SalaryAcctResultService) ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); } + + private SalarySendService getSalarySendService(User user) { + return ServiceUtil.getService(SalarySendServiceImpl.class, user); + } // private SalaryCheckResultService salaryCheckResultService; // // private SalaryCheckResultDetailService salaryCheckResultDetailService; @@ -361,8 +362,8 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe salaryAcctRecordPO.setStatus(SalaryAcctRecordStatusEnum.ARCHIVED.getValue()); salaryAcctRecordPO.setUpdateTime(new Date()); getSalaryAcctRecordMapper().updateIgnoreNull(salaryAcctRecordPO); - //todo 生成工资单 -// salarySendService.generateSalaryBill(salaryAcctRecordId, employeeId, tenantKey); + // 生成工资单 + getSalarySendService(user).generateSalaryBill(salaryAcctRecordId); // 记录日志 // String targetName = getLogTargetNameById(salaryAcctRecordId); // LoggerContext loggerContext = new LoggerContext<>(); diff --git a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java index bd9b185b2..f420efab6 100644 --- a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java @@ -155,78 +155,76 @@ public class SalarySendServiceImpl extends Service implements SalarySendService return salarySends.stream().map(SalarySendPO::getSalaryAccountingId).collect(Collectors.toList()); } -// @Override -// @Transactional(rollbackFor = Exception.class) -// public WeaResult generateSalaryBill(Long salaryAccountingId, Long currentEmployeeId, String currentTenantKey) { -// // 校验salaryAccountingId -// if (salaryAccountingId == null) { -// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100497, "核算id必传")); -// } -// -// List acctRecords = new LambdaQueryChainWrapper<>(salaryAcctRecordMapper) -// .eq(SalaryAcctRecordPO::getDeleteType, 0) -// .eq(SalaryAcctRecordPO::getTenantKey, currentTenantKey) -// .eq(SalaryAcctRecordPO::getId, salaryAccountingId) -// .eq(SalaryAcctRecordPO::getStatus, SalaryAcctRecordStatusEnum.ARCHIVED.getValue()).list(); -// // 检查核算的归档记录 -// if (CollectionUtils.isEmpty(acctRecords)) { -// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100498, "核算记录不存在")); -// } -// -// List salarySends = new LambdaQueryChainWrapper<>(mapper) -// .eq(SalarySendPO::getDeleteType, 0) -// .eq(SalarySendPO::getTenantKey, currentTenantKey) -// .eq(SalarySendPO::getSalaryAccountingId, salaryAccountingId).list(); -// if (CollectionUtils.isNotEmpty(salarySends)) { -// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100499, "工资单已生成过,不可再重复生成")); -// } -// -// List salaryAcctEmployees = new LambdaQueryChainWrapper<>(salaryAcctEmployeeMapper) -// .eq(SalaryAcctEmployeePO::getDeleteType, 0) -// .eq(SalaryAcctEmployeePO::getTenantKey, currentTenantKey) -// .eq(SalaryAcctEmployeePO::getSalaryAcctRecordId, salaryAccountingId).list(); -// -// Long salarySendId = IdGenerator.generate(); -// -// SalaryAcctRecordPO salaryAcctRecord = acctRecords.get(0); -// -// List salarySendInfos = org.apache.commons.collections4.CollectionUtils.emptyIfNull(salaryAcctEmployees).stream().map(m -> -// SalarySendInfoPO.builder() -// .id(IdGenerator.generate()) -// .salarySendId(salarySendId) -// .employeeId(m.getEmployeeId()) -// .salaryMonth(m.getSalaryMonth()) -// .taxAgentId(m.getTaxAgentId()) -// .salaryAcctRecordId(m.getSalaryAcctRecordId()) -// .sendStatus(SalarySendStatusEnum.UNSEND.getValue()) -// .salaryTemplate("") -// .creator(currentEmployeeId) -// .createTime(LocalDateTime.now()) -// .updateTime(LocalDateTime.now()) -// .tenantKey(currentTenantKey) -// .build() -// ).collect(Collectors.toList()); -// -// SalarySendPO salarySend = SalarySendPO.builder() -// .id(salarySendId) -// .salaryMonth(salaryAcctRecord.getSalaryMonth()) -// .salaryAccountingId(salaryAccountingId) -// .salarySobId(salaryAcctRecord.getSalarySobId()) -// .sendNum(0) -// .sendTotal(salarySendInfos.size()) -// .lastSendTime(LocalDateTime.now()) -// .creator(currentEmployeeId) -// .createTime(LocalDateTime.now()) -// .updateTime(LocalDateTime.now()) -// .tenantKey(currentTenantKey) -// .build(); -// // 插入工资单发放记录 -// mapper.insert(salarySend); -// // 插入工资单人员记录 -// salarySendInfoMapper.batchInsert(salarySendInfos, currentTenantKey); -// -// return WeaResult.success(Boolean.TRUE); -// } + @Override + public String generateSalaryBill(Long salaryAccountingId) { + // 校验salaryAccountingId + if (salaryAccountingId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100497, "核算id必传")); + } + + SalaryAcctRecordPO recordPo = new SalaryAcctRecordPO(); + recordPo.setDeleteType(0); + recordPo.setId(salaryAccountingId); + recordPo.setStatus(SalaryAcctRecordStatusEnum.ARCHIVED.getValue()); + List acctRecords = getSalaryAcctRecordMapper().listSome(recordPo); + // 检查核算的归档记录 + if (CollectionUtils.isEmpty(acctRecords)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100498, "核算记录不存在")); + } + + + SalarySendPO sendPO = new SalarySendPO(); + sendPO.setDeleteType(0); + sendPO.setSalaryAccountingId(salaryAccountingId); + List salarySends = mapper.listSome(sendPO); + if (CollectionUtils.isNotEmpty(salarySends)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100499, "工资单已生成过,不可再重复生成")); + } + + SalaryAcctEmployeePO employeePO = new SalaryAcctEmployeePO(); + employeePO.setDeleteType(0); + employeePO.setSalaryAcctRecordId(salaryAccountingId); + List salaryAcctEmployees = getSalaryAcctEmployeeMapper().listSome(employeePO); + + Long salarySendId = IdGenerator.generate(); + + SalaryAcctRecordPO salaryAcctRecord = acctRecords.get(0); + + List salarySendInfos = salaryAcctEmployees.stream().map(m -> + SalarySendInfoPO.builder() + .id(IdGenerator.generate()) + .salarySendId(salarySendId) + .employeeId(m.getEmployeeId()) + .salaryMonth(m.getSalaryMonth()) + .taxAgentId(m.getTaxAgentId()) + .salaryAcctRecordId(m.getSalaryAcctRecordId()) + .sendStatus(SalarySendStatusEnum.UNSEND.getValue()) + .salaryTemplate("") + .creator((long) user.getUID()) + .createTime(new Date()) + .updateTime(new Date()) + .build() + ).collect(Collectors.toList()); + + SalarySendPO salarySend = SalarySendPO.builder() + .id(salarySendId) + .salaryMonth(salaryAcctRecord.getSalaryMonth()) + .salaryAccountingId(salaryAccountingId) + .salarySobId(salaryAcctRecord.getSalarySobId()) + .sendNum(0) + .sendTotal(salarySendInfos.size()) + .lastSendTime(new Date()) + .creator((long) user.getUID()) + .createTime(new Date()) + .updateTime(new Date()) + .build(); + // 插入工资单发放记录 + mapper.insert(salarySend); + // 插入工资单人员记录 + salarySendInfoMapper.batchInsert(salarySendInfos); + + return ""; + } // @Override // @Transactional(rollbackFor = Exception.class)