重新计算关联考勤记录

This commit is contained in:
2024-08-28 08:56:01 +08:00
parent ef8a34dbbf
commit 6e5abeb9e7

View File

@@ -86,15 +86,10 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
public Object report(EmpSalaryReportRequest request) {
if (CollectionUtils.isEmpty(request.getFieldInfos())){
if (CollectionUtils.isEmpty(request.getFieldInfos())) {
request.setFieldInfos(new ArrayList<>());
}
String sql =
FreeMakerUtils.render(
"""
@@ -107,7 +102,7 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
<#if field?is_first> ,</#if>
${underScore(field)} as ${underScore(field)}
<#if field == 'employeeId'>, max(emp_name) as emp_name, max(emp_code) as emp_code </#if>
<#if field == 'd8epartmentId'>, max(department_name) as department_name, max(department_code) as department_code </#if>
<#if field == 'jobPostId'>, max(job_post_name) as job_post_name, max(job_post_code) as job_post_code </#if>
@@ -143,7 +138,7 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
<#if departmentIds??> and department_id in :departmentIds </#if>
<#if jobPostIds??> and job_post_id in :jobPostIds </#if>
<#if nations??> and nation in :nations </#if>
<#if marriages??> and marriage in :marriages </#if>
<#if educations??> and education in :educations </#if>
@@ -158,7 +153,7 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
<#if idCard??> and id_card like :idCard </#if>
<#if phone??> and phone like :phone </#if>
group by 1, date_trunc('${timeDimension}', batch_year_month)
@@ -185,11 +180,11 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
var selectSql =
"select * from ("
+ sql
+ ") as t limit "
+ request.getPageSize()
+ " offset "
+ request.getPageNo() * request.getPageSize();
+ sql
+ ") as t limit "
+ request.getPageSize()
+ " offset "
+ request.getPageNo() * request.getPageSize();
Integer count = JpaUtils.execNativeQuery(em, countSql, request, Integer.class).get(0);
@@ -203,22 +198,22 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
x ->
((Map) x)
.entrySet().stream()
.collect(
Collectors.toMap(
(Map.Entry e) ->
CaseFormat
.LOWER_UNDERSCORE
.to(
CaseFormat
.LOWER_CAMEL,
e.getKey()
.toString()),
e ->
ObjectUtils
.defaultIfNull(
e
.getValue(),
""))))
.collect(
Collectors.toMap(
(Map.Entry e) ->
CaseFormat
.LOWER_UNDERSCORE
.to(
CaseFormat
.LOWER_CAMEL,
e.getKey()
.toString()),
e ->
ObjectUtils
.defaultIfNull(
e
.getValue(),
""))))
.toList();
return new PageImpl<>(ans, PageRequest.of(0, request.getPageSize()), count);
@@ -442,6 +437,24 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
*/
public void recalculate(IdRequest ids) {
int update =
this.em
.createQuery(
"""
update EmpSalaryEntity s set s.empMonthAttendance = (select a from EmpMonthAttendanceEntity a where a.employee.id = s.employee.id and a.yearMonth = s.batch.batchYearMonth)
where s.id in :ids
and s.empMonthAttendance is null
""")
.setParameter("ids", ids.getIds())
.executeUpdate();
if (update > 0) {
log.info("更新了 {} 条数据的考勤数据", update);
}
List<EmpSalaryEntity> salaries =
em.createQuery(
"""
@@ -953,14 +966,15 @@ select id from tmp1 where rk = 1
if (header.equals("身份证号") || header.equals("身份证")) {
object.put("idCard", value);
} else if (StringUtils.equalsAny(header,"姓名", "员工", "部门", "岗位")) {
} else if (StringUtils.equalsAny(header, "姓名", "员工", "部门", "岗位")) {
// 忽略这些字段
} else if (itemMap.containsKey(header)) {
if (value == null || (value instanceof String && StringUtils.isBlank((String) value))){
if (value == null
|| (value instanceof String
&& StringUtils.isBlank((String) value))) {
return;
}