Эх сурвалжийг харах

room_code和exam_id条件加入,去掉导入导出任务线程池

wangliang 4 жил өмнө
parent
commit
6156fdaa88

+ 51 - 51
themis-business/src/main/java/com/qmth/themis/business/threadPool/MyThreadPool.java

@@ -1,51 +1,51 @@
-package com.qmth.themis.business.threadPool;
-
-import com.qmth.themis.business.constant.SystemConstant;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-
-import javax.annotation.PostConstruct;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ThreadPoolExecutor;
-
-/**
- * @Description: 线程池应用配置
- * @Param:
- * @return:
- * @Author: wangliang
- * @Date: 2019/3/21
- */
-@Configuration
-public class MyThreadPool extends ThreadPoolTaskExecutor {
-
-    public MyThreadPool arbitratePoolTaskExecutor = null;
-
-    @PostConstruct
-    public void init() {
-        arbitrateThreadPool();
-    }
-
-    /**
-     * 仲裁线程池
-     *
-     * @return
-     */
-    @Bean
-    public Executor arbitrateThreadPool() {
-        if (arbitratePoolTaskExecutor == null) {
-            arbitratePoolTaskExecutor = new MyThreadPool();
-            arbitratePoolTaskExecutor.setCorePoolSize(SystemConstant.THREAD_POOL_CORE_POOL_SIZE);//核心线程数
-            arbitratePoolTaskExecutor.setMaxPoolSize(SystemConstant.THREAD_POOL_MAX_POOL_SIZE);//最大线程数
-            arbitratePoolTaskExecutor.setKeepAliveSeconds(SystemConstant.THREAD_POOL_KEEP_ALIVE_SECONDS);//线程空闲时间
-            arbitratePoolTaskExecutor.setQueueCapacity(SystemConstant.THREAD_POOL_QUEUE_CAPACITY);//队列容量
-            arbitratePoolTaskExecutor.setThreadNamePrefix(SystemConstant.THREAD_POOL_NAME);
-
-            // rejection-policy:当pool已经达到max size的时候,如何处理新任务
-            // CALLER_RUNS:不在新线程中执行任务,而是由调用者所在的线程来执行
-            arbitratePoolTaskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
-            arbitratePoolTaskExecutor.initialize();
-        }
-        return arbitratePoolTaskExecutor;
-    }
-}
+//package com.qmth.themis.business.threadPool;
+//
+//import com.qmth.themis.business.constant.SystemConstant;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+//
+//import javax.annotation.PostConstruct;
+//import java.util.concurrent.Executor;
+//import java.util.concurrent.ThreadPoolExecutor;
+//
+///**
+// * @Description: 线程池应用配置
+// * @Param:
+// * @return:
+// * @Author: wangliang
+// * @Date: 2019/3/21
+// */
+//@Configuration
+//public class MyThreadPool extends ThreadPoolTaskExecutor {
+//
+//    public MyThreadPool arbitratePoolTaskExecutor = null;
+//
+//    @PostConstruct
+//    public void init() {
+//        arbitrateThreadPool();
+//    }
+//
+//    /**
+//     * 仲裁线程池
+//     *
+//     * @return
+//     */
+//    @Bean
+//    public Executor arbitrateThreadPool() {
+//        if (arbitratePoolTaskExecutor == null) {
+//            arbitratePoolTaskExecutor = new MyThreadPool();
+//            arbitratePoolTaskExecutor.setCorePoolSize(SystemConstant.THREAD_POOL_CORE_POOL_SIZE);//核心线程数
+//            arbitratePoolTaskExecutor.setMaxPoolSize(SystemConstant.THREAD_POOL_MAX_POOL_SIZE);//最大线程数
+//            arbitratePoolTaskExecutor.setKeepAliveSeconds(SystemConstant.THREAD_POOL_KEEP_ALIVE_SECONDS);//线程空闲时间
+//            arbitratePoolTaskExecutor.setQueueCapacity(SystemConstant.THREAD_POOL_QUEUE_CAPACITY);//队列容量
+//            arbitratePoolTaskExecutor.setThreadNamePrefix(SystemConstant.THREAD_POOL_NAME);
+//
+//            // rejection-policy:当pool已经达到max size的时候,如何处理新任务
+//            // CALLER_RUNS:不在新线程中执行任务,而是由调用者所在的线程来执行
+//            arbitratePoolTaskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+//            arbitratePoolTaskExecutor.initialize();
+//        }
+//        return arbitratePoolTaskExecutor;
+//    }
+//}

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

@@ -22,7 +22,7 @@
                 t_b_exam_invigilate_user tbeiu
                 left join t_e_exam_student tees on
                 tees.exam_id = tbeiu.exam_id
-                and tees.room_code = tbeiu.room_code
+                and tees.room_code = tbeiu.room_code and tees.exam_id = tbeiu.exam_id
                 where
                 tbeiu.user_id = #{userId}
                 and t.id = tbeiu.exam_id)
@@ -95,7 +95,7 @@
                 t_b_exam_invigilate_user tbeiu
                 left join t_e_exam_student tees on
                 tees.exam_id = tbeiu.exam_id
-                and tees.room_code = tbeiu.room_code
+                and tees.room_code = tbeiu.room_code and tees.exam_id = tbeiu.exam_id
                 where
                 tbeiu.user_id = #{userId}
                 and t.id = tbeiu.exam_id)
@@ -195,7 +195,7 @@
         t_b_exam_invigilate_user tbeiu
         left join t_e_exam_student tees on
         tees.exam_id = tbeiu.exam_id
-        and tees.room_code = tbeiu.room_code
+        and tees.room_code = tbeiu.room_code and tees.exam_id = tbeiu.exam_id
         <where>1 = 1
             <if test="userId != null and userId != ''">
                 and tbeiu.user_id = #{userId}

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

@@ -29,7 +29,7 @@
                 <if test="userId != null and userId != ''">
                     and tbeiu.user_id = #{userId}
                 </if>
-                    and tbeiu.exam_id = tees.exam_id
+                    and tbeiu.exam_id = tees.exam_id and tees.exam_id = tbeiu.exam_id
                 )
                 <if test="examId != null and examId != ''">
                     and tees.exam_id = #{examId}

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

@@ -12,7 +12,7 @@
         <if test="userId != null and userId != ''">
             tbeiu.user_id = #{userId} and
         </if>
-        tbeiu.room_code = tees.room_code and toer.exam_student_id = tees.id and toer.exam_id = tbeiu.exam_id))) t on t.id = tiiwi.exam_record_id
+        tbeiu.room_code = tees.room_code and toer.exam_id = tbeiu.exam_id and toer.exam_student_id = tees.id))) t on t.id = tiiwi.exam_record_id
         <where>
             <if test="examId != null and examId != ''">
                 and tiiwi.exam_id = #{examId}

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

@@ -117,7 +117,7 @@
 		<if test="userId != null and userId != ''">
 			tbeiu.user_id = #{userId} and
 		</if>
-		tbeiu.room_code = tees.room_code and toer.exam_student_id = tees.id)))
+		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>
 
@@ -353,7 +353,7 @@
 		<if test="userId != null and userId != ''">
 			tbeiu.user_id = #{userId} and
 		</if>
-		tbeiu.room_code = tees.room_code and toer.exam_student_id = tees.id)))
+		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
@@ -443,7 +443,7 @@
 		<if test="userId != null and userId != ''">
 			tbeiu.user_id = #{userId} and
 		</if>
-		tbeiu.room_code = tees.room_code and toer.exam_student_id = tees.id)))
+		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
@@ -771,7 +771,7 @@
 		<if test="userId != null and userId != ''">
 			and tbeiu.user_id = #{userId}
 		</if>
-		and tbeiu.exam_id = tees.exam_id))) t1 on
+		and tbeiu.exam_id = tees.exam_id and tees.room_code = tbeiu.room_code))) t1 on
 		t1.id = t.id
 		<where> 1 = 1
 			<if test="examId != null and examId != ''">

+ 36 - 37
themis-mq/src/main/java/com/qmth/themis/mq/service/impl/MqLogicServiceImpl.java

@@ -18,7 +18,6 @@ import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.templete.TaskExportTemplete;
 import com.qmth.themis.business.templete.TaskImportTemplete;
 import com.qmth.themis.business.templete.impl.*;
-import com.qmth.themis.business.threadPool.MyThreadPool;
 import com.qmth.themis.business.util.JacksonUtil;
 import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.business.util.UidUtil;
