maven
2 天以前 577fd97c572af76ac2464543e74e7edc2c35ffa0
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?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.StaffLeaveMapper">
    <select id="staffLeaveListPage" resultType="com.ruoyi.staff.dto.StaffLeaveDto">
        SELECT
        staff_leave.*,
        soj.staff_name as staffName,
        soj.staff_state as staffState,
        soj.staff_no as staffNo,
        soj.sex as sex,
        soj.native_place as nativePlace,
        soj.adress as adress,
        soj.first_study as firstStudy,
        soj.profession as profession,
        soj.identity_card as identityCard,
        soj.age as age,
        soj.phone as phone,
        soj.emergency_contact as emergencyContact,
        soj.emergency_contact_phone as emergencyContactPhone,
        sp.post_name as postName,
        sd.dept_name as deptName
        FROM staff_leave
        LEFT JOIN
        staff_on_job soj ON soj.id = staff_leave.staff_on_job_id
        LEFT JOIN
        sys_post sp ON sp.post_id = soj.sys_post_id
        LEFT JOIN
        sys_dept sd ON sd.dept_id = soj.sys_dept_id
        where 1=1
        <if test="c.staffName != null and c.staffName != '' ">
            AND soj.staff_name LIKE CONCAT('%',#{c.staffName},'%')
        </if>
    </select>
    <select id="staffLeaveList" resultType="com.ruoyi.staff.dto.StaffLeaveDto">
        SELECT
        staff_leave.*,
        soj.staff_name as staffName,
        soj.staff_state as staffState,
        soj.staff_no as staffNo,
        soj.sex as sex,
        soj.native_place as nativePlace,
        soj.adress as adress,
        soj.first_study as firstStudy,
        soj.profession as profession,
        soj.identity_card as identityCard,
        soj.age as age,
        soj.phone as phone,
        soj.emergency_contact as emergencyContact,
        soj.emergency_contact_phone as emergencyContactPhone,
        sp.post_name as postName,
        sd.dept_name as deptName
        FROM staff_leave
        LEFT JOIN
        staff_on_job soj ON soj.id = staff_leave.staff_on_job_id
        LEFT JOIN
        sys_post sp ON sp.post_id = soj.sys_post_id
        LEFT JOIN
        sys_dept sd ON sd.dept_id = soj.sys_dept_id
        where 1=1
        <if test="c.staffName != null and c.staffName != '' ">
            AND soj.staff_name LIKE CONCAT('%',#{c.staffName},'%')
        </if>
    </select>
 
    <select id="staffLeaveReasonAnalytics" resultType="com.ruoyi.staff.dto.StaffLeaveDto">
        SELECT
        staff_leave.reason as reason,
        COUNT(*) as count
        FROM staff_leave
        LEFT JOIN
        staff_on_job soj ON soj.id = staff_leave.staff_on_job_id
        where 1=1
        GROUP BY staff_leave.reason
    </select>
 
    <!-- 统计指定月份的离职员工数 -->
    <select id="countLeaveByMonth" resultType="java.lang.Integer">
        SELECT COUNT(*)
        FROM staff_leave sl
        LEFT JOIN staff_on_job soj ON sl.staff_on_job_id = soj.id
        WHERE DATE_FORMAT(sl.create_time, '%Y-%m-%d') BETWEEN #{monthStart} AND #{monthEnd}
        AND soj.staff_state = 0
    </select>
</mapper>