From 07794736f879adb9cf02a69e5c6ada6a94b7bbde Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Mon, 06 Nov 2023 14:10:58 +0800
Subject: [PATCH] 考试报名查询修改,分新报名和考试未通过

---
 src/main/java/org/springblade/modules/system/mapper/UserMapper.xml |  104 +++++++++++++++++++++++++++-------------------------
 1 files changed, 54 insertions(+), 50 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 80dfff4..10ff25f 100644
--- a/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
+++ b/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -127,8 +127,11 @@
         <if test="user.roleAlias!=null and user.roleAlias != ''">
             and br.role_alias = '保安'
         </if>
-        <if test="user.status!=null and user.status != '' and user.status != 6">
+        <if test="user.status!=null and user.status != 6">
             and bu.status = #{user.status}
+        </if>
+        <if test="user.isFreeze!=null">
+            and bu.is_freeze = #{user.isFreeze}
         </if>
         <if test="user.education!=null  and user.education != ''">
             and bu.education = #{user.education}
@@ -244,6 +247,9 @@
             <if test="user.account!=null and user.account != ''">
                 and bu.account like concat('%', #{user.account},'%')
             </if>
+            <if test="user.isFreeze!=null">
+                and bu.is_freeze = #{user.isFreeze}
+            </if>
             <if test="user.hold!=null and user.hold != ''">
                 and bu.hold = #{user.hold}
             </if>
@@ -356,6 +362,9 @@
         </if>
         <if test="user.account!=null and user.account != ''">
             and account like concat('%', #{user.account},'%')
+        </if>
+        <if test="user.isFreeze!=null">
+            and bu.is_freeze = #{user.isFreeze}
         </if>
         <if test="user.roleId!=null and user.roleId != ''">
             and (br.role_alias = '公安管理员' or br.role_alias = '民警')
@@ -483,6 +492,9 @@
         <if test="user.sex!=null and user.sex != ''">
             and bu.sex = #{user.sex}
         </if>
+        <if test="user.isFreeze!=null">
+            and bu.is_freeze = #{user.isFreeze}
+        </if>
         <if test="user.dispatch!=null and user.dispatch != ''">
             <if test="user.dispatch==1">
                 and (bu.dispatch = #{user.dispatch} or bu.dispatch is null)
@@ -537,6 +549,9 @@
         <if test="user.roleId!=null and user.roleId != ''">
             and bu.role_id = #{user.roleId}
         </if>
+        <if test="user.isFreeze!=null">
+            and bu.is_freeze = #{user.isFreeze}
+        </if>
         <if test="user.status!=null and user.status != ''">
             and bu.status = #{user.status}
         </if>
@@ -558,55 +573,40 @@
 
     <!--保安员列表树 安员列表树,帅选无保安证,下拉tree-->
     <select id="getSecurityApplyTree" resultType="org.springblade.modules.system.node.TreeNode">
-        (
-            select #{user.deptId} as id,
-                '全部' as name,
-                0 as parentId
-                from blade_user
-        )
-
-        union all
-
-        (
+        select
+        a.id,
+        a.name,
+        a.type,
+        a.parentId
+        from (
             select
-            a.id,
-            a.name,
-            a.parentId
-            from (
-                select
-                    distinct
-                    bu.id,
-                    ifnull(TIMESTAMPDIFF(YEAR, SUBSTRING(bu.cardid, 7, 8), CURDATE()),0) AS age,
-                    bu.is_apply isApply,
-                    bu.is_train isTrain,
-                    bu.real_name as name,
-                    #{user.deptId} parentId
-                from
-                    blade_user bu
-                left join
-                blade_dept bd
-                on
-                bu.dept_id = bd.id
-                left join
-                blade_role br
-                on
-                br.id = bu.role_id
-                where
-                bu.is_deleted = 0
-                and bu.status = 1
-                and (bu.examination_type != 1 or bu.examination_type is null)
-                and (hold = 2 or hold = 3)
-                and bd.id = #{user.deptId}
-                and br.role_alias = '保安'
-            ) a
-            where 1 = 1
-            <if test="user.examType==1">
-                and a.isApply != 1
-            </if>
-            <if test="user.examType==2">
-                and a.isTrain != 1
-            </if>
-        )
+                distinct
+                bu.id,
+                ifnull(TIMESTAMPDIFF(YEAR, SUBSTRING(bu.cardid, 7, 8), CURDATE()),0) AS age,
+                bu.is_apply isApply,
+                bu.is_train isTrain,
+                bu.real_name as name,
+                if(es.user_id is not null,1,2) as type,
+                #{user.deptId} parentId
+            from blade_user bu
+            left join blade_dept bd on bu.dept_id = bd.id
+            left join blade_role br on br.id = bu.role_id
+            left join (select user_id,max(id) from exam_score where (qualified =1 or qualified =3) GROUP BY user_id) es
+            on es.user_id = bu.id
+            where
+            bu.is_deleted = 0 and bu.status = 1 and bu.is_freeze = 0
+            and (bu.examination_type != 1 or bu.examination_type is null)
+            and (hold = 2 or hold = 3)
+            and bd.id = #{user.deptId}
+            and br.role_alias = '保安'
+        ) a
+        where 1 = 1
+        <if test="user.examType==1">
+            and a.isApply != 1
+        </if>
+        <if test="user.examType==2">
+            and a.isTrain != 1
+        </if>
     </select>
 
 
@@ -673,6 +673,7 @@
         </if>
         and bu.status = 1
         and bu.is_deleted = 0
+        and bu.is_freeze = 0
     </select>
 
 
@@ -918,6 +919,9 @@
         <if test="user.isAvatar==2">
             and (bu.avatar is null or bu.avatar="")
         </if>
+        <if test="user.isFreeze!=null">
+            and bu.is_freeze = #{user.isFreeze}
+        </if>
         <if test="user.unitName!=null and user.unitName != ''">
             and bu.unit_name like concat('%', #{user.unitName},'%')
         </if>
@@ -1149,7 +1153,7 @@
 
     <!--用户冻结操作-->
     <update id="updateFreeze">
-        update blade_user set is_deleted = 1
+        update blade_user set is_freeze = 1
         <choose>
             <when test="list!=null and list.size()>0">
                 where id in

--
Gitblit v1.9.3