From 559b2e34c983f615b6d6747f52c801022c561803 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期一, 27 十月 2025 23:05:08 +0800
Subject: [PATCH] feat: 优化任务显示列表

---
 ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
index 2d8e21a..aa40711 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
@@ -45,8 +45,13 @@
 		<if test="status != null and status != ''">
 			AND status = #{status}
 		</if>
-		<!-- 鏁版嵁鑼冨洿杩囨护 -->
-		${params.dataScope}
+		<if test="serviceOrderClass != null and serviceOrderClass != ''">
+			AND service_order_class = #{serviceOrderClass}
+		</if>
+		<if test="dispatchOrderClass != null and dispatchOrderClass != ''">
+			AND dispatch_order_class = #{dispatchOrderClass}
+		</if>
+
 		order by d.parent_id, d.order_num
     </select>
     
@@ -184,4 +189,24 @@
 		limit 1
 	</select>
 
+	<!-- 鑾峰彇鎸囧畾閮ㄩ棬ID鐨勫垎鍏徃ID锛坧arent_id=100鐨勯儴闂級 -->
+	<select id="selectBranchCompanyIdByDeptId" parameterType="Long" resultType="Long">
+		select case 
+			-- 濡傛灉浼犲叆鐨勫氨鏄垎鍏徃锛坧arent_id=100锛夛紝鐩存帴杩斿洖
+			when exists(select 1 from sys_dept where dept_id = #{deptId} and parent_id = 100 and del_flag = '0') 
+			then #{deptId}
+			else (
+				-- 鍚﹀垯浠� ancestors 涓煡鎵惧垎鍏徃ID
+				select d.dept_id
+				from sys_dept d
+				where d.parent_id = 100
+				and d.del_flag = '0'
+				and FIND_IN_SET(d.dept_id, (
+					select ancestors from sys_dept where dept_id = #{deptId} and del_flag = '0'
+				))
+				limit 1
+			)
+		end
+	</select>
+
 </mapper> 
\ No newline at end of file

--
Gitblit v1.9.1