From aa6fd3986a72524dea1547f2b1cce85ea71228bd Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Thu, 19 Oct 2023 17:16:31 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/jtdev' into jtdev

---
 skjcmanager/skjcmanager-service/skjcmanager-user/src/main/java/cn/gistack/system/user/mapper/UserMapper.xml |   81 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 72 insertions(+), 9 deletions(-)

diff --git a/skjcmanager/skjcmanager-service/skjcmanager-user/src/main/java/cn/gistack/system/user/mapper/UserMapper.xml b/skjcmanager/skjcmanager-service/skjcmanager-user/src/main/java/cn/gistack/system/user/mapper/UserMapper.xml
index 7bca0b4..ae3e54f 100644
--- a/skjcmanager/skjcmanager-service/skjcmanager-user/src/main/java/cn/gistack/system/user/mapper/UserMapper.xml
+++ b/skjcmanager/skjcmanager-service/skjcmanager-user/src/main/java/cn/gistack/system/user/mapper/UserMapper.xml
@@ -27,24 +27,33 @@
         <result column="post_id" property="postId"/>
     </resultMap>
 
-    <select id="selectUserPage" resultMap="userResultMap">
-        select * from blade_user where is_deleted = 0
+    <select id="selectUserPage" resultType="cn.gistack.system.user.vo.UserVO">
+        select bu.*,armp.jobName from blade_user bu
+        left join (
+            select "user_phone" as userPhone,CONCAT_WS('-',"user_unit","position") jobName from SJZT_MD."att_res_manage_person" where "guid" in (
+                select max("guid") as guid from SJZT_MD."att_res_manage_person" group by "user_phone"
+            )
+        ) armp on bu.phone = armp.userPhone
+        where bu.is_deleted = 0
         <if test="tenantId!=null and tenantId != ''">
-            and tenant_id = #{tenantId}
+            and bu.tenant_id = #{tenantId}
         </if>
         <if test="user.tenantId!=null and user.tenantId != ''">
-            and tenant_id = #{user.tenantId}
+            and bu.tenant_id = #{user.tenantId}
         </if>
         <if test="user.account!=null and user.account != ''">
-            and account = #{user.account}
+            and bu.account like concat('%',#{user.account},'%')
         </if>
         <if test="user.realName!=null and user.realName != ''">
-            and real_name = #{user.realName}
+            and bu.real_name like concat(concat('%',#{user.realName}),'%')
         </if>
         <if test="user.userType!=null and user.userType != ''">
-            and user_type = #{user.userType}
+            and bu.user_type = #{user.userType}
         </if>
-        <if test="deptIdList!=null and deptIdList.size>0">
+        <if test="user.roleId!=null and user.roleId != ''">
+            and bu.role_id like concat('%',#{user.roleId},'%')
+        </if>
+        <if test="deptIdList!=null and deptIdList.size()>0">
             and id in (
             SELECT
             user_id
@@ -57,7 +66,49 @@
             </foreach>
             )
         </if>
-        ORDER BY id
+        ORDER BY bu.id
+    </select>
+
+    <select id="getAllUser" resultType="cn.gistack.system.user.vo.UserVO">
+        select bu.*,armp.jobName from blade_user bu
+        left join (
+        select "user_phone" as userPhone,CONCAT_WS('-',"user_unit","position") jobName from SJZT_MD."att_res_manage_person" where "guid" in (
+        select max("guid") as guid from SJZT_MD."att_res_manage_person" group by "user_phone"
+        )
+        ) armp on bu.phone = armp.userPhone
+        where bu.is_deleted = 0
+        <if test="tenantId!=null and tenantId != ''">
+            and bu.tenant_id = #{tenantId}
+        </if>
+        <if test="user.tenantId!=null and user.tenantId != ''">
+            and bu.tenant_id = #{user.tenantId}
+        </if>
+        <if test="user.account!=null and user.account != ''">
+            and bu.account = #{user.account}
+        </if>
+        <if test="user.realName!=null and user.realName != ''">
+            and bu.real_name like concat(concat('%',#{user.realName}),'%')
+        </if>
+        <if test="user.userType!=null and user.userType != ''">
+            and bu.user_type = #{user.userType}
+        </if>
+        <if test="user.roleId!=null and user.roleId != ''">
+            and bu.role_id like concat('%',#{user.roleId},'%')
+        </if>
+        <if test="deptIdList!=null and deptIdList.size()>0">
+            and id in (
+            SELECT
+            user_id
+            FROM
+            blade_user_dept
+            WHERE
+            dept_id IN
+            <foreach collection="deptIdList" index="index" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+            )
+        </if>
+        ORDER BY bu.id
     </select>
 
     <select id="getUser" resultMap="userResultMap">
@@ -78,4 +129,16 @@
         where D.AD_CODE = #{user.adCode} and U.ROLE_ID like CONCAT('%',(select id from BLADE_ROLE where ROLE_ALIAS = 'qxgly'),'%')
     </select>
 
+    <!--根据手机号码或者账户查询用户信息-->
+    <select id="selectUserByPhoneOrAccount" resultType="cn.gistack.system.user.entity.User">
+        select * from BLADE_USER where is_deleted = 0
+        and TENANT_ID = #{tenantId}
+        and (ACCOUNT = #{key} or PHONE = #{key})
+    </select>
+    <select id="getUserByPhoneIds" resultType="cn.gistack.system.user.entity.User">
+        SELECT * FROM BLADE_USER
+        WHERE IS_DELETED = 0 AND PHONE LIKE CONCAT('%',#{phoneIds},'%')
+    </select>
+
+
 </mapper>

--
Gitblit v1.9.3