From f714d9c0738f54d3212fe933a4a816f87aac76e2 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 29 五月 2026 13:48:33 +0800
Subject: [PATCH] feat: 添加日期处理以及定义objectMapper

---
 src/main/resources/mapper/staff/StaffLeaveMapper.xml |   50 +++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/src/main/resources/mapper/staff/StaffLeaveMapper.xml b/src/main/resources/mapper/staff/StaffLeaveMapper.xml
index c3faf41..fef5c81 100644
--- a/src/main/resources/mapper/staff/StaffLeaveMapper.xml
+++ b/src/main/resources/mapper/staff/StaffLeaveMapper.xml
@@ -18,18 +18,24 @@
         soj.emergency_contact as emergencyContact,
         soj.emergency_contact_phone as emergencyContactPhone,
         sp.post_name as postName,
-        sd.dept_name as deptName
+        sd.dept_name as deptName,
+        se.education as first_study,
+        se.major as profession
         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
+        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
+        LEFT JOIN staff_education se ON se.staff_on_job_id = staff_leave.staff_on_job_id
+        AND se.id = (
+        SELECT MAX(se2.id)
+        FROM staff_education se2
+        WHERE se2.staff_on_job_id = staff_leave.staff_on_job_id
+        )
+        WHERE 1=1
         <if test="c.staffName != null and c.staffName != '' ">
             AND soj.staff_name LIKE CONCAT('%',#{c.staffName},'%')
         </if>
+        order by staff_leave.create_time desc
     </select>
     <select id="staffLeaveList" resultType="com.ruoyi.staff.dto.StaffLeaveDto">
         SELECT
@@ -56,9 +62,31 @@
         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>
+            <if test="c.staffName != null and c.staffName != '' ">
+                AND soj.staff_name LIKE CONCAT('%',#{c.staffName},'%')
+            </if>
+        </where>
+        order by staff_leave.create_time desc
+    </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
-        <if test="c.staffName != null and c.staffName != '' ">
-            AND soj.staff_name LIKE CONCAT('%',#{c.staffName},'%')
-        </if>
+        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>

--
Gitblit v1.9.3