From 62eb499b0c969f246d3245d1429a97da4de1ce28 Mon Sep 17 00:00:00 2001
From: 钟日健 <arsn163@163.com>
Date: Mon, 01 Jun 2026 20:46:13 +0800
Subject: [PATCH] feat: 成绩查询增加年龄查询返回

---
 src/main/java/org/springblade/modules/system/mapper/UserMapper.xml |  252 +++++++++++++++++++++++++------------------------
 1 files changed, 128 insertions(+), 124 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 0f1148c..1c0698f 100644
--- a/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
+++ b/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -33,9 +33,6 @@
         <result column="height" property="height"/>
         <result column="cell" property="cell"/>
         <result column="emails" property="emails"/>
-        <result column="address" property="address"/>
-        <result column="registered" property="registered"/>
-        <result column="rtime" property="rtime"/>
         <result column="hold" property="hold"/>
         <result column="jurisdiction" property="jurisdiction"/>
         <result column="securitynumber" property="securitynumber"/>
@@ -48,6 +45,8 @@
         <result column="healstats" property="healstats"/>
         <result column="soil" property="soil"/>
         <result column="reason_for_leav" property="reasonForLeav"/>
+        <result column="accreditationStatus" property="accreditationStatus"/>
+        <result column="ancestors" property="ancestors"/>
     </resultMap>
 
     <!--带坐标-->
@@ -57,35 +56,32 @@
         bu.*,IF(mod(SUBSTR(bu.cardid,17,1),2),1,2) sexs,
         ifnull(TIMESTAMPDIFF(YEAR, SUBSTRING(bu.cardid, 7, 8), CURDATE()),0) AS age,
         sll.longitude,sll.latitude,
-        bd.dept_name
+        bud.unit_name,
+        bud.permanent_residence_address as registered,
+        bd.dept_name,
+        bd.ancestors,
+        CASE WHEN sar.audit_status is not null THEN sar.audit_status ELSE -1 END AS accreditationStatus
         from
         blade_user bu
