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/accreditation/mapper/AccreditationRecordsMapper.xml |  303 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 280 insertions(+), 23 deletions(-)

diff --git a/src/main/java/org/springblade/modules/accreditation/mapper/AccreditationRecordsMapper.xml b/src/main/java/org/springblade/modules/accreditation/mapper/AccreditationRecordsMapper.xml
index 5d289ab..9c51ba7 100644
--- a/src/main/java/org/springblade/modules/accreditation/mapper/AccreditationRecordsMapper.xml
+++ b/src/main/java/org/springblade/modules/accreditation/mapper/AccreditationRecordsMapper.xml
@@ -8,36 +8,34 @@
             sar.*,
             bt.dept_name AS deptName,
             bu.real_name realName,
-            bu.sex,bu.cardid idCardNo,
+            IF(mod(SUBSTR(bu.cardid,17,1),2),1,2) sex,
+            bu.cardid idCardNo,
             bu.securitynumber securityNumber,
             bu.avatar,
+            bud.permanent_residence_address as registered,
             ifnull(DATE_FORMAT(NOW(), '%Y') - SUBSTRING( bu.cardid,7,4),0) age,
             bu1.real_name applyName,
             bt1.dept_name applyUnit,
-            bu.registered,
-            bu.user_type userType
+            bu.user_type userType,
+            bu.paper_time as userPaperTime
         FROM
             sys_accreditation_records sar
         left join
             blade_user bu
         on
             sar.user_id = bu.id
-        LEFT JOIN
-            blade_dept bt
-        ON
-            bu.dept_id = bt.id
-        left join
-        blade_user bu1
-        on
-        sar.create_user = bu1.id
-        LEFT JOIN
-        blade_dept bt1
-        ON
-        bu1.dept_id = bt1.id
-        WHERE
-            1=1
+        LEFT JOIN blade_user_detail bud ON bud.user_id = bu.id
+        LEFT JOIN  blade_dept bt ON bu.dept_id = bt.id
+        left join blade_user bu1 on sar.create_user = bu1.id
+        LEFT JOIN  blade_dept bt1  ON  bu1.dept_id = bt1.id
+        left join sys_information si on bt.id = si.departmentid
+        left join sys_jurisdiction sj on sj.id = si.jurisdiction
+        WHERE  1=1
         and bu.status = 1
         and bu.is_deleted = 0
