197 lines
12 KiB
XML
197 lines
12 KiB
XML
<?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">
|
|
<mapper namespace="com.ruoyi.credit.mapper.EmployeeInfoMapper">
|
|
|
|
<resultMap type="EmployeeInfo" id="EmployeeInfoResult">
|
|
<result property="employeeId" column="employee_id" />
|
|
<result property="employeeNumber" column="employee_number" />
|
|
<result property="employeeName" column="employee_name" />
|
|
<result property="idCardNumber" column="id_card_number" />
|
|
<result property="position" column="position" />
|
|
<result property="department" column="department" />
|
|
<result property="salaryUnit" column="salary_unit" />
|
|
<result property="hourlySalary" column="hourly_salary" />
|
|
<result property="dailySalary" column="daily_salary" />
|
|
<result property="monthlySalary" column="monthly_salary" />
|
|
<result property="employeeStatus" column="employee_status" />
|
|
<result property="hireDate" column="hire_date" />
|
|
<result property="contactPhone" column="contact_phone" />
|
|
<result property="libraryId" column="library_id" />
|
|
<result property="isTemporary" column="is_temporary" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="createBy" column="created_by" />
|
|
<result property="updateBy" column="updated_by" />
|
|
<result property="remark" column="remark" />
|
|
<result property="deptId" column="dept_id" />
|
|
<result property="verificationStatus" column="verification_status"/>
|
|
</resultMap>
|
|
|
|
<sql id="selectEmployeeInfoVo">
|
|
select e.employee_id, e.employee_number, e.employee_name, e.id_card_number, e.position, e.department,
|
|
e.salary_unit, e.hourly_salary, e.daily_salary, e.monthly_salary, e.employee_status,
|
|
e.hire_date, e.contact_phone, e.library_id, e.is_temporary, e.create_time, e.update_time,
|
|
e.created_by, e.updated_by, e.remark, e.dept_id,
|
|
qr.verification_status
|
|
from dc_employee_info e
|
|
left join (
|
|
select employee_id, verification_status
|
|
from dc_employee_qr_code
|
|
where (employee_id, generate_time) in (
|
|
select employee_id, max(generate_time) from dc_employee_qr_code group by employee_id
|
|
)
|
|
) qr on e.employee_id = qr.employee_id
|
|
</sql>
|
|
|
|
<select id="selectEmployeeInfoList" parameterType="EmployeeInfo" resultMap="EmployeeInfoResult">
|
|
<include refid="selectEmployeeInfoVo"/>
|
|
<where>
|
|
<if test="employeeNumber != null and employeeNumber != ''"> and e.employee_number like concat('%', #{employeeNumber}, '%')</if>
|
|
<if test="employeeName != null and employeeName != ''"> and e.employee_name like concat('%', #{employeeName}, '%')</if>
|
|
<if test="idCardNumber != null and idCardNumber != ''"> and e.id_card_number like concat('%', #{idCardNumber}, '%')</if>
|
|
<if test="position != null and position != ''"> and e.position = #{position}</if>
|
|
<if test="department != null and department != ''"> and e.department = #{department}</if>
|
|
<if test="salaryUnit != null and salaryUnit != ''"> and e.salary_unit = #{salaryUnit}</if>
|
|
<if test="employeeStatus != null and employeeStatus != ''"> and e.employee_status = #{employeeStatus}</if>
|
|
<if test="hireDate != null "> and e.hire_date = #{hireDate}</if>
|
|
<if test="libraryId != null "> and e.library_id = #{libraryId}</if>
|
|
<if test="isTemporary != null "> and e.is_temporary = #{isTemporary}</if>
|
|
<if test="params.beginTime != null and params.beginTime != ''">
|
|
and date_format(e.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
|
</if>
|
|
<if test="params.endTime != null and params.endTime != ''">
|
|
and date_format(e.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
|
</if>
|
|
</where>
|
|
order by e.create_time desc
|
|
</select>
|
|
|
|
<select id="selectEmployeeInfoByEmployeeId" parameterType="Long" resultMap="EmployeeInfoResult">
|
|
<include refid="selectEmployeeInfoVo"/>
|
|
where e.employee_id = #{employeeId}
|
|
</select>
|
|
|
|
<select id="selectEmployeeInfoByEmployeeNumber" parameterType="String" resultMap="EmployeeInfoResult">
|
|
<include refid="selectEmployeeInfoVo"/>
|
|
where e.employee_number = #{employeeNumber}
|
|
</select>
|
|
|
|
<select id="selectEmployeeInfosByLibraryId" parameterType="Long" resultMap="EmployeeInfoResult">
|
|
<include refid="selectEmployeeInfoVo"/>
|
|
where e.library_id = #{libraryId}
|
|
order by e.create_time desc
|
|
</select>
|
|
|
|
<select id="selectEmployeeInfosByPosition" parameterType="String" resultMap="EmployeeInfoResult">
|
|
<include refid="selectEmployeeInfoVo"/>
|
|
where e.position = #{position}
|
|
order by e.create_time desc
|
|
</select>
|
|
|
|
<select id="countEmployeesByLibraryId" parameterType="Long" resultType="int">
|
|
select count(*) from dc_employee_info where library_id = #{libraryId}
|
|
</select>
|
|
|
|
<select id="getMaxEmployeeNumberByLibraryId" parameterType="Long" resultType="int">
|
|
select COALESCE(MAX(CAST(SUBSTRING(employee_number, LENGTH(CAST(#{libraryId} AS CHAR)) + 1) AS UNSIGNED)), 0)
|
|
from dc_employee_info
|
|
where library_id = #{libraryId}
|
|
and employee_number REGEXP CONCAT('^', #{libraryId}, '[0-9]+$')
|
|
</select>
|
|
|
|
<insert id="insertEmployeeInfo" parameterType="EmployeeInfo" useGeneratedKeys="true" keyProperty="employeeId">
|
|
insert into dc_employee_info
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="employeeNumber != null and employeeNumber != ''">employee_number,</if>
|
|
<if test="employeeName != null and employeeName != ''">employee_name,</if>
|
|
<if test="idCardNumber != null and idCardNumber != ''">id_card_number,</if>
|
|
<if test="position != null">position,</if>
|
|
<if test="department != null">department,</if>
|
|
<if test="salaryUnit != null">salary_unit,</if>
|
|
<if test="hourlySalary != null">hourly_salary,</if>
|
|
<if test="dailySalary != null">daily_salary,</if>
|
|
<if test="monthlySalary != null">monthly_salary,</if>
|
|
<if test="employeeStatus != null and employeeStatus != ''">employee_status,</if>
|
|
<if test="hireDate != null">hire_date,</if>
|
|
<if test="contactPhone != null">contact_phone,</if>
|
|
<if test="libraryId != null">library_id,</if>
|
|
<if test="isTemporary != null">is_temporary,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="createBy != null">created_by,</if>
|
|
<if test="updateBy != null">updated_by,</if>
|
|
<if test="remark != null">remark,</if>
|
|
<if test="deptId != null">dept_id,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="employeeNumber != null and employeeNumber != ''">#{employeeNumber},</if>
|
|
<if test="employeeName != null and employeeName != ''">#{employeeName},</if>
|
|
<if test="idCardNumber != null and idCardNumber != ''">#{idCardNumber},</if>
|
|
<if test="position != null">#{position},</if>
|
|
<if test="department != null">#{department},</if>
|
|
<if test="salaryUnit != null">#{salaryUnit},</if>
|
|
<if test="hourlySalary != null">#{hourlySalary},</if>
|
|
<if test="dailySalary != null">#{dailySalary},</if>
|
|
<if test="monthlySalary != null">#{monthlySalary},</if>
|
|
<if test="employeeStatus != null and employeeStatus != ''">#{employeeStatus},</if>
|
|
<if test="hireDate != null">#{hireDate},</if>
|
|
<if test="contactPhone != null">#{contactPhone},</if>
|
|
<if test="libraryId != null">#{libraryId},</if>
|
|
<if test="isTemporary != null">#{isTemporary},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
<if test="deptId != null">#{deptId},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateEmployeeInfo" parameterType="EmployeeInfo">
|
|
update dc_employee_info
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="employeeNumber != null and employeeNumber != ''">employee_number = #{employeeNumber},</if>
|
|
<if test="employeeName != null and employeeName != ''">employee_name = #{employeeName},</if>
|
|
<if test="idCardNumber != null and idCardNumber != ''">id_card_number = #{idCardNumber},</if>
|
|
<if test="position != null">position = #{position},</if>
|
|
<if test="department != null">department = #{department},</if>
|
|
<if test="salaryUnit != null">salary_unit = #{salaryUnit},</if>
|
|
<!-- 薪资字段允许设置为null来清空 -->
|
|
hourly_salary = #{hourlySalary},
|
|
daily_salary = #{dailySalary},
|
|
monthly_salary = #{monthlySalary},
|
|
<if test="employeeStatus != null and employeeStatus != ''">employee_status = #{employeeStatus},</if>
|
|
<if test="hireDate != null">hire_date = #{hireDate},</if>
|
|
<if test="contactPhone != null">contact_phone = #{contactPhone},</if>
|
|
<if test="libraryId != null">library_id = #{libraryId},</if>
|
|
<if test="isTemporary != null">is_temporary = #{isTemporary},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="updateBy != null">updated_by = #{updateBy},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
<if test="deptId != null">dept_id = #{deptId},</if>
|
|
</trim>
|
|
where employee_id = #{employeeId}
|
|
</update>
|
|
|
|
<delete id="deleteEmployeeInfoByEmployeeId" parameterType="Long">
|
|
delete from dc_employee_info where employee_id = #{employeeId}
|
|
</delete>
|
|
|
|
<delete id="deleteEmployeeInfoByEmployeeIds" parameterType="String">
|
|
delete from dc_employee_info where employee_id in
|
|
<foreach item="employeeId" collection="array" open="(" separator="," close=")">
|
|
#{employeeId}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<insert id="batchInsertEmployeeInfo" parameterType="java.util.List">
|
|
insert into dc_employee_info (employee_number, employee_name, id_card_number, position, department, salary_unit, hourly_salary, daily_salary, monthly_salary, employee_status, hire_date, contact_phone, library_id, is_temporary, create_time, created_by, dept_id)
|
|
values
|
|
<foreach collection="list" item="item" separator=",">
|
|
(#{item.employeeNumber}, #{item.employeeName}, #{item.idCardNumber}, #{item.position}, #{item.department}, #{item.salaryUnit}, #{item.hourlySalary}, #{item.dailySalary}, #{item.monthlySalary}, #{item.employeeStatus}, #{item.hireDate}, #{item.contactPhone}, #{item.libraryId}, #{item.isTemporary}, #{item.createTime}, #{item.createBy}, #{item.deptId})
|
|
</foreach>
|
|
</insert>
|
|
|
|
</mapper> |