From 9529220c815bfe6e43c992fde2f392be823450eb Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期二, 11 十一月 2025 20:27:33 +0800
Subject: [PATCH] feat:增加天地图接口,并增加车辆GPS统计

---
 ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml |   83 ++++++++++++++++++++++-------------------
 1 files changed, 45 insertions(+), 38 deletions(-)

diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
index 03654d9..3f59bac 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -81,44 +81,11 @@
 			AND date_format(u.create_time,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
 		</if>
 		<if test="deptId != null and deptId != 0">
-			<![CDATA[
-			AND u.dept_id IN (
-				-- 鏌ヨ鐢ㄦ埛鎵�灞炲垎鍏徃鍙婂叾鎵�鏈夊瓙閮ㄩ棬
-				SELECT t.dept_id FROM sys_dept t 
-				WHERE t.del_flag = '0' AND (
-					-- 鎯呭喌1锛氫紶鍏ョ殑閮ㄩ棬灏辨槸鍒嗗叕鍙�(parent_id=100)
-					(t.dept_id = ]]>#{deptId}<![CDATA[ AND EXISTS (
-						SELECT 1 FROM sys_dept d WHERE d.dept_id = ]]>#{deptId}<![CDATA[ AND d.parent_id = 100
-					))
-					OR
-					-- 鏌ヨ璇ュ垎鍏徃鐨勬墍鏈夊瓙閮ㄩ棬
-					(find_in_set(
-						(SELECT d.dept_id FROM sys_dept d WHERE d.dept_id = ]]>#{deptId}<![CDATA[ AND d.parent_id = 100),
-						t.ancestors
-					) > 0)
-					OR
-					-- 鎯呭喌2锛氫紶鍏ョ殑鏄瓙閮ㄩ棬锛屾壘鍒板叾鎵�灞炲垎鍏徃
-					(t.dept_id IN (
-						SELECT branch.dept_id FROM sys_dept branch
-						WHERE branch.parent_id = 100
-						  AND find_in_set(branch.dept_id, (
-							SELECT sub.ancestors FROM sys_dept sub WHERE sub.dept_id = ]]>#{deptId}<![CDATA[
-						  )) > 0
-					))
-					OR
-					-- 鏌ヨ璇ュ垎鍏徃鐨勬墍鏈夊瓙閮ㄩ棬
-					(find_in_set(
-						(SELECT branch.dept_id FROM sys_dept branch
-						 WHERE branch.parent_id = 100
-						   AND find_in_set(branch.dept_id, (
-							 SELECT sub.ancestors FROM sys_dept sub WHERE sub.dept_id = ]]>#{deptId}<![CDATA[
-						   )) > 0
-						),
-						t.ancestors
-					) > 0)
-				)
-			)
-			]]>
+			-- 鏌ヨ鎸囧畾閮ㄩ棬鍙婂叾鎵�鏈夊瓙閮ㄩ棬鐨勭敤鎴�
+			AND (u.dept_id = #{deptId} OR u.dept_id IN (
+				SELECT dept_id FROM sys_dept
+				WHERE del_flag = '0' AND find_in_set(#{deptId}, ancestors) > 0
+			))
 		</if>
 		<!-- 鏁版嵁鑼冨洿杩囨护 -->
 		${params.dataScope}
@@ -234,6 +201,9 @@
  			<if test="status != null and status != ''">status = #{status},</if>
  			<if test="oaUserId != null">oa_user_id = #{oaUserId},</if>
  			<if test="oaOrderClass != null">oa_order_class = #{oaOrderClass},</if>
+ 			<if test="openId != null and openId != ''">open_id = #{openId},</if>
+ 			<if test="unionId != null and unionId != ''">union_id = #{unionId},</if>
+ 			<if test="wechatNickname != null and wechatNickname != ''">wechat_nickname = #{wechatNickname},</if>
  			<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
  			<if test="loginDate != null">login_date = #{loginDate},</if>
  			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
@@ -274,4 +244,41 @@
 		limit 1
 	</select>
 	
+	<!-- 閫氳繃寰俊OpenID鏌ヨ鐢ㄦ埛 -->
+	<select id="selectUserByOpenId" parameterType="String" resultMap="SysUserResult">
+		<include refid="selectUserVo"/>
+		where u.open_id = #{openId} and u.del_flag = '0'
+	</select>
+	
+	<!-- 鏍规嵁鍒嗗叕鍙窱D鍒楄〃鏌ヨ鐢ㄦ埛锛堝寘鍚垎鍏徃鍙婂叾鎵�鏈夊瓙閮ㄩ棬鐨勭敤鎴凤級 -->
+	<select id="selectUsersByBranchDeptIds" resultMap="SysUserResult">
+		SELECT DISTINCT
+			u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, 
+			u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.create_time,
+			d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
+			r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
+		FROM sys_user u
+		LEFT JOIN sys_dept d ON u.dept_id = d.dept_id
+		LEFT JOIN sys_user_role ur ON u.user_id = ur.user_id
+		LEFT JOIN sys_role r ON r.role_id = ur.role_id
+		WHERE u.del_flag = '0'
+			AND u.status = '0'
+			AND u.dept_id IN (				
+				SELECT t.dept_id 
+				FROM sys_dept t
+				WHERE t.del_flag = '0' 
+					AND (						
+						t.dept_id IN
+						<foreach collection="branchDeptIds" item="deptId" open="(" separator="," close=")">
+							#{deptId}
+						</foreach>
+						OR						
+						<foreach collection="branchDeptIds" item="deptId" open="(" separator=" OR " close=")">
+							find_in_set(#{deptId}, t.ancestors) > 0
+						</foreach>
+					)
+			)
+		ORDER BY u.create_time DESC
+	</select>
+	
 </mapper> 
\ No newline at end of file

--
Gitblit v1.9.1