Commit aaa66ed4 by 张富康

feat(attendance): 优化考勤数据清理实现内存管理与多线程支持

- 采用分批次处理员工考勤数据,防止内存溢出
- 支持多线程异步处理,提升数据处理效率
- 添加事务管理,确保数据一致性和幂等性
- 实现失败记录存储、限流与自动重试机制
- 使用策略模式处理不同打卡场景,提高代码可维护性
- 优化商户查找逻辑,依据距离判定有效打卡地点
- 增加内存释放和垃圾回收调用,降低内存占用峰值
- 统一日志记录,方便定位和分析失败原因
1 parent bb691f4e
package cn.com.glsx.dj.staff.dto.perfSalary;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.math.BigDecimal;
/**
* 打卡结果
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class ClockInResult {
/**
* 门店考勤清单id
*/
private Integer merchantAttendanceListId;
/**
* 出勤工时统计(小时)
*/
private BigDecimal totalWorkHours;
/**
* 迟到早退工时统计(小时)
*/
private BigDecimal lateEarlyHours;
/**
* 迟到早退工时统计(分钟)
*/
private BigDecimal lateEarlyMinutes;
/**
* 正常打卡次数
*/
private int normalClockCount;
}
\ No newline at end of file
package cn.com.glsx.dj.staff.model.perfSalary;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Table(name = "sal_attendance_failure_record")
public class AttendanceFailureRecord implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private String id;
/**
* mobilePhone
*/
@Column(name = "mobile_phone")
private String mobilePhone;
/**
* 统计日期 StatDate
*/
@Column(name = "stat_date")
private Date statDate;
/**
* ErrorMessage
*/
@Column(name = "error_message")
private String errorMessage;
/**
* FailureTime
*/
@Column(name = "failure_time")
private Date failureTime;
}
......@@ -45,8 +45,8 @@ public class AttendanceSummary implements Serializable {
* 门店考勤清单id
*/
@ApiModelProperty(notes = "门店考勤清单id")
@Column(name = "merchant_attendance_list_id")
private Integer merchantAttendanceListId;
@Column(name = "merchant_attendance_list_ids")
private String merchantAttendanceListIds;
/**
* 考勤月份
......
package cn.com.glsx.dj.staff.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import javax.sql.DataSource;
/**
* 事务配置类
*/
@Configuration
public class TransactionConfig {
@Bean
public PlatformTransactionManager transactionManager(DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
}
\ No newline at end of file
......@@ -7,4 +7,5 @@ import org.oreframework.datasource.mybatis.mapper.OreMapper;
@Mapper
public interface AttendanceSummaryMapper extends OreMapper<AttendanceSummary> {
void insertOrUpdate(AttendanceSummary summary);
}
\ No newline at end of file
......@@ -4,5 +4,50 @@
<mapper namespace="cn.com.glsx.dj.staff.mapper.perfSalary.AttendanceSummaryMapper">
<insert id="insertOrUpdate" parameterType="cn.com.glsx.dj.staff.model.perfSalary.AttendanceSummary">
INSERT INTO sal_attendance_summary (mobile_phone,
name,
merchant_attendance_list_id,
attendance_month,
expected_attendance_days,
actual_attendance_days,
appeal_attendance_days,
total_work_hours,
late_early_minutes,
late_early_hours,
missing_punch_count,
superior_leader_mobile_phone,
created_by,
created_date,
updated_by,
updated_date,
deleted_flag
)
VALUES (#{mobilePhone},
#{name},
#{merchantAttendanceListId},
#{attendanceMonth},
#{expectedAttendanceDays},
#{actualAttendanceDays},
#{appealAttendanceDays},
#{totalWorkHours},
#{lateEarlyMinutes},
#{lateEarlyHours},
#{missingPunchCount},
#{superiorLeaderMobilePhone},
#{createdBy},
#{createdDate},
#{updatedBy},
#{updatedDate},
#{deletedFlag}) ON DUPLICATE KEY UPDATE
merchant_attendance_list_id = VALUES(merchant_attendance_list_id),
expected_attendance_days = VALUES(expected_attendance_days),
actual_attendance_days = VALUES(actual_attendance_days),
appeal_attendance_days = VALUES(appeal_attendance_days),
total_work_hours = VALUES(total_work_hours),
late_early_minutes = VALUES(late_early_minutes),
late_early_hours = VALUES(late_early_hours),
missing_punch_count = VALUES(missing_punch_count),
superior_leader_mobile_phone = VALUES(superior_leader_mobile_phone)
</insert>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!