wangliang 2 роки тому
батько
коміт
99c9809ed8

+ 19 - 10
themis-task/src/main/java/com/qmth/themis/task/quartz/MqActivityJob.java

@@ -2,6 +2,7 @@ package com.qmth.themis.task.quartz;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
+import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.entity.TEExam;
 import com.qmth.themis.business.entity.TEExamActivity;
 import com.qmth.themis.business.entity.TOeExamRecord;
@@ -84,11 +85,15 @@ public class MqActivityJob extends QuartzJobBean {
                                     Long examStudentId = s.getExamStudentId();
                                     ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
                                     //候考阶段且没有进入考试则不交卷
-                                    if (examRecordStatusEnum == ExamRecordStatusEnum.FIRST_PREPARE && Objects.isNull(s.getFirstStartTime())) {
-                                        commonService.deleteExamStudentCache(s.getId(), examStudentCacheBean.getStudentId());
-                                        commonService.DismissRoomByStrRoomId(s.getId());
-                                    } else {//交卷
-                                        teExamService.finish(examStudentCacheBean.getStudentId(), s.getId(), FinishTypeEnum.AUTO.name(), durationSeconds);
+                                    try {
+                                        if (examRecordStatusEnum == ExamRecordStatusEnum.FIRST_PREPARE && Objects.isNull(s.getFirstStartTime())) {
+                                            commonService.deleteExamStudentCache(s.getId(), examStudentCacheBean.getStudentId());
+                                            commonService.DismissRoomByStrRoomId(s.getId());
+                                        } else {//交卷
+                                            teExamService.finish(examStudentCacheBean.getStudentId(), s.getId(), FinishTypeEnum.AUTO.name(), durationSeconds);
+                                        }
+                                    } catch (Exception e) {
+                                        log.error(SystemConstant.LOG_ERROR, e);
                                     }
                                 }
                             });
@@ -106,11 +111,15 @@ public class MqActivityJob extends QuartzJobBean {
                                     Long examStudentId = s.getExamStudentId();
                                     ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
                                     //候考阶段且没有进入考试则不交卷
-                                    if (examRecordStatusEnum == ExamRecordStatusEnum.FIRST_PREPARE && Objects.isNull(s.getFirstStartTime())) {
-                                        commonService.deleteExamStudentCache(s.getId(), examStudentCacheBean.getStudentId());
-                                        commonService.DismissRoomByStrRoomId(s.getId());
-                                    } else {//交卷
-                                        teExamService.finish(examStudentCacheBean.getStudentId(), s.getId(), FinishTypeEnum.AUTO.name(), durationSeconds);
+                                    try {
+                                        if (examRecordStatusEnum == ExamRecordStatusEnum.FIRST_PREPARE && Objects.isNull(s.getFirstStartTime())) {
+                                            commonService.deleteExamStudentCache(s.getId(), examStudentCacheBean.getStudentId());
+                                            commonService.DismissRoomByStrRoomId(s.getId());
+                                        } else {//交卷
+                                            teExamService.finish(examStudentCacheBean.getStudentId(), s.getId(), FinishTypeEnum.AUTO.name(), durationSeconds);
+                                        }
+                                    } catch (Exception e) {
+                                        log.error(SystemConstant.LOG_ERROR, e);
                                     }
                                 }
                             });

+ 15 - 12
themis-task/src/main/java/com/qmth/themis/task/quartz/ObjectiveAnswerCacheLoadJob.java

@@ -1,9 +1,8 @@
 package com.qmth.themis.task.quartz;
 
-import java.util.List;
-
-import javax.annotation.Resource;
-
+import com.qmth.themis.business.constant.SystemConstant;
+import com.qmth.themis.business.service.TEExamActivityService;
+import com.qmth.themis.business.service.TEExamPaperService;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.slf4j.Logger;
@@ -11,8 +10,8 @@ import org.slf4j.LoggerFactory;
 import org.springframework.scheduling.quartz.QuartzJobBean;
 import org.springframework.stereotype.Component;
 
