From 8b375fe00a241b3a769b82fe3dac8d1c9dce8a02 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Thu, 16 Jun 2022 14:36:07 +0800
Subject: [PATCH] 模拟考试修改

---
 src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml |  144 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 143 insertions(+), 1 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 f300dd1..92a8174 100644
--- a/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
+++ b/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
@@ -465,7 +465,149 @@
         left join blade_dept bd on a.dept_id = bd.id
         left join (select bu.dept_id,count(*) c from sys_training_registration str left join blade_user bu on bu.id = str.user_id left join ksxt_exam ke on ke.id = str.train_exam_id where str.training_unit_id = #{examPaper.trainUnitId} and date_format(ke.start_time,'%Y-%m-%d') = #{examPaper.startTime} and cancel =1 and is_exam = 1 and bu.examination_type = 1 GROUP BY bu.dept_id) d on d.dept_id = a.dept_id
         left join (select bu.dept_id,count(*) c from sys_training_registration str left join blade_user bu on bu.id = str.user_id left join ksxt_exam ke on ke.id = str.train_exam_id where str.training_unit_id = #{examPaper.trainUnitId} and date_format(ke.start_time,'%Y-%m-%d') = #{examPaper.startTime} and is_exam = 4 GROUP BY bu.dept_id) b on b.dept_id = a.dept_id
-        left join (select bu.dept_id,count(*) c from exam_score es left join blade_user bu on bu.id = es.user_id left join ksxt_exam ke on ke.id = es.exam_id left join sys_training_registration str on str.id = es.apply_id where str.training_unit_id = #{examPaper.trainUnitId} and date_format(ke.start_time,'%Y-%m-%d') = #{examPaper.startTime} and es.qualified = 0 GROUP BY bu.dept_id) c on c.dept_id = a.dept_id
+        left join (select bu.dept_id,count(*) c from exam_score es left join blade_user bu on bu.id = es.user_id left join ksxt_exam ke on ke.id = es.exam_id left join sys_training_registration str on str.id = es.apply_id where str.training_unit_id = #{examPaper.trainUnitId} and date_format(ke.start_time,'%Y-%m-%d') = #{examPaper.startTime} and es.theory_grade &gt;= 60 GROUP BY bu.dept_id) c on c.dept_id = a.dept_id
     </select>
 
+    <!--根据考试id 统计查询考试信息-->
+    <select id="getExamInfoByExamIdList" resultType="org.springblade.modules.exam.vo.ExamStatisticsVO">
+        select (@i:=@i+1) no,aa.*  from (
+        select
+        bd.dept_name deptName,
+        ifnull(a.c,0) znum,
+        ifnull(b.c,0) qknum,
+        ifnull(d.c,0) ycnum,
+        ifnull(c.c,0) yknum from
+        (select bu.dept_id,count(*) c from sys_training_registration str left join blade_user bu on bu.id = str.user_id left join ksxt_exam ke on ke.id = str.train_exam_id where str.training_unit_id = #{examPaper.trainUnitId} and date_format(ke.start_time,'%Y-%m-%d') = #{examPaper.examDate} GROUP BY bu.dept_id) a
+        left join blade_dept bd on a.dept_id = bd.id
+        left join (select bu.dept_id,count(*) c from sys_training_registration str left join blade_user bu on bu.id = str.user_id left join ksxt_exam ke on ke.id = str.train_exam_id where str.training_unit_id = #{examPaper.trainUnitId} and date_format(ke.start_time,'%Y-%m-%d') = #{examPaper.examDate} and cancel =1 and is_exam = 1 and bu.examination_type = 1 GROUP BY bu.dept_id) d on d.dept_id = a.dept_id
+        left join (select bu.dept_id,count(*) c from sys_training_registration str left join blade_user bu on bu.id = str.user_id left join ksxt_exam ke on ke.id = str.train_exam_id where str.training_unit_id = #{examPaper.trainUnitId} and date_format(ke.start_time,'%Y-%m-%d') = #{examPaper.examDate} and is_exam = 4 GROUP BY bu.dept_id) b on b.dept_id = a.dept_id
+        left join (select bu.dept_id,count(*) c from exam_score es left join blade_user bu on bu.id = es.user_id left join ksxt_exam ke on ke.id = es.exam_id left join sys_training_registration str on str.id = es.apply_id where str.training_unit_id = #{examPaper.trainUnitId} and date_format(ke.start_time,'%Y-%m-%d') = #{examPaper.examDate} and es.theory_grade &gt;= 60 GROUP BY bu.dept_id) c on c.dept_id = a.dept_id
+        ) aa,(select @i:=0) bb
+    </select>
+
+    <!--导出-按条件查询成绩数据-模拟考试-->
+    <select id="getExamScoreList" resultType="org.springblade.modules.exam.vo.ExamScoreVO">
+        select (@i:=@i+1) no,aa.* from (
+        SELECT
+        bu.real_name securityName,
+        bd.dept_name companyName,
+        es.theory_grade theoryGrade,es.learn_grade learnGrade,es.all_grade allGrade,
+        case when es.qualified=0 then "合格"
+        when es.qualified=1 then "不合格"
+        when es.qualified=2 then "暂未录入实操成绩"
+        when es.qualified=3 then "缺考"
+        else "" end as sortName
+        from
+        exam_score es
+        left join
+        ksxt_exam ke
+        on
+        ke.id = es.exam_id
+        left join
+        blade_user bu
+        on
+        es.user_id = bu.id
+        left join
+        blade_dept bd
+        on
+        bd.id = bu.dept_id
+        left join
+        sys_training_registration str
+        on
+        str.id = es.apply_id
+        where
+        1=1
+        and (str.is_exam = 2 or str.is_exam = 3 or str.is_exam = 4 or str.is_exam = 5)
+        <if test="examScore.trainUnitId!=null">
+            and str.training_unit_id = #{examScore.trainUnitId}
+        </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.examDate!=null  and examScore.examDate!=''">
+            and date_format(ke.start_time,'%Y-%m-%d') = #{examScore.examDate}
+        </if>
+        order by es.id desc
+        ) aa,(select @i:=0) bb
+    </select>
+
+    <!--ExamSubjectChoicesInfoMap 多表联查 一对多查询 -->
+    <resultMap id="ExamSubjectChoicesInfoMap" type="org.springblade.modules.exam.vo.ExamSubjectChoicesVO">
+        <id property="id" column="id"/>
+        <id property="categoryId" column="category_id"/>
+        <id property="subjectName" column="subject_name"/>
+        <id property="choicesType" column="choices_type"/>
+        <id property="answer" column="answer"/>
+        <id property="score" column="score"/>
+        <id property="level" column="level"/>
+        <result column="id" property="id"/>
+        <collection property="examSubjectOptions" javaType="java.util.List" ofType="org.springblade.modules.exam.entity.ExamSubjectOption" autoMapping="true">
+            <id property="id" column="eso_id"/>
+        </collection>
+    </resultMap>
+
+    <!--已缴费人员题目查询-->
+    <select id="queryRandomSubjectList" resultMap="ExamSubjectChoicesInfoMap">
+        select
+        esc.id,esc.category_id,esc.subject_name,esc.choices_type,esc.score,esc.answer,
+        eso.id eso_id,eso.subject_choices_id,eso.option_name,eso.option_content,eso.creator,
+        eso.create_date,eso.modifier,eso.modify_date,eso.del_flag,eso.application_code,eso.tenant_code
+        from (
+            select
+            id,
+            category_id,
+            subject_name,
+            choices_type,
+            score,
+            answer,
+            analysis,
+            tktype
+            from (
+            select * from exam_subject_choices
+            where id in
+            <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+            ) a ORDER BY RAND() LIMIT #{number}
+        ) esc
+        left join
+        exam_subject_option eso
+        on
+        esc.id = eso.subject_choices_id
+    </select>
+
+    <!--模拟考试随机抽题-->
+    <select id="simulateQueryRandomSubjectList" resultMap="ExamSubjectChoicesInfoMap">
+        SELECT
+            esc.id,
+            esc.category_id,
+            esc.subject_name,
+            esc.choices_type,
+            esc.score,
+            esc.answer,
+            eso.id eso_id,
+            eso.subject_choices_id,
+            eso.option_name,
+            eso.option_content,
+            eso.creator,
+            eso.create_date,
+            eso.modifier,
+            eso.modify_date,
+            eso.del_flag,
+            eso.application_code,
+            eso.tenant_code
+        FROM
+            (
+                SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 0 ORDER BY RAND( ) LIMIT 25 ) a UNION ALL
+                SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 1 ORDER BY RAND( ) LIMIT 10 ) b UNION ALL
+                SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 2 ORDER BY RAND( ) LIMIT 20 ) c UNION ALL
+                SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 3 ORDER BY RAND( ) LIMIT 5 ) d
+            ) esc
+            LEFT JOIN exam_subject_option eso ON esc.id = eso.subject_choices_id
+    </select>
+
+
 </mapper>

--
Gitblit v1.9.3