chenhj
7 天以前 a2d1636333fc785f84de829a096f0aa210560102
src/main/resources/mapper/staff/StaffLeaveMapper.xml
@@ -17,12 +17,15 @@
        soj.phone as phone,
        soj.emergency_contact as emergencyContact,
        soj.emergency_contact_phone as emergencyContactPhone,
        sp.post_name as postName
        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},'%')
@@ -44,15 +47,38 @@
        soj.phone as phone,
        soj.emergency_contact as emergencyContact,
        soj.emergency_contact_phone as emergencyContactPhone,
        sp.post_name as postName
        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>