From fe9c6432b0b6eea428bbb856fabe4f7d1e84f0cb Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Wed, 27 Oct 2021 17:16:01 +0800
Subject: [PATCH] 保安员资格审查查询修改

---
 src/main/java/org/springblade/modules/system/mapper/UserMapper.xml             |   85 ++++++++++++++++++++++++++++
 src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java |    2 
 src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml          |   43 ++++++--------
 src/main/java/org/springblade/modules/exam/excel/ExportExamScoreExcel.java     |    8 ++
 src/main/java/org/springblade/modules/system/excel/SecurityExcel.java          |   13 +++-
 src/main/java/org/springblade/modules/system/mapper/UserMapper.java            |    8 ++
 6 files changed, 130 insertions(+), 29 deletions(-)

diff --git a/src/main/java/org/springblade/modules/exam/excel/ExportExamScoreExcel.java b/src/main/java/org/springblade/modules/exam/excel/ExportExamScoreExcel.java
index f62072e..5e87f19 100644
--- a/src/main/java/org/springblade/modules/exam/excel/ExportExamScoreExcel.java
+++ b/src/main/java/org/springblade/modules/exam/excel/ExportExamScoreExcel.java
@@ -71,4 +71,12 @@
 	@ColumnWidth(15)
 	@ExcelProperty("总成绩")
 	private Integer allGrade;
+
+	@ColumnWidth(15)
+	@ExcelProperty("是否合格")
+	private String qualified;
+
+	@ColumnWidth(15)
+	@ExcelProperty("是否发证")
+	private String isSecurity;
 }
diff --git a/src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml b/src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml
index 74caf54..d99d5a3 100644
--- a/src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml
+++ b/src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml
@@ -23,8 +23,19 @@
         ksxt_exam ke
         on
         ke.id = es.exam_id
+        left join
+        sys_information si
+        on
+        si.departmentid = bd.id
+        left join
+        sys_jurisdiction sj
+        on
+        sj.id = si.jurisdiction
         WHERE
         1=1
