Ver código fonte

exists条件修改

wangliang 4 anos atrás
pai
commit
724478d110

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

@@ -7,16 +7,15 @@
         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
-        inner join (select toer.id from t_oe_exam_record toer where EXISTS(select tees.id from t_e_exam_student tees where EXISTS (select distinct tbeiu.room_code from t_b_exam_invigilate_user tbeiu
-        where
-        <if test="userId != null and userId != ''">
-            tbeiu.user_id = #{userId} and
-        </if>
-        tbeiu.room_code = tees.room_code and tees.exam_id = tbeiu.exam_id and toer.exam_student_id = tees.id))) t on t.id = tiiwi.exam_record_id
-        <where>
+        <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)
+            </if>
             <if test="orgId != null and orgId != ''">
                 and tee.org_id = #{orgId}
             </if>

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

@@ -110,15 +110,6 @@
 		left join t_e_exam_student s on t.exam_student_id = s.id
 		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
-		inner join (select toer.id from t_oe_exam_record toer where EXISTS(select
-		tees.id from t_e_exam_student tees where EXISTS (select distinct
-		tbeiu.room_code from t_b_exam_invigilate_user tbeiu
-		where
-		<if test="userId != null and userId != ''">
-			tbeiu.user_id = #{userId} and
-		</if>
-		tbeiu.room_code = tees.room_code and tees.exam_id = tbeiu.exam_id and toer.exam_student_id = tees.id)))
-		t1 on t1.id = t.id
 	</sql>
 
 	<sql id="invigilatePageFoot">
@@ -126,6 +117,11 @@
 			<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>
@@ -160,18 +156,20 @@
 			<if test="clientWebsocketStatus != null and clientWebsocketStatus != ''">
 				and t.client_websocket_status = #{clientWebsocketStatus}
 			</if>
-			and s.enable = 1
-			and tee.enable = 1
-			and teea.enable = 1
 			and teea.finish_time > unix_timestamp(current_timestamp()) * 1000
 		</where>
 	</sql>
 
 	<sql id="invigilatePageHistoryFoot">
-		<where>
+		<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>
@@ -203,9 +201,6 @@
 			<if test="minWarningCount != null and minWarningCount != '' or minWarningCount == 0">
 				and t.warning_count &gt;= #{minWarningCount}
 			</if>
-			and s.enable = 1
-			and tee.enable = 1
-			and teea.enable = 1
 		</where>
 	</sql>
 
@@ -218,11 +213,6 @@
 		<include refid="invigilatePageHead"/>
 		,(select count(1) from t_ie_invigilate_warn_info tiiwi where tiiwi.exam_record_id = t.id and
 		tiiwi.approve_status = 0) as warningNew
-		<!--,case
-		when tee.mode = 'ANYTIME' then SEC_TO_TIME(IFNULL(teea.max_duration_seconds, tee.max_duration_seconds) - t.duration_seconds)
-		when tee.mode = 'TOGETHER' and tee.force_finish = 1 then SEC_TO_TIME((IFNULL(teea.finish_time, tee.end_time) - unix_timestamp(current_timestamp()) * 1000) / 1000)
-		else SEC_TO_TIME(IFNULL(teea.max_duration_seconds, tee.max_duration_seconds) - t.duration_seconds)
-		end as remainTime-->
 		<include refid="invigilatePageMiddle"/>
 		<include refid="invigilatePageFoot"/>
 		<if test="paperDownload != null and paperDownload != '' or paperDownload == 0">
@@ -245,11 +235,6 @@
 		<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 tiiwi.approve_status = 0) as warningNew
-		<!--,case
-		when tee.mode = 'ANYTIME' then SEC_TO_TIME(IFNULL(teea.max_duration_seconds, tee.max_duration_seconds) - t.duration_seconds)
-		when tee.mode = 'TOGETHER' and tee.force_finish = 1 then SEC_TO_TIME((IFNULL(teea.finish_time, tee.end_time) - unix_timestamp(current_timestamp()) * 1000) / 1000)
-		else SEC_TO_TIME(IFNULL(teea.max_duration_seconds, tee.max_duration_seconds) - t.duration_seconds)
-		end as remainTime-->
 		<include refid="invigilatePageMiddle" />
 		<include refid="invigilatePageFoot" />
 		<if test="paperDownload != null and paperDownload != '' or paperDownload == 0">
@@ -267,11 +252,6 @@
 		<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 tiiwi.approve_status = 0) as warningNew
-		<!--,case
-		when tee.mode = 'ANYTIME' then SEC_TO_TIME(IFNULL(teea.max_duration_seconds, tee.max_duration_seconds) - t.duration_seconds)
-		when tee.mode = 'TOGETHER' and tee.force_finish = 1 then SEC_TO_TIME((IFNULL(teea.finish_time, tee.end_time) - unix_timestamp(current_timestamp()) * 1000) / 1000)
-		else SEC_TO_TIME(IFNULL(teea.max_duration_seconds, tee.max_duration_seconds) - t.duration_seconds)
-		end as remainTime-->
 		<include refid="invigilatePageMiddle" />
 		<where> 1 = 1
 			<if test="examId != null and examId != ''">
@@ -290,11 +270,6 @@
 		,(select count(1) from t_ie_invigilate_exception_info tiiei where tiiei.exam_record_id = t.id) as exceptionCount
 		,(select count(1) from t_ie_invigilate_warn_info tiiwi where tiiwi.exam_record_id = t.id and tiiwi.`type` =
 		'FACE_COUNT_ERROR' and tiiwi.`level` = 'D8') as multipleFaceCount