-import com.qmth.themis.business.service.TEExamActivityService;
-import com.qmth.themis.business.service.TEExamPaperService;
+import javax.annotation.Resource;
+import java.util.List;
 
 /**
  * @Description: 客观题缓存加载
@@ -25,18 +24,22 @@ public class ObjectiveAnswerCacheLoadJob extends QuartzJobBean {
 
     @Resource
     TEExamActivityService examActivityService;
-    
+
     @Resource
     TEExamPaperService examPaperService;
 
     @Override
     protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
         log.info("ObjectiveAnswerCacheLoadJob进来了,context:{}", context);
-        List<Long> examids=examActivityService.findExamIdToday();
-        if(examids!=null&&examids.size()>0) {
-        	for(Long examId:examids) {
-        		examPaperService.disposeObjectiveAnswer(examId);
-        	}
+        List<Long> examids = examActivityService.findExamIdToday();
+        if (examids != null && examids.size() > 0) {
+            for (Long examId : examids) {
+                try {
+                    examPaperService.disposeObjectiveAnswer(examId);
+                } catch (Exception e) {
+                    log.error(SystemConstant.LOG_ERROR, e);
+                }
+            }
         }
     }
 }

+ 32 - 29
themis-task/src/main/java/com/qmth/themis/task/quartz/service/impl/QuartzLogicServiceImpl.java

@@ -1,20 +1,14 @@
 package com.qmth.themis.task.quartz.service.impl;
 
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
 import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
 import com.qmth.themis.business.constant.SystemConstant;
-import com.qmth.themis.business.dto.MqDto;
-import com.qmth.themis.business.entity.TBAttachment;
-import com.qmth.themis.business.entity.TEAudio;
 import com.qmth.themis.business.entity.TOeExamRecord;
 import com.qmth.themis.business.enums.ExamRecordStatusEnum;
 import com.qmth.themis.business.enums.FinishTypeEnum;
-import com.qmth.themis.business.enums.MonitorVideoSourceEnum;
-import com.qmth.themis.business.enums.MqTagEnum;
 import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.util.MqUtil;
 import com.qmth.themis.business.util.OssUtil;
@@ -26,10 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
-import java.io.File;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Objects;
 
 /**
@@ -99,14 +90,18 @@ public class QuartzLogicServiceImpl implements QuartzLogicService {
                             Long examStudentId = s.getExamStudentId();
                             ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
                             //候考阶段且没有进入考试则不交卷
-                            if (examRecordStatusEnum == ExamRecordStatusEnum.FIRST_PREPARE && Objects.isNull(s.getFirstStartTime())) {
-                                commonService.deleteExamStudentCache(s.getId(), examStudentCacheBean.getStudentId());
-                                commonService.DismissRoomByStrRoomId(s.getId());
-                            } else {//交卷
-                                Long recordEndTime = s.getEndTime();
-                                if (Objects.nonNull(examActivityCacheBean.getFinishTime()) && Objects.nonNull(recordEndTime) && examActivityCacheBean.getFinishTime().longValue() == recordEndTime.longValue()) {
-                                    teExamService.finish(examStudentCacheBean.getStudentId(), s.getId(), FinishTypeEnum.AUTO.name(), durationSeconds);
+                            try {
+                                if (examRecordStatusEnum == ExamRecordStatusEnum.FIRST_PREPARE && Objects.isNull(s.getFirstStartTime())) {
+                                    commonService.deleteExamStudentCache(s.getId(), examStudentCacheBean.getStudentId());
+                                    commonService.DismissRoomByStrRoomId(s.getId());
+                                } else {//交卷
+                                    Long recordEndTime = s.getEndTime();
+                                    if (Objects.nonNull(examActivityCacheBean.getFinishTime()) && Objects.nonNull(recordEndTime) && examActivityCacheBean.getFinishTime().longValue() == recordEndTime.longValue()) {
+                                        teExamService.finish(examStudentCacheBean.getStudentId(), s.getId(), FinishTypeEnum.AUTO.name(), durationSeconds);
+                                    }
                                 }
+                            } catch (Exception e) {
+                                log.error(SystemConstant.LOG_ERROR, e);
                             }
                         }
                     });
@@ -126,11 +121,15 @@ public class QuartzLogicServiceImpl implements QuartzLogicService {
                                 Long examStudentId = s.getExamStudentId();
                                 ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
                                 //候考阶段且没有进入考试则不交卷
-                                if (examRecordStatusEnum == ExamRecordStatusEnum.FIRST_PREPARE && Objects.isNull(s.getFirstStartTime())) {
-                                    commonService.deleteExamStudentCache(s.getId(), examStudentCacheBean.getStudentId());
-                                    commonService.DismissRoomByStrRoomId(s.getId());
-                                } else {//交卷
-                                    teExamService.finish(examStudentCacheBean.getStudentId(), s.getId(), FinishTypeEnum.AUTO.name(), durationSeconds);
+                                try {
+                                    if (examRecordStatusEnum == ExamRecordStatusEnum.FIRST_PREPARE && Objects.isNull(s.getFirstStartTime())) {
+                                        commonService.deleteExamStudentCache(s.getId(), examStudentCacheBean.getStudentId());
+                                        commonService.DismissRoomByStrRoomId(s.getId());
+                                    } else {//交卷
+                                        teExamService.finish(examStudentCacheBean.getStudentId(), s.getId(), FinishTypeEnum.AUTO.name(), durationSeconds);
+                                    }
+                                } catch (Exception e) {
+                                    log.error(SystemConstant.LOG_ERROR, e);
                                 }
                             }
                         }
@@ -165,15 +164,19 @@ public class QuartzLogicServiceImpl implements QuartzLogicService {
                 firstStartTime = tOeExamRecord.getFirstStartTime();
             }
             //候考阶段且没有进入考试则不交卷
-            if (examRecordStatusEnum == ExamRecordStatusEnum.FIRST_PREPARE && Objects.isNull(firstStartTime)) {
-                commonService.deleteExamStudentCache(recordId, examStudentCacheBean.getStudentId());
-                commonService.DismissRoomByStrRoomId(recordId);
-            } else {//交卷
-                Long recordEndTime = ExamRecordCacheUtil.getEndTime(recordId);
-                if (examActivityCacheBean.getFinishTime().longValue() == recordEndTime.longValue()) {
-                    Integer durationSeconds = ExamRecordCacheUtil.getDurationSeconds(recordId);
-                    teExamService.finish(examStudentCacheBean.getStudentId(), recordId, FinishTypeEnum.AUTO.name(), durationSeconds);
+            try {
+                if (examRecordStatusEnum == ExamRecordStatusEnum.FIRST_PREPARE && Objects.isNull(firstStartTime)) {
+                    commonService.deleteExamStudentCache(recordId, examStudentCacheBean.getStudentId());
+                    commonService.DismissRoomByStrRoomId(recordId);
+                } else {//交卷
+                    Long recordEndTime = ExamRecordCacheUtil.getEndTime(recordId);
+                    if (examActivityCacheBean.getFinishTime().longValue() == recordEndTime.longValue()) {
+                        Integer durationSeconds = ExamRecordCacheUtil.getDurationSeconds(recordId);
+                        teExamService.finish(examStudentCacheBean.getStudentId(), recordId, FinishTypeEnum.AUTO.name(), durationSeconds);
+                    }
                 }
+            } catch (Exception e) {
+                log.error(SystemConstant.LOG_ERROR, e);
             }
         }
     }