+        <if test="examScore.jurisdiction!=null and examScore.jurisdiction!='' and examScore.jurisdiction!='1372091709474910209'">
+            and (sj.id = #{coinspect.jurisdiction} or sj.parent_id = #{coinspect.jurisdiction})
+        </if>
         <if test="examScore.examName!=null and  examScore.examName!=''">
             and es.exam_name like concat('%', #{examScore.examName},'%')
         </if>
@@ -75,7 +86,8 @@
         bd.dept_name companyName,
         es.exam_time examTime,exam_end_time examEndTime,
         es.theory_grade theoryGrade,es.learn_grade learnGrade,
-        all_grade allGrade
+        all_grade allGrade,if(es.qualified=0,'合格','不合格或未导入实操成绩') qualified,
+        if(es.qualified=0,'是','否') isSecurity
         from
         exam_score es
         left join
@@ -91,10 +103,6 @@
         on
         bd.id = bu.dept_id
         left join
-        sys_training_registration str
-        on
-        str.id = es.apply_id
-        left join
         sys_information si
         on
         si.departmentid = bd.id
@@ -104,12 +112,11 @@
         sj.id = si.jurisdiction
         where
         1=1
-        and (str.is_exam = 2 or str.is_exam = 3)
         <if test="examScore.jurisdiction!=null and examScore.jurisdiction!='' and examScore.jurisdiction!='1372091709474910209'">
             and (sj.id = #{coinspect.jurisdiction} or sj.parent_id = #{coinspect.jurisdiction})
         </if>
         <if test="examScore.examName!=null and  examScore.examName!=''">
-            and ke.exam_name like concat('%', #{examScore.examName},'%')
+            and es.exam_name like concat('%', #{examScore.examName},'%')
         </if>
         <if test="examScore.companyName!=null and  examScore.companyName!=''">
             and bd.dept_name like concat('%', #{examScore.companyName},'%')
@@ -117,23 +124,8 @@
         <if test="examScore.securityName!=null and  examScore.securityName!=''">
             and bu.real_name like concat('%', #{examScore.securityName},'%')
         </if>
-        <if test="examScore.account!=null and  examScore.account!=''">
-            and bu.account like concat('%', #{examScore.account},'%')
-        </if>
-        <if test="examScore.trainUnitId!=null">
-            and str.training_unit_id = #{examScore.trainUnitId}
-        </if>
         <if test="examScore.userId!=null and  examScore.userId!=''">
             and es.user_id = #{examScore.userId}
-        </if>
-        <if test="examScore.deptId!=null and  examScore.deptId!=''">
-            and bd.id = #{examScore.deptId}
-        </if>
-        <if test="examScore.isExam!=null and  examScore.isExam!=''">
-            and str.is_exam = #{examScore.isExam}
-        </if>
-        <if test="examScore.examType!=null and  examScore.examType!=''">
-            and ke.exam_type = #{examScore.examType}
         </if>
         <if test="examScore.candidateNo!=null and  examScore.candidateNo!=''">
             and es.candidate_no = #{examScore.candidateNo}
@@ -141,8 +133,11 @@
         <if test="examScore.qualified!=null">
             and es.qualified = #{examScore.qualified}
         </if>
-        <if test="examScore.examDate!=null and examScore.examDate!=''">
-            and date_format(es.exam_time,'%Y-%m-%d') = #{examScore.examDate}
+        <if test="examScore.startTime!=null and examScore.startTime!=''">
+            and es.exam_time &gt;= #{examScore.startTime}
+        </if>
+        <if test="examScore.endTime!=null and examScore.endTime!=''">
+            and es.exam_time &lt;= #{examScore.endTime}
         </if>
         order by es.id desc
     </select>
diff --git a/src/main/java/org/springblade/modules/system/excel/SecurityExcel.java b/src/main/java/org/springblade/modules/system/excel/SecurityExcel.java
index 098c74b..711c921 100644
--- a/src/main/java/org/springblade/modules/system/excel/SecurityExcel.java
+++ b/src/main/java/org/springblade/modules/system/excel/SecurityExcel.java
@@ -27,9 +27,10 @@
 import java.util.Date;
 
 /**
- * UserExcel
+ * SecurityExcel
+ * @author zhongrj
+ * @since 2021-10-27
  *
- * @author Chill
  */
 @Data
 @ColumnWidth(25)
@@ -40,9 +41,9 @@
 
 	@ColumnWidth(15)
 	@ExcelProperty("保安姓名")
-	private String roleName;
+	private String realName;
 
-	@ColumnWidth(10)
+	@ColumnWidth(30)
 	@ExcelProperty("保安公司")
 	private String deptName;
 
@@ -50,6 +51,7 @@
 	@ExcelProperty("性别")
 	private String sex;
 
+	@ColumnWidth(20)
 	@ExcelProperty("身份证号")
 	private String cardid;
 
@@ -57,12 +59,15 @@
 	@ExcelProperty("年龄")
 	private String age;
 
+	@ColumnWidth(15)
 	@ExcelProperty("保安证编号")
 	private String securitynumber;
 
+	@ColumnWidth(15)
 	@ExcelProperty("联系方式")
 	private String phone;
 
+	@ColumnWidth(15)
 	@ExcelProperty("审查状态")
 	private String examinationType;
 
diff --git a/src/main/java/org/springblade/modules/system/mapper/UserMapper.java b/src/main/java/org/springblade/modules/system/mapper/UserMapper.java
index dda2ef2..91a1a64 100644
--- a/src/main/java/org/springblade/modules/system/mapper/UserMapper.java
+++ b/src/main/java/org/springblade/modules/system/mapper/UserMapper.java
@@ -22,6 +22,7 @@
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
+import org.springblade.modules.system.excel.SecurityExcel;
 import org.springblade.modules.system.excel.UserExcel;
 import org.springblade.modules.system.entity.User;
 import org.springblade.modules.system.vo.UserVO;
@@ -99,4 +100,11 @@
 	 * @return
 	 */
     UserVO getUserInfoBySecurityNumber(@Param("securityNumber") String securityNumber);
+
+	/**
+	 * 导出用户审查明细
+	 * @param user
+	 * @return
+	 */
+    List<SecurityExcel> exportSecurity(@Param("user") UserVO user);
 }
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 96ae4de..fbf2038 100644
--- a/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
+++ b/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -329,4 +329,89 @@
         where securitynumber = #{securityNumber}
     </select>
 
+    <!--保安员列表-->
+    <select id="exportSecurity" resultType="org.springblade.modules.system.excel.SecurityExcel">
+        select
+        bu.real_name realName,
+        bd.dept_name as deptName,
+        if(bu.sex=1,'男','女') sex,
+        bu.cardid,
+        ifnull(DATE_FORMAT(NOW(), '%Y') - SUBSTRING( bu.cardid,7,4),0) age,
+        bu.phone,
+        if(bu.examination_type=0,'正常','异常') examinationType,
+        bu.examination_mx examinationMx,
+        bu.paper_time paperTime
+        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
+        sys_information si
+        on
+        si.departmentid = bd.id
+        left join
+        sys_jurisdiction sj
+        on
+        sj.id = si.jurisdiction
+        where
+        bu.is_deleted = 0
+        and
+        br.role_alias = "安保人员"
+        and
+        bu.status = 1
+        and bd.parent_id!=1425365577303621633
+        and bd.id != 1425365577303621633
+        and bd.id != 1432625856013971457
+        <if test="user.jurisdiction!=null and user.jurisdiction != '' and user.jurisdiction != '1372091709474910209'">
+            and (sj.id = #{user.jurisdiction} or sj.parent_id = #{user.jurisdiction})
+        </if>
+        <if test="user.cardid!=null and user.cardid != ''">
+            and bu.cardid like concat(concat('%', #{user.cardid}),'%')
+        </if>
+        <if test="user.realName!=null and user.realName != ''">
+            and bu.real_name like concat(concat('%', #{user.realName}),'%')
+        </if>
+        <if test="user.userType!=null and user.userType != ''">
+            and bu.user_type = #{user.userType}
+        </if>
+        <if test="user.nativeplace!=null and user.nativeplace != ''">
+            and bu.nativeplace = #{user.nativeplace}
+        </if>
+        <if test="user.sex!=null and user.sex != ''">
+            and bu.sex = #{user.sex}
+        </if>
+        <if test="user.status!=null and user.status != ''">
+            and bu.status = #{user.status}
+        </if>
+        <if test="user.hold!=null and user.hold != ''">
+            and bu.hold = #{user.hold}
+        </if>
+        <if test="user.securitynumber!=null and user.securitynumber != ''">
+            and bu.securitynumber like concat('%', #{user.securitynumber},'%')
+        </if>
+        <if test="user.deptId!=null and user.deptId!=''">
+            and bu.dept_id =#{user.deptId}
+        </if>
+        <if test="user.startTime!=null and user.startTime!=''">
+            and bu.paper_time &gt;= #{user.startTime}
+        </if>
+        <if test="user.endTime!=null and user.endTime!=''">
+            and bu.paper_time &lt;= #{user.endTime}
+        </if>
+        <if test="user.useName==null or user.useName==''">
+            order by bu.id
+        </if>
+        <if test="user.useName!=null and user.useName!='' and user.useName=='examinationType'">
+            order by bu.examination_type ${user.sort}
+        </if>
+        <if test="user.useName!=null and user.useName!='' and  user.useName=='examinationMx'">
+            order by bu.examination_mx ${user.sort}
+        </if>
+    </select>
 </mapper>
diff --git a/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java b/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
index 3629e1b..155e3dd 100644
--- a/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
+++ b/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -483,6 +483,6 @@
 	 */
 	@Override
 	public List<SecurityExcel> exportSecurity(UserVO user) {
-		return null;
+		return baseMapper.exportSecurity(user);
 	}
 }

--
Gitblit v1.9.3