+        <if test="accreditationRecords.userPaperTime != null and accreditationRecords.userPaperTime !=''">
+            AND DATE_FORMAT(bu.paper_time,'%Y-%m-%d')  = #{accreditationRecords.userPaperTime}
+        </if>
         <if test="accreditationRecords.deptName!=null and  accreditationRecords.deptName!=''">
             and bt.dept_name like concat('%', #{accreditationRecords.deptName},'%')
         </if>
@@ -53,8 +51,23 @@
         <if test="accreditationRecords.securityNumber!=null and  accreditationRecords.securityNumber!=''">
             and bu.securitynumber like concat('%', #{accreditationRecords.securityNumber},'%')
         </if>
-        <if test="accreditationRecords.status!=null">
+        <if test="accreditationRecords.jurisdiction!=null and accreditationRecords.jurisdiction!='' and accreditationRecords.jurisdiction!='1372091709474910209'">
+            and (sj.id = #{accreditationRecords.jurisdiction} or sj.parent_id = #{accreditationRecords.jurisdiction})
+        </if>
+        <if test="accreditationRecords.status==1">
             and sar.status = #{accreditationRecords.status}
+        </if>
+        <if test="accreditationRecords.status==2">
+            and sar.status = #{accreditationRecords.status}
+        </if>
+        <if test="accreditationRecords.createUser!=null">
+            and sar.create_user = #{accreditationRecords.createUser}
+        </if>
+        <if test="accreditationRecords.deptId!=null">
+            and bt.id = #{accreditationRecords.deptId}
+        </if>
+        <if test="accreditationRecords.userType!=null">
+            and bu.user_type = #{accreditationRecords.userType}
         </if>
         <if test="accreditationRecords.type!=null">
             and sar.type = #{accreditationRecords.type}
@@ -74,7 +87,7 @@
         <if test="accreditationRecords.endTime!=null and accreditationRecords.endTime!='' and accreditationRecords.endTime!='undefined'">
             and sar.create_time &lt;= #{accreditationRecords.endTime}
         </if>
-        order by sar.create_time desc
+        order by sar.id desc
     </select>
 
     <!--自定义详情信息-->
@@ -83,7 +96,8 @@
         sar.*,
         bt.dept_name AS deptName,
         bu.real_name realName,
-        bu.sex,bu.cardid idCardNo,
+        IF(mod(SUBSTR(bu.cardid,17,1),2),1,2) sex,
+        bu.cardid idCardNo,
         bu.securitynumber securityNumber,
         bu.avatar,
         ifnull(DATE_FORMAT(NOW(), '%Y') - SUBSTRING( bu.cardid,7,4),0) age
@@ -103,13 +117,14 @@
     </select>
 
 
-    <!--导出保安员证信息-->
+    <!--导出保安员证信息(上岗证)-->
     <select id="exportSecurityPaperList" resultType="org.springblade.modules.accreditation.vo.AccreditationRecordsVo">
         SELECT
         sar.*,
         bt.dept_name AS deptName,
         bu.real_name realName,
-        bu.sex,bu.cardid idCardNo,
+        IF(mod(SUBSTR(bu.cardid,17,1),2),1,2) sex,
+        bu.cardid idCardNo,
         bu.securitynumber securityNumber,
         bu.avatar,
         ifnull(DATE_FORMAT(NOW(), '%Y') - SUBSTRING( bu.cardid,7,4),0) age
@@ -123,6 +138,22 @@
         blade_dept bt
         ON
         bu.dept_id = bt.id
+        left join
+        blade_user bu1
+        on
+        sar.create_user = bu1.id
+        LEFT JOIN
+        blade_dept bt1
+        ON
+        bu1.dept_id = bt1.id
+        left join
+        sys_information si
+        on
+        bt.id = si.departmentid
+        left join
+        sys_jurisdiction sj
+        on
+        sj.id = si.jurisdiction
         WHERE
         1=1
         and bu.status = 1
@@ -136,11 +167,145 @@
         <if test="accreditationRecords.idCardNo!=null and  accreditationRecords.idCardNo!=''">
             and bu.cardid like concat('%', #{accreditationRecords.idCardNo},'%')
         </if>
+        <if test="accreditationRecords.status==1">
+            and sar.status = #{accreditationRecords.status}
+        </if>
+        <if test="accreditationRecords.status==2">
+            and sar.status = #{accreditationRecords.status}
+        </if>
         <if test="accreditationRecords.securityNumber!=null and  accreditationRecords.securityNumber!=''">
             and bu.securitynumber like concat('%', #{accreditationRecords.securityNumber},'%')
         </if>
+        <if test="accreditationRecords.userType!=null">
+            and bu.user_type = #{accreditationRecords.userType}
+        </if>
+        <if test="accreditationRecords.jurisdiction!=null and accreditationRecords.jurisdiction!='' and accreditationRecords.jurisdiction!='1372091709474910209'">
+            and (sj.id = #{accreditationRecords.jurisdiction} or sj.parent_id = #{accreditationRecords.jurisdiction})
+        </if>
+        <if test="accreditationRecords.applyUnit!=null and  accreditationRecords.applyUnit!=''">
+            and bt1.dept_name like concat('%', #{accreditationRecords.applyUnit},'%')
+        </if>
+        <if test="accreditationRecords.createUser!=null">
+            and sar.create_user = #{accreditationRecords.createUser}
+        </if>
+        <if test="accreditationRecords.deptId!=null">
+            and bt.id = #{accreditationRecords.deptId}
+        </if>
+        <if test="accreditationRecords.type!=null">
+            and sar.type = #{accreditationRecords.type}
+        </if>
         <if test="accreditationRecords.status!=null">
             and sar.status = #{accreditationRecords.status}
+        </if>
+        <if test="accreditationRecords.isAvatar==1">
+            and bu.avatar is not null and bu.avatar!=""
+        </if>
+        <if test="accreditationRecords.isAvatar==2">
+            and (bu.avatar is null or bu.avatar="")
+        </if>
+        <if test="accreditationRecords.auditStatus!=null">
+            and sar.audit_status = #{accreditationRecords.auditStatus}
+        </if>
+        <if test="accreditationRecords.startTime!=null and accreditationRecords.startTime!='' and accreditationRecords.startTime!='undefined'">
+            and sar.create_time &gt;= #{accreditationRecords.startTime}
+        </if>
+        <if test="accreditationRecords.endTime!=null and accreditationRecords.endTime!='' and accreditationRecords.endTime!='undefined'">
+            and sar.create_time &lt;= #{accreditationRecords.endTime}
+        </if>
+        order by sar.id desc
+    </select>
+
+
+    <!--导出证书制证信息-->
+    <select id="exportSecurityBookPaper" resultType="org.springblade.modules.accreditation.excel.ExportSecurityBookPaperExcel">
+        SELECT
+        bu.real_name realName,
+        IF(mod(SUBSTR(bu.cardid,17,1),2),1,2) sex,
+        bu.cardid idCardNo,
+        bt.dept_name AS deptName,
+        bu.securitynumber securityNumber,
+        bu1.real_name applyName,
+        bt1.dept_name applyUnit,
+        sar.create_time createTime,
+        ELT(sar.audit_status,"待审核","审核通过","审核不通过") auditStatus,
+        sar.audit_time auditTime,
+        sar.audit_detail auditDetail,
+        if(bu.user_type=6,"是","否") userType,
+        DATE_FORMAT(bu.paper_time,'%Y-%m-%d') as userPaperTime
+        FROM
+        sys_accreditation_records sar
+        left join
+        blade_user bu
+        on
+        sar.user_id = bu.id
+        LEFT JOIN
+        blade_dept bt
+        ON
+        bu.dept_id = bt.id
+        left join
+        blade_user bu1
+        on
+        sar.create_user = bu1.id
+        LEFT JOIN
+        blade_dept bt1
+        ON
+        bu1.dept_id = bt1.id
+        left join
+        sys_information si
+        on
+        bt.id = si.departmentid
+        left join
+        sys_jurisdiction sj
+        on
+        sj.id = si.jurisdiction
+        WHERE
+        1=1
+        and bu.status = 1
+        and bu.is_deleted = 0
+        <if test="accreditationRecords.userPaperTime != null and accreditationRecords.userPaperTime !=''">
+            AND DATE_FORMAT(bu.paper_time,'%Y-%m-%d')  = #{accreditationRecords.userPaperTime}
+        </if>
+        <if test="accreditationRecords.deptName!=null and  accreditationRecords.deptName!=''">
+            and bt.dept_name like concat('%', #{accreditationRecords.deptName},'%')
+        </if>
+        <if test="accreditationRecords.realName!=null and  accreditationRecords.realName!=''">
+            and bu.real_name like concat('%', #{accreditationRecords.realName},'%')
+        </if>
+        <if test="accreditationRecords.idCardNo!=null and  accreditationRecords.idCardNo!=''">
+            and bu.cardid like concat('%', #{accreditationRecords.idCardNo},'%')
+        </if>
+        <if test="accreditationRecords.applyUnit!=null and  accreditationRecords.applyUnit!=''">
+            and bt1.dept_name like concat('%', #{accreditationRecords.applyUnit},'%')
+        </if>
+        <if test="accreditationRecords.securityNumber!=null and  accreditationRecords.securityNumber!=''">
+            and bu.securitynumber like concat('%', #{accreditationRecords.securityNumber},'%')
+        </if>
+        <if test="accreditationRecords.status==1">
+            and sar.status = #{accreditationRecords.status}
+        </if>
+        <if test="accreditationRecords.status==2">
+            and sar.status = #{accreditationRecords.status}
+        </if>
+        <if test="accreditationRecords.jurisdiction!=null and accreditationRecords.jurisdiction!='' and accreditationRecords.jurisdiction!='1372091709474910209'">
+            and (sj.id = #{accreditationRecords.jurisdiction} or sj.parent_id = #{accreditationRecords.jurisdiction})
+        </if>
+        <if test="accreditationRecords.status!=null">
+            and sar.status = #{accreditationRecords.status}
+        </if>
+        <if test="accreditationRecords.userType!=null">
+            and bu.user_type = #{accreditationRecords.userType}
+        </if>
+        <if test="accreditationRecords.createUser!=null">
+            and sar.create_user = #{accreditationRecords.createUser}
+        </if>
+        <if test="accreditationRecords.deptId!=null">
+            and bt.id = #{accreditationRecords.deptId}
+        </if>
+        <if test="accreditationRecords.type!=null">
+            and sar.type = #{accreditationRecords.type}
+        </if>
+        <if test="accreditationRecords.auditStatus!=null">
+            and sar.audit_status = #{accreditationRecords.auditStatus}
         </if>
         <if test="accreditationRecords.isAvatar==1">
             and bu.avatar is not null and bu.avatar!=""
@@ -154,6 +319,98 @@
         <if test="accreditationRecords.endTime!=null and accreditationRecords.endTime!='' and accreditationRecords.endTime!='undefined'">
             and sar.create_time &lt;= #{accreditationRecords.endTime}
         </if>
-        order by sar.create_time desc
+        order by sar.id desc
+    </select>
+
+
+    <!--导出证书制证信息(包含照片)-->
+    <select id="exportSecurityBookPapers" resultType="org.springblade.modules.accreditation.vo.AccreditationRecordsVo">
+        SELECT
+        sar.*,
+        bt.dept_name AS deptName,
+        bu.real_name realName,
+        IF(mod(SUBSTR(bu.cardid,17,1),2),1,2) sex,
+        bu.cardid idCardNo,
+        bu.securitynumber securityNumber,
+        bu.avatar,
+        ifnull(DATE_FORMAT(NOW(), '%Y') - SUBSTRING( bu.cardid,7,4),0) age,
+        bu1.real_name applyName,
+        bt1.dept_name applyUnit,
+        bu.user_type userType
+        FROM
+        sys_accreditation_records sar
+        left join blade_user bu on sar.user_id = bu.id
+        LEFT JOIN blade_dept bt ON bu.dept_id = bt.id
+        left join blade_user bu1 on sar.create_user = bu1.id
+        LEFT JOIN blade_dept bt1 ON bu1.dept_id = bt1.id
+        left join sys_information si on bt.id = si.departmentid
+        left join sys_jurisdiction sj on sj.id = si.jurisdiction
+        WHERE 1=1 and bu.status = 1 and bu.is_deleted = 0
+        <if test="accreditationRecords.deptName!=null and  accreditationRecords.deptName!=''">
+            and bt.dept_name like concat('%', #{accreditationRecords.deptName},'%')
+        </if>
+        <if test="accreditationRecords.realName!=null and  accreditationRecords.realName!=''">
+            and bu.real_name like concat('%', #{accreditationRecords.realName},'%')
+        </if>
+        <if test="accreditationRecords.idCardNo!=null and  accreditationRecords.idCardNo!=''">
+            and bu.cardid like concat('%', #{accreditationRecords.idCardNo},'%')
+        </if>
+        <if test="accreditationRecords.applyUnit!=null and  accreditationRecords.applyUnit!=''">
+            and bt1.dept_name like concat('%', #{accreditationRecords.applyUnit},'%')
+        </if>
+        <if test="accreditationRecords.securityNumber!=null and  accreditationRecords.securityNumber!=''">
+            and bu.securitynumber like concat('%', #{accreditationRecords.securityNumber},'%')
+        </if>
+        <if test="accreditationRecords.jurisdiction!=null and accreditationRecords.jurisdiction!='' and accreditationRecords.jurisdiction!='1372091709474910209'">
+            and (sj.id = #{accreditationRecords.jurisdiction} or sj.parent_id = #{accreditationRecords.jurisdiction})
+        </if>
+        <if test="accreditationRecords.status!=null">
+            and sar.status = #{accreditationRecords.status}
+        </if>
+        <if test="accreditationRecords.status==1">
+            and sar.status = #{accreditationRecords.status}
+        </if>
+        <if test="accreditationRecords.status==2">
+            and sar.status = #{accreditationRecords.status}
+        </if>
+        <if test="accreditationRecords.createUser!=null">
+            and sar.create_user = #{accreditationRecords.createUser}
+        </if>
+        <if test="accreditationRecords.deptId!=null">
+            and bt.id = #{accreditationRecords.deptId}
+        </if>
+        <if test="accreditationRecords.userType!=null">
+            and bu.user_type = #{accreditationRecords.userType}
+        </if>
+        <if test="accreditationRecords.type!=null">
+            and sar.type = #{accreditationRecords.type}
+        </if>
+        <if test="accreditationRecords.auditStatus!=null">
+            and sar.audit_status = #{accreditationRecords.auditStatus}
+        </if>
+        <if test="accreditationRecords.isAvatar==1">
+            and bu.avatar is not null and bu.avatar!=""
+        </if>
+        <if test="accreditationRecords.isAvatar==2">
+            and (bu.avatar is null or bu.avatar="")
+        </if>
+        <if test="accreditationRecords.startTime!=null and accreditationRecords.startTime!='' and accreditationRecords.startTime!='undefined'">
+            and sar.create_time &gt;= #{accreditationRecords.startTime}
+        </if>
+        <if test="accreditationRecords.endTime!=null and accreditationRecords.endTime!='' and accreditationRecords.endTime!='undefined'">
+            and sar.create_time &lt;= #{accreditationRecords.endTime}
+        </if>
+        order by sar.id desc
+    </select>
+
+    <!--根据用户 id 查询上岗证申请记录-->
+    <select id="getAccreditationRecordsByUserIdCount" resultType="java.lang.Integer">
+        select count(*) from sys_accreditation_records where user_id = #{userId} and type = 1
+    </select>
+
+
+    <!--根据用户 id 查询当前人员是否有待审核和审核通过的记录数-->
+    <select id="getAccreditationRecordsByUserIdAuditCount" resultType="java.lang.Integer">
+        select count(*) from sys_accreditation_records where (audit_status = 1 or audit_status = 2) and user_id = #{userId} and type = #{type}
     </select>
 </mapper>

--
Gitblit v1.9.3