diff --git a/src/main/java/cn/lihongjie/coal/common/ReflectUtils.java b/src/main/java/cn/lihongjie/coal/common/ReflectUtils.java index d94cf8c9..07f7687c 100644 --- a/src/main/java/cn/lihongjie/coal/common/ReflectUtils.java +++ b/src/main/java/cn/lihongjie/coal/common/ReflectUtils.java @@ -222,4 +222,9 @@ public class ReflectUtils { return objectMapper.convertValue(map, cls); } + + public void invalidateAll() { + fieldCache.invalidateAll(); + getFieldCache.invalidateAll(); + } } diff --git a/src/main/java/cn/lihongjie/coal/empSalaryBatch/dto/EmpSalaryBatchDto.java b/src/main/java/cn/lihongjie/coal/empSalaryBatch/dto/EmpSalaryBatchDto.java index aea62166..04947491 100644 --- a/src/main/java/cn/lihongjie/coal/empSalaryBatch/dto/EmpSalaryBatchDto.java +++ b/src/main/java/cn/lihongjie/coal/empSalaryBatch/dto/EmpSalaryBatchDto.java @@ -13,15 +13,12 @@ import java.time.LocalDate; @Data public class EmpSalaryBatchDto extends OrgCommonDto { - @Comment("批次年月") private LocalDate batchYearMonth; @Comment("批次号") private String batchNo; - - @Comment("批次状态 0-初始化 1-编辑中 2-已送审 3-已审核 4-已归档") private String batchStatus; @@ -30,7 +27,12 @@ public class EmpSalaryBatchDto extends OrgCommonDto { private String archiveStatus; - - @DictTranslate(dictKey = DictCode.ARCHIVESTATUS) + @DictTranslate(dictKey = DictCode.ARCHIVESTATUS) private String archiveStatusName; + + private Integer cnt; + private Integer cnt2; + private Double yfheji; + private Double kfheji; + private Double sfheji; } diff --git a/src/main/java/cn/lihongjie/coal/empSalaryBatch/service/EmpSalaryBatchService.java b/src/main/java/cn/lihongjie/coal/empSalaryBatch/service/EmpSalaryBatchService.java index 5550817f..9833aec0 100644 --- a/src/main/java/cn/lihongjie/coal/empSalaryBatch/service/EmpSalaryBatchService.java +++ b/src/main/java/cn/lihongjie/coal/empSalaryBatch/service/EmpSalaryBatchService.java @@ -5,6 +5,7 @@ import cn.lihongjie.coal.base.dto.CommonQuery; import cn.lihongjie.coal.base.dto.IdRequest; import cn.lihongjie.coal.base.service.BaseService; import cn.lihongjie.coal.common.Ctx; +import cn.lihongjie.coal.common.JpaUtils; import cn.lihongjie.coal.empSalary.service.EmpSalaryService; import cn.lihongjie.coal.empSalaryBatch.dto.BatchInitRequest; import cn.lihongjie.coal.empSalaryBatch.dto.CreateEmpSalaryBatchDto; @@ -19,6 +20,7 @@ import cn.lihongjie.coal.exception.BizException; import jakarta.persistence.EntityManager; import jakarta.persistence.PersistenceContext; +import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaQuery; import jakarta.persistence.criteria.Predicate; @@ -37,6 +39,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDate; +import java.util.List; +import java.util.Map; import java.util.Objects; @Service @@ -152,7 +156,30 @@ public class EmpSalaryBatchService query.getPageSize(), Sort.by(query.getOrders()))); - return page.map(this.mapper::toDto); + List tuples = em.createNativeQuery( + """ + + select count(s.id) as cnt, + (select count(1) from t_employee e where e.organization_id = b.organization_id and ((e.emp_status = '1' and e.entry_date <= b.batch_year_month) or (e.emp_status = '2' and e.entry_date <= b.batch_year_month and e.resign_date!=null and e.resign_date >=b.batch_year_month) ) ) as cnt2, + round(sum(s.yfheji)::::numeric, 2) as yfheji, + round(sum(s.kfheji)::::numeric, 2) as kfheji, + round(sum(s.sfheji)::::numeric, 2) as sfheji, + b.id as id + + from t_emp_salary_batch b left join t_emp_salary s on b.id = s.batch_id where b.id in :ids + group by b.id + + """, + Tuple.class).setParameter("ids", page.map(EmpSalaryBatchEntity::getId).toList()).getResultList(); + + List maps = JpaUtils.convertTuplesToRawMap(tuples); + + + Page pageDto = page.map(this.mapper::toDto); + + + JpaUtils.mergeMapToPojo(pageDto.getContent(), maps, conversionService); + return pageDto; } public void archive(IdRequest dto) {