2026-01-28 14:40:27 +08:00
|
|
|
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
|
|
|
<!DOCTYPE mapper
|
|
|
|
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
2026-02-24 17:12:11 +08:00
|
|
|
|
<mapper namespace="com.ruoyi.info.collection.mapper.CcdiBaseStaffMapper">
|
2026-01-28 14:40:27 +08:00
|
|
|
|
|
2026-01-29 09:07:50 +08:00
|
|
|
|
<!-- 员工基本信息ResultMap(用于列表查询,不包含亲属) -->
|
2026-02-24 17:12:11 +08:00
|
|
|
|
<resultMap type="com.ruoyi.info.collection.domain.vo.CcdiBaseStaffVO" id="CcdiBaseStaffVOResult">
|
2026-02-09 14:28:25 +08:00
|
|
|
|
<id property="staffId" column="staff_id"/>
|
2026-01-28 14:40:27 +08:00
|
|
|
|
<result property="name" column="name"/>
|
2026-01-28 16:57:38 +08:00
|
|
|
|
<result property="deptId" column="dept_id"/>
|
|
|
|
|
|
<result property="deptName" column="dept_name"/>
|
2026-01-28 14:40:27 +08:00
|
|
|
|
<result property="idCard" column="id_card"/>
|
|
|
|
|
|
<result property="phone" column="phone"/>
|
|
|
|
|
|
<result property="hireDate" column="hire_date"/>
|
|
|
|
|
|
<result property="status" column="status"/>
|
|
|
|
|
|
<result property="createTime" column="create_time"/>
|
2026-01-29 09:07:50 +08:00
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
2026-02-09 14:28:25 +08:00
|
|
|
|
<select id="selectBaseStaffPageWithDept" resultMap="CcdiBaseStaffVOResult">
|
2026-01-28 16:57:38 +08:00
|
|
|
|
SELECT
|
2026-02-09 14:28:25 +08:00
|
|
|
|
e.staff_id, e.name, e.dept_id, e.id_card, e.phone, e.hire_date, e.status, e.create_time,
|
2026-01-28 16:57:38 +08:00
|
|
|
|
d.dept_name
|
2026-02-09 14:28:25 +08:00
|
|
|
|
FROM ccdi_base_staff e
|
2026-01-28 16:57:38 +08:00
|
|
|
|
LEFT JOIN sys_dept d ON e.dept_id = d.dept_id
|
|
|
|
|
|
<where>
|
|
|
|
|
|
<if test="query.name != null and query.name != ''">
|
|
|
|
|
|
AND e.name LIKE CONCAT('%', #{query.name}, '%')
|
|
|
|
|
|
</if>
|
2026-02-09 14:28:25 +08:00
|
|
|
|
<if test="query.staffId != null">
|
|
|
|
|
|
AND e.staff_id = #{query.staffId}
|
2026-01-28 16:57:38 +08:00
|
|
|
|
</if>
|
|
|
|
|
|
<if test="query.deptId != null">
|
|
|
|
|
|
AND e.dept_id = #{query.deptId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="query.idCard != null and query.idCard != ''">
|
2026-01-29 09:07:50 +08:00
|
|
|
|
AND e.id_card LIKE CONCAT('%', #{query.idCard}, '%')
|
2026-01-28 16:57:38 +08:00
|
|
|
|
</if>
|
|
|
|
|
|
<if test="query.status != null and query.status != ''">
|
|
|
|
|
|
AND e.status = #{query.status}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</where>
|
|
|
|
|
|
ORDER BY e.create_time DESC
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
2026-02-06 11:19:40 +08:00
|
|
|
|
<!-- 批量插入或更新员工信息(只更新非null字段) -->
|
2026-02-06 09:22:06 +08:00
|
|
|
|
<insert id="insertOrUpdateBatch" parameterType="java.util.List">
|
2026-02-09 14:28:25 +08:00
|
|
|
|
INSERT INTO ccdi_base_staff
|
|
|
|
|
|
(staff_id, name, dept_id, id_card, phone, hire_date, status,
|
2026-02-06 09:24:40 +08:00
|
|
|
|
create_time, create_by, update_by, update_time)
|
2026-02-06 09:22:06 +08:00
|
|
|
|
VALUES
|
|
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
2026-02-09 14:28:25 +08:00
|
|
|
|
(#{item.staffId}, #{item.name}, #{item.deptId}, #{item.idCard},
|
2026-02-06 09:22:06 +08:00
|
|
|
|
#{item.phone}, #{item.hireDate}, #{item.status}, NOW(),
|
2026-02-06 09:24:40 +08:00
|
|
|
|
#{item.createBy}, #{item.updateBy}, NOW())
|
2026-02-06 09:22:06 +08:00
|
|
|
|
</foreach>
|
|
|
|
|
|
ON DUPLICATE KEY UPDATE
|
2026-02-06 11:19:40 +08:00
|
|
|
|
name = COALESCE(VALUES(name), name),
|
|
|
|
|
|
dept_id = COALESCE(VALUES(dept_id), dept_id),
|
|
|
|
|
|
phone = COALESCE(VALUES(phone), phone),
|
|
|
|
|
|
hire_date = COALESCE(VALUES(hire_date), hire_date),
|
|
|
|
|
|
status = COALESCE(VALUES(status), status),
|
|
|
|
|
|
update_by = COALESCE(VALUES(update_by), update_by),
|
2026-02-06 09:24:40 +08:00
|
|
|
|
update_time = NOW()
|
2026-02-06 09:22:06 +08:00
|
|
|
|
</insert>
|
|
|
|
|
|
|
2026-02-06 09:41:50 +08:00
|
|
|
|
<!-- 批量插入员工信息 -->
|
|
|
|
|
|
<insert id="insertBatch" parameterType="java.util.List">
|
2026-02-09 14:28:25 +08:00
|
|
|
|
INSERT INTO ccdi_base_staff
|
|
|
|
|
|
(staff_id, name, dept_id, id_card, phone, hire_date, status,
|
2026-02-06 09:41:50 +08:00
|
|
|
|
create_time, create_by, update_by, update_time)
|
|
|
|
|
|
VALUES
|
|
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
2026-02-09 14:28:25 +08:00
|
|
|
|
(#{item.staffId}, #{item.name}, #{item.deptId}, #{item.idCard},
|
2026-02-06 09:41:50 +08:00
|
|
|
|
#{item.phone}, #{item.hireDate}, #{item.status}, NOW(),
|
|
|
|
|
|
#{item.createBy}, #{item.updateBy}, NOW())
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
2026-02-11 10:42:38 +08:00
|
|
|
|
<!-- 查询员工选项(用于下拉选择框) -->
|
|
|
|
|
|
<!-- 支持按员工ID或姓名模糊搜索,只返回在职员工 -->
|
2026-02-24 17:12:11 +08:00
|
|
|
|
<select id="selectStaffOptions" resultType="com.ruoyi.info.collection.domain.vo.CcdiBaseStaffOptionVO">
|
2026-02-11 10:42:38 +08:00
|
|
|
|
SELECT
|
|
|
|
|
|
e.staff_id,
|
|
|
|
|
|
e.name,
|
|
|
|
|
|
e.dept_id,
|
|
|
|
|
|
d.dept_name
|
|
|
|
|
|
FROM ccdi_base_staff e
|
|
|
|
|
|
LEFT JOIN sys_dept d ON e.dept_id = d.dept_id
|
|
|
|
|
|
<where>
|
|
|
|
|
|
e.status = '0'
|
|
|
|
|
|
<if test="query != null and query != ''">
|
|
|
|
|
|
AND (CAST(e.staff_id AS CHAR) LIKE CONCAT('%', #{query}, '%')
|
|
|
|
|
|
OR e.name LIKE CONCAT('%', #{query}, '%'))
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</where>
|
|
|
|
|
|
ORDER BY e.staff_id
|
|
|
|
|
|
LIMIT 100
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
2026-01-28 14:40:27 +08:00
|
|
|
|
</mapper>
|