@@ -68,8 +67,8 @@ public class MqLogicServiceImpl implements MqLogicService {
     @Resource
     TBSessionService tbSessionService;
 
-    @Resource
-    MyThreadPool myThreadPool;
+//    @Resource
+//    MyThreadPool myThreadPool;
 
     @Resource
     TOeExamBreakHistoryService tOeExamBreakHistoryService;
@@ -206,39 +205,39 @@ public class MqLogicServiceImpl implements MqLogicService {
         Gson gson = new Gson();
         Map<String, Object> map = (Map<String, Object>) mqDto.getBody();
         String tag = mqDto.getTag();
-        myThreadPool.arbitratePoolTaskExecutor.execute(() -> {
-            if (tag.contains("Import".toUpperCase())) {
-                TaskImportTemplete taskImportTemplete = null;
-                if (Objects.equals(MqTagEnum.EXAM_STUDENT_IMPORT.name(), tag)) {
-                    taskImportTemplete = SpringContextHolder.getBean(TaskExamStudentImportTemplete.class);
-                } else if (Objects.equals(MqTagEnum.ROOM_CODE_IMPORT.name(), tag)) {
-                    taskImportTemplete = SpringContextHolder.getBean(TaskRoomCodeImportTemplete.class);
-                } else if (Objects.equals(MqTagEnum.EXAM_PAPER_IMPORT.name(), tag)) {
-                    taskImportTemplete = SpringContextHolder.getBean(TaskExamPaperImportTemplete.class);
-                }
-                try {
-                    taskImportTemplete.importTask(map);
-                } catch (IOException e) {
-                    log.error("请求出错", e);
-                }
-            } else {
-                TaskExportTemplete taskExportTemplete = null;
-                if (Objects.equals(MqTagEnum.ROOM_CODE_EXPORT.name(), tag)) {
-                    taskExportTemplete = SpringContextHolder.getBean(TaskRoomCodeExportTemplete.class);
-                } else if (Objects.equals(MqTagEnum.EXAM_STUDENT_EXPORT.name(), tag)) {
-                    taskExportTemplete = SpringContextHolder.getBean(TaskExamStudentExportTemplete.class);
-                } else if (Objects.equals(MqTagEnum.MARK_RESULT_SIMPLE_EXPORT.name(), tag)) {
-                    taskExportTemplete = SpringContextHolder.getBean(TaskMarkResultSimpleExportTemplete.class);
-                } else if (Objects.equals(MqTagEnum.MARK_RESULT_STANDARD_EXPORT.name(), tag)) {
-                    taskExportTemplete = SpringContextHolder.getBean(TaskMarkResultStandardExportTemplete.class);
-                }
-                try {
-                    taskExportTemplete.exportTask(map);
-                } catch (IOException e) {
-                    log.error("请求出错", e);
-                }
+//        myThreadPool.arbitratePoolTaskExecutor.execute(() -> {
+        if (tag.contains("Import".toUpperCase())) {
+            TaskImportTemplete taskImportTemplete = null;
+            if (Objects.equals(MqTagEnum.EXAM_STUDENT_IMPORT.name(), tag)) {
+                taskImportTemplete = SpringContextHolder.getBean(TaskExamStudentImportTemplete.class);
+            } else if (Objects.equals(MqTagEnum.ROOM_CODE_IMPORT.name(), tag)) {
+                taskImportTemplete = SpringContextHolder.getBean(TaskRoomCodeImportTemplete.class);
+            } else if (Objects.equals(MqTagEnum.EXAM_PAPER_IMPORT.name(), tag)) {
+                taskImportTemplete = SpringContextHolder.getBean(TaskExamPaperImportTemplete.class);
             }
-        });
+            try {
+                taskImportTemplete.importTask(map);
+            } catch (IOException e) {
+                log.error("请求出错", e);
+            }
+        } else {
+            TaskExportTemplete taskExportTemplete = null;
+            if (Objects.equals(MqTagEnum.ROOM_CODE_EXPORT.name(), tag)) {
+                taskExportTemplete = SpringContextHolder.getBean(TaskRoomCodeExportTemplete.class);
+            } else if (Objects.equals(MqTagEnum.EXAM_STUDENT_EXPORT.name(), tag)) {
+                taskExportTemplete = SpringContextHolder.getBean(TaskExamStudentExportTemplete.class);
+            } else if (Objects.equals(MqTagEnum.MARK_RESULT_SIMPLE_EXPORT.name(), tag)) {
+                taskExportTemplete = SpringContextHolder.getBean(TaskMarkResultSimpleExportTemplete.class);
+            } else if (Objects.equals(MqTagEnum.MARK_RESULT_STANDARD_EXPORT.name(), tag)) {
+                taskExportTemplete = SpringContextHolder.getBean(TaskMarkResultStandardExportTemplete.class);
+            }
+            try {
+                taskExportTemplete.exportTask(map);
+            } catch (IOException e) {
+                log.error("请求出错", e);
+            }
+        }
+//        });
         mqDto.setAck(SystemConstant.STANDARD_ACK_TYPE);
         mqDto.setBody(JacksonUtil.parseJson(mqDto.getBody()));
         TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);
@@ -935,7 +934,7 @@ public class MqLogicServiceImpl implements MqLogicService {
      */
     @Override
     public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
-            ConsumeConcurrentlyContext consumeConcurrentlyContext, MqExecTypeEnum mqExecTypeEnum) {
+                                                    ConsumeConcurrentlyContext consumeConcurrentlyContext, MqExecTypeEnum mqExecTypeEnum) {
         MqDto mqDto = null;
         try {
             long threadId = Thread.currentThread().getId();
@@ -984,7 +983,7 @@ public class MqLogicServiceImpl implements MqLogicService {
      */
     @Override
     public ConsumeConcurrentlyStatus consumeMessageDelay(List<MessageExt> msgs,
-            ConsumeConcurrentlyContext consumeConcurrentlyContext, MqExecTypeEnum mqExecTypeEnum) {
+                                                         ConsumeConcurrentlyContext consumeConcurrentlyContext, MqExecTypeEnum mqExecTypeEnum) {
         MqDto mqDto = null;
         try {
             long threadId = Thread.currentThread().getId();