wangliang 2 жил өмнө
parent
commit
fd0aba7ab6

+ 1 - 1
themis-business/src/main/resources/mapper/TEExamReexamMapper.xml

@@ -19,7 +19,7 @@
         t_e_exam_student tees
         left join t_e_exam tee on
         tees.exam_id = tee.id
-        join t_b_exam_invigilate_user tbeiu on
+        left join t_b_exam_invigilate_user tbeiu on
         tbeiu.exam_id = tee.id
         and tbeiu.org_id = tee.org_id
         and tbeiu.room_code = tees.room_code

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

@@ -495,7 +495,7 @@
                     #{paperId}
                 </foreach>
             </if>
-          and (toer.status = 'FINISHED' or toer.status = 'PERSISTED')
+          and toer.status in ('FINISHED','PERSISTED')
           and toer.first_start_time is not null
           and toer.finish_time is not null
           <if test="examStudentBreachPush != null and (examStudentBreachPush == false or examStudentBreachPush == 0)">

+ 1 - 1
themis-business/src/main/resources/mapper/TIeExamInvigilateCallMapper.xml

@@ -42,7 +42,7 @@
             </if>
         </where>
         <if test="callStatus != null and callStatus != '' and (callStatus == 'START' or callStatus == 'START,CANCEL')">
