Просмотр исходного кода

Merge branch 'dev_v1.1.1' into release_v1.1.1
merge

wangliang 3 лет назад
Родитель
Сommit
f82b095959

+ 15 - 2
themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeExamRecordServiceImpl.java

@@ -1152,7 +1152,15 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
                     ExamRecordCacheUtil.setLastBreakTime(recordId, lastBreakTimeNow);
                     ExamRecordCacheUtil.setAlreadyBreakCount(recordId, alreadyBreakCount);
 
-                    ExamStudentCacheBean es = teExamStudentService.getExamStudentCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId));
+                    Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
+                    Long examId = ExamRecordCacheUtil.getExamId(recordId);
+                    if (Objects.isNull(examStudentId)) {
+                        TOeExamRecord tOeExamRecord = this.getById(recordId);
+                        Optional.ofNullable(tOeExamRecord).orElseThrow(() -> new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD));
+                        examStudentId = tOeExamRecord.getExamStudentId();
+                        examId = tOeExamRecord.getExamId();
+                    }
+                    ExamStudentCacheBean es = teExamStudentService.getExamStudentCacheBean(examStudentId);
                     ExamingDataCacheUtil.setUnFinishedRecordId(es.getStudentId(), recordId);
                     ExamRecordStatusEnum examRecordStatusEnum = ExamRecordCacheUtil.getStatus(recordId);
                     if (Objects.nonNull(examRecordStatusEnum) && examRecordStatusEnum == ExamRecordStatusEnum.BREAK_OFF) {
@@ -1164,7 +1172,6 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
                         mqDtoService.assembleSendOneWayMsg(mqDtoBreak);
 //                        //考试断点异常原因 发送mq end
 
-                        Long examId = ExamRecordCacheUtil.getExamId(recordId);
                         ExamCacheBean ec = examService.getExamCacheBean(examId);//考试缓存
                         Integer breakExpireSeconds = Objects.isNull(ec.getBreakExpireSeconds()) ?
                                 0 :
@@ -1217,6 +1224,12 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
             }
             Long examId = ExamRecordCacheUtil.getExamId(recordId);
             Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
+            if (Objects.isNull(examStudentId)) {
+                TOeExamRecord tOeExamRecord = this.getById(recordId);
+                Optional.ofNullable(tOeExamRecord).orElseThrow(() -> new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD));
+                examStudentId = tOeExamRecord.getExamStudentId();
+                examId = tOeExamRecord.getExamId();
+            }
             ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
             ExamCacheBean ec = examService.getExamCacheBean(examId);//考试缓存
             Long lastBreakTime = ExamRecordCacheUtil.getLastBreakTime(recordId);

+ 28 - 1
themis-business/src/main/java/com/qmth/themis/business/service/impl/WarningServiceImpl.java

@@ -7,10 +7,13 @@ import com.qmth.themis.business.dto.WarningDto;
 import com.qmth.themis.business.entity.TEConfig;
 import com.qmth.themis.business.entity.TEExamStudentLog;
 import com.qmth.themis.business.entity.TIeInvigilateWarnInfo;
+import com.qmth.themis.business.entity.TOeExamRecord;
 import com.qmth.themis.business.enums.ExamTypeEnum;
 import com.qmth.themis.business.enums.VerifyExceptionEnum;
 import com.qmth.themis.business.enums.WarningLevelEnum;
 import com.qmth.themis.business.service.*;