-        left join
-        blade_dept bd
-        on
-        bu.dept_id = bd.id
-        left join
-        sys_information si
-        on
-        si.departmentid = bd.id
-        left join
-        sys_jurisdiction sj
-        on
-        sj.id = si.jurisdiction
-        left join
-        sys_live_location sll
-        on
-        sll.worker_id = bu.id
-        left join
-        blade_role br
-        on
-        br.id = bu.role_id
-        left join
-        sys_training_registration str
-        on
-        bu.id = str.user_id
-        where
-        bu.is_deleted = 0
+        left join blade_user_detail bud on bud.user_id = bu.id
+        left join blade_dept bd on bu.dept_id = bd.id
+        left join sys_information si on si.departmentid = bd.id
+        left join sys_jurisdiction sj on sj.id = si.jurisdiction
+        left join sys_live_location sll on sll.worker_id = bu.id
+        left join blade_role br on br.id = bu.role_id
+        left join sys_training_registration str on bu.id = str.user_id
+        LEFT JOIN sys_accreditation_records sar ON sar.user_id = bu.id
+        where bu.is_deleted = 0
+
+        <if test="user.accreditationStatus != null and user.accreditationStatus != ''">
+            <if test="user.accreditationStatus == -1">
+                AND sar.audit_status is null
+            </if>
+            <if test="user.accreditationStatus != -1">
+                AND sar.audit_status = #{user.accreditationStatus}
+            </if>
+        </if>
+
         <if test="user.examinationType!=null and user.examinationType != ''">
             <if test="user.examinationType == 0">
                 and (bu.examination_type = #{user.examinationType} or bu.examination_type is null or bu.examination_type ='')
@@ -123,6 +119,9 @@
         </if>
         <if test="user.roleId!=null and user.roleId != ''">
             and bu.role_id = #{user.roleId}
+        </if>
+        <if test="user.auditStatus != null and user.auditStatus != ''">
+            and bu.audit_status = #{user.auditStatus}
         </if>
         <if test="user.roleAlias!=null and user.roleAlias != ''">
             and br.role_alias = '保安'
@@ -187,7 +186,7 @@
             and bu.cardid like concat('%', #{user.cardid},'%')
         </if>
         <if test="user.unitName!=null and user.unitName != ''">
-            and bu.unit_name like concat('%', #{user.unitName},'%')
+            and bud.unit_name like concat('%', #{user.unitName},'%')
         </if>
         <if test="user.sortName!=null and user.sortName!=''">
             ORDER BY bu.${user.sortName} ${user.sort},bu.id desc
@@ -207,35 +206,18 @@
             bu.*,IF(mod(SUBSTR(bu.cardid,17,1),2),1,2) sexs,
             ifnull(TIMESTAMPDIFF(YEAR, SUBSTRING(bu.cardid, 7, 8), CURDATE()),0) AS age,
             sll.longitude,sll.latitude,
+            bud.unit_name,
             bd.dept_name
             from
             blade_user bu
-            left join
-            blade_dept bd
-            on
-            bu.dept_id = bd.id
-            left join
-            sys_information si
-            on
-            si.departmentid = bd.id
-            left join
-            sys_jurisdiction sj
-            on
-            sj.id = si.jurisdiction
-            left join
-            sys_live_location sll
-            on
-            sll.worker_id = bu.id
-            left join
-            blade_role br
-            on
-            br.id = bu.role_id
-            left join
-            sys_training_registration str
-            on
-            bu.id = str.user_id
-            where
-            bu.is_deleted = 0
+            left join blade_user_detail bud on bud.user_id = bu.id
+            left join blade_dept bd on bu.dept_id = bd.id
+            left join sys_information si on si.departmentid = bd.id
+            left join sys_jurisdiction sj on sj.id = si.jurisdiction
+            left join sys_live_location sll on sll.worker_id = bu.id
+            left join blade_role br on br.id = bu.role_id
+            left join sys_training_registration str on bu.id = str.user_id
+            where bu.is_deleted = 0
             <if test="user.examinationType!=null and user.examinationType != ''">
                 <if test="user.examinationType == 0">
                     and (bu.examination_type = #{user.examinationType} or bu.examination_type is null or bu.examination_type ='')
@@ -299,7 +281,7 @@
                 and bu.real_name like concat('%', #{user.realName},'%')
             </if>
             <if test="user.unitName!=null and user.unitName != ''">
-                and bu.unit_name like concat('%', #{user.unitName},'%')
+                and bud.unit_name like concat('%', #{user.unitName},'%')
             </if>
             <if test="user.dispatch!=null and user.dispatch != ''">
                 <if test="user.dispatch == 0">
@@ -324,6 +306,9 @@
             </if>
             <if test="user.userType!=null and user.userType != ''">
                 and bu.user_type = #{user.userType}
+            </if>
+            <if test="user.auditStatus != null and user.auditStatus != ''">
+                and bu.audit_status = #{user.auditStatus}
             </if>
             <if test="user.securitynumber!=null and user.securitynumber != ''">
                 and bu.securitynumber like concat('%', #{user.securitynumber},'%')
@@ -399,9 +384,6 @@
         <if test="user.nativeplace!=null and user.nativeplace != ''">
             and nativeplace = #{user.nativeplace}
         </if>
-        <if test="user.unitName!=null and user.unitName != ''">
-            and bu.unit_name like concat('%', #{user.unitName},'%')
-        </if>
         <if test="user.sex!=null and user.sex != ''">
             and sex = #{user.sex}
         </if>
@@ -434,24 +416,31 @@
     </select>
 
     <select id="exportUser" resultType="org.springblade.modules.system.excel.UserExcel">
-        SELECT id,
-               tenant_id,
-               user_type,
-               account,
-               name,
-               real_name,
-               email,
-               phone,
-               birthday,
-               role_id,
-               dept_id,
-               post_id
-        FROM blade_user ${ew.customSqlSegment}
+            SELECT
+                bu.id,
+                bd.dept_name AS deptId,
+                bu.real_name,
+                bu.phone,
+                bu.sex,
+                bu.cardid
+            FROM
+                blade_user bu
+                    LEFT JOIN blade_dept bd ON bu.dept_id = bd.id
+                where bu.is_deleted = 0
+                <if test="obj.account != null and obj.account != ''">
+                    AND bu.account LIKE CONCAT('%',#{obj.account},'%')
+                </if>
+                <if test="obj.realName != null and obj.realName != ''">
+                    AND bu.real_name LIKE CONCAT('%',#{obj.realName},'%')
+                </if>
+                <if test="obj.deptId != null and obj.deptId != ''">
+                    AND bu.dept_id = #{obj.deptId}
+                </if>
     </select>
 
     <!--通过 身份证号查询用户信息-->
     <select id="getUserInfoByIdCardNo" resultType="org.springblade.modules.system.entity.User">
-        SELECT id, name, real_name RealName,securitynumber
+        SELECT id, name, real_name RealName,securitynumber,dept_id,dispatch
         FROM blade_user
         where 1=1
         and is_deleted = 0
@@ -466,16 +455,10 @@
         bu.*,IF(mod(SUBSTR(bu.cardid,17,1),2),1,2) sexs
         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
+        left join blade_user_detail bud on bud.user_id = bu.id
+        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 role_alias = '保安'
         <if test="user.realName!=null and user.realName != ''">
             and bu.real_name like concat(concat('%', #{user.realName}),'%')
@@ -512,9 +495,9 @@
         <if test="user.jurisdiction!=null and user.jurisdiction != ''">
             and bu.jurisdiction = #{user.jurisdiction}
         </if>
-        <if test="user.unitName!=null and user.unitName != ''">
-            and bu.unit_name like concat('%', #{user.unitName},'%')
-        </if>
+<!--        <if test="user.unitName!=null and user.unitName != ''">-->
+<!--            and bud.unit_name like concat('%', #{user.unitName},'%')-->
+<!--        </if>-->
         <if test="user.securitynumber!=null and user.securitynumber != ''">
             and bu.securitynumber = #{user.securitynumber}
         </if>
@@ -527,18 +510,11 @@
         bd.dept_name
         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
-        (hold = 2 or hold = 3)
+        left join blade_user_detail bud on bud.user_id = bu.id
+        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 (hold = 2 or hold = 3)
         and br.role_alias = "保安"
         <if test="user.deptId!=null and user.deptId != ''">
             and bu.dept_id = #{user.deptId}
@@ -559,7 +535,7 @@
             and bu.real_name like concat('%', #{user.realName},'%')
         </if>
         <if test="user.unitName!=null and user.unitName != ''">
-            and bu.unit_name like concat('%', #{user.unitName},'%')
+            and bud.unit_name like concat('%', #{user.unitName},'%')
         </if>
         <if test="user.userType!=null and user.userType != ''">
             and bu.user_type = #{user.userType}
@@ -883,23 +859,16 @@
         select
         distinct bu.id,
         bd.dept_name deptId,
-        bu.real_name realName,
-        bu.phone,
-        if(IF(mod(SUBSTR(bu.cardid,17,1),2),1,2)=1,"男","女") sex,
-        bu.cardid,
-        bu.nation,
-        bu.registered,
-        bu.unit_name unitName,
-        case when bu.education=1 then '初中及以下'
-        when bu.education=2 then '高中/中技/中专'
-        when bu.education=3 then '大专'
-        when bu.education=4 then '本科'
-        when bu.education=5 then '博士'
-        when bu.education=6 then '硕士'
-        else '' end as education,
-        bu.politicaloutlook,
-        bu.address
-        from blade_user bu left join blade_dept bd on bu.dept_id = bd.id
+        bu.real_name realName,if(IF(mod(SUBSTR(bu.cardid,17,1),2),1,2)=1,"男","女") sex,
+        bu.phone,bu.cardid,bu.nation,bu.education,bu.politicaloutlook,
+        bud.unit_name unitName,bud.marriage_status marriageStatus,bud.sign_level signLevel,
+        bud.permanent_residence_address permanentResidenceAddress,bud.dwell_address dwellAddress,
+        bud.member_of_family memberOfFamily,bud.work_experience workExperience,
+        bud.education_experience educationExperience,bud.acceptance_police_unit acceptancePoliceUnit,
+        bud.acceptance_person acceptancePerson,bud.acceptance_time acceptanceTime
+        from blade_user bu
+        left join blade_user_detail bud on bud.user_id = bu.id and bud.is_deleted = 0
+        left join blade_dept bd on bu.dept_id = bd.id and bd.is_deleted = 0
         left join sys_information si on si.departmentid = bd.id
         left join sys_jurisdiction sj on sj.id = si.jurisdiction
         left join blade_role br on br.id = bu.role_id
@@ -923,7 +892,7 @@
             and bu.is_freeze = #{user.isFreeze}
         </if>
         <if test="user.unitName!=null and user.unitName != ''">
-            and bu.unit_name like concat('%', #{user.unitName},'%')
+            and bud.unit_name like concat('%', #{user.unitName},'%')
         </if>
         <if test="user.isFingerprint==1">
             and bu.fingerprint is not null and bu.fingerprint!=""
@@ -1044,16 +1013,17 @@
         (id,
         tenant_id,account,password,name,real_name,avatar,email,phone,sex,
         role_id,dept_id,cardid,nativePlace,nation,fingerprint,education,
-        politicaloutlook,healstats,height,address,registered,securitynumber,
-        hold,jurisdiction,examination_type,status,is_deleted,dispatch,create_time,unit_name
+        politicaloutlook,healstats,height,securitynumber,
+        hold,jurisdiction,examination_type,status,is_deleted,dispatch,create_time
         )
         values
         <foreach collection="list" item="user" separator=",">
-            (#{user.id},
+            (
+            #{user.id},
             #{user.tenantId},#{user.account},#{user.password},#{user.name},#{user.realName},#{user.avatar},#{user.email},#{user.phone},#{user.sex},
             #{user.roleId},#{user.deptId},#{user.cardid},#{user.nativeplace},#{user.nation},#{user.fingerprint},#{user.education},
-            #{user.politicaloutlook},#{user.healstats},#{user.height},#{user.address},#{user.registered},#{user.securitynumber},
-            #{user.hold},#{user.jurisdiction},#{user.examinationType},#{user.status},#{user.isDeleted},#{user.dispatch},#{user.createTime},#{user.unitName}
+            #{user.politicaloutlook},#{user.healstats},#{user.height},#{user.securitynumber},
+            #{user.hold},#{user.jurisdiction},#{user.examinationType},#{user.status},#{user.isDeleted},#{user.dispatch},#{user.createTime}
             )
         </foreach>
     </insert>
@@ -1183,6 +1153,15 @@
         </choose>
     </update>
 
+
+    <update id="batchAudit">
+        UPDATE BLADE_USER SET audit_status = #{auditStatus}
+         WHERE is_deleted = 0 and id in
+         <foreach collection="ids.split(',')" item="item" open="(" separator="," close=")">
+             #{item}
+         </foreach>
+    </update>
+
     <!--判断是否报名-->
     <select id="getUserIsApply" resultType="org.springblade.modules.system.entity.User">
         select bu.* from blade_user bu
@@ -1198,5 +1177,30 @@
         and bu.id = #{id}
     </select>
 
+    <!--查询未关联的保安员-->
+    <select id="getNotGlList" resultType="org.springblade.modules.system.entity.User">
+        select bu.* from blade_user bu
+        left join blade_user_detail bud on bu.id = bud.user_id and bud.is_deleted = 0
+        where bu.is_deleted = 0
+        and bu.role_id = '1412226235153731586'
+        and bud.id is null
+    </select>
+    <select id="getUserInfoDetail" resultType="org.springblade.modules.system.vo.UserInfoDetail">
+        SELECT * FROM blade_user bu
+        LEFT JOIN blade_user_detail bud on bud.user_id = bu.id and bud.is_deleted = 0
+        WHERE bu.is_deleted = 0 and bu.id = #{id}
+    </select>
+    <select id="getUserInfoByIdCardNoAndSecurityNumber"
+            resultType="org.springblade.modules.system.entity.User">
+
+        SELECT id, name, real_name RealName,securitynumber,dept_id
+        FROM blade_user
+        where 1=1
+          and is_deleted = 0
+          and status = 1
+          and cardid = #{cardid}
+        and securitynumber = #{securityNumber}
+    </select>
+
 
 </mapper>

--
Gitblit v1.9.3