From 29e064a60b78ae87d0479159089ffeb27f43833c Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Wed, 19 Jan 2022 13:32:47 +0800
Subject: [PATCH] 新增考试查询统计

---
 src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml |   38 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml b/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
index dfc1bce..d5ba0dd 100644
--- a/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
+++ b/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
@@ -130,10 +130,16 @@
         <if test="paper.deptId!=null and paper.deptId!=''">
             and bd.id = #{paper.deptId}
         </if>
+        <if test="paper.deptName!=null and paper.deptName!=''">
+            and bd.dept_name like concat('%',#{paper.deptName},'%')
+        </if>
+        <if test="paper.examTime!=null and paper.examTime!=''">
+            and date_format(ke.start_time,'%Y-%m-%d') = #{paper.examTime}
+        </if>
         <if test="paper.auditStatus!=null and paper.auditStatus!=''">
             and audit_status = #{paper.auditStatus}
         </if>
-        order by start_time desc
+        order by ke.start_time desc,ke.id desc
     </select>
 
     <select id="PagerSubject" resultMap="PagerSubjectAnswer">
@@ -237,7 +243,7 @@
 			exam_score es
 		on
 		es.apply_id = str.id
-        where str.user_id = #{userId}
+        where str.user_id = #{examPaper.userId}
         and bu.is_train = 1
         and (str.is_exam = 1 or str.is_exam = 3)
         and ke.audit_status = 1
@@ -378,4 +384,32 @@
         and cancel = 1
     </select>
 
+    <!--考试查询统计-->
+    <select id="getExamStatistics" resultType="org.springblade.modules.exam.vo.ExamStatisticsVO">
+        SELECt
+        ke.id,ke.start_time startTime,ke.end_time endTime,bd.dept_name schoolName,
+        ifnull(a.c,0) znum,
+        ifnull(b.c,0) yknum,
+        ifnull(c.c,0) qknum,
+        ifnull(d.c,0) ycnum,
+        ifnull(e.c,0) qxnum
+        from ksxt_exam ke
+        left join (select count(*) c,train_exam_id from sys_training_registration GROUP BY train_exam_id) a on a.train_exam_id = ke.id
+        left join (select count(*) c,train_exam_id from sys_training_registration where 1=1 and (is_exam = 2 or is_exam = 3)  GROUP BY train_exam_id) b on b.train_exam_id = ke.id
+        left join (select count(*) c,train_exam_id from sys_training_registration str left join blade_user bu on bu.id = str.user_id where 1=1 and is_exam = 4 and cancel =2 or (is_exam=1 and cancel =1) and bu.examination_type!=1 GROUP BY train_exam_id) c on c.train_exam_id = ke.id
+        left join (select count(*) c,train_exam_id from sys_training_registration str left join blade_user bu on bu.id = str.user_id where 1=1 and cancel =1 and is_exam = 1 and bu.examination_type = 1 GROUP BY train_exam_id) d on d.train_exam_id = ke.id
+        left join (select count(*) c,train_exam_id from sys_training_registration where 1=1 and is_exam = 1 and cancel =2 GROUP BY train_exam_id) e on e.train_exam_id = ke.id
+        left join blade_user bu2 on bu2.id = ke.creator
+        left join blade_dept bd on bd.id = bu2.dept_id
+        where 1=1
+        and ke.audit_status = 1
+        <if test="examPaper.schoolName!=null and examPaper.schoolName!=''">
+            and bd.dept_name like concat('%',#{examPaper.schoolName},'%')
+        </if>
+        <if test="examPaper.examTime!=null and examPaper.examTime!=''">
+            and date_format(ke.start_time,'%Y-%m-%d') = #{examPaper.examTime}
+        </if>
+        order by ke.id desc
+    </select>
+
 </mapper>

--
Gitblit v1.9.3