Merge branch 'feature/salaryBill' into develop

This commit is contained in:
MustangDeng 2022-04-21 16:45:33 +08:00
commit c327aafd6c
8 changed files with 193 additions and 85 deletions

View File

@ -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();
}
}
} }

View File

@ -104,4 +104,15 @@ public class SalarySendInfoBiz {
sqlSession.close(); sqlSession.close();
} }
} }
public void batchInsert(List<SalarySendInfoPO> salarySendInfos) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
SalarySendInfoMapper mapper = sqlSession.getMapper(SalarySendInfoMapper.class);
mapper.batchInsert(salarySendInfos);
sqlSession.commit();
} finally {
sqlSession.close();
}
}
} }

View File

@ -64,9 +64,8 @@ public interface SalarySendInfoMapper {
/** /**
* 批量插入工资单信息记录 * 批量插入工资单信息记录
* @param pos * @param pos
* @param currentTenantKey
*/ */
void batchInsert(@Param("collection") List<SalarySendInfoPO> pos, String currentTenantKey); void batchInsert(@Param("collection") List<SalarySendInfoPO> pos);
/** /**
* 发放撤回工资单 * 发放撤回工资单

View File

@ -55,4 +55,6 @@ public interface SalarySendMapper {
* @return * @return
*/ */
List<SalarySendPO> listSome(SalarySendPO params); List<SalarySendPO> listSome(SalarySendPO params);
void insertIgnoreNull(SalarySendPO salarySend);
} }

View File

@ -164,9 +164,9 @@
<if test="salaryAccountingId != null and salaryAccountingId != ''"> <if test="salaryAccountingId != null and salaryAccountingId != ''">
AND salary_accounting_id = #{salaryAccountingId} AND salary_accounting_id = #{salaryAccountingId}
</if> </if>
<if test="salaryAcctRecordId != null and salaryAcctRecordId != ''"> <!-- <if test="salaryAcctRecordId != null and salaryAcctRecordId != ''">-->
AND salary_acct_record_id = #{salaryAcctRecordId} <!-- AND salary_acct_record_id = #{salaryAcctRecordId}-->
</if> <!-- </if>-->
<if test="salarySobId != null and salarySobId != ''"> <if test="salarySobId != null and salarySobId != ''">
AND salary_sob_id = #{salarySobId} AND salary_sob_id = #{salarySobId}
</if> </if>
@ -198,5 +198,93 @@
</select> </select>
<!-- 插入不为NULL的字段 -->
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.salaryBill.po.SalarySendPO"
keyProperty="id" keyColumn="id" useGeneratedKeys="true"
>
INSERT INTO hrsa_salary_send
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="salaryMonth != null">
salary_month,
</if>
<if test="salaryAccountingId != null">
salary_accounting_id,
</if>
<if test="salarySobId != null">
salary_sob_id,
</if>
<if test="sendNum != null">
send_num,
</if>
<if test="sendTotal != null">
send_total,
</if>
<if test="lastSendTime != null">
last_send_time,
</if>
<if test="creator != null">
creator,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="tenantKey != null">
tenant_key,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id},
</if>
<if test="salaryMonth != null">
#{salaryMonth},
</if>
<if test="salaryAccountingId != null">
#{salaryAccountingId},
</if>
<if test="salarySobId != null">
#{salarySobId},
</if>
<if test="sendNum != null">
#{sendNum},
</if>
<if test="sendTotal != null">
#{sendTotal},
</if>
<if test="lastSendTime != null">
#{lastSendTime},
</if>
<if test="creator != null">
#{creator},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="tenantKey != null">
#{tenantKey},
</if>
</trim>
</insert>
</mapper> </mapper>

View File

