Commit 074cf36d by 张富康

feat(attendance): 添加批量插入或更新考勤汇总数据接口

- 在AttendanceSummaryMapper接口中新增insertOrUpdateBatch方法
- 在MyBatis映射文件中增加批量插入SQL,使用foreach循环插入多条数据
- 批量插入操作支持主键冲突时更新记录的字段
- 优化考勤汇总数据插入更新逻辑,提高数据处理效率
1 parent aaa66ed4
...@@ -4,8 +4,12 @@ import cn.com.glsx.dj.staff.model.perfSalary.AttendanceSummary; ...@@ -4,8 +4,12 @@ import cn.com.glsx.dj.staff.model.perfSalary.AttendanceSummary;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper; import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.List;
@Mapper @Mapper
public interface AttendanceSummaryMapper extends OreMapper<AttendanceSummary> { public interface AttendanceSummaryMapper extends OreMapper<AttendanceSummary> {
void insertOrUpdate(AttendanceSummary summary); void insertOrUpdate(AttendanceSummary summary);
void insertOrUpdateBatch(List<AttendanceSummary> summaries);
} }
\ No newline at end of file \ No newline at end of file
...@@ -50,4 +50,37 @@ ...@@ -50,4 +50,37 @@
missing_punch_count = VALUES(missing_punch_count), missing_punch_count = VALUES(missing_punch_count),
superior_leader_mobile_phone = VALUES(superior_leader_mobile_phone) superior_leader_mobile_phone = VALUES(superior_leader_mobile_phone)
</insert> </insert>
<!-- 批量插入(使用MyBatis foreach) -->
<insert id="insertOrUpdateBatch" parameterType="java.util.List">
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
<foreach collection="list" item="item" separator=",">
(
#{item.mobilePhone}, #{item.name}, #{item.merchantAttendanceListId},
#{item.attendanceMonth}, #{item.expectedAttendanceDays},
#{item.actualAttendanceDays}, #{item.appealAttendanceDays},
#{item.totalWorkHours}, #{item.lateEarlyMinutes}, #{item.lateEarlyHours},
#{item.missingPunchCount}, #{item.superiorLeaderMobilePhone},
#{item.createdBy}, #{item.createdDate}, #{item.updatedBy},
#{item.updatedDate}, #{item.deletedFlag}
)
</foreach>
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> </mapper>
\ No newline at end of file \ 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!