wangliang 2 жил өмнө
parent
commit
3792c2d433

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

@@ -3,7 +3,7 @@
 <mapper namespace="com.qmth.themis.business.dao.TEExamReexamMapper">
 
     <select id="reexamPageRequestList" resultType="com.qmth.themis.business.bean.admin.ReexamListRequestBean">
-        select * from(select distinct
+        select distinct
         tees.room_code as roomCode,
         tees.room_name as roomName,
         tees.`identity`,
@@ -14,23 +14,16 @@
         tees.course_name as courseName,
         tees.exam_id as examId,
         if(tee.exam_count - tees.already_exam_count <![CDATA[ < ]]> 0,0,tee.exam_count - tees.already_exam_count) as examCount,
-        (select count(1) from t_oe_exam_record toer where (toer.status <![CDATA[ <> ]]> 'FINISHED' and toer.status <![CDATA[ <> ]]> 'PERSISTED') and toer.exam_student_id = tees.id) as statusCount,
         (select count(1) from t_e_exam_reexam teer where teer.exam_student_id = tees.id and teer.status = 1) as reexamCount
         from
         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
+        tbeiu.exam_id = tee.id
+        and tbeiu.org_id = tee.org_id
+        and tbeiu.room_code = tees.room_code
         <where>
-            exists(
-            select
-            distinct tbeiu.exam_id
-            from
-            t_b_exam_invigilate_user tbeiu where 1 = 1
-            <if test="userId != null and userId != ''">
-                and tbeiu.user_id = #{userId}
-            </if>
-            and tbeiu.exam_id = tees.exam_id and tees.room_code = tbeiu.room_code
-            )
             <if test="examId != null and examId != ''">
                 and tees.exam_id = #{examId}
             </if>
@@ -53,9 +46,21 @@
                 and tees.identity like CONCAT('%', #{identity},'%')
             </if>
             and tee.monitor_status <![CDATA[ <> ]]> 'FINISHED'
+            and (tee.exam_count <![CDATA[ <= ]]> tees.already_exam_count
+            or tee.exam_count = tees.already_exam_count)
+            and not exists(
+            select
+            toer.exam_student_id
+            from
+            t_oe_exam_record toer
+            where 1 = 1
+            <if test="examId != null and examId != ''">
+                and toer.exam_id = #{examId}
+            </if>
+            and toer.status in('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
+            and toer.exam_student_id = tees.id
+            )
         </where>
-        ) t where t.examCount = 0 and statusCount = 0
-        order by t.roomCode
     </select>
 
     <select id="reexamPageNotDoneList" resultType="com.qmth.themis.business.bean.admin.ReexamListNotDoneBean">
@@ -232,7 +237,7 @@
 
     <select id="getExamReexamPage" resultType="com.qmth.themis.business.bean.admin.ExamReexamListBean">
         SELECT
-            tee.name as examName,
+        tee.name as examName,
         f.exam_student_id examStudentId,
         t.exam_id examId,
         t.exam_activity_id examActivityId,

+ 333 - 374
themis-business/src/main/resources/mapper/TOeExamRecordMapper.xml

@@ -11,20 +11,20 @@
                         t.exam_student_id  examStudentId,
                         t.id               examRecordId,
         INSERT(rpad(substring(s.identity, 1, 2), char_length(s.identity), '*'),char_length(s.identity)-1,char_length(s.identity),substring(s.identity, char_length(s.identity) - 1 , char_length(s.identity) - 2)) as identity,
-		s.room_code roomCode,
-		s.room_name roomName,
-		s.name name,
-		s.course_name courseName,
-		s.course_code courseCode,
-		IFNULL(t.paper_download,1) paperDownload,
-		t.status statusCode,
-	    TRUNCATE(t.answer_progress,2) progress,
-		IFNULL(t.client_current_ip,'无') clientCurrentIp,
-		IFNULL(t.warning_count,0) as warningCount,
-		IFNULL(t.breach_status,1) as breachStatus,
-		IFNULL(t.client_websocket_status,'OFF_LINE') as clientWebsocketStatus,
-		t.client_last_sync_time as updateTime,
-		t.monitor_video_source as monitorVideoSource,
+        s.room_code roomCode,
+        s.room_name roomName,
+        s.name name,
+        s.course_name courseName,
+        s.course_code courseCode,
+        IFNULL(t.paper_download,1) paperDownload,
+        t.status statusCode,
+        TRUNCATE(t.answer_progress,2) progress,
+        IFNULL(t.client_current_ip,'无') clientCurrentIp,
+        IFNULL(t.warning_count,0) as warningCount,
+        IFNULL(t.breach_status,1) as breachStatus,
+        IFNULL(t.client_websocket_status,'OFF_LINE') as clientWebsocketStatus,
+        t.client_last_sync_time as updateTime,
+        t.monitor_video_source as monitorVideoSource,
         t.monitor_record as monitorRecord
     </sql>
 
@@ -759,7 +759,18 @@
     <sql id="invigilatePageListHistorySql">
         select (@i := @i + 1) as seq,t.* from(
         select
-        temp.*,
+        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,
@@ -772,26 +783,18 @@
         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.`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
+        ,(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 1 = 1
+        <if test="examId != null and examId != ''">
+            and tiiei.exam_id = #{examId}
+        </if>
+        and tiiei.exam_record_id = toer.id) as
         exceptionCount
         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
@@ -799,33 +802,26 @@
         teea.id = s.exam_activity_id
         left join t_e_student tes on
         s.student_id = tes.id
-        WHERE
+        left join t_oe_exam_record toer on toer.exam_student_id = s.id
+        WHERE 1 = 1
         <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 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)
         </if>
         <if test="orgId != null and orgId != ''">
             and tee.org_id = #{orgId}
@@ -845,64 +841,59 @@
         <if test="courseCode != null and courseCode != ''">
             and s.course_code = #{courseCode}
         </if>
-        ) temp
-        left join t_oe_exam_record toer on
-        toer.exam_student_id = temp.examStudentId
-        <where> 1 = 1
-            <choose>
-                <when test="status == null">
-                    and toer.status <![CDATA[ <> ]]> 'JUNK'
-                </when>
-                <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')
-                        </when>
-                        <otherwise>
-                            and toer.status = #{status}
-                        </otherwise>
-                    </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>
-            <if test="minWarningCount != null and minWarningCount != '' or minWarningCount == 0">
-                and toer.warning_count &gt;= #{minWarningCount}
-            </if>
-            <if test="breachStatus != null and breachStatus != '' or breachStatus == 0">
-                <if test="breachStatus == 0">
-                    and toer.breach_status = #{breachStatus}
-                </if>
-                <if test="breachStatus == 1">
-                    and (toer.breach_status = #{breachStatus} or toer.breach_status is null)
-                </if>
-            </if>
-            <if test="finishType != null and finishType != ''">
+        <choose>
+            <when test="status == null">
+                and toer.status <![CDATA[ <> ]]> 'JUNK'
+            </when>
+            <when test="status != null and status != '' and status != 'UN_FINISH'">
                 <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')
+                    <when test="status == 'EXAMING'">
+                        and (toer.status = 'ANSWERING' or toer.status = 'RESUME_PREPARE' or toer.status = 'BREAK_OFF')
                     </when>
                     <otherwise>
-                        and toer.finish_type = #{finishType}
+                        and toer.status = #{status}
                     </otherwise>
                 </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>
+        <if test="minWarningCount != null and minWarningCount != '' or minWarningCount == 0">
+            and toer.warning_count &gt;= #{minWarningCount}
+        </if>
+        <if test="breachStatus != null and breachStatus != '' or breachStatus == 0">
+            <if test="breachStatus == 0">
+                and toer.breach_status = #{breachStatus}
             </if>
-        </where>
+            <if test="breachStatus == 1">
+                and (toer.breach_status = #{breachStatus} or toer.breach_status is null)
+            </if>
+        </if>
+        <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')
+                </when>
+                <otherwise>
+                    and toer.finish_type = #{finishType}
+                </otherwise>
+            </choose>
+        </if>
         ) t,
         (SELECT @i := 0) as i
         <where>1 = 1
@@ -919,7 +910,6 @@
                 and t.exceptionCount &lt;= #{maxExceptionCount}
             </if>
         </where>
-        order by t.roomCode
     </sql>
 
     <select id="invigilatePageListHistoryExport"
@@ -1327,18 +1317,18 @@
         left join t_e_exam_student s on
         t.exam_student_id = s.id
         <where>
-        t.exam_id = #{examId}
-        and s.room_code in
-        <foreach collection="roomCodeSet" item="roomCode" index="index" open="(" close=")" separator=",">
-            #{roomCode}
-        </foreach>
-        <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')
+            t.exam_id = #{examId}
+            and s.room_code in
+            <foreach collection="roomCodeSet" item="roomCode" index="index" open="(" close=")" separator=",">
+                #{roomCode}
+            </foreach>
+            <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')
         </where>
         group by
         t.client_websocket_status,
@@ -1358,14 +1348,14 @@
         from
         t_e_exam_student t
         <where>
-        t.exam_id = #{examId}
-        and t.room_code in
-        <foreach collection="roomCodeSet" item="roomCode" index="index" open="(" close=")" separator=",">
-            #{roomCode}
-        </foreach>
-        <if test="examActivityId != null and examActivityId != ''">
-            and t.exam_activity_id = #{examActivityId}
-        </if>
+            t.exam_id = #{examId}
+            and t.room_code in
+            <foreach collection="roomCodeSet" item="roomCode" index="index" open="(" close=")" separator=",">
+                #{roomCode}
+            </foreach>
+            <if test="examActivityId != null and examActivityId != ''">
+                and t.exam_activity_id = #{examActivityId}
+            </if>
         </where>) t
     </select>
 
@@ -1377,15 +1367,15 @@
         left join t_e_exam_student s on
         t.exam_student_id = s.id
         <where>
-        t.exam_id = #{examId}
-        and s.room_code in
-        <foreach collection="roomCodeSet" item="roomCode" index="index" open="(" close=")" separator=",">
-            #{roomCode}
-        </foreach>
-        <if test="examActivityId != null and examActivityId != ''">
-            and t.exam_activity_id = #{examActivityId}
-        </if>
-        and t.STATUS = 'FIRST_PREPARE'
+            t.exam_id = #{examId}
+            and s.room_code in
+            <foreach collection="roomCodeSet" item="roomCode" index="index" open="(" close=")" separator=",">
+                #{roomCode}
+            </foreach>
+            <if test="examActivityId != null and examActivityId != ''">
+                and t.exam_activity_id = #{examActivityId}
+            </if>
+            and t.STATUS = 'FIRST_PREPARE'
         </where>
         union all
         select
@@ -1395,17 +1385,17 @@
         left join t_e_exam_student s on
         t.exam_student_id = s.id
         <where>
-        t.exam_id = #{examId}
-        and s.room_code in
-        <foreach collection="roomCodeSet" item="roomCode" index="index" open="(" close=")" separator=",">
-            #{roomCode}
-        </foreach>
-        <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')
+            t.exam_id = #{examId}
+            and s.room_code in
+            <foreach collection="roomCodeSet" item="roomCode" index="index" open="(" close=")" separator=",">
+                #{roomCode}
+            </foreach>
+            <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')
         </where>
         union all
         select
@@ -1415,16 +1405,16 @@
         left join t_e_exam_student s on
         t.exam_student_id = s.id
         <where>
-        t.exam_id = #{examId}
-        and s.room_code in
-        <foreach collection="roomCodeSet" item="roomCode" index="index" open="(" close=")" separator=",">
-            #{roomCode}
-        </foreach>
-        <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
+            t.exam_id = #{examId}
+            and s.room_code in
+            <foreach collection="roomCodeSet" item="roomCode" index="index" open="(" close=")" separator=",">
+                #{roomCode}
+            </foreach>
+            <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
         </where>
         union all
         select
@@ -1442,15 +1432,15 @@
         from
         t_oe_exam_record toer
         <where>
-        t.id = toer.exam_student_id)
-        and t.exam_id = #{examId}
-        and t.room_code in
-        <foreach collection="roomCodeSet" item="roomCode" index="index" open="(" close=")" separator=",">
-            #{roomCode}
-        </foreach>
-        <if test="examActivityId != null and examActivityId != ''">
-            and t.exam_activity_id = #{examActivityId}
-        </if>
+            t.id = toer.exam_student_id)
+            and t.exam_id = #{examId}
+            and t.room_code in
+            <foreach collection="roomCodeSet" item="roomCode" index="index" open="(" close=")" separator=",">
+                #{roomCode}
+            </foreach>
+            <if test="examActivityId != null and examActivityId != ''">
+                and t.exam_activity_id = #{examActivityId}
+            </if>
         </where>
     </select>
 
@@ -1459,81 +1449,50 @@
         count(1) as c
         from
         t_e_exam_student tees
-        join t_e_student tes on
-        tees.student_id = tes.id
-        where
-        exists(
-        select
-        tee.id
-        from
-        t_e_exam tee
-        <where>1 = 1
-            <if test="orgId != null and orgId != ''">
-                and tee.org_id = #{orgId}
-            </if>
-            <if test="examId != null and examId != ''">
-                and tee.id = #{examId}
-            </if>
-            <if test="examActivityId != null and examActivityId != ''">
-                and tees.exam_activity_id = #{examActivityId}
-            </if>
-            <if test="roomCode != null and roomCode != ''">
-                and tees.room_code = #{roomCode}
-            </if>
-            <if test="courseCode != null and courseCode != ''">
-                and tees.course_code = #{courseCode}
-            </if>
-            and tees.exam_id = tee.id
-            and tes.org_id = tee.org_id
-        </where>
-        )
+        where 1 = 1
+        <if test="examId != null and examId != ''">
+            and tees.exam_id = #{examId}
+        </if>
+        <if test="examActivityId != null and examActivityId != ''">
+            and tees.exam_activity_id = #{examActivityId}
+        </if>
+        <if test="roomCode != null and roomCode != ''">
+            and tees.room_code = #{roomCode}
+        </if>
+        <if test="courseCode != null and courseCode != ''">
+            and tees.course_code = #{courseCode}
+        </if>
         union all
         select
         count(distinct toer.exam_student_id) as c
         from
         t_oe_exam_record toer
-        where
-        exists (
-        select
-        *
-        from
-        (
-        select
+        where 1 = 1
+        <if test="examId != null and examId != ''">
+            and toer.exam_id = #{examId}
+        </if>
+        and exists (select
         tees.id
         from
         t_e_exam_student tees
-        join t_e_student tes on
-        tees.student_id = tes.id
-        where
-        exists(
-        select
-        tee.id
-        from
-        t_e_exam tee
-        <where>1 = 1
-            <if test="orgId != null and orgId != ''">
-                and tee.org_id = #{orgId}
-            </if>
-            <if test="examId != null and examId != ''">
-                and tee.id = #{examId}
-            </if>
-            <if test="examActivityId != null and examActivityId != ''">
-                and tees.exam_activity_id = #{examActivityId}
-            </if>
-            <if test="roomCode != null and roomCode != ''">
-                and tees.room_code = #{roomCode}
-            </if>
-            <if test="courseCode != null and courseCode != ''">
-                and tees.course_code = #{courseCode}
-            </if>
-            and tees.exam_id = tee.id
-        </where>
-        )) t
-        where
-        t.id = toer.exam_student_id
+        where 1 = 1
+        <if test="examId != null and examId != ''">
+            and tees.exam_id = #{examId}
+        </if>
+        <if test="examActivityId != null and examActivityId != ''">
+            and tees.exam_activity_id = #{examActivityId}
+        </if>
+        <if test="roomCode != null and roomCode != ''">
+            and tees.room_code = #{roomCode}
+        </if>
+        <if test="courseCode != null and courseCode != ''">
+            and tees.course_code = #{courseCode}
+        </if>
+        and toer.exam_student_id = tees.id
+        )
         <if test="monitorStatus != null and monitorStatus != '' and monitorStatus == 'FINISHED'">
             and toer.first_start_time is not null
-        </if>)
+        </if>
         union all
         select
         count(1)
@@ -1782,8 +1741,8 @@
         select * from t_oe_exam_record toer
         where
             toer.exam_id = #{examId}
-            and toer.exam_activity_id = #{examActivityId}
-            and (toer.status = 'FIRST_PREPARE'
+          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')
@@ -1799,106 +1758,106 @@
                 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')
+            or toer.status = 'ANSWERING'
+            or toer.status = 'BREAK_OFF'
+            or toer.status = 'RESUME_PREPARE')
         </where>
     </select>
 
     <select id="findExamRecordNeedMarkAll" resultType="com.qmth.themis.business.entity.TOeExamRecord">
         select
-            t1.*
+        t1.*
         from
-            (
-                select
-                    t.exam_student_id
-                from
-                    t_oe_exam_record t
-                where
-                    exists(
-                            select
-                                tees.id
-                            from
-                                t_e_exam_student tees
-                                    join t_oe_exam_record toer on
-                                            toer.exam_id = tees.exam_id
-                                        and toer.exam_activity_id = tees.exam_activity_id
-                                        and toer.exam_student_id = tees.id
-                              <where>
-                                  <if test="examId != null and examId != ''">
-                                      and tees.exam_id = #{examId}
-                                  </if>
-                              and tees.enable = 1
-                              and tees.already_exam_count is not null
-                              and tees.already_exam_count <![CDATA[ > ]]> 0
-                              <if test="examPaperIdSet != null and examPaperIdSet != '' and examPaperIdSet.size > 0">
-                                  and toer.paper_id in
-                                  <foreach collection="examPaperIdSet" item="paperId" index="index" open="(" close=")" separator=",">
-                                      #{paperId}
-                                  </foreach>
-                              </if>
-                              and (toer.status = 'FINISHED' or toer.status = '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)">
-                                and (toer.breach_status is null or toer.breach_status = 1)
-                              </if>
-                              and t.exam_student_id = tees.id
-                        </where>)
-                group by
-                    t.exam_student_id
-                <if test="many != null and many != '' or many == 0">
-                    <choose>
-                        <when test="many == true">
-                            HAVING count(t.exam_student_id) <![CDATA[ > ]]> 1
-                        </when>
-                        <otherwise>
-                            HAVING count(t.exam_student_id) = 1
-                        </otherwise>
-                    </choose>
-                </if>
-                ) t
-                join t_oe_exam_record t1 on
-                t1.exam_student_id = t.exam_student_id
-                where (t1.status = 'FINISHED' or t1.status = '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)">
-                    and (t1.breach_status is null or t1.breach_status = 1)
-                </if>
-                <!--<if test="many != null and many != '' or many == 0">
-                    <choose>
-                        <when test="many == true">
-                            order by t1.id limit 510
-                        </when>
-                        <otherwise>
-                            order by t1.id limit 500
-                        </otherwise>
-                    </choose>
-                </if>-->
-                order by t1.id
+        (
+        select
+        t.exam_student_id
+        from
+        t_oe_exam_record t
+        where
+        exists(
+        select
+        tees.id
+        from
+        t_e_exam_student tees
+        join t_oe_exam_record toer on
+        toer.exam_id = tees.exam_id
+        and toer.exam_activity_id = tees.exam_activity_id
+        and toer.exam_student_id = tees.id
+        <where>
+            <if test="examId != null and examId != ''">
+                and tees.exam_id = #{examId}
+            </if>
+            and tees.enable = 1
+            and tees.already_exam_count is not null
+            and tees.already_exam_count <![CDATA[ > ]]> 0
+            <if test="examPaperIdSet != null and examPaperIdSet != '' and examPaperIdSet.size > 0">
+                and toer.paper_id in
+                <foreach collection="examPaperIdSet" item="paperId" index="index" open="(" close=")" separator=",">
+                    #{paperId}
+                </foreach>
+            </if>
+            and (toer.status = 'FINISHED' or toer.status = '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)">
+                and (toer.breach_status is null or toer.breach_status = 1)
+            </if>
+            and t.exam_student_id = tees.id
+        </where>)
+        group by
+        t.exam_student_id
+        <if test="many != null and many != '' or many == 0">
+            <choose>
+                <when test="many == true">
+                    HAVING count(t.exam_student_id) <![CDATA[ > ]]> 1
+                </when>
+                <otherwise>
+                    HAVING count(t.exam_student_id) = 1
+                </otherwise>
+            </choose>
+        </if>
+        ) t
+        join t_oe_exam_record t1 on
+        t1.exam_student_id = t.exam_student_id
+        where (t1.status = 'FINISHED' or t1.status = '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)">
+            and (t1.breach_status is null or t1.breach_status = 1)
+        </if>
+        <!--<if test="many != null and many != '' or many == 0">
+            <choose>
+                <when test="many == true">
+                    order by t1.id limit 510
+                </when>
+                <otherwise>
+                    order by t1.id limit 500
+                </otherwise>
+            </choose>
+        </if>-->
+        order by t1.id
     </select>
 
     <select id="persistedAnswerBatch" resultType="com.qmth.themis.business.entity.TOeExamRecord">
-            select toer.* from t_oe_exam_record toer
-                left join t_oe_exam_answer toea on toea.exam_record_id = toer.id
-            <where>
-                <if test="examId != null and examId != ''">
-                    and toer.exam_id = #{examId}
-                </if>
-                <if test="examActivityId != null and examActivityId != ''">
-                    and toer.exam_activity_id = #{examActivityId}
-                </if>
-                <if test="status != null and status != ''">
-                    and toer.status = #{status}
-                </if>
-              and toer.objective_score > 0
-              and toea.id is null
-              and toer.first_start_time is not null
-              and toer.finish_time is not null
-            </where>
-            group by toer.id
-            having count(toea.id) = 0
+        select toer.* from t_oe_exam_record toer
+        left join t_oe_exam_answer toea on toea.exam_record_id = toer.id
+        <where>
+            <if test="examId != null and examId != ''">
+                and toer.exam_id = #{examId}
+            </if>
+            <if test="examActivityId != null and examActivityId != ''">
+                and toer.exam_activity_id = #{examActivityId}
+            </if>
+            <if test="status != null and status != ''">
+                and toer.status = #{status}
+            </if>
+            and toer.objective_score > 0
+            and toea.id is null
+            and toer.first_start_time is not null
+            and toer.finish_time is not null
+        </where>
+        group by toer.id
+        having count(toea.id) = 0
     </select>
 
     <select id="cleanExamFirstPrepareCache" resultType="java.util.Map">
@@ -1907,30 +1866,30 @@
         from
         (
         select
-            tes.id as studentId,
-            toer.id as examRecordId,
-            DATE_FORMAT(FROM_UNIXTIME(toer.first_prepare_time  / 1000), '%Y-%m-%d %H:%i:%s') as 'firstPrepareTime',
-            DATE_FORMAT(FROM_UNIXTIME(toer.finish_time / 1000), '%Y-%m-%d %H:%i:%s') as 'finishTime',
-            DATE_FORMAT(FROM_UNIXTIME(toer.first_start_time / 1000), '%Y-%m-%d %H:%i:%s') as 'firstStartTime',
-            DATE_FORMAT(FROM_UNIXTIME(toer.start_time / 1000), '%Y-%m-%d %H:%i:%s') as 'startTime',
-            DATE_FORMAT(FROM_UNIXTIME(toer.end_time / 1000), '%Y-%m-%d %H:%i:%s') as 'endTime'
+        tes.id as studentId,
+        toer.id as examRecordId,
+        DATE_FORMAT(FROM_UNIXTIME(toer.first_prepare_time  / 1000), '%Y-%m-%d %H:%i:%s') as 'firstPrepareTime',
+        DATE_FORMAT(FROM_UNIXTIME(toer.finish_time / 1000), '%Y-%m-%d %H:%i:%s') as 'finishTime',
+        DATE_FORMAT(FROM_UNIXTIME(toer.first_start_time / 1000), '%Y-%m-%d %H:%i:%s') as 'firstStartTime',
+        DATE_FORMAT(FROM_UNIXTIME(toer.start_time / 1000), '%Y-%m-%d %H:%i:%s') as 'startTime',
+        DATE_FORMAT(FROM_UNIXTIME(toer.end_time / 1000), '%Y-%m-%d %H:%i:%s') as 'endTime'
         from
         t_oe_exam_record toer
         join t_e_exam_student tees on tees.id = toer.exam_student_id
         join t_e_student tes on tes.id = tees.student_id
         <where>
-        toer.status = 'FIRST_PREPARE'
-        <if test="examIds != null and examIds != ''">
-            and toer.exam_id in
-            <foreach collection="examIds" item="examId" index="index" open="(" close=")" separator=",">
-                #{examId}
-            </foreach>
-        </if>
-        and toer.first_prepare_time is not null
-        and toer.first_start_time is null
-        and toer.finish_time is null
-        and (toer.objective_score is null
-        or toer.objective_score = 0)
+            toer.status = 'FIRST_PREPARE'
+            <if test="examIds != null and examIds != ''">
+                and toer.exam_id in
+                <foreach collection="examIds" item="examId" index="index" open="(" close=")" separator=",">
+                    #{examId}
+                </foreach>
+            </if>
+            and toer.first_prepare_time is not null
+            and toer.first_start_time is null
+            and toer.finish_time is null
+            and (toer.objective_score is null
+            or toer.objective_score = 0)
         </where>
         group by
         toer.id
@@ -1987,42 +1946,42 @@
             sum(examCount) as examCount
         from
             (select
-            tbo.name,
-            tbo.code,
-            count(toer.id) as onlineCount,
-            0 as examCount
-        from
-            t_b_org tbo
-                join t_e_exam tee on
-                tbo.id = tee.org_id
-                join t_oe_exam_record toer on
-                tee.id = toer.exam_id
-        WHERE
-            toer.client_websocket_status = 'ON_LINE'
-        group by
-            tbo.name,
-            tbo.code
-        union all
-        select
-            tbo.name,
-            tbo.code,
-            0 as onlineCount,
-            count(toer.id) as examCount
-        from
-            t_b_org tbo
-                join t_e_exam tee on
-                tbo.id = tee.org_id
-                join t_oe_exam_record toer on
-                tee.id = toer.exam_id
-        WHERE
-            (toer.STATUS = 'ANSWERING'
-                or toer.STATUS = 'RESUME_PREPARE')
-          and toer.client_websocket_status = 'ON_LINE'
-        group by
-            tbo.name,
-            tbo.code) t group by
-                            t.name,
-                            t.code
+                 tbo.name,
+                 tbo.code,
+                 count(toer.id) as onlineCount,
+                 0 as examCount
+             from
+                 t_b_org tbo
+                     join t_e_exam tee on
+                     tbo.id = tee.org_id
+                     join t_oe_exam_record toer on
+                     tee.id = toer.exam_id
+             WHERE
+                 toer.client_websocket_status = 'ON_LINE'
+             group by
+                 tbo.name,
+                 tbo.code
+             union all
+             select
+                 tbo.name,
+                 tbo.code,
+                 0 as onlineCount,
+                 count(toer.id) as examCount
+             from
+                 t_b_org tbo
+                     join t_e_exam tee on
+                     tbo.id = tee.org_id
+                     join t_oe_exam_record toer on
+                     tee.id = toer.exam_id
+             WHERE
+                 (toer.STATUS = 'ANSWERING'
+                     or toer.STATUS = 'RESUME_PREPARE')
+               and toer.client_websocket_status = 'ON_LINE'
+             group by
+                 tbo.name,
+                 tbo.code) t group by
+                                 t.name,
+                                 t.code
     </select>
 
     <select id="mapDataCount" resultType="com.qmth.themis.business.bean.admin.MapDataCountBean">
@@ -2038,7 +1997,7 @@
                 toer.exam_id = tee.id
         WHERE
             toer.client_websocket_status = 'ON_LINE'
-            and tir.country != '0'
+          and tir.country != '0'
 	        and tir.province != '0'
         group by
             tir.country,