Bladeren bron

监考老师逻辑代码和sql优化

wangliang 1 jaar geleden
bovenliggende
commit
f47c4787c5
1 gewijzigde bestanden met toevoegingen van 127 en 127 verwijderingen
  1. 127 127
      themis-business/src/main/resources/mapper/TOeExamRecordMapper.xml

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

@@ -30,8 +30,8 @@
 
     <sql id="invigilatePageMiddle">
         from t_e_exam_student s
-		left join t_e_exam tee on tee.id = t.exam_id
-		left join t_e_exam_activity teea on teea.id = t.exam_activity_id
+		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_oe_exam_record t on t.id = s.current_record_id
     </sql>
 
@@ -197,70 +197,70 @@
         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
         <where> 1 = 1
-        <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="examId != null and examId != ''">
-            and s.exam_id = #{examId}
-        </if>
-        <if test="examActivityId != null and examActivityId != ''">
-            and s.exam_activity_id = #{examActivityId}
-        </if>
-        <if test="roomCodeList != null and roomCodeList != '' and roomCodeList.size > 0">
-            and s.room_code in
-            <foreach collection="roomCodeList" item="roomCode" index="index" open="(" close=")" separator=",">
-                #{roomCode}
-            </foreach>
-        </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>
-        and teea.finish_time > unix_timestamp(current_timestamp()) * 1000
-        <if test="status != null and status != '' and status != 'UN_FINISH'">
+            <if test="orgId != null and orgId != ''">
+                and tee.org_id = #{orgId}
+            </if>
             <choose>
-                <when test="status == 'EXAMING'">
-                    and toer.status in ('ANSWERING','RESUME_PREPARE','BREAK_OFF')
+                <when test="status != null and status != '' and status == 'UN_FINISH'">
+                    and toer.id is null
                 </when>
                 <otherwise>
-                    and toer.status = #{status}
+                    and toer.id is not null
                 </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>
-        <if test="minMultipleFaceCount != null and minMultipleFaceCount != '' or minMultipleFaceCount == 0">
-            and toer.warning_multiple_face_count &gt;= #{minMultipleFaceCount}
-        </if>
-        <if test="maxMultipleFaceCount != null and maxMultipleFaceCount != '' or maxMultipleFaceCount == 0">
-            and toer.warning_multiple_face_count &lt;= #{maxMultipleFaceCount}
-        </if>
-        <if test="minExceptionCount != null and minExceptionCount != '' or minExceptionCount == 0">
-            and toer.exception_count &gt;= #{minExceptionCount}
-        </if>
-        <if test="maxExceptionCount != null and maxExceptionCount != '' or maxExceptionCount == 0">
-            and toer.exception_count &lt;= #{maxExceptionCount}
-        </if>
+            <if test="examId != null and examId != ''">
+                and s.exam_id = #{examId}
+            </if>
+            <if test="examActivityId != null and examActivityId != ''">
+                and s.exam_activity_id = #{examActivityId}
+            </if>
+            <if test="roomCodeList != null and roomCodeList != '' and roomCodeList.size > 0">
+                and s.room_code in
+                <foreach collection="roomCodeList" item="roomCode" index="index" open="(" close=")" separator=",">
+                    #{roomCode}
+                </foreach>
+            </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>
+            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="status == null or status == ''">
+                and toer.status in ('FIRST_PREPARE','ANSWERING','BREAK_OFF','RESUME_PREPARE')
+            </if>
+            <if test="minMultipleFaceCount != null and minMultipleFaceCount != '' or minMultipleFaceCount == 0">
+                and toer.warning_multiple_face_count &gt;= #{minMultipleFaceCount}
+            </if>
+            <if test="maxMultipleFaceCount != null and maxMultipleFaceCount != '' or maxMultipleFaceCount == 0">
+                and toer.warning_multiple_face_count &lt;= #{maxMultipleFaceCount}
+            </if>
+            <if test="minExceptionCount != null and minExceptionCount != '' or minExceptionCount == 0">
+                and toer.exception_count &gt;= #{minExceptionCount}
+            </if>
+            <if test="maxExceptionCount != null and maxExceptionCount != '' or maxExceptionCount == 0">
+                and toer.exception_count &lt;= #{maxExceptionCount}
+            </if>
         </where>
         <if test="(examActivityId != null and examActivityId != '') or (roomCodeList != null and roomCodeList != '' and roomCodeList.size > 0)">
             order by CAST(teea.code AS UNSIGNED),CAST(s.room_code AS UNSIGNED)
