生成工资单
This commit is contained in:
parent
38179daee9
commit
3003d0fadb
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,4 +104,15 @@ public class SalarySendInfoBiz {
|
|||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,9 +64,8 @@ public interface SalarySendInfoMapper {
|
|||
/**
|
||||
* 批量插入工资单信息记录
|
||||
* @param pos
|
||||
* @param currentTenantKey
|
||||
*/
|
||||
void batchInsert(@Param("collection") List<SalarySendInfoPO> pos, String currentTenantKey);
|
||||
void batchInsert(@Param("collection") List<SalarySendInfoPO> pos);
|
||||
|
||||
/**
|
||||
* 发放、撤回工资单
|
||||
|
|
|
|||
|
|
@ -55,4 +55,6 @@ public interface SalarySendMapper {
|
|||
* @return
|
||||
*/
|
||||
List<SalarySendPO> listSome(SalarySendPO params);
|
||||
|
||||
void insertIgnoreNull(SalarySendPO salarySend);
|
||||
}
|
||||
|
|
@ -164,9 +164,9 @@
|
|||
<if test="salaryAccountingId != null and salaryAccountingId != ''">
|
||||
AND salary_accounting_id = #{salaryAccountingId}
|
||||
</if>
|
||||
<if test="salaryAcctRecordId != null and salaryAcctRecordId != ''">
|
||||
AND salary_acct_record_id = #{salaryAcctRecordId}
|
||||
</if>
|
||||
<!-- <if test="salaryAcctRecordId != null and salaryAcctRecordId != ''">-->
|
||||
<!-- AND salary_acct_record_id = #{salaryAcctRecordId}-->
|
||||
<!-- </if>-->
|
||||
<if test="salarySobId != null and salarySobId != ''">
|
||||
AND salary_sob_id = #{salarySobId}
|
||||
</if>
|
||||
|
|
@ -198,5 +198,93 @@
|
|||
</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>
|
||||
|
|
@ -28,10 +28,9 @@ public interface SalarySendService {
|
|||
/**
|
||||
* 薪资核算-归档生成工资单
|
||||
* @param salaryAccountingId
|
||||
* @param currentTenantKey
|
||||
* @return
|
||||
*/
|
||||
// Map<String, Object> generateSalaryBill(Long salaryAccountingId, Long currentEmployeeId, String currentTenantKey);
|
||||
String generateSalaryBill(Long salaryAccountingId);
|
||||
|
||||
/**
|
||||
* 薪资核算-归档撤销工资单
|
||||
|
|
|
|||
|
|
@ -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<SalaryAcctRecordPO> loggerContext = new LoggerContext<>();
|
||||
|
|
|
|||
|
|
@ -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<Boolean> generateSalaryBill(Long salaryAccountingId, Long currentEmployeeId, String currentTenantKey) {
|
||||
// // 校验salaryAccountingId
|
||||
// if (salaryAccountingId == null) {
|
||||
// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100497, "核算id必传"));
|
||||
// }
|
||||
//
|
||||
// List<SalaryAcctRecordPO> 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<SalarySendPO> 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<SalaryAcctEmployeePO> 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<SalarySendInfoPO> 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<SalaryAcctRecordPO> 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<SalarySendPO> 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<SalaryAcctEmployeePO> salaryAcctEmployees = getSalaryAcctEmployeeMapper().listSome(employeePO);
|
||||
|
||||
Long salarySendId = IdGenerator.generate();
|
||||
|
||||
SalaryAcctRecordPO salaryAcctRecord = acctRecords.get(0);
|
||||
|
||||
List<SalarySendInfoPO> 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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue