Browse Source

考务菜单优化

wangliang 2 years ago
parent
commit
3f4c11ad5d

+ 15 - 36
themis-business/src/main/resources/mapper/TBExamInvigilateUserMapper.xml

@@ -3,20 +3,19 @@
 <mapper namespace="com.qmth.themis.business.dao.TBExamInvigilateUserMapper">
 
     <sql id="queryCommon">
-        (
         select
-        tbeiu.room_code as roomCode, tbeiu.room_name as roomName, tbeiu.user_id as userId,tee.id as examId,
-        tee.name as examName, (
-        select
-        tbu.name
-        from
-        t_b_user tbu
-        where
-        tbu.id = tbeiu.user_id) as name
+        tbeiu.room_code as roomCode,
+        tbeiu.room_name as roomName,
+        tee.id as examId,
+        tee.name as examName,
+        GROUP_CONCAT(tbeiu.user_id) as userId,
+        GROUP_CONCAT(tbu.name) as name
         from
         t_b_exam_invigilate_user tbeiu
         left join t_e_exam tee on
         tee.id = tbeiu.exam_id
+        left join t_b_user tbu on
+        tbu.id = tbeiu.user_id
         <where>
             <if test="examId != null and examId != ''">
                 and tbeiu.exam_id = #{examId}
@@ -31,41 +30,21 @@
                 and tbeiu.org_id = #{orgId}
             </if>
         </where>
-        ) t
+        group by
+        tee.id,
+        tee.name,
+        tbeiu.room_code,
+        tbeiu.room_name
     </sql>
 
     <select id="examInvigilateUserQuery" resultType="com.qmth.themis.business.dto.response.TBExamInvigilateUserDto">
-        select
-        t.examId,
-        t.examName,
-        t.roomCode,
-        t.roomName,
-        GROUP_CONCAT(t.userId) as userId,
-        GROUP_CONCAT(t.name) as name
-        from
         <include refid="queryCommon"/>
-        group by
-        t.examId,
-        t.examName,
-        t.roomCode,
-        t.roomName
-        order by t.examName,CAST(t.roomCode AS UNSIGNED)
+        order by tee.name,CAST(tbeiu.room_code AS UNSIGNED)
     </select>
 
     <select id="examInvigilateUserExport" resultType="com.qmth.themis.business.dto.RoomCodeExportDto">
-        select
-        t.examId,
-        t.examName,
-        t.roomCode,
-        t.roomName,
-        GROUP_CONCAT(t.name) as name
-        from
         <include refid="queryCommon"/>
-        group by
-        t.examId,
-        t.examName,
-        t.roomCode,
-        t.roomName
+        order by tee.name,CAST(tbeiu.room_code AS UNSIGNED)
     </select>
 
     <select id="getInvigilateUsers" resultType="java.util.Map">

+ 5 - 9
themis-business/src/main/resources/mapper/TBTaskHistoryMapper.xml

@@ -18,17 +18,13 @@
             tbth.create_id as createId,
             tbth.import_file_name as importFileName,
             h.name examName,
-            (select tee.name from t_e_exam tee where tee.id = tbth.entity_id) as entityName,
-            (
-            select
-                tbu.name
-            from
-                t_b_user tbu
-            where
-                tbu.id = tbth.create_id) as createName
+            tee1.name as entityName,
+            tbu.name as createName
         from
             t_b_task_history tbth
-            left join t_e_exam h on tbth.exam_id=h.id
+            left join t_e_exam tee1 on tee1.id =  tbth.entity_id
+            left join t_b_user tbu on tbu.id = tbth.create_id
+            left join t_e_exam h on tbth.exam_id = h.id
             <where>
             	<if test="examId != null">
                     and h.id = #{examId}

+ 8 - 35
themis-business/src/main/resources/mapper/TEExamCourseMapper.xml

@@ -4,44 +4,18 @@
 	namespace="com.qmth.themis.business.dao.TEExamCourseMapper">
 
 	<select id="examCourseQuery" resultType="com.qmth.themis.business.dto.response.TEExamCourseDto">
-		select
-		t.id,
-		t.examId,
-		t.courseCode,
-		t.courseName,
-		t.paperCount,
-		t.hasPaper,
-		t.objectiveShuffle,
-		t.optionShuffle,
-		t.audioPlayCount,
-		t.hasAnswer,
-		t.hasAudio,
-		if(t.updateName is not null, t.updateName, t.createName) as updateName,
-		if(t.updateTime is not null, t.updateTime, t.createTime) as updateTime,
-        t.mobilePhotoUpload
-		from
-		(
 		select
 		teec.exam_id as examId,teec.id,teec.course_code as courseCode, teec.course_name as courseName, teec.paper_count as paperCount,
 		if(teec.paper_count > 0, 1, 0) as hasPaper, teec.objective_shuffle as objectiveShuffle, teec.option_shuffle as
 		optionShuffle, teec.audio_play_count as audioPlayCount, teec.has_answer as hasAnswer, teec.has_audio as
-		hasAudio, teec.create_time as createTime, teec.update_time as updateTime, (
-		select
-		t.name
-		from
-		t_b_user t
-		where
-		t.id = teec.create_id) as createName, (
-		select
-		t.name
-		from
-		t_b_user t
-		where
-		t.id = teec.update_id) as updateName,
-        teec.mobile_photo_upload as mobilePhotoUpload
+		hasAudio,
+        teec.mobile_photo_upload as mobilePhotoUpload,
+        if(tbu2.name is not null,tbu2.name,tbu1.name) as updateName,
+        if(teec.update_time is not null,teec.update_time, teec.create_time) as updateTime
 		from
-		t_e_exam_course teec
-		left join t_e_exam tee on teec.exam_id = tee.id
+		t_e_exam_course teec left join t_e_exam tee on teec.exam_id = tee.id
+        left join t_b_user tbu1 on teec.create_id = tbu1.id
+        left join t_b_user tbu2 on teec.update_id = tbu2.id
 		<where>
 			<if test="id != null and id != ''">
 				and teec.id = #{id}
@@ -65,8 +39,7 @@
 					</otherwise>
 				</choose>
 			</if>
-		</where>
-		) t order by t.courseCode,t.updateTime desc
+		</where> order by teec.course_code,teec.update_time desc
 	</select>
 
 	<select id="findByExamIdAndCourseCode"

+ 48 - 79
themis-business/src/main/resources/mapper/TEExamMapper.xml

@@ -7,6 +7,9 @@
         t.id as examId
         from
         t_e_exam t
+        <if test="userId != null and userId != ''">
+            left join t_b_exam_invigilate_user tbeiu on tbeiu.exam_id = t.id
+        </if>
         <where>1 = 1
             and t.monitor_status <![CDATA[ <> ]]> 'FINISHED'
             and t.start_time <![CDATA[ <= ]]> unix_timestamp(current_timestamp()) * 1000
@@ -15,48 +18,13 @@
                 and t.org_id = #{orgId}
             </if>
             <if test="userId != null and userId != ''">
-                and EXISTS(
-                select
-                DISTINCT tbeiu.exam_id
-                from
-                t_b_exam_invigilate_user tbeiu
-                left join t_e_exam_student tees on
-                tees.room_code = tbeiu.room_code and tees.exam_id = tbeiu.exam_id
-                where
-                tbeiu.user_id = #{userId}
-                and t.id = tbeiu.exam_id)
+                and tbeiu.user_id = #{userId}
             </if>
         </where>
     </select>
 
     <select id="examQuery" resultType="com.qmth.themis.business.dto.response.TEExamQueryDto">