@@ -594,77 +594,77 @@
         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
         <where> 1 = 1
-        <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="orgId != null and orgId != ''">
-            and tee.org_id = #{orgId}
-        </if>
-        <if test="examId != null and examId != ''">
-            and s.exam_id = #{examId}
-        </if>
-        <if test="examActivityId != null and examActivityId != ''">
-            and s.exam_activity_id = #{examActivityId}
-        </if>
-        <if test="roomCodeList != null and roomCodeList != '' and roomCodeList.size > 0">
-            and s.room_code in
-            <foreach collection="roomCodeList" item="roomCode" index="index" open="(" close=")" separator=",">
-                #{roomCode}
-            </foreach>
-        </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="courseCode != null and courseCode != ''">
-            and s.course_code = #{courseCode}
-        </if>
-        <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 != null and status != '' and status == 'UN_FINISH'">
+                    and toer.id is null
+                </when>
+                <otherwise>
+                    and toer.id is not null
+                </otherwise>
+            </choose>
+            <if test="orgId != null and orgId != ''">
+                and tee.org_id = #{orgId}
+            </if>
+            <if test="examId != null and examId != ''">
+                and s.exam_id = #{examId}
+            </if>
+            <if test="examActivityId != null and examActivityId != ''">
+                and s.exam_activity_id = #{examActivityId}
+            </if>
+            <if test="roomCodeList != null and roomCodeList != '' and roomCodeList.size > 0">
+                and s.room_code in
+                <foreach collection="roomCodeList" item="roomCode" index="index" open="(" close=")" separator=",">
+                    #{roomCode}
+                </foreach>
+            </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="courseCode != null and courseCode != ''">
+                and s.course_code = #{courseCode}
+            </if>
+            <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 in ('ANSWERING','RESUME_PREPARE','BREAK_OFF')
+                        </when>
+                        <otherwise>
+                            and toer.status = #{status}
+                        </otherwise>
+                    </choose>
+                </when>
+            </choose>
+            <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 == 'EXAMING'">
-                        and toer.status in ('ANSWERING','RESUME_PREPARE','BREAK_OFF')
+                    <when test="finishType == 'ALL'">
+                        and toer.finish_type in ('MANUAL','AUTO','BREACH','INTERRUPT')
                     </when>
                     <otherwise>
-                        and toer.status = #{status}
+                        and toer.finish_type = #{finishType}
                     </otherwise>
                 </choose>
-            </when>
-        </choose>
-        <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="finishType == 'ALL'">
-                    and toer.finish_type in ('MANUAL','AUTO','BREACH','INTERRUPT')
-                </when>
-                <otherwise>
-                    and toer.finish_type = #{finishType}
-                </otherwise>
-            </choose>
-        </if>
             <if test="minMultipleFaceCount != null and minMultipleFaceCount != '' or minMultipleFaceCount == 0">
                 and toer.warning_multiple_face_count &gt;= #{minMultipleFaceCount}
             </if>
@@ -1737,7 +1737,7 @@
             <if test="roomCode != null and roomCode != ''">
                 and tees.room_code = #{roomCode}
             </if>
-                and (t.status = 'FINISHED' or t.status = 'PERSISTED') and t.first_start_time is not null
+            and (t.status = 'FINISHED' or t.status = 'PERSISTED') and t.first_start_time is not null
         </where>
     </select>
 </mapper>