fix: 修复员工导入Service层的事务管理和批量插入性能问题

问题1: importEmployeeAsync方法缺少@Transactional注解
- 在第239行添加@Transactional注解,确保异步操作的事务一致性

问题2: saveBatch方法性能问题
- 原实现: 循环内逐条调用insert(),不是真正的批量插入
- 修复方案:
  1. 在CcdiEmployeeMapper接口中新增insertBatch方法
  2. 在CcdiEmployeeMapper.xml中实现真正的批量插入SQL
  3. saveBatch方法改为调用insertBatch,分批次批量插入

性能提升:
- 之前: 1000条数据需要1000次数据库往返
- 之后: 1000条数据只需2次数据库往返(分批次500条)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
wkc
2026-02-06 09:41:50 +08:00
parent d5af1602f9
commit 6101d94d82
3 changed files with 24 additions and 3 deletions

View File

@@ -66,4 +66,17 @@
update_time = NOW()
</insert>
<!-- 批量插入员工信息 -->
<insert id="insertBatch" parameterType="java.util.List">
INSERT INTO ccdi_employee
(employee_id, name, dept_id, id_card, phone, hire_date, status,
create_time, create_by, update_by, update_time)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.employeeId}, #{item.name}, #{item.deptId}, #{item.idCard},
#{item.phone}, #{item.hireDate}, #{item.status}, NOW(),
#{item.createBy}, #{item.updateBy}, NOW())
</foreach>
</insert>
</mapper>