-        select
-        t.id,
-        t.code,
-        t.name,
-        t.tag,
-        t.mode,
-        t.enable,
-        t.startTime,
-        t.endTime,
-        t.progress,
-        t.score_status scoreStatus,
-        if(t.updateName is not null, t.updateName, t.createName) as updateName,
-        if(t.updateTime is not null, t.updateTime, t.createTime) as updateTime,
-        t.enableIpLimit,
-        t.monitorVideoSource,
-        t.monitorRecord,
-        t.monitorStatus,
-        t.examStudentCallEnable,
-        t.objectiveScorePush,
-        (select tbth.status from t_b_task_history tbth where tbth.exam_id = t.id and tbth.`type` = 'CLOUD_MARK_DATA_PUSH' and tbth.progress = 100 order by tbth.create_time desc limit 1) as cloudMarkPushDataStatus,
-        t.examStudentBreachPush
-        <if test="type != null and type != '' and type == 'monitor'">
-            ,group_concat(distinct tees.room_code) as roomCode,
-            group_concat(distinct tees.room_name) as roomName
-        </if>
-        from
-        (select t.id,
+        select t.id,
         t.code,
         t.name,
         t.tag,
@@ -71,24 +39,37 @@
         t.monitor_record as monitorRecord,
         t.monitor_status as monitorStatus,
         TRUNCATE(t.progress,2) as progress,
-        t.score_status,
+        t.score_status as scoreStatus,
+        tbu1.name as createName,
+        tbu2.name as updateName,
+        t.exam_student_call_enable as examStudentCallEnable,
+        t.objective_score_push as objectiveScorePush,
+        t.exam_student_breach_push as examStudentBreachPush,
         (
         select
-        t1.name
-        from
-        t_b_user t1
-        where
-        t1.id = t.create_id) as createName, (
-        select
-        t1.name
+        tbth.status
         from
-        t_b_user t1
+        t_b_task_history tbth
         where
-        t1.id = t.update_id) as updateName,
-        t.exam_student_call_enable as examStudentCallEnable,
-        t.objective_score_push as objectiveScorePush,
-        t.exam_student_breach_push as examStudentBreachPush
+        tbth.exam_id = t.id
+        and tbth.`type` = 'CLOUD_MARK_DATA_PUSH'
+        and tbth.progress = 100
+        order by
+        tbth.create_time desc
+        limit 1) as cloudMarkPushDataStatus
+        <if test="type != null and type != '' and type == 'monitor'">
+            ,group_concat(distinct tees.room_code) as roomCode,
+            group_concat(distinct tees.room_name) as roomName
+        </if>
         from t_e_exam t
+        left join t_b_user tbu1 on t.create_id = tbu1.id
+        left join t_b_user tbu2 on t.update_id = tbu2.id
+        <if test="type != null and type != '' and type == 'monitor'">
+            left join t_e_exam_student tees on tees.exam_id = t.id
+        </if>
+        <if test="userId != null and userId != ''">
+            left join t_b_exam_invigilate_user tbeiu on tbeiu.exam_id = t.id
+        </if>
         <where>1 = 1
             <if test="type != null and type != '' and type == 'monitor'">
                 and t.monitor_status <![CDATA[ <> ]]> 'FINISHED'
@@ -98,17 +79,7 @@
                 and t.monitor_status = 'FINISHED'
             </if>
             <if test="userId != null and userId != ''">
-                and t.enable = 1
-                and EXISTS(
-                select
-                DISTINCT tbeiu.exam_id
-                from
-                t_b_exam_invigilate_user tbeiu
-                left join t_e_exam_student tees on
-                tees.room_code = tbeiu.room_code and tees.exam_id = tbeiu.exam_id
-                where
-                tbeiu.user_id = #{userId}
-                and t.id = tbeiu.exam_id)
+                and tbeiu.user_id = #{userId}
             </if>
             <if test="orgId != null and orgId != ''">
                 and t.org_id = #{orgId}
@@ -129,26 +100,24 @@
                 and t.enable = #{enable}
             </if>
         </where>
-        ) t
         <if test="type != null and type != '' and type == 'monitor'">
-            left join t_e_exam_student tees on tees.exam_id = t.id
+            group by t.id,
+            t.code,
+            t.name,
+            t.tag,
+            t.mode,
+            t.enable,
+            t.start_time,
+            t.end_time,
+            t.progress,
+            tbu2.name,
+            t.update_ime,
+            t.enable_ip_limit,
+            t.monitor_video_source,
+            t.monitor_record,
+            t.monitor_status
         </if>
-        group by t.id,
-        t.code,
-        t.name,
-        t.tag,
-        t.mode,
-        t.enable,
-        t.startTime,
-        t.endTime,
-        t.progress,
-        t.updateName,
-        t.updateTime,
-        t.enableIpLimit,
-        t.monitorVideoSource,
-        t.monitorRecord,
-        t.monitorStatus
-        order by t.createTime desc
+        order by t.create_time desc
     </select>
 
     <select id="examroomQuery" resultType="java.util.HashMap">