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 |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 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 6478a01..d5ba0dd 100644
--- a/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
+++ b/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
@@ -384,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