Bläddra i källkod

监考和管理员报表优化

wangliang 2 år sedan
förälder
incheckning
25e5637101

+ 4 - 16
themis-business/src/main/resources/mapper/TEExamMapper.xml

@@ -111,7 +111,7 @@
             t.end_time,
             t.progress,
             tbu2.name,
-            t.update_ime,
+            t.update_time,
             t.enable_ip_limit,
             t.monitor_video_source,
             t.monitor_record,
@@ -186,19 +186,9 @@
     </select>
 
     <select id="examPrivilegeQuery" resultType="com.qmth.themis.business.entity.TEExam">
-        select
-        *
-        from
-        t_e_exam tee
-        where
-        EXISTS(
-        select
-        DISTINCT tbeiu.exam_id
-        from
-        t_b_exam_invigilate_user tbeiu
-        left join t_e_exam_student tees on
-        tees.room_code = tbeiu.room_code and tees.exam_id = tbeiu.exam_id
-        <where>1 = 1
+        select * from t_e_exam tee
+        left join t_b_exam_invigilate_user tbeiu on tee.id = tbeiu.exam_id
+        <where> 1 = 1
             <if test="userId != null and userId != ''">
                 and tbeiu.user_id = #{userId}
             </if>
@@ -208,9 +198,7 @@
             <if test="type != null and type != '' and type == 'monitor'">
                 and tee.monitor_status <![CDATA[ <> ]]> 'FINISHED'
             </if>
-            and tee.id = tbeiu.exam_id
         </where>
-        )
         order by tee.create_time desc
     </select>
 

+ 21 - 86
themis-business/src/main/resources/mapper/TEExamStudentMapper.xml

@@ -93,13 +93,6 @@
     <select id="getTotalCountInfo"
             resultType="com.qmth.themis.business.bean.admin.ExamViewCountListBean">
         select
-        t.*,
-        if(t.monitorStatus = 'FINISHED',
-        t.examTotal - t.actualExamTotal,
-        0) as deficiencyExamTotal
-        from
-        (
-        select
         tee.name as examName,
         t.exam_id examId,
         t.exam_activity_id examActivityId,
@@ -108,25 +101,13 @@
         count(1) examTotal,
         teea.code as examActivityCode,
         tee.monitor_status as monitorStatus,
-        (
-        select
-        count(distinct toer.exam_student_id)
-        from
-        t_oe_exam_record toer
-        join t_e_exam_student tees on
-        toer.exam_student_id = tees.id
-        where
-        toer.exam_id = t.exam_id
-        and toer.exam_activity_id = t.exam_activity_id
-        and tees.room_code = t.room_code and tees.room_name = t.room_name and toer.first_start_time is not null) as actualExamTotal
-        from
-        t_e_exam_student t
-        left join t_e_student h on
-        t.student_id = h.id
-        left join t_e_exam_activity teea on
-        teea.id = t.exam_activity_id
-        join t_e_exam tee on
-        tee.id = t.exam_id
+        count(toer.exam_student_id) as actualExamTotal,
+        if(tee.monitor_status = 'FINISHED',count(1)- count(distinct toer.exam_student_id),0) as deficiencyExamTotal
+        from t_e_exam_student t
+        left join t_e_student h on t.student_id = h.id
+        left join t_e_exam_activity teea on teea.id = t.exam_activity_id
+        join t_e_exam tee on tee.id = t.exam_id
+        left join t_oe_exam_record toer on toer.exam_student_id = t.id and toer.first_start_time is not null
         where t.exam_id = #{examId}
         <if test="orgId != null">
             and h.org_id=#{orgId}
@@ -144,9 +125,9 @@
         t.exam_id,
         t.exam_activity_id,
         t.room_code,
-        t.room_name) t
+        t.room_name
         order by
-        t.examId
+        t.exam_id
     </select>
 
     <select id="getDoneCountByActivityIds"
@@ -220,16 +201,10 @@
         t.id
         from
         t_e_exam_student t
-        join t_e_exam_activity f on
-        t.exam_activity_id = f.id
-        join t_e_exam tee on
-        tee.id = t.exam_id
-        where
-        NOT EXISTS(
-        select distinct toer.exam_student_id
-        from
-        t_oe_exam_record toer
-        where t.id = toer.exam_student_id)
+        join t_e_exam_activity f on t.exam_activity_id = f.id
+        join t_e_exam tee on tee.id = t.exam_id
+        left join t_oe_exam_record toer on t.id = toer.exam_student_id
+        where 1 = 1
         and t.exam_id = #{examId}
         and t.exam_activity_id in
         <foreach collection="activityIds" item="acid" index="index"
@@ -251,6 +226,7 @@
         <if test="name != null and name != ''">
             and t.name like concat('%',#{name},'%')
         </if>
+        and toer.id is null
         union all
         select
         distinct tee.name as examName,
@@ -266,16 +242,12 @@
         t.id
         from
         t_oe_exam_record toer
-        join t_e_exam_student t on
-        t.id = toer.exam_student_id
-        and t.exam_id = toer.exam_id
-        and t.exam_activity_id = toer.exam_activity_id
-        join t_e_exam_activity f on
-        t.exam_activity_id = f.id
-        join t_e_exam tee on
-        tee.id = t.exam_id
-        where
-        toer.exam_id = #{examId}
+        join t_e_exam_student t on t.id = toer.exam_student_id
+        join t_e_exam_activity f on t.exam_activity_id = f.id
+        join t_e_exam tee on tee.id = t.exam_id
+        left join t_oe_exam_record toer1 on t.id = toer1.exam_student_id and toer1.first_start_time is not null
+        where 1 = 1
+        and toer.exam_id = #{examId}
         and toer.exam_activity_id in
         <foreach collection="activityIds" item="acid" index="index"
                  open="(" close=")" separator=",">
@@ -297,44 +269,7 @@
             and t.name like concat('%',#{name},'%')
         </if>
         and toer.first_start_time is null
-        and not exists(
-        select
-        *
-        from
-        (
-        select
-        distinct t.exam_student_id as id
-        from
-        t_oe_exam_record t
-        join t_e_exam_student s on
-        t.exam_student_id = s.id
-        where
-        t.exam_id = #{examId}
-        and t.first_start_time is not null
-        and t.exam_activity_id in
-        <foreach collection="activityIds" item="acid" index="index"
-                 open="(" close=")" separator=",">
-            #{acid}
-        </foreach>
-        <if test="activityId != null and activityId != ''">
-            and s.exam_activity_id = #{activityId}
-        </if>
-        <if test="roomCode != null and roomCode != ''">
-            and s.room_code =#{roomCode}
-        </if>
-        <if test="courseCode != null and courseCode != ''">
-            and s.course_code = #{courseCode}
-        </if>
-        <if test="identity != null and identity != ''">
-            and s.identity like concat('%',#{identity},'%')
-        </if>
-        <if test="name != null and name != ''">
-            and s.name like concat('%',#{name},'%')
-        </if>
-        ) temp
-        where
-        temp.id = toer.exam_student_id)
-            ) t
+        and toer1.id is null) t
         order by
         t.examActivityId,
         t.roomCode