@ -28,10 +28,9 @@ public interface SalarySendService {
/** /**
* 薪资核算-归档生成工资单 * 薪资核算-归档生成工资单
* @param salaryAccountingId * @param salaryAccountingId
* @param currentTenantKey
* @return * @return
*/ */
// Map<String, Object> generateSalaryBill(Long salaryAccountingId, Long currentEmployeeId, String currentTenantKey); String generateSalaryBill(Long salaryAccountingId);
/** /**
* 薪资核算-归档撤销工资单 * 薪资核算-归档撤销工资单

View File

@ -15,10 +15,7 @@ import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
import com.engine.salary.enums.salarysob.IncomeCategoryEnum; import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper; import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper;
import com.engine.salary.service.SalaryAcctEmployeeService; import com.engine.salary.service.*;
import com.engine.salary.service.SalaryAcctRecordService;
import com.engine.salary.service.SalaryAcctResultService;
import com.engine.salary.service.SalarySobService;
import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.SalaryI18nUtil;
@ -64,6 +61,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
return (SalaryAcctResultService) ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); return (SalaryAcctResultService) ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user);
} }
private SalarySendService getSalarySendService(User user) {
return ServiceUtil.getService(SalarySendServiceImpl.class, user);
}
// private SalaryCheckResultService salaryCheckResultService; // private SalaryCheckResultService salaryCheckResultService;
// //
// private SalaryCheckResultDetailService salaryCheckResultDetailService; // private SalaryCheckResultDetailService salaryCheckResultDetailService;
@ -361,8 +362,8 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
salaryAcctRecordPO.setStatus(SalaryAcctRecordStatusEnum.ARCHIVED.getValue()); salaryAcctRecordPO.setStatus(SalaryAcctRecordStatusEnum.ARCHIVED.getValue());
salaryAcctRecordPO.setUpdateTime(new Date()); salaryAcctRecordPO.setUpdateTime(new Date());
getSalaryAcctRecordMapper().updateIgnoreNull(salaryAcctRecordPO); getSalaryAcctRecordMapper().updateIgnoreNull(salaryAcctRecordPO);
//todo 生成工资单 // 生成工资单
// salarySendService.generateSalaryBill(salaryAcctRecordId, employeeId, tenantKey); getSalarySendService(user).generateSalaryBill(salaryAcctRecordId);
// 记录日志 // 记录日志
// String targetName = getLogTargetNameById(salaryAcctRecordId); // String targetName = getLogTargetNameById(salaryAcctRecordId);
// LoggerContext<SalaryAcctRecordPO> loggerContext = new LoggerContext<>(); // LoggerContext<SalaryAcctRecordPO> loggerContext = new LoggerContext<>();

View File

@ -155,78 +155,76 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
return salarySends.stream().map(SalarySendPO::getSalaryAccountingId).collect(Collectors.toList()); return salarySends.stream().map(SalarySendPO::getSalaryAccountingId).collect(Collectors.toList());
} }
// @Override @Override
// @Transactional(rollbackFor = Exception.class) public String generateSalaryBill(Long salaryAccountingId) {
// public WeaResult<Boolean> generateSalaryBill(Long salaryAccountingId, Long currentEmployeeId, String currentTenantKey) { // 校验salaryAccountingId
// // 校验salaryAccountingId if (salaryAccountingId == null) {
// if (salaryAccountingId == null) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100497, "核算id必传"));
// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100497, "核算id必传")); }
// }
// SalaryAcctRecordPO recordPo = new SalaryAcctRecordPO();
// List<SalaryAcctRecordPO> acctRecords = new LambdaQueryChainWrapper<>(salaryAcctRecordMapper) recordPo.setDeleteType(0);
// .eq(SalaryAcctRecordPO::getDeleteType, 0) recordPo.setId(salaryAccountingId);
// .eq(SalaryAcctRecordPO::getTenantKey, currentTenantKey) recordPo.setStatus(SalaryAcctRecordStatusEnum.ARCHIVED.getValue());
// .eq(SalaryAcctRecordPO::getId, salaryAccountingId) List<SalaryAcctRecordPO> acctRecords = getSalaryAcctRecordMapper().listSome(recordPo);
// .eq(SalaryAcctRecordPO::getStatus, SalaryAcctRecordStatusEnum.ARCHIVED.getValue()).list(); // 检查核算的归档记录
// // 检查核算的归档记录 if (CollectionUtils.isEmpty(acctRecords)) {
// if (CollectionUtils.isEmpty(acctRecords)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100498, "核算记录不存在"));
// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100498, "核算记录不存在")); }
// }
//
// List<SalarySendPO> salarySends = new LambdaQueryChainWrapper<>(mapper) SalarySendPO sendPO = new SalarySendPO();
// .eq(SalarySendPO::getDeleteType, 0) sendPO.setDeleteType(0);
// .eq(SalarySendPO::getTenantKey, currentTenantKey) sendPO.setSalaryAccountingId(salaryAccountingId);
// .eq(SalarySendPO::getSalaryAccountingId, salaryAccountingId).list(); List<SalarySendPO> salarySends = mapper.listSome(sendPO);
// if (CollectionUtils.isNotEmpty(salarySends)) { if (CollectionUtils.isNotEmpty(salarySends)) {
// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100499, "工资单已生成过,不可再重复生成")); throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100499, "工资单已生成过,不可再重复生成"));
// } }
//
// List<SalaryAcctEmployeePO> salaryAcctEmployees = new LambdaQueryChainWrapper<>(salaryAcctEmployeeMapper) SalaryAcctEmployeePO employeePO = new SalaryAcctEmployeePO();
// .eq(SalaryAcctEmployeePO::getDeleteType, 0) employeePO.setDeleteType(0);
// .eq(SalaryAcctEmployeePO::getTenantKey, currentTenantKey) employeePO.setSalaryAcctRecordId(salaryAccountingId);
// .eq(SalaryAcctEmployeePO::getSalaryAcctRecordId, salaryAccountingId).list(); List<SalaryAcctEmployeePO> salaryAcctEmployees = getSalaryAcctEmployeeMapper().listSome(employeePO);
//
// Long salarySendId = IdGenerator.generate(); Long salarySendId = IdGenerator.generate();
//
// SalaryAcctRecordPO salaryAcctRecord = acctRecords.get(0); SalaryAcctRecordPO salaryAcctRecord = acctRecords.get(0);
//
// List<SalarySendInfoPO> salarySendInfos = org.apache.commons.collections4.CollectionUtils.emptyIfNull(salaryAcctEmployees).stream().map(m -> List<SalarySendInfoPO> salarySendInfos = salaryAcctEmployees.stream().map(m ->
// SalarySendInfoPO.builder() SalarySendInfoPO.builder()
// .id(IdGenerator.generate()) .id(IdGenerator.generate())
// .salarySendId(salarySendId) .salarySendId(salarySendId)
// .employeeId(m.getEmployeeId()) .employeeId(m.getEmployeeId())
// .salaryMonth(m.getSalaryMonth()) .salaryMonth(m.getSalaryMonth())
// .taxAgentId(m.getTaxAgentId()) .taxAgentId(m.getTaxAgentId())
// .salaryAcctRecordId(m.getSalaryAcctRecordId()) .salaryAcctRecordId(m.getSalaryAcctRecordId())
// .sendStatus(SalarySendStatusEnum.UNSEND.getValue()) .sendStatus(SalarySendStatusEnum.UNSEND.getValue())
// .salaryTemplate("") .salaryTemplate("")
// .creator(currentEmployeeId) .creator((long) user.getUID())
// .createTime(LocalDateTime.now()) .createTime(new Date())
// .updateTime(LocalDateTime.now()) .updateTime(new Date())
// .tenantKey(currentTenantKey) .build()
// .build() ).collect(Collectors.toList());
// ).collect(Collectors.toList());
// SalarySendPO salarySend = SalarySendPO.builder()
// SalarySendPO salarySend = SalarySendPO.builder() .id(salarySendId)
// .id(salarySendId) .salaryMonth(salaryAcctRecord.getSalaryMonth())
// .salaryMonth(salaryAcctRecord.getSalaryMonth()) .salaryAccountingId(salaryAccountingId)
// .salaryAccountingId(salaryAccountingId) .salarySobId(salaryAcctRecord.getSalarySobId())
// .salarySobId(salaryAcctRecord.getSalarySobId()) .sendNum(0)
// .sendNum(0) .sendTotal(salarySendInfos.size())
// .sendTotal(salarySendInfos.size()) .lastSendTime(new Date())
// .lastSendTime(LocalDateTime.now()) .creator((long) user.getUID())
// .creator(currentEmployeeId) .createTime(new Date())
// .createTime(LocalDateTime.now()) .updateTime(new Date())
// .updateTime(LocalDateTime.now()) .build();
// .tenantKey(currentTenantKey) // 插入工资单发放记录
// .build(); mapper.insert(salarySend);
// // 插入工资单发放记录 // 插入工资单人员记录
// mapper.insert(salarySend); salarySendInfoMapper.batchInsert(salarySendInfos);
// // 插入工资单人员记录
// salarySendInfoMapper.batchInsert(salarySendInfos, currentTenantKey); return "";
// }
// return WeaResult.success(Boolean.TRUE);
// }
// @Override // @Override
// @Transactional(rollbackFor = Exception.class) // @Transactional(rollbackFor = Exception.class)