From eddc08aa2fa3402688ec8b4b24669ddd2e51bf86 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期五, 08 五月 2026 17:43:19 +0800
Subject: [PATCH] feat(staff): 添加民族字段及相关查询支持

---
 src/main/resources/mapper/staff/StaffLeaveMapper.xml |   34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/main/resources/mapper/staff/StaffLeaveMapper.xml b/src/main/resources/mapper/staff/StaffLeaveMapper.xml
index 1d43ecc..b1b55b4 100644
--- a/src/main/resources/mapper/staff/StaffLeaveMapper.xml
+++ b/src/main/resources/mapper/staff/StaffLeaveMapper.xml
@@ -9,6 +9,7 @@
         soj.staff_no as staffNo,
         soj.sex as sex,
         soj.native_place as nativePlace,
+        soj.nation as nation,
         soj.adress as adress,
         soj.first_study as firstStudy,
         soj.profession as profession,
@@ -17,15 +18,21 @@
         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>
+        <if test="c.nation != null and c.nation != '' ">
+            AND soj.nation = #{c.nation}
         </if>
     </select>
     <select id="staffLeaveList" resultType="com.ruoyi.staff.dto.StaffLeaveDto">
@@ -44,15 +51,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>

--
Gitblit v1.9.3