智慧保安后台管理-外网
Administrator
2022-01-20 cb04ed62736efe70cf5babe534220b4ae4c1ca67
src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
@@ -262,7 +262,7 @@
    <!--查询当前考试已报名的人员培训报名数据集合-->
    <select id="getTrainList" resultType="org.springblade.modules.training.entity.TrainingRegistration">
        SELECT
        str.id,str.user_id userId
        str.id,str.user_id userId,str.candidate_no candidateNo
        FROM
        sys_training_registration str
        left join
@@ -305,7 +305,7 @@
        on
            bu.id = str.user_id
        where
            bu.is_deleted = 0 and bu.status = 1
            1=1
        and train_exam_id = #{examPaper.id}
    </select>
@@ -378,38 +378,94 @@
        on
            bu.id = str.user_id
        where
            bu.is_deleted = 0 and bu.status = 1
            1=1
        and train_exam_id = #{examPaper.id}
        and (is_exam = 2 or is_exam = 3)
        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>    -->
    <!--考试查询统计,按天,培训学校分组-->
    <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,
        si.enterpriseName schoolName,
        a.time startTime,
        a.training_unit_id trainUnitId,
        ifnull(a.c,0) znum,
        ifnull(b.c,0) yknum,
        ifnull(f.c,0) zznum,
        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
        from
        (select date_format(ke.start_time,'%Y-%m-%d') time,str.training_unit_id,count(*) c from sys_training_registration str left join ksxt_exam ke on ke.id = str.train_exam_id where 1=1 and ke.audit_status =1 GROUP BY date_format(ke.start_time,'%Y-%m-%d'),str.training_unit_id ) a
        left join
        (select count(*) c,date_format(ke.start_time,'%Y-%m-%d') time,str.training_unit_id from sys_training_registration str left join ksxt_exam ke on ke.id = str.train_exam_id where 1=1 and ke.audit_status =1 and (is_exam = 2 or is_exam = 3) GROUP BY date_format(ke.start_time,'%Y-%m-%d'),str.training_unit_id ) b
        on a.time = b.time and a.training_unit_id = b.training_unit_id
        left join
        (select count(*) c,date_format(ke.start_time,'%Y-%m-%d') time,str.training_unit_id from sys_training_registration str left join ksxt_exam ke on ke.id = str.train_exam_id where 1=1 and ke.audit_status =1 and is_exam = 5 GROUP BY date_format(ke.start_time,'%Y-%m-%d'),str.training_unit_id ) f
        on a.time = f.time and a.training_unit_id = f.training_unit_id
        left join
        (select count(*) c,date_format(ke.start_time,'%Y-%m-%d') time,str.training_unit_id from sys_training_registration str left join ksxt_exam ke on ke.id = str.train_exam_id left join blade_user bu on bu.id = str.user_id where 1=1 and is_exam = 4 GROUP BY date_format(ke.start_time,'%Y-%m-%d'),str.training_unit_id ) c
        on a.time = c.time and a.training_unit_id = c.training_unit_id
        left join
        (select count(*) c,date_format(ke.start_time,'%Y-%m-%d') time,str.training_unit_id from sys_training_registration str left join ksxt_exam ke on ke.id = str.train_exam_id 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 date_format(ke.start_time,'%Y-%m-%d'),str.training_unit_id ) d
        on a.time = d.time and a.training_unit_id = d.training_unit_id
        left join
        (select count(*) c,date_format(ke.start_time,'%Y-%m-%d') time,str.training_unit_id from sys_training_registration str left join ksxt_exam ke on ke.id = str.train_exam_id where 1=1 and is_exam = 1 and cancel =2 GROUP BY date_format(ke.start_time,'%Y-%m-%d'),str.training_unit_id ) e
        on a.time = e.time and a.training_unit_id = e.training_unit_id
        left join sys_information si on si.departmentid = a.training_unit_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},'%')
            and si.enterpriseName like concat('%',#{examPaper.schoolName},'%')
        </if>
        <if test="examPaper.examTime!=null and examPaper.examTime!=''">
            and date_format(ke.start_time,'%Y-%m-%d') = #{examPaper.examTime}
            and a.time = #{examPaper.examTime}
        </if>
        order by ke.id desc
        order by a.time desc,si.enterpriseName desc
    </select>
    <!--根据考试id 统计查询考试信息-->
    <select id="getExamInfoByExamId" resultType="org.springblade.modules.exam.vo.ExamStatisticsVO">
        select
        a.dept_id id,
        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.startTime} 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.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
    </select>
</mapper>