From 8d43111bd0e598bc0b2014cbfa69a32e74959dff Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Wed, 15 Dec 2021 19:24:05 +0800
Subject: [PATCH] ftp sql 同步封装

---
 src/main/java/org/springblade/modules/system/mapper/UserMapper.xml |  107 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 98 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml b/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
index fce225c..220ebc5 100644
--- a/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
+++ b/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -100,7 +100,25 @@
             and bu.hold = #{user.hold}
         </if>
         <if test="user.deptId!=null and user.deptId != ''">
-            and (bd.id = #{user.deptId} or bd.parent_id = #{user.deptId})
+            and bd.id in
+            (
+                select id from blade_dept where id = #{user.deptId}
+                union
+                SELECT
+                id
+                FROM
+                (
+                SELECT
+                t1.id,t1.parent_id,t1.dept_name,
+                IF
+                ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
+                FROM
+                ( SELECT id, parent_id,dept_name FROM blade_dept t ORDER BY parent_id, id ) t1,
+                ( SELECT @pids := #{user.deptId} ) t2
+                ) t3
+                WHERE
+                ischild != 0
+            )
         </if>
         <if test="user.roleId!=null and user.roleId != ''">
             and bu.role_id = #{user.roleId}
@@ -124,7 +142,12 @@
             and bu.real_name like concat('%', #{user.realName},'%')
         </if>
         <if test="user.dispatch!=null and user.dispatch != ''">
-            and bu.dispatch = #{user.dispatch}
+            <if test="user.dispatch == 0">
+                and bu.dispatch = #{user.dispatch}
+            </if>
+            <if test="user.dispatch == 1">
+                and bu.dispatch = #{user.dispatch}
+            </if>
         </if>
         <if test="user.userType!=null and user.userType != ''">
             and bu.user_type = #{user.userType}
@@ -166,7 +189,25 @@
             and real_name like concat(concat('%', #{user.realName}),'%')
         </if>
         <if test="user.deptId!=null and user.deptId != ''">
-            and (bd.id = #{user.deptId} or bd.parent_id = #{user.deptId})
+            and bd.id in
+            (
+                select id from blade_dept where id = #{user.deptId}
+                union
+                SELECT
+                id
+                FROM
+                (
+                SELECT
+                t1.id,t1.parent_id,t1.dept_name,
+                IF
+                ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
+                FROM
+                ( SELECT id, parent_id,dept_name FROM blade_dept t ORDER BY parent_id, id ) t1,
+                ( SELECT @pids := #{user.deptId} ) t2
+                ) t3
+                WHERE
+                ischild != 0
+            )
         </if>
         <if test="user.userType!=null and user.userType != ''">
             and user_type = #{user.userType}
@@ -275,6 +316,9 @@
         <if test="user.status!=null and user.status != ''">
             and bu.status = #{user.status}
         </if>
+        <if test="user.equipmentCode!=null">
+            and bu.equipment_code !="" and bu.equipment_code is not null and bu.equipment_code !=null
+        </if>
         <if test="user.jurisdiction!=null and user.jurisdiction != ''">
             and bu.jurisdiction = #{user.jurisdiction}
         </if>
@@ -374,13 +418,9 @@
             where 1 = 1
             <if test="user.examType==1">
                 and a.isApply != 1
-                and a.age&gt;=18
-                and a.age&lt;=60
             </if>
             <if test="user.examType==2">
                 and a.isTrain != 1
-                and a.age&gt;=18
-                and a.age&lt;=60
             </if>
         )
     </select>
@@ -647,6 +687,7 @@
     <!--导出保安员信息-->
     <select id="exportSecurityInfo" resultType="org.springblade.modules.system.excel.SecurityExcel">
         select
+        distinct bu.id,
         bd.dept_name deptId,
         bu.real_name realName,
         bu.phone,
@@ -695,7 +736,25 @@
             and bu.hold = #{user.hold}
         </if>
         <if test="user.deptId!=null and user.deptId != ''">
-            and (bd.id = #{user.deptId} or bd.parent_id = #{user.deptId})
+            and bd.id in
+            (
+                select id from blade_dept where id = #{user.deptId}
+                union
+                SELECT
+                id
+                FROM
+                (
+                SELECT
+                t1.id,t1.parent_id,t1.dept_name,
+                IF
+                ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
+                FROM
+                ( SELECT id, parent_id,dept_name FROM blade_dept t ORDER BY parent_id, id ) t1,
+                ( SELECT @pids := #{user.deptId} ) t2
+                ) t3
+                WHERE
+                ischild != 0
+            )
         </if>
         <if test="user.roleId!=null and user.roleId != ''">
             and bu.role_id = #{user.roleId}
@@ -733,6 +792,36 @@
         ORDER BY bu.id desc
     </select>
 
+    <!--查询押运人员编码不为null的保安信息-->
+    <select id="selectEquipent" resultType="java.util.HashMap">
+        SELECT id,
+               equipment_code as code
+        FROM blade_user
+        WHERE dept_id = '1460129345988239362'
+          AND role_id = '1412226235153731586'
+          AND is_deleted = 0
+          AND `status` = 1
+          AND equipment_code IS NOT NULL
+    </select>
 
-
+    <!--查詢用戶派遣記錄信息-->
+    <select id="getUserDispatcherInfo" resultType="org.springblade.modules.dispatcher.vo.DispatcherVO">
+        select
+        sdu.name dispatcherCompany,
+        dispatcherTime dispatchertime,
+        sd.end_time endTime
+        from blade_user bu
+        left join
+        sys_dispatcher sd
+        on
+        sd.user_ids = bu.id
+        left join
+        sys_dispatcher_unit sdu
+        on
+        sdu.id = sd.dispatcher_unit_id
+        where 1=1
+        and sd.status = 0
+        and bu.dispatch = 0
+        and bu.id = #{id}
+    </select>
 </mapper>

--
Gitblit v1.9.3