mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 15:55:18 +08:00
批次归档同步进行工资归档
This commit is contained in:
@@ -298,7 +298,8 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
|
||||
@Autowired EmpSalaryItemService empSalaryItemService;
|
||||
|
||||
private static void assertBatchEditable(EmpSalaryBatchEntity salaryBatch) {
|
||||
if (salaryBatch.getStatus() != 1 || ObjectUtils.notEqual(salaryBatch.getArchiveStatus(), "0")) {
|
||||
if (salaryBatch.getStatus() != 1
|
||||
|| ObjectUtils.notEqual(salaryBatch.getArchiveStatus(), "0")) {
|
||||
throw new BizException("批次不属于编辑状态, 无法编辑或删除");
|
||||
}
|
||||
}
|
||||
@@ -311,6 +312,22 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void archiveByBatchId(IdRequest request) {
|
||||
|
||||
em.createQuery(
|
||||
"update EmpSalaryEntity s set s.archiveStatus = '1' where s.batch.id in :batchId")
|
||||
.setParameter("batchId", request.getIds())
|
||||
.executeUpdate();
|
||||
}
|
||||
|
||||
public void unarchiveByBatchId(IdRequest request) {
|
||||
|
||||
em.createQuery(
|
||||
"update EmpSalaryEntity s set s.archiveStatus = '0' where s.batch.id in :batchId")
|
||||
.setParameter("batchId", request.getIds())
|
||||
.executeUpdate();
|
||||
}
|
||||
|
||||
public EmpSalaryDto update(UpdateEmpSalaryDto request) {
|
||||
|
||||
assertBatchEditable(request.getBatch());
|
||||
@@ -858,8 +875,9 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
|
||||
|
||||
private List<EmpSalaryEntity> queryHisSalary(List<String> employeesIds) {
|
||||
|
||||
List<String> ids = em.createNativeQuery(
|
||||
"""
|
||||
List<String> ids =
|
||||
em.createNativeQuery(
|
||||
"""
|
||||
with tmp1 as (
|
||||
|
||||
select s.id, rank() over (partition by employee_id order by batch_year_month desc ) rk from t_emp_salary s where s.employee_id in :ids
|
||||
@@ -868,13 +886,12 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
|
||||
select id from tmp1 where rk = 1
|
||||
|
||||
""",
|
||||
String.class)
|
||||
.setParameter("ids", employeesIds)
|
||||
.getResultList();
|
||||
String.class)
|
||||
.setParameter("ids", employeesIds)
|
||||
.getResultList();
|
||||
|
||||
return em.createQuery(
|
||||
"select s from EmpSalaryEntity s where s.id in :ids",
|
||||
EmpSalaryEntity.class)
|
||||
"select s from EmpSalaryEntity s where s.id in :ids", EmpSalaryEntity.class)
|
||||
.setParameter("ids", ids)
|
||||
.getResultList();
|
||||
}
|
||||
|
||||
@@ -182,12 +182,15 @@ public class EmpSalaryBatchService
|
||||
return pageDto;
|
||||
}
|
||||
|
||||
|
||||
public void archive(IdRequest dto) {
|
||||
this.repository.archive(dto);
|
||||
empSalaryService.archiveByBatchId(dto);
|
||||
}
|
||||
|
||||
public void unarchive(IdRequest dto) {
|
||||
this.repository.unArchive(dto);
|
||||
empSalaryService.unarchiveByBatchId(dto);
|
||||
}
|
||||
|
||||
@Autowired EmpSalaryBatchAuditLogService batchAuditLogService;
|
||||
|
||||
Reference in New Issue
Block a user