-		<!--,case
-		when tee.mode = 'ANYTIME' then SEC_TO_TIME(IFNULL(teea.max_duration_seconds, tee.max_duration_seconds) - t.duration_seconds)
-		when tee.mode = 'TOGETHER' and tee.force_finish = 1 then SEC_TO_TIME((IFNULL(teea.finish_time, tee.end_time) - unix_timestamp(current_timestamp()) * 1000) / 1000)
-		else SEC_TO_TIME(IFNULL(teea.max_duration_seconds, tee.max_duration_seconds) - t.duration_seconds)
-		end as remainTime-->
 		<include refid="invigilatePageMiddle" />
 		<include refid="invigilatePageFoot" />
 		<if test="status == null or status == ''">
@@ -346,21 +321,17 @@
 		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
-		inner join (select toer.id from t_oe_exam_record toer where EXISTS(select
-		tees.id from t_e_exam_student tees where EXISTS (select distinct
-		tbeiu.room_code from t_b_exam_invigilate_user tbeiu
-		where
-		<if test="userId != null and userId != ''">
-			tbeiu.user_id = #{userId} and
-		</if>
-		tbeiu.room_code = tees.room_code and tees.exam_id = tbeiu.exam_id and toer.exam_student_id = tees.id)))
-		t on t.id = tiiwi.exam_record_id
-		left join t_oe_exam_record toer on toer.id = t.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
-		<where>
+		<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)
+			</if>
 			<if test="orgId != null and orgId != ''">
 				and tee.org_id = #{orgId}
 			</if>
@@ -385,8 +356,6 @@
 			<if test="minWarningCount != null and minWarningCount != '' or minWarningCount == 0">
 				and toer.warning_count &gt;= #{minWarningCount}
 			</if>
-			and tee.enable = 1
-			and teea.enable = 1
 		</where>
 		) t,(SELECT @i := 0) as i
 		<where>
@@ -436,21 +405,17 @@
 		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
-		inner join (select toer.id from t_oe_exam_record toer where EXISTS(select
-		tees.id from t_e_exam_student tees where EXISTS (select distinct
-		tbeiu.room_code from t_b_exam_invigilate_user tbeiu
-		where
-		<if test="userId != null and userId != ''">
-			tbeiu.user_id = #{userId} and
-		</if>
-		tbeiu.room_code = tees.room_code and tees.exam_id = tbeiu.exam_id and toer.exam_student_id = tees.id)))
-		t on t.id = tiiwi.exam_record_id
 		left join t_oe_exam_record toer on toer.id = t.id
 		left join t_e_exam_student tees on tees.id = tiiwi.exam_student_id
-		<where>
+		<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)
+			</if>
 			<if test="orgId != null and orgId != ''">
 				and tee.org_id = #{orgId}
 			</if>
@@ -475,8 +440,6 @@
 			<if test="minWarningCount != null and minWarningCount != '' or minWarningCount == 0">
 				and toer.warning_count &gt;= #{minWarningCount}
 			</if>
-			and tee.enable = 1
-			and teea.enable = 1
 		</where>
 		) t
 		<where> 1 = 1
@@ -520,20 +483,15 @@
 		left join t_e_exam_activity teea on
 		teea.id = tees.exam_activity_id
 		left join t_e_student tes on tees.student_id = tes.id
-		<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
-			)
+		<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)
+			</if>
 			<if test="orgId != null and orgId != ''">
 				and tee.org_id = #{orgId}
 			</if>
@@ -552,8 +510,6 @@
 			<if test="identity != null and identity !=''">
 				and tees.identity like CONCAT('%', #{identity},'%')
 			</if>
-			and tee.enable = 1
-			and teea.enable = 1
 			and tee.monitor_status <![CDATA[ <> ]]> 'FINISHED'
 		</where>
 		order by tees.room_code
@@ -582,20 +538,15 @@
 		left join t_e_exam_activity teea on
 		teea.id = tees.exam_activity_id
 		left join t_e_student tes on tees.student_id = tes.id
-		<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
-			)
+		<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)
+			</if>
 			<if test="orgId != null and orgId != ''">
 				and tee.org_id = #{orgId}
 			</if>
@@ -614,8 +565,6 @@
 			<if test="identity != null and identity !=''">
 				and tees.identity like CONCAT('%', #{identity},'%')
 			</if>
-			and tee.enable = 1
-			and teea.enable = 1
 			and tee.monitor_status <![CDATA[ <> ]]> 'FINISHED'
 		</where>
 		group by tee.id,tees.room_code,tee.name,teea.id,teea.code,tees.`identity`,tees.name,leftExamCount,status,tes.mobile_number
@@ -751,35 +700,15 @@
 		tee.id = t.exam_id
 		left join t_e_exam_activity teea on
 		teea.id = t.exam_activity_id
-		inner join (
-		select
-		toer.id
-		from
-		t_oe_exam_record toer
-		where
-		EXISTS(
-		select
-		tees.id
-		from
-		t_e_exam_student tees
-		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))) t1 on
-		t1.id = t.id
-		<where> 1 = 1
+		<where>
 			<if test="examId != null and examId != ''">
 				and t.exam_id = #{examId}
 			</if>
-			and s.enable = 1
-			and tee.enable = 1
-			and teea.enable = 1
+			<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 <![CDATA[ <> ]]> 'PERSISTED' and t.status <![CDATA[ <> ]]> 'FINISHED')
 		</where> ) t
 		group by