From a4ff6ea9260c42293cb0d37b4e93ce45c9f61bf7 Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Sat, 09 Dec 2023 10:09:34 +0800
Subject: [PATCH] 无用字段去除

---
 src/main/java/org/springblade/modules/accreditation/mapper/AccreditationRecordsMapper.xml |   80 ++++++++++++++++++++++++----------------
 1 files changed, 48 insertions(+), 32 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 317e9c1..77c4a7c 100644
--- a/src/main/java/org/springblade/modules/accreditation/mapper/AccreditationRecordsMapper.xml
+++ b/src/main/java/org/springblade/modules/accreditation/mapper/AccreditationRecordsMapper.xml
@@ -15,7 +15,6 @@
             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
         FROM
             sys_accreditation_records sar
@@ -65,7 +64,10 @@
         <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">
+        <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">
@@ -95,6 +97,7 @@
         <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>
 
     <!--自定义详情信息-->
@@ -124,7 +127,7 @@
     </select>
 
 
-    <!--导出保安员证信息-->
+    <!--导出保安员证信息(上岗证)-->
     <select id="exportSecurityPaperList" resultType="org.springblade.modules.accreditation.vo.AccreditationRecordsVo">
         SELECT
         sar.*,
@@ -174,6 +177,12 @@
         <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>
@@ -204,12 +213,16 @@
         <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>
 
 
@@ -273,6 +286,12 @@
         <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>
@@ -306,6 +325,7 @@
         <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>
 
 
@@ -322,38 +342,16 @@
         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
         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
+        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>
@@ -375,6 +373,12 @@
         <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>
@@ -402,5 +406,17 @@
         <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