智慧保安后台管理-外网项目备份
钟日健
2026-06-01 62eb499b0c969f246d3245d1429a97da4de1ce28
src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
@@ -79,10 +79,9 @@
    </select>
    <select id="queryRandomSubject" resultMap="RandomResult" >
        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 = 0 ORDER BY RAND( ) LIMIT 70) 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
        SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 2 ORDER BY RAND( ) LIMIT 20 ) c
    </select>
    <select id="selectExamPaperPages" resultType="org.springblade.modules.exam.vo.ExamPaperVO">
@@ -104,7 +103,8 @@
            ke.*,
            bu.real_name realName,
            bd.dept_name deptName,
            bu1.real_name confirmUserName
            bu1.real_name confirmUserName,
            bu2.real_name auditUserName
        FROM
            ksxt_exam ke
        left join
@@ -119,6 +119,10 @@
            blade_user bu1
        on
            ke.confirm_user = bu1.id
        left join
            blade_user bu2
        on
            ke.audit_user = bu2.id
        where
        1=1
        <if test="paper.examType!=null and paper.examType!=''">
@@ -227,22 +231,12 @@
        select
            ke.id,ke.exam_name examName,ke.start_time startTime,ke.end_time endTime,ke.exam_type examType,
            str.candidate_no candidateNo,str.id applyId,str.is_exam isExam,
            bu.real_name realName,bu.sex,bu.cardid idCardNo,
            bu.real_name realName,IF(mod(SUBSTR(bu.cardid,17,1),2),1,2) sex,bu.cardid idCardNo,
            es.exam_time examStartTime,es.id scoreId
        from
            ksxt_exam ke
        left join
            sys_training_registration str
        on
            str.train_exam_id = ke.id
        left join
            blade_user bu
        on
            bu.id = str.user_id
        left join
         exam_score es
      on
      es.apply_id = str.id
        from ksxt_exam ke
        left join sys_training_registration str on str.train_exam_id = ke.id
        left join blade_user bu on bu.id = str.user_id
        left join exam_score es on es.apply_id = str.id and es.is_deleted = 0
        where str.user_id = #{examPaper.userId}
        and bu.is_train = 1
        and (str.is_exam = 1 or str.is_exam = 3)
@@ -465,7 +459,7 @@
        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.theory_grade &gt;= 60 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 es.is_deleted = 0 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 统计查询考试信息-->
@@ -481,7 +475,7 @@
        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
        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 es.is_deleted = 0 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>
@@ -516,7 +510,7 @@
        on
        str.id = es.apply_id
        where
        1=1
        1=1 and es.is_deleted = 0
        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}
@@ -549,6 +543,7 @@
        </collection>
    </resultMap>
    <!--已缴费人员题目查询-->
    <select id="queryRandomSubjectList" resultMap="ExamSubjectChoicesInfoMap">
        select
        esc.id,esc.category_id,esc.subject_name,esc.choices_type,esc.score,esc.answer,
@@ -578,5 +573,51 @@
        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 70 ) 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
            ) esc
            LEFT JOIN exam_subject_option eso ON esc.id = eso.subject_choices_id
    </select>
    <select id="getList" resultType="org.springblade.modules.exam.vo.ExamPaperVO">
        SELECT * FROM ksxt_exam
        where 1=1
        <if test="vo.examTime != null and vo.examTime != ''">
            AND DATE_FORMAT(start_time,'%Y-%m-%d') = DATE_FORMAT(#{vo.examTime},'%Y-%m-%d')
        </if>
        ORDER BY start_time DESC
    </select>
    <select id="getLatest" resultType="org.springblade.modules.exam.vo.ExamPaperVO">
        SELECT * FROM ksxt_exam
        where 1=1
        <if test="vo.examTime != null and vo.examTime != ''">
            AND DATE_FORMAT(start_time,'%Y-%m-%d') = DATE_FORMAT(#{vo.examTime},'%Y-%m-%d')
        </if>
        ORDER BY start_time DESC
        LIMIT 1
    </select>
</mapper>