-            and (toer.status = 'FIRST_PREPARE' or toer.status = 'ANSWERING' or toer.status = 'BREAK_OFF' or toer.status = 'RESUME_PREPARE')
+            and toer.status in ('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
         </if>
         order by tieic.start_time desc
     </select>

+ 8 - 6
themis-business/src/main/resources/mapper/TIeInvigilateWarnInfoMapper.xml

@@ -7,15 +7,16 @@
         from t_ie_invigilate_warn_info tiiwi
         left join t_e_exam_student tees on tees.id = tiiwi.exam_student_id
         left join t_e_exam tee on tee.id = tees.exam_id
+        <if test="userId != null and userId != ''">
+            left join t_b_exam_invigilate_user tbeiu on tbeiu.exam_id = tees.exam_id
+        </if>
         <where> 1 = 1
             and tee.monitor_status <![CDATA[ <> ]]> 'FINISHED'
             <if test="examId != null and examId != ''">
                 and tiiwi.exam_id = #{examId}
             </if>
             <if test="userId != null and userId != ''">
-                and exists (select tbeiu.exam_id from t_b_exam_invigilate_user tbeiu
-                where tbeiu.user_id = #{userId}
-                and tbeiu.exam_id = tees.exam_id and tbeiu.room_code = tees.room_code)
+                and tbeiu.user_id = #{userId}
             </if>
             <if test="orgId != null and orgId != ''">
                 and tee.org_id = #{orgId}
@@ -38,6 +39,9 @@
         from t_ie_invigilate_warn_info tiiwi
         left join t_e_exam_student tees on tees.id = tiiwi.exam_student_id
         left join t_e_exam tee on tee.id = tees.exam_id
+        <if test="userId != null and userId != ''">
+            left join t_b_exam_invigilate_user tbeiu on tbeiu.exam_id = tees.exam_id
+        </if>
         <where> 1 = 1
             and tee.monitor_status <![CDATA[ <> ]]> 'FINISHED'
             <if test="examIdList != null and examIdList != '' and examIdList.size > 0">
@@ -47,9 +51,7 @@
                 </foreach>
             </if>
             <if test="userId != null and userId != ''">
-                and exists (select tbeiu.exam_id from t_b_exam_invigilate_user tbeiu
-                where tbeiu.user_id = #{userId}
-                and tbeiu.exam_id = tees.exam_id and tbeiu.room_code = tees.room_code)
+                and tbeiu.user_id = #{userId}
             </if>
             <if test="orgId != null and orgId != ''">
                 and tee.org_id = #{orgId}

+ 230 - 400
themis-business/src/main/resources/mapper/TOeExamRecordMapper.xml

@@ -35,119 +35,9 @@
 		left join t_e_exam_activity teea on teea.id = t.exam_activity_id
     </sql>
 
-    <sql id="invigilatePageFoot">
-        <where>
-            <if test="examId != null and examId != ''">
-                and t.exam_id = #{examId}
-            </if>
-            <if test="userId != null and userId != ''">
-                and exists (select tbeiu.exam_id from t_b_exam_invigilate_user tbeiu
-                where tbeiu.user_id = #{userId}
-                and tbeiu.exam_id = s.exam_id and tbeiu.room_code = s.room_code)
-            </if>
-            <if test="orgId != null and orgId != ''">
-                and tee.org_id = #{orgId}
-            </if>
-            <if test="examActivityId != null and examActivityId != ''">
-                and t.exam_activity_id = #{examActivityId}
-            </if>
-            <if test="roomCode != null and roomCode != ''">
-                and s.room_code = #{roomCode}
-            </if>
-            <if test="status != null and status != ''">
-                <choose>
-                    <when test="status == 'EXAMING'">
-                        and (t.status = 'ANSWERING' or t.status = 'RESUME_PREPARE' or t.status = 'BREAK_OFF')
-                    </when>
-                    <otherwise>
-                        and t.status = #{status}
-                    </otherwise>
-                </choose>
-            </if>
-            <if test="name != null and name !=''">
-                and s.name like CONCAT('%', #{name},'%')
-            </if>
-            <if test="identity != null and identity !=''">
-                and s.identity like CONCAT('%', #{identity},'%')
-            </if>
-            <if test="maxWarningCount != null and maxWarningCount != '' or maxWarningCount == 0">
-                and t.warning_count &lt;= #{maxWarningCount}
-            </if>
-            <if test="minWarningCount != null and minWarningCount != '' or minWarningCount == 0">
-                and t.warning_count &gt;= #{minWarningCount}
-            </if>
-            <if test="clientWebsocketStatus != null and clientWebsocketStatus != ''">
-                and t.client_websocket_status = #{clientWebsocketStatus}
-            </if>
-            and teea.finish_time > unix_timestamp(current_timestamp()) * 1000
-        </where>
-    </sql>
-
-    <sql id="invigilatePageHistoryFoot">
-        <where>1 = 1
-            <if test="examId != null and examId != ''">
-                and t.exam_id = #{examId}
-            </if>
-            <if test="userId != null and userId != ''">
-                and exists (select tbeiu.exam_id from t_b_exam_invigilate_user tbeiu
-                where tbeiu.user_id = #{userId}
-                and tbeiu.exam_id = t.exam_id and tbeiu.room_code = s.room_code)
-            </if>
-            <if test="orgId != null and orgId != ''">
-                and tee.org_id = #{orgId}
-            </if>
-            <if test="examActivityId != null and examActivityId != ''">
-                and t.exam_activity_id = #{examActivityId}
-            </if>
-            <if test="roomCode != null and roomCode != ''">
-                and s.room_code = #{roomCode}
-            </if>
-            <if test="status != null and status != ''">
-                <choose>
-                    <when test="status == 'EXAMING'">
-                        and (t.status = 'ANSWERING' or t.status = 'RESUME_PREPARE')
-                    </when>
-                    <otherwise>
-                        and t.status = #{status}
-                    </otherwise>
-                </choose>
-            </if>
-            <if test="name != null and name !=''">
-                and s.name like CONCAT('%', #{name},'%')
-            </if>
-            <if test="identity != null and identity !=''">
-                and s.identity like CONCAT('%', #{identity},'%')
-            </if>
-            <if test="maxWarningCount != null and maxWarningCount != '' or maxWarningCount == 0">
-                and t.warning_count &lt;= #{maxWarningCount}
-            </if>
-            <if test="minWarningCount != null and minWarningCount != '' or minWarningCount == 0">
-                and t.warning_count &gt;= #{minWarningCount}
-            </if>
-        </where>
-    </sql>
-
     <select id="invigilatePageListVideo" resultType="com.qmth.themis.business.bean.admin.InvigilateListVideoBean">
         select (@i := @i + 1) as seq,t.* from(
         select
-        temp.*,
-        toer.id as examRecordId,
-        IFNULL(toer.paper_download,1) as paperDownload,
-        toer.status as statusCode,
-        TRUNCATE(toer.answer_progress,2) as progress,
-        IFNULL(toer.client_current_ip,'无') as clientCurrentIp,
-        IFNULL(toer.warning_count,0) as warningCount,
-        IFNULL(toer.breach_status,1) as breachStatus,
-        IFNULL(toer.client_websocket_status,'OFF_LINE') as clientWebsocketStatus,
-        toer.client_last_sync_time as updateTime,
-        toer.monitor_video_source as monitorVideoSource,
-        toer.monitor_record as monitorRecord,
-        toer.finish_type as finishType
-        ,(select count(1) from t_ie_invigilate_warn_info tiiwi where tiiwi.exam_record_id = toer.id and
-        tiiwi.approve_status = 0) as warningNew
-        from
-        (
-        select
         distinct s.exam_id as examId,
         tee.name as examName,
         s.exam_activity_id as examActivityId,
@@ -160,46 +50,51 @@
         s.course_name as courseName,
         s.course_code as courseCode,
         tes.mobile_number as mobileNumber,
-        tes.base_photo_path as basePhotoPath
+        tes.base_photo_path as basePhotoPath,
+        toer.id as examRecordId,
+        IFNULL(toer.paper_download,1) as paperDownload,
+        toer.status as statusCode,
+        TRUNCATE(toer.answer_progress,2) as progress,
+        IFNULL(toer.client_current_ip,'无') as clientCurrentIp,
+        IFNULL(toer.warning_count,0) as warningCount,
+        IFNULL(toer.breach_status,1) as breachStatus,
+        IFNULL(toer.client_websocket_status,'OFF_LINE') as clientWebsocketStatus,
+        toer.client_last_sync_time as updateTime,
+        toer.monitor_video_source as monitorVideoSource,
+        toer.monitor_record as monitorRecord,
+        toer.finish_type as finishType
+        ,(select count(1) from t_ie_invigilate_warn_info tiiwi where 1 = 1
+        <if test="examId != null and examId != ''">
+            and tiiwi.exam_id = #{examId}
+        </if>
+            and tiiwi.exam_record_id = toer.id and tiiwi.approve_status = 0) as warningNew
         from
         t_e_exam_student s
-        left join t_e_exam tee on
-        tee.id = s.exam_id
-        left join t_e_exam_activity teea on
-        teea.id = s.exam_activity_id
-        left join t_e_student tes on
-        s.student_id = tes.id
-        WHERE
-        <choose>
-            <when test="status != null and status != '' and status == 'UN_FINISH'">
-                NOT EXISTS(
-            </when>
-            <otherwise>
-                EXISTS(
-            </otherwise>
-        </choose>
-        select
-        toer.exam_student_id
-        from
-        t_oe_exam_record toer
-        where
-        s.id = toer.exam_student_id
-        <!--<if test="status != null and status != '' and status == 'UN_FINISH'">
-            and (toer.STATUS = 'FINISHED' or toer.STATUS = 'PERSISTED')
-            and toer.first_start_time is not null
-        </if>-->
-        )
+        left join t_e_exam tee on tee.id = s.exam_id
+        left join t_e_exam_activity teea on teea.id = s.exam_activity_id
+        left join t_e_student tes on s.student_id = tes.id
+        <if test="userId != null and userId != ''">
+            left join t_b_exam_invigilate_user tbeiu on tbeiu.exam_id = s.exam_id
+        </if>
+        left join t_oe_exam_record toer on toer.exam_student_id = s.id
+        WHERE 1 = 1
         <if test="examId != null and examId != ''">
             and s.exam_id = #{examId}
         </if>
         <if test="userId != null and userId != ''">
-            and exists (select tbeiu.exam_id from t_b_exam_invigilate_user tbeiu
-            where tbeiu.user_id = #{userId}
-            and tbeiu.exam_id = s.exam_id and tbeiu.room_code = s.room_code)
+            and tbeiu.user_id = #{userId}
         </if>
         <if test="orgId != null and orgId != ''">
             and tee.org_id = #{orgId}
         </if>
+        <choose>
+            <when test="status != null and status != '' and status == 'UN_FINISH'">
+                and toer.id is null
+            </when>
+            <otherwise>
+                and toer.id is not null
+            </otherwise>
+        </choose>
         <if test="examActivityId != null and examActivityId != ''">
             and s.exam_activity_id = #{examActivityId}
         </if>
@@ -212,53 +107,44 @@
         <if test="identity != null and identity !=''">
             and s.identity like CONCAT('%', #{identity},'%')
         </if>
-        and teea.finish_time > unix_timestamp(current_timestamp()) * 1000
-        ) temp
-        left join t_oe_exam_record toer on
-        toer.exam_student_id = temp.examStudentId
-        <where>1 = 1
-            <if test="status != null and status != '' and status != 'UN_FINISH'">
-                <choose>
-                    <when test="status == 'EXAMING'">
-                        and (toer.status = 'ANSWERING' or toer.status = 'RESUME_PREPARE' or toer.status = 'BREAK_OFF')
-                    </when>
-                    <otherwise>
-                        and toer.status = #{status}
-                    </otherwise>
-                </choose>
-            </if>
-            <!--<if test="status != null and status != '' and status == 'UN_FINISH'">
-                and (toer.first_start_time is null or toer.first_prepare_time is null)
-            </if>-->
-            <if test="maxWarningCount != null and maxWarningCount != '' or maxWarningCount == 0">
-                and toer.warning_count &lt;= #{maxWarningCount}
-            </if>
-            <if test="minWarningCount != null and minWarningCount != '' or minWarningCount == 0">
-                and toer.warning_count &gt;= #{minWarningCount}
-            </if>
-            <if test="clientWebsocketStatus != null and clientWebsocketStatus != ''">
-                and toer.client_websocket_status = #{clientWebsocketStatus}
-            </if>
-            <if test="paperDownload != null and paperDownload != '' or paperDownload == 0">
-                and toer.paper_download = #{paperDownload}
-            </if>
-            <if test="status == null or status == ''">
-                and (toer.status = 'FIRST_PREPARE' or toer.status = 'ANSWERING' or toer.status = 'BREAK_OFF' or
-                toer.status = 'RESUME_PREPARE')
-            </if>
-            <if test="cameraMonitorStatus != null and cameraMonitorStatus != ''">
-                and toer.camera_monitor_status = upper(#{cameraMonitorStatus})
-            </if>
-            <if test="screenMonitorStatus != null and screenMonitorStatus != ''">
-                and toer.screen_monitor_status = upper(#{screenMonitorStatus})
-            </if>
-            <if test="mobileFirstMonitorStatus != null and mobileFirstMonitorStatus != ''">
-                and toer.mobile_first_monitor_status = upper(#{mobileFirstMonitorStatus})
-            </if>
-            <if test="mobileSecondMonitorStatus != null and mobileSecondMonitorStatus != ''">
-                and toer.mobile_second_monitor_status = upper(#{mobileSecondMonitorStatus})
-            </if>
-        </where>
+            and teea.finish_time > unix_timestamp(current_timestamp()) * 1000
+        <if test="status != null and status != '' and status != 'UN_FINISH'">
+            <choose>
+                <when test="status == 'EXAMING'">
+                    and toer.status in ('ANSWERING','RESUME_PREPARE','BREAK_OFF')
+                </when>
+                <otherwise>
+                    and toer.status = #{status}
+                </otherwise>
+            </choose>
+        </if>
+        <if test="maxWarningCount != null and maxWarningCount != '' or maxWarningCount == 0">
+            and toer.warning_count &lt;= #{maxWarningCount}
+        </if>
+        <if test="minWarningCount != null and minWarningCount != '' or minWarningCount == 0">
+            and toer.warning_count &gt;= #{minWarningCount}
+        </if>
+        <if test="clientWebsocketStatus != null and clientWebsocketStatus != ''">
+            and toer.client_websocket_status = #{clientWebsocketStatus}
+        </if>
+        <if test="paperDownload != null and paperDownload != '' or paperDownload == 0">
+            and toer.paper_download = #{paperDownload}
+        </if>
+        <if test="status == null or status == ''">
+            and toer.status in ('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
+        </if>
+        <if test="cameraMonitorStatus != null and cameraMonitorStatus != ''">
+            and toer.camera_monitor_status = upper(#{cameraMonitorStatus})
+        </if>
+        <if test="screenMonitorStatus != null and screenMonitorStatus != ''">
+            and toer.screen_monitor_status = upper(#{screenMonitorStatus})
+        </if>
+        <if test="mobileFirstMonitorStatus != null and mobileFirstMonitorStatus != ''">
+            and toer.mobile_first_monitor_status = upper(#{mobileFirstMonitorStatus})
+        </if>
+        <if test="mobileSecondMonitorStatus != null and mobileSecondMonitorStatus != ''">
+            and toer.mobile_second_monitor_status = upper(#{mobileSecondMonitorStatus})
+        </if>
         ) t,
         (SELECT @i := 0) as i
         order by t.identity desc
@@ -267,7 +153,11 @@
     <select id="invigilatePageListVideoRandom" resultType="com.qmth.themis.business.bean.admin.InvigilateListVideoBean">
         <include refid="invigilatePageHead"/>
         <!--,t.monitor_live_url as monitorLiveUrl-->
-        ,(select count(1) from t_ie_invigilate_warn_info tiiwi where tiiwi.exam_record_id = t.id and
+        ,(select count(1) from t_ie_invigilate_warn_info tiiwi where 1 = 1
+            <if test="examId != null and examId != ''">
+                and tiiwi.exam_id = #{examId}
+            </if>
+            and tiiwi.exam_record_id = t.id and
         tiiwi.approve_status = 0) as warningNew
         <include refid="invigilatePageMiddle"/>
         <where>1 = 1
@@ -277,83 +167,73 @@
             <if test="orgId != null and orgId != ''">
                 and tee.org_id = #{orgId}
             </if>
-            and (t.status = 'FIRST_PREPARE' or t.status = 'ANSWERING' or t.status = 'BREAK_OFF' or t.status =
-            'RESUME_PREPARE')
+            and t.status in('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
         </where>
         ORDER BY RAND() LIMIT #{randomNum}
     </select>
 
     <select id="invigilatePagePatrolList" resultType="com.qmth.themis.business.bean.admin.InvigilateListPatrolBean">
         select (@i := @i + 1) as seq,t.* from(
-        select
-        temp.*,
-        toer.id as examRecordId,
-        IFNULL(toer.paper_download,1) as paperDownload,
-        toer.status as statusCode,
-        TRUNCATE(toer.answer_progress,2) as progress,
-        IFNULL(toer.client_current_ip,'无') as clientCurrentIp,
-        IFNULL(toer.warning_count,0) as warningCount,
-        IFNULL(toer.breach_status,1) as breachStatus,
-        IFNULL(toer.client_websocket_status,'OFF_LINE') as clientWebsocketStatus,
-        toer.client_last_sync_time as updateTime,
-        toer.monitor_video_source as monitorVideoSource,
-        toer.monitor_record as monitorRecord,
-        toer.finish_type as finishType
-        ,(select count(1) from t_ie_invigilate_exception_info tiiei where tiiei.exam_record_id = toer.id) as
-        exceptionCount
-        ,(select count(1) from t_ie_invigilate_warn_info tiiwi where tiiwi.exam_record_id = toer.id and tiiwi.`type` =
-        'FACE_COUNT_ERROR' and tiiwi.`level` = 'D8') as multipleFaceCount
-        from
-        (
-        select
-        distinct s.exam_id as examId,
-        tee.name as examName,
-        s.exam_activity_id as examActivityId,
-        teea.code as examActivityCode,
-        s.id as examStudentId,
-        s.identity,
-        s.room_code as roomCode,
-        s.room_name as roomName,
-        s.name,
-        s.course_name as courseName,
-        s.course_code as courseCode,
-        tes.mobile_number as mobileNumber
-        from
-        t_e_exam_student s
-        left join t_e_exam tee on
-        tee.id = s.exam_id
-        left join t_e_exam_activity teea on
-        teea.id = s.exam_activity_id
-        left join t_e_student tes on
-        s.student_id = tes.id
-        WHERE
+            select
+            distinct s.exam_id as examId,
+            tee.name as examName,
+            s.exam_activity_id as examActivityId,
+            teea.code as examActivityCode,
+            s.id as examStudentId,
+            s.identity,
+            s.room_code as roomCode,
+            s.room_name as roomName,
+            s.name,
+            s.course_name as courseName,
+            s.course_code as courseCode,
+            tes.mobile_number as mobileNumber,
+            toer.id as examRecordId,
+            IFNULL(toer.paper_download,1) as paperDownload,
+            toer.status as statusCode,
+            TRUNCATE(toer.answer_progress,2) as progress,
+            IFNULL(toer.client_current_ip,'无') as clientCurrentIp,
+            IFNULL(toer.warning_count,0) as warningCount,
+            IFNULL(toer.breach_status,1) as breachStatus,
+            IFNULL(toer.client_websocket_status,'OFF_LINE') as clientWebsocketStatus,
+            toer.client_last_sync_time as updateTime,
+            toer.monitor_video_source as monitorVideoSource,
+            toer.monitor_record as monitorRecord,
+            toer.finish_type as finishType
+            ,(select count(1) from t_ie_invigilate_exception_info tiiei where 1 = 1
+                <if test="examId != null and examId != ''">
+                    and tiiei.exam_id = #{examId}
+                </if>
+                    and tiiei.exam_record_id = toer.id) as
+            exceptionCount
+            ,(select count(1) from t_ie_invigilate_warn_info tiiwi where 1 = 1
+                <if test="examId != null and examId != ''">
+                    and tiiwi.exam_id = #{examId}
+                </if>
+                    and tiiwi.exam_record_id = toer.id and tiiwi.`type` = 'FACE_COUNT_ERROR' and tiiwi.`level` = 'D8') as multipleFaceCount
+            from
+            t_e_exam_student s
+            left join t_e_exam tee on tee.id = s.exam_id
+            left join t_e_exam_activity teea on teea.id = s.exam_activity_id
+            left join t_e_student tes on s.student_id = tes.id
+            LEFT JOIN t_oe_exam_record toer on toer.exam_student_id = s.id
+            <if test="userId != null and userId != ''">
+                left join t_b_exam_invigilate_user tbeiu on tbeiu.exam_id = s.exam_id
+            </if>
+        WHERE 1 = 1
+        <if test="examId != null and examId != ''">
+            and s.exam_id = #{examId}
+        </if>
+        <if test="userId != null and userId != ''">
+            and tbeiu.user_id = #{userId}
+        </if>
         <choose>
             <when test="status != null and status != '' and status == 'UN_FINISH'">
-                NOT EXISTS(
+                and toer.id is null
             </when>
             <otherwise>
-                EXISTS(
+                and toer.id is not null
             </otherwise>
         </choose>
-        select
-        toer.exam_student_id
-        from
-        t_oe_exam_record toer
-        where
-        s.id = toer.exam_student_id
-        <!--<if test="status != null and status != '' and status == 'UN_FINISH'">
-            and (toer.STATUS = 'FINISHED' or toer.STATUS = 'PERSISTED')
-            and toer.first_start_time is not null
-        </if>-->
-        )
-        <if test="examId != null and examId != ''">
-            and s.exam_id = #{examId}
-        </if>
-        <if test="userId != null and userId != ''">
-            and exists (select tbeiu.exam_id from t_b_exam_invigilate_user tbeiu
-            where tbeiu.user_id = #{userId}
-            and tbeiu.exam_id = s.exam_id and tbeiu.room_code = s.room_code)
-        </if>
         <if test="orgId != null and orgId != ''">
             and tee.org_id = #{orgId}
         </if>
@@ -370,40 +250,31 @@
             and s.identity like CONCAT('%', #{identity},'%')
         </if>
         and teea.finish_time > unix_timestamp(current_timestamp()) * 1000
-        ) temp
-        left join t_oe_exam_record toer on
-        toer.exam_student_id = temp.examStudentId
-        <where>1 = 1
-            <if test="status != null and status != '' and status != 'UN_FINISH'">
-                <choose>
-                    <when test="status == 'EXAMING'">
-                        and (toer.status = 'ANSWERING' or toer.status = 'RESUME_PREPARE' or toer.status = 'BREAK_OFF')
-                    </when>
-                    <otherwise>
-                        and toer.status = #{status}
-                    </otherwise>
-                </choose>
-            </if>
-            <!--<if test="status != null and status != '' and status == 'UN_FINISH'">
-                and (toer.first_start_time is null or toer.first_prepare_time is null)
-            </if>-->
-            <if test="maxWarningCount != null and maxWarningCount != '' or maxWarningCount == 0">
-                and toer.warning_count &lt;= #{maxWarningCount}
-            </if>
-            <if test="minWarningCount != null and minWarningCount != '' or minWarningCount == 0">
-                and toer.warning_count &gt;= #{minWarningCount}
-            </if>
-            <if test="clientWebsocketStatus != null and clientWebsocketStatus != ''">
-                and toer.client_websocket_status = #{clientWebsocketStatus}
-            </if>
-            <if test="status == null or status == ''">
-                and (toer.status = 'FIRST_PREPARE' or toer.status = 'ANSWERING' or toer.status = 'BREAK_OFF' or
-                toer.status = 'RESUME_PREPARE')
-            </if>
-        </where>
+        <if test="status != null and status != '' and status != 'UN_FINISH'">
+            <choose>
+                <when test="status == 'EXAMING'">
+                    and toer.status in ('ANSWERING','RESUME_PREPARE','BREAK_OFF')
+                </when>
+                <otherwise>
+                    and toer.status = #{status}
+                </otherwise>
+            </choose>
+        </if>
+        <if test="maxWarningCount != null and maxWarningCount != '' or maxWarningCount == 0">
+            and toer.warning_count &lt;= #{maxWarningCount}
+        </if>
+        <if test="minWarningCount != null and minWarningCount != '' or minWarningCount == 0">
+            and toer.warning_count &gt;= #{minWarningCount}
+        </if>
+        <if test="clientWebsocketStatus != null and clientWebsocketStatus != ''">
+            and toer.client_websocket_status = #{clientWebsocketStatus}
+        </if>
+        <if test="status == null or status == ''">
+            and toer.status in ('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
+        </if>
         ) t,
         (SELECT @i := 0) as i
-        <where>1 = 1
+        <where> 1 = 1
             <if test="minMultipleFaceCount != null and minMultipleFaceCount != '' or minMultipleFaceCount == 0">
                 and t.multipleFaceCount &gt;= #{minMultipleFaceCount}
             </if>
@@ -417,7 +288,6 @@
                 and t.exceptionCount &lt;= #{maxExceptionCount}
             </if>
         </where>
-        order by t.roomCode desc
     </select>
 
     <select id="invigilatePageWarningList" resultType="com.qmth.themis.business.bean.admin.InvigilateListWarningBean">
@@ -440,25 +310,32 @@
         IFNULL(toer.breach_status,1) as breachStatus,
         toer.client_last_sync_time as updateTime,
         tiiwi.approve_status as approveStatus
-        ,(select count(1) from t_ie_invigilate_warn_info tiiwi where
-        tiiwi.exam_record_id = toer.id and tiiwi.`type` =
+        ,(select count(1) from t_ie_invigilate_warn_info tiiwi where 1 = 1
+        <if test="examId != null and examId != ''">
+            and tiiwi.exam_id = #{examId}
+        </if>
+            and tiiwi.exam_record_id = toer.id and tiiwi.`type` =
         'FACE_COUNT_ERROR' and tiiwi.`level` = 'D8') as multipleFaceCount
-        ,(select count(1) from t_ie_invigilate_exception_info tiiei where
-        tiiei.exam_record_id = toer.id) as exceptionCount
+        ,(select count(1) from t_ie_invigilate_exception_info tiiei where 1 = 1
+        <if test="examId != null and examId != ''">
+            and tiiei.exam_id = #{examId}
+        </if>
+            and tiiei.exam_record_id = toer.id) as exceptionCount
         from t_ie_invigilate_warn_info tiiwi
         left join t_e_exam tee on tee.id = tiiwi.exam_id
         left join t_e_exam_activity teea on teea.id = tiiwi.exam_activity_id
         left join t_oe_exam_record toer on toer.id = tiiwi.exam_record_id
         left join t_e_exam_student tees on tees.id = tiiwi.exam_student_id
+        <if test="userId != null and userId != ''">
+            left join t_b_exam_invigilate_user tbeiu on tbeiu.exam_id = tees.exam_id
+        </if>
         <where> 1 = 1
             and tee.monitor_status <![CDATA[ <> ]]> 'FINISHED'
             <if test="examId != null and examId != ''">
                 and tiiwi.exam_id = #{examId}
             </if>
             <if test="userId != null and userId != ''">
-                and exists (select tbeiu.exam_id from t_b_exam_invigilate_user tbeiu
-                where tbeiu.user_id = #{userId}
-                and tbeiu.exam_id = tees.exam_id and tbeiu.room_code = tees.room_code)
+                and tbeiu.user_id = #{userId}
             </if>
             <if test="orgId != null and orgId != ''">
                 and tee.org_id = #{orgId}
@@ -513,14 +390,15 @@
         left join t_e_exam_activity teea on teea.id = tiiwi.exam_activity_id
         left join t_oe_exam_record toer on toer.id = tiiwi.exam_record_id
         left join t_e_exam_student tees on tees.id = tiiwi.exam_student_id
+        <if test="userId != null and userId != ''">
+            left join t_b_exam_invigilate_user tbeiu on tbeiu.exam_id = tees.exam_id
+        </if>
         <where>1 = 1
             <if test="examId != null and examId != ''">
                 and tiiwi.exam_id = #{examId}
             </if>
             <if test="userId != null and userId != ''">
-                and exists (select tbeiu.exam_id from t_b_exam_invigilate_user tbeiu
-                where tbeiu.user_id = #{userId}
-                and tbeiu.exam_id = tees.exam_id and tbeiu.room_code = tees.room_code)
+                and tbeiu.user_id = #{userId}
             </if>
             <if test="orgId != null and orgId != ''">
                 and tee.org_id = #{orgId}
@@ -585,8 +463,11 @@
         tees.course_name as courseName,
         if(tee.exam_count - tees.already_exam_count <![CDATA[ < ]]> 0,0,tee.exam_count - tees.already_exam_count) as
         leftExamCount,
-        (select count(1) from t_oe_exam_record toer where toer.exam_student_id =
-        tees.id and (toer.status = 'FINISHED' or toer.status = 'PERSISTED') and toer.first_start_time is not null) as
+        (select count(1) from t_oe_exam_record toer where 1 = 1
+        <if test="examId != null and examId != ''">
+            and toer.exam_id = #{examId}
+        </if>
+            and toer.exam_student_id = tees.id and toer.status in ('FINISHED','PERSISTED') and toer.first_start_time is not null) as
         statusTemp,
         <!--tes.mobile_number as mobileNumber,-->
         t.id as examRecordId,
@@ -603,19 +484,19 @@
         IFNULL(t.breach_status,1) as breachStatus
         from
         t_e_exam_student tees
-        left join t_e_exam tee on
-        tee.id = tees.exam_id
+        left join t_e_exam tee on tee.id = tees.exam_id
         left join t_e_exam_activity teea on teea.id = tees.exam_activity_id and teea.exam_id = tee.id
         left join t_e_student tes on tees.student_id = tes.id
         left join t_oe_exam_record t on t.exam_id = tees.exam_id and t.exam_activity_id = tees.exam_activity_id and t.exam_student_id = tees.id
+        <if test="userId != null and userId != ''">
+            left join t_b_exam_invigilate_user tbeiu on tbeiu.exam_id = tees.exam_id
+        </if>
         <where>1 = 1
             <if test="examId != null and examId != ''">
                 and tees.exam_id = #{examId}
             </if>
             <if test="userId != null and userId != ''">
-                and exists (select tbeiu.exam_id from t_b_exam_invigilate_user tbeiu
-                where tbeiu.user_id = #{userId}
-                and tbeiu.exam_id = tees.exam_id and tbeiu.room_code = tees.room_code)
+                and tbeiu.user_id = #{userId}
             </if>
             <if test="orgId != null and orgId != ''">
                 and tee.org_id = #{orgId}
@@ -684,8 +565,11 @@
         group_concat(tees.course_name,CONCAT(CONCAT('(',tees.course_code),')')) as courseName,
         if(tee.exam_count - tees.already_exam_count <![CDATA[ < ]]> 0,0,tee.exam_count - tees.already_exam_count) as
         leftExamCount,
-        (select count(1) from t_oe_exam_record toer where toer.exam_student_id =
-        tees.id and (toer.status = 'FINISHED' or toer.status = 'PERSISTED') and toer.first_start_time is not null) as
+        (select count(1) from t_oe_exam_record toer where 1 = 1
+        <if test="examId != null and examId != ''">
+            and toer.exam_id = #{examId}
+        </if>
+            and toer.exam_student_id = tees.id and toer.status in ('FINISHED','PERSISTED') and toer.first_start_time is not null) as
         statusTemp,
         <!--tes.mobile_number as mobileNumber,-->
         t.breach_status as breachStatusTemp
@@ -697,14 +581,15 @@
         teea.id = tees.exam_activity_id
         left join t_e_student tes on tees.student_id = tes.id
         left join t_oe_exam_record t on t.exam_id = tees.exam_id and t.exam_activity_id = tees.exam_activity_id and t.exam_student_id = tees.id
-        <where>1 = 1
+        <if test="userId != null and userId != ''">
+            left join t_b_exam_invigilate_user tbeiu on tbeiu.exam_id = tees.exam_id
+        </if>
+        <where> 1 = 1
             <if test="examId != null and examId != ''">
                 and tees.exam_id = #{examId}
             </if>
             <if test="userId != null and userId != ''">
-                and exists (select tbeiu.exam_id from t_b_exam_invigilate_user tbeiu
-                where tbeiu.user_id = #{userId}
-                and tbeiu.exam_id = tees.exam_id and tbeiu.room_code = tees.room_code)
+                and tbeiu.user_id = #{userId}
             </if>
             <if test="orgId != null and orgId != ''">
                 and tee.org_id = #{orgId}
@@ -803,6 +688,9 @@
         left join t_e_student tes on
         s.student_id = tes.id
         left join t_oe_exam_record toer on toer.exam_student_id = s.id
+        <if test="userId != null and userId != ''">
+            left join t_b_exam_invigilate_user tbeiu on tbeiu.exam_id = s.exam_id
+        </if>
         WHERE 1 = 1
         <choose>
             <when test="status != null and status != '' and status == 'UN_FINISH'">
@@ -816,12 +704,7 @@
             and s.exam_id = #{examId}
         </if>
         <if test="userId != null and userId != ''">
-            and exists (select tbeiu.exam_id from t_b_exam_invigilate_user tbeiu
-            where tbeiu.user_id = #{userId}
-            <if test="orgId != null and orgId != ''">
-                and tbeiu.org_id = #{orgId}
-            </if>
-            and tbeiu.exam_id = s.exam_id and tbeiu.org_id = tee.org_id and tbeiu.room_code = s.room_code)
+            and tbeiu.user_id = #{userId}
         </if>
         <if test="orgId != null and orgId != ''">
             and tee.org_id = #{orgId}
@@ -848,7 +731,7 @@
             <when test="status != null and status != '' and status != 'UN_FINISH'">
                 <choose>
                     <when test="status == 'EXAMING'">
-                        and (toer.status = 'ANSWERING' or toer.status = 'RESUME_PREPARE' or toer.status = 'BREAK_OFF')
+                        and toer.status in ('ANSWERING','RESUME_PREPARE','BREAK_OFF')
                     </when>
                     <otherwise>
                         and toer.status = #{status}
@@ -856,19 +739,6 @@
                 </choose>
             </when>
         </choose>
-        <!--            <if test="status != null and status != '' and status != 'UN_FINISH'">-->
-        <!--                <choose>-->
-        <!--                    <when test="status == 'EXAMING'">-->
-        <!--                        and (toer.status = 'ANSWERING' or toer.status = 'RESUME_PREPARE' or toer.status = 'BREAK_OFF')-->
-        <!--                    </when>-->
-        <!--                    <otherwise>-->
-        <!--                        and toer.status = #{status}-->
-        <!--                    </otherwise>-->
-        <!--                </choose>-->
-        <!--            </if>-->
-        <!--<if test="status != null and status != '' and status == 'UN_FINISH'">
-            and (toer.first_start_time is null or toer.first_prepare_time is null)
-        </if>-->
         <if test="maxWarningCount != null and maxWarningCount != '' or maxWarningCount == 0">
             and toer.warning_count &lt;= #{maxWarningCount}
         </if>
@@ -886,8 +756,7 @@
         <if test="finishType != null and finishType != ''">
             <choose>
                 <when test="finishType == 'ALL'">
-                    and (toer.finish_type = 'MANUAL' or toer.finish_type = 'AUTO' or toer.finish_type = 'BREACH' or
-                    toer.finish_type = 'INTERRUPT')
+                    and toer.finish_type in ('MANUAL','AUTO','BREACH','INTERRUPT')
                 </when>
                 <otherwise>
                     and toer.finish_type = #{finishType}
@@ -999,19 +868,17 @@
         tee.id = t.exam_id
         left join t_e_exam_activity teea on
         teea.id = t.exam_activity_id
+        <if test="userId != null and userId != ''">
+            left join t_b_exam_invigilate_user tbeiu on tbeiu.exam_id = t.exam_id
+        </if>
         <where>
             <if test="examId != null and examId != ''">
                 and t.exam_id = #{examId}
             </if>
             <if test="userId != null and userId != ''">
-                and exists (select tbeiu.exam_id from t_b_exam_invigilate_user tbeiu
-                where tbeiu.user_id = #{userId}
-                and tbeiu.exam_id = t.exam_id and tbeiu.room_code = s.room_code)
-            </if>
-            and (t.STATUS = 'FIRST_PREPARE'
-            or t.STATUS = 'ANSWERING'
-            or t.STATUS = 'BREAK_OFF'
-            or t.STATUS = 'RESUME_PREPARE')
+                and tbeiu.user_id = #{userId}
+            </if>
+            and t.STATUS in ('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
         </where>
         ) t
         group by
@@ -1040,8 +907,7 @@
         <if test="orgId != null and orgId != ''">
             and h.org_id=#{orgId}
         </if>
-        and (f.STATUS = 'FIRST_PREPARE' or f.STATUS = 'ANSWERING'
-        or f.STATUS = 'BREAK_OFF' or f.STATUS = 'RESUME_PREPARE')
+        and f.STATUS in ('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
         AND t.id IS NOT NULL
     </select>
 
@@ -1057,8 +923,7 @@
             and h.org_id=#{orgId}
         </if>
         and h.monitor_status <![CDATA[ <> ]]> 'FINISHED'
-        and (f.STATUS = 'FIRST_PREPARE' or f.STATUS = 'ANSWERING'
-        or f.STATUS = 'BREAK_OFF' or f.STATUS = 'RESUME_PREPARE')
+        and f.STATUS in ('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
         AND t.type!='NONE'
         AND t.id IS NOT NULL
     </select>
@@ -1075,8 +940,7 @@
             and h.org_id=#{orgId}
         </if>
         and h.monitor_status <![CDATA[ <> ]]> 'FINISHED'
-        and  (f.STATUS = 'FIRST_PREPARE' or f.STATUS = 'ANSWERING'
-        or f.STATUS = 'BREAK_OFF' or f.STATUS = 'RESUME_PREPARE')
+        and f.STATUS in ('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
         AND t.status = 0
         AND t.id IS NOT NULL
     </select>
@@ -1095,8 +959,7 @@
             and tee.org_id = #{orgId}
         </if>
         and tee.monitor_status <![CDATA[ <> ]]> 'FINISHED'
-        and (toer.STATUS = 'FIRST_PREPARE' or toer.STATUS = 'ANSWERING'
-        or toer.STATUS = 'BREAK_OFF' or toer.STATUS = 'RESUME_PREPARE')
+        and toer.STATUS in ('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
         group by
         tiiwi.`info`
     </select>
@@ -1119,8 +982,7 @@
             and tee.org_id = #{orgId}
         </if>
         and tee.monitor_status <![CDATA[ <> ]]> 'FINISHED'
-        and (toer.STATUS = 'FIRST_PREPARE' or toer.STATUS = 'ANSWERING'
-        or toer.STATUS = 'BREAK_OFF' or toer.STATUS = 'RESUME_PREPARE')
+        and toer.STATUS in ('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
         and tir.country != '0' and tir.province != '0'
         group by
         tir.country,
@@ -1152,10 +1014,7 @@
         </if>
         and tee.monitor_status <![CDATA[ <> ]]> 'FINISHED'
         and toer.client_websocket_status = 'ON_LINE'
-        and (toer.STATUS = 'FIRST_PREPARE'
-        or toer.STATUS = 'ANSWERING'
-        or toer.STATUS = 'BREAK_OFF'
-        or toer.STATUS = 'RESUME_PREPARE')
+        and toer.STATUS in ('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
         and tir.country != '0' and tir.province != '0'
         group by
         tir.country,
@@ -1179,10 +1038,7 @@
             and tee.org_id = #{orgId}
         </if>
         and tee.monitor_status <![CDATA[ <> ]]> 'FINISHED'
-        and (toer.STATUS = 'FIRST_PREPARE'
-        or toer.STATUS = 'ANSWERING'
-        or toer.STATUS = 'BREAK_OFF'
-        or toer.STATUS = 'RESUME_PREPARE')
+        and toer.STATUS in ('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
         and tir.country != '0' and tir.province != '0'
         group by
         tir.country,
@@ -1242,8 +1098,7 @@
         <where>
             (toer.breach_status = 1
             or breach_status is null)
-            and (toer.status = 'FINISHED'
-            or toer.status = 'PERSISTED')
+            and toer.status in ('FINISHED','PERSISTED')
             <if test="examId != null and examId != ''">
                 and toer.exam_id = #{examId}
             </if>
@@ -1265,10 +1120,7 @@
                   and toer.exam_id = tee.id
                   and tee.monitor_status <![CDATA[ <> ]]> 'FINISHED'
             )
-          and (toer.STATUS = 'FIRST_PREPARE'
-            or toer.STATUS = 'ANSWERING'
-            or toer.STATUS = 'BREAK_OFF'
-            or toer.STATUS = 'RESUME_PREPARE')
+          and toer.STATUS in ('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
           and toer.client_websocket_status = 'ON_LINE'
         union all
         select count(1) as c
@@ -1325,10 +1177,7 @@
         <if test="examActivityId != null and examActivityId != ''">
             and t.exam_activity_id = #{examActivityId}
         </if>
-        and (t.STATUS = 'FIRST_PREPARE'
-        or t.STATUS = 'ANSWERING'
-        or t.STATUS = 'BREAK_OFF'
-        or t.STATUS = 'RESUME_PREPARE')
+        and t.STATUS in ('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
         </where>
         group by
         t.client_websocket_status,
@@ -1393,9 +1242,8 @@
         <if test="examActivityId != null and examActivityId != ''">
             and t.exam_activity_id = #{examActivityId}
         </if>
-        and ((t.STATUS = 'ANSWERING' and t.client_websocket_status = 'ON_LINE')
-        or t.STATUS = 'RESUME_PREPARE'
-        or t.STATUS = 'BREAK_OFF')
+        and (t.STATUS = 'ANSWERING' and t.client_websocket_status = 'ON_LINE')
+        or t.STATUS in ('RESUME_PREPARE','BREAK_OFF')
         </where>
         union all
         select
@@ -1413,8 +1261,7 @@
         <if test="examActivityId != null and examActivityId != ''">
             and t.exam_activity_id = #{examActivityId}
         </if>
-        and (t.STATUS = 'FINISHED'
-        or t.STATUS = 'PERSISTED') and t.first_start_time is not null
+        and t.STATUS in ('FINISHED','PERSISTED') and t.first_start_time is not null
         </where>
         union all
         select
@@ -1563,8 +1410,7 @@
             <if test="finishType != null and finishType != ''">
                 <choose>
                     <when test="finishType == 'ALL'">
-                        and (toer.finish_type = 'MANUAL' or toer.finish_type = 'AUTO' or toer.finish_type = 'BREACH' or
-                        toer.finish_type = 'INTERRUPT')
+                        and toer.finish_type in ('MANUAL','AUTO','BREACH','INTERRUPT')
                     </when>
                     <otherwise>
                         and toer.finish_type = #{finishType}
@@ -1742,10 +1588,7 @@
         where
             toer.exam_id = #{examId}
             and toer.exam_activity_id = #{examActivityId}
-            and (toer.status = 'FIRST_PREPARE'
-            or toer.status = 'ANSWERING'
-            or toer.status = 'BREAK_OFF'
-            or toer.status = 'RESUME_PREPARE')
+            and toer.status in ('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
     </select>
 
     <select id="findByExamIdOrExamActivityIdCount" resultType="java.lang.Integer">
@@ -1757,10 +1600,7 @@
             <if test="examActivityId != null and examActivityId != ''">
                 and toer.exam_activity_id = #{examActivityId}
             </if>
-            and (toer.status = 'FIRST_PREPARE'
-                or toer.status = 'ANSWERING'
-                or toer.status = 'BREAK_OFF'
-                or toer.status = 'RESUME_PREPARE')
+            and toer.status in ('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
         </where>
     </select>
 
@@ -1796,7 +1636,7 @@
                                       #{paperId}
                                   </foreach>
                               </if>
-                              and (toer.status = 'FINISHED' or toer.status = 'PERSISTED')
+                              and toer.status in ('FINISHED','PERSISTED')
                               and toer.first_start_time is not null
                               and toer.finish_time is not null
                               <if test="examStudentBreachPush != null and (examStudentBreachPush == false or examStudentBreachPush == 0)">
@@ -1819,7 +1659,7 @@
                 ) t
                 join t_oe_exam_record t1 on
                 t1.exam_student_id = t.exam_student_id
-                where (t1.status = 'FINISHED' or t1.status = 'PERSISTED')
+                where t1.status in ('FINISHED','PERSISTED')
                 and t1.first_start_time is not null
                 and t1.finish_time is not null
                 <if test="examStudentBreachPush != null and (examStudentBreachPush == false or examStudentBreachPush == 0)">
@@ -1910,8 +1750,7 @@
         from
             t_oe_exam_record toer
         where
-            (toer.STATUS = 'ANSWERING'
-                or toer.STATUS = 'RESUME_PREPARE')
+            toer.STATUS in ('ANSWERING','RESUME_PREPARE')
           and toer.client_websocket_status = 'ON_LINE'
         union all
         select
@@ -1919,23 +1758,15 @@
         from
             t_oe_exam_record toer
         where
-            (toer.STATUS = 'FINISHED'
-                or toer.STATUS = 'PERSISTED')
+            toer.STATUS in ('FINISHED','PERSISTED')
         union all
         select
-            count(1) as c
+            count(distinct tees.id) as c
         from
             t_e_exam_student tees
+        left join t_oe_exam_record toer on toer.exam_student_id = tees.id
         where
-            EXISTS (
-                    select
-                        toer.exam_student_id
-                    from
-                        t_oe_exam_record toer
-                    where
-                        (toer.STATUS = 'FINISHED'
-                            or toer.STATUS = 'PERSISTED')
-                      and tees.id = toer.exam_student_id)
+            toer.STATUS in ('FINISHED', 'PERSISTED') and toer.id is not null
     </select>
 
     <select id="orgDataCount" resultType="com.qmth.themis.business.bean.admin.OrgDataCountBean">
@@ -1974,8 +1805,7 @@
                 join t_oe_exam_record toer on
                 tee.id = toer.exam_id
         WHERE
-            (toer.STATUS = 'ANSWERING'
-                or toer.STATUS = 'RESUME_PREPARE')
+            toer.STATUS in ('ANSWERING','RESUME_PREPARE')
           and toer.client_websocket_status = 'ON_LINE'
         group by
             tbo.name,