+import com.qmth.themis.common.enums.ExceptionResultEnum;
+import com.qmth.themis.common.exception.BusinessException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -65,6 +68,12 @@ public class WarningServiceImpl implements WarningService {
         Long examId = ExamRecordCacheUtil.getExamId(recordId);
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
         Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
+        if (Objects.isNull(examStudentId)) {
+            TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(recordId);
+            Optional.ofNullable(tOeExamRecord).orElseThrow(() -> new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD));
+            examStudentId = tOeExamRecord.getExamStudentId();
+            examActivityId = tOeExamRecord.getExamActivityId();
+        }
         ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
         if (faceCount > 1) {//多张人脸
             Map<String, Object> map = faceVerifyHistoryService.faceCountError(recordId, warningDto.getWarningEnum().name(), faceCount, true, ExamTypeEnum.IN_PROCESS.name(), warningDto.getRandom());
@@ -108,6 +117,12 @@ public class WarningServiceImpl implements WarningService {
         Long examId = ExamRecordCacheUtil.getExamId(recordId);
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
         Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
+        if (Objects.isNull(examStudentId)) {
+            TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(recordId);
+            Optional.ofNullable(tOeExamRecord).orElseThrow(() -> new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD));
+            examStudentId = tOeExamRecord.getExamStudentId();
+            examActivityId = tOeExamRecord.getExamActivityId();
+        }
         ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
         Map<String, Object> map = faceVerifyHistoryService.faceCompareError(recordId, warningDto.getWarningEnum().name(), ExamTypeEnum.IN_PROCESS.name(), warningDto.getRandom());
         if (Objects.nonNull(map) && map.size() > 0) {
@@ -137,6 +152,12 @@ public class WarningServiceImpl implements WarningService {
         Long examId = ExamRecordCacheUtil.getExamId(recordId);
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
         Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
+        if (Objects.isNull(examStudentId)) {
+            TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(recordId);
+            Optional.ofNullable(tOeExamRecord).orElseThrow(() -> new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD));
+            examStudentId = tOeExamRecord.getExamStudentId();
+            examActivityId = tOeExamRecord.getExamActivityId();
+        }
         ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
         Map<String, Object> map = faceVerifyHistoryService.eyeCloseError(recordId, warningDto.getWarningEnum().name(), ExamTypeEnum.IN_PROCESS.name(), warningDto.getRandom());
         if (Objects.nonNull(map) && map.size() > 0) {
@@ -176,6 +197,12 @@ public class WarningServiceImpl implements WarningService {
         Long examId = ExamRecordCacheUtil.getExamId(recordId);
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
         Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
+        if (Objects.isNull(examStudentId)) {
+            TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(recordId);
+            Optional.ofNullable(tOeExamRecord).orElseThrow(() -> new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD));
+            examStudentId = tOeExamRecord.getExamStudentId();
+            examActivityId = tOeExamRecord.getExamActivityId();
+        }
         ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
         Map<String, Object> map = faceVerifyHistoryService.realnessError(recordId, warningDto.getWarningEnum().name(), ExamTypeEnum.IN_PROCESS.name(), warningDto.getRandom());
         if (Objects.nonNull(map) && map.size() > 0) {
@@ -231,7 +258,7 @@ public class WarningServiceImpl implements WarningService {
         teExamStudentLogService.saveOrUpdate(teExamStudentLog);
     }
 
-    public static void main(String[] args){
+    public static void main(String[] args) {
         AtomicInteger atomicInteger = new AtomicInteger(0);
         atomicInteger.incrementAndGet();
         System.out.println(atomicInteger.get());

+ 8 - 0
themis-exam/src/main/java/com/qmth/themis/exam/config/ExamConstant.java

@@ -5,6 +5,7 @@ import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
 import com.qmth.themis.business.constant.SpringContextHolder;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.MqDto;
+import com.qmth.themis.business.entity.TOeExamRecord;
 import com.qmth.themis.business.enums.MonitorStatusSourceEnum;
 import com.qmth.themis.business.enums.MonitorVideoSourceEnum;
 import com.qmth.themis.business.enums.MqTagEnum;
@@ -12,6 +13,7 @@ import com.qmth.themis.business.service.MqDtoService;
 import com.qmth.themis.business.service.TEExamStudentService;
 import com.qmth.themis.business.service.TOeExamRecordService;
 import com.qmth.themis.business.util.MqUtil;
+import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 
 import java.security.NoSuchAlgorithmException;
@@ -36,6 +38,7 @@ public class ExamConstant {
         MqUtil mqUtil = SpringContextHolder.getBean(MqUtil.class);
         MqDtoService mqDtoService = SpringContextHolder.getBean(MqDtoService.class);
         TEExamStudentService teExamStudentService = SpringContextHolder.getBean(TEExamStudentService.class);
+        TOeExamRecordService tOeExamRecordService = SpringContextHolder.getBean(TOeExamRecordService.class);
         Map<String, Object> mapParameter = new HashMap<>();
         mapParameter.put(SystemConstant.RECORD_ID, recordId);
         mapParameter.put(SystemConstant.REMOVE_WEBSOCKET, true);
@@ -51,6 +54,11 @@ public class ExamConstant {
         //移动端考试结束
         if (mobileStop) {
             Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
+            if (Objects.isNull(examStudentId)) {
+                TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(recordId);
+                Optional.ofNullable(tOeExamRecord).orElseThrow(() -> new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD));
+                examStudentId = tOeExamRecord.getExamStudentId();
+            }
             ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
             Optional.ofNullable(examStudentCacheBean).orElseThrow(() -> new BusinessException("考生数据为空"));
 

+ 17 - 8
themis-exam/src/main/java/com/qmth/themis/exam/listener/service/impl/MqOeLogicServiceImpl.java

@@ -8,13 +8,12 @@ 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.dto.WebsocketDto;
-import com.qmth.themis.business.entity.TEExamStudentLog;
-import com.qmth.themis.business.entity.TIeExamInvigilateNotice;
-import com.qmth.themis.business.entity.TMRocketMessage;
+import com.qmth.themis.business.entity.*;
 import com.qmth.themis.business.enums.*;
 import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.util.JacksonUtil;
 import com.qmth.themis.business.util.RedisUtil;
+import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.exam.listener.service.MqOeLogicService;
 import com.qmth.themis.exam.websocket.WebSocketMobileServer;
@@ -57,7 +56,7 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
     TIeExamInvigilateNoticeService tIeExamInvigilateNoticeService;
 
     @Resource
-    CacheService cacheService;
+    TOeExamRecordService tOeExamRecordService;
 
     /**
      * oe逻辑
@@ -301,8 +300,18 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
             Long recordId = Long.parseLong(String.valueOf(mqDto.getBody()));
             ExamRecordStatusEnum examRecordStatusEnum = ExamRecordCacheUtil.getStatus(recordId);
             Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
-            ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
-            Optional.ofNullable(examStudentCacheBean).orElseThrow(() -> new BusinessException("考生数据为空"));
+            Long studentId = null;
+            if (Objects.isNull(examStudentId)) {
+                TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(recordId);
+                Optional.ofNullable(tOeExamRecord).orElseThrow(() -> new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD));
+
+                TEExamStudent teExamStudent = teExamStudentService.getById(tOeExamRecord.getExamStudentId());
+                studentId = teExamStudent.getStudentId();
+            } else {
+                ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
+                Optional.ofNullable(examStudentCacheBean).orElseThrow(() -> new BusinessException("考生数据为空"));
+                studentId = examStudentCacheBean.getStudentId();
+            }
 
             String mobileFirstWebsocketId = ExamRecordCacheUtil.getMobileFirstWebsocketId(recordId);
             if (Objects.nonNull(mobileFirstWebsocketId) && Objects.nonNull(webSocketMap.get(mobileFirstWebsocketId + "-" + MonitorVideoSourceEnum.MOBILE_FIRST.name()))) {
@@ -315,7 +324,7 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
                         case "EXAM_STOP":
                             if (!Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum)) {
                                 websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_STOP.name(), mqDto.getProperties());
-                                SystemConstant.mobileMonitorStatusStop(examStudentCacheBean.getStudentId(), recordId, false);
+                                SystemConstant.mobileMonitorStatusStop(studentId, recordId, false);
                                 Map<String, Object> properties = mqDto.getProperties();
                                 if (Objects.nonNull(properties) && properties.size() > 0) {
                                     Boolean removeWebsocket = (Boolean) properties.get(SystemConstant.REMOVE_WEBSOCKET);
@@ -348,7 +357,7 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
                         case "EXAM_STOP":
                             if (!Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum)) {
                                 websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_STOP.name(), mqDto.getProperties());
-                                SystemConstant.mobileMonitorStatusStop(examStudentCacheBean.getStudentId(), recordId, false);
+                                SystemConstant.mobileMonitorStatusStop(studentId, recordId, false);
                                 Map<String, Object> properties = mqDto.getProperties();
                                 if (Objects.nonNull(properties) && properties.size() > 0) {
                                     Boolean mobileRemoveWebsocket = (Boolean) properties.get(SystemConstant.REMOVE_WEBSOCKET);

+ 23 - 0
themis-mq/src/main/java/com/qmth/themis/mq/service/impl/MqLogicServiceImpl.java

@@ -22,6 +22,7 @@ import com.qmth.themis.business.templete.TaskImportTemplete;
 import com.qmth.themis.business.templete.impl.*;
 import com.qmth.themis.business.util.*;
 import com.qmth.themis.common.contanst.Constants;
+import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.enums.Source;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.SimpleBeanUtil;
@@ -292,6 +293,11 @@ public class MqLogicServiceImpl implements MqLogicService {
         ExamRecordStatusEnum status = ExamRecordCacheUtil.getStatus(recordId);
         WebsocketStatusEnum websocketStatusEnum = ExamRecordCacheUtil.getClientWebsocketStatus(recordId);
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
+        if (Objects.isNull(examStudentId)) {
+            TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(recordId);
+            Optional.ofNullable(tOeExamRecord).orElseThrow(() -> new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD));
+            examStudentId = tOeExamRecord.getExamStudentId();
+        }
         if (Objects.nonNull(websocketStatusEnum) && (Objects.equals(websocketStatusEnum, WebsocketStatusEnum.OFF_LINE)
                 && Objects.equals(status, ExamRecordStatusEnum.ANSWERING))) {
             examRecordService.examBreakLogic(recordId, true);
@@ -434,6 +440,11 @@ public class MqLogicServiceImpl implements MqLogicService {
         String exception = (String) param.get("exception");
         TEConfig teConfig = teConfigService.getGlobalConfig();
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
+        if (Objects.isNull(examStudentId)) {
+            TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(recordId);
+            Optional.ofNullable(tOeExamRecord).orElseThrow(() -> new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD));
+            examStudentId = tOeExamRecord.getExamStudentId();
+        }
         ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
         if (Objects.nonNull(photoUrl) && (Objects.equals(type.toUpperCase(), ExamTypeEnum.FIRST_START.name()) || Objects
                 .equals(type.toUpperCase(), ExamTypeEnum.RESUME_START.name()))) {
@@ -585,6 +596,11 @@ public class MqLogicServiceImpl implements MqLogicService {
         String exception = (String) param.get("exception");
         TEConfig teConfig = teConfigService.getGlobalConfig();
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
+        if (Objects.isNull(examStudentId)) {
+            TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(recordId);
+            Optional.ofNullable(tOeExamRecord).orElseThrow(() -> new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD));
+            examStudentId = tOeExamRecord.getExamStudentId();
+        }
         ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
         if (Objects.equals(type.toUpperCase(), ExamTypeEnum.FIRST_START.name()) || Objects
                 .equals(type.toUpperCase(), ExamTypeEnum.RESUME_START.name())) {
@@ -931,6 +947,13 @@ public class MqLogicServiceImpl implements MqLogicService {
         Long examId = ExamRecordCacheUtil.getExamId(recordId);
         Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
+        if (Objects.isNull(examStudentId)) {
+            TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(recordId);
+            Optional.ofNullable(tOeExamRecord).orElseThrow(() -> new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD));
+            examStudentId = tOeExamRecord.getExamStudentId();
+            examActivityId = tOeExamRecord.getExamActivityId();
+            examId = tOeExamRecord.getExamId();
+        }
         ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
         //增加异常日志
         TIeInvigilateExceptionInfo tIeInvigilateExceptionInfo = new TIeInvigilateExceptionInfo(examId, examActivityId,