maven
2025-11-19 72a372cb26c4ba489efae6b65dbf9fdfea1b5815
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?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.staff.mapper.StaffJoinLeaveRecordMapper">
    <select id="staffJoinLeaveRecordListPage" resultType="com.ruoyi.staff.pojo.StaffJoinLeaveRecord">
        SELECT
        t1.*,
        t2.name as deptPositionName
        FROM staff_join_leave_record t1
        left join dept_position  t2 on t1.dept_position_id = t2.id and t2.type = 2
        where
        staff_state = #{staffJoinLeaveRecord.staffState}
        <if test="staffJoinLeaveRecord.staffName != null and staffJoinLeaveRecord.staffName != '' ">
            AND t1.staff_name LIKE CONCAT('%',#{staffJoinLeaveRecord.staffName},'%')
        </if>
        <if test="staffJoinLeaveRecord.entryDateStart != null and staffJoinLeaveRecord.entryDateStart != '' ">
            and t1.contract_start_time like concat('%',#{staffJoinLeaveRecord.entryDateStart},'%')
        </if>
        <if test="staffJoinLeaveRecord.entryDateEnd != null and staffJoinLeaveRecord.entryDateEnd != '' ">
            and t1.contract_end_time like concat('%',#{staffJoinLeaveRecord.entryDateEnd},'%')
        </if>
        order by t1.create_time desc
    </select>
    <select id="staffJoinLeaveRecordList" resultType="com.ruoyi.staff.pojo.StaffJoinLeaveRecord">
        SELECT
        *
        FROM staff_join_leave_record
        where
        staff_state = #{staffJoinLeaveRecord.staffState}
        <if test="staffJoinLeaveRecord.staffName != null and staffJoinLeaveRecord.staffName != '' ">
            AND staff_name LIKE CONCAT('%',#{staffJoinLeaveRecord.staffName},'%')
        </if>
    </select>
    <select id="staffOnJobList" resultType="com.ruoyi.staff.pojo.StaffJoinLeaveRecord">
        select *
        from (select *,
                     ROW_NUMBER() over (PARTITION BY staff_no ORDER BY create_time DESC ) as rn
              from staff_join_leave_record
              where staff_state = 1) t
        where rn = 1
 
    </select>
</mapper>