|
@@ -1,12 +1,23 @@
|
|
|
package com.qmth.themis.exam.config;
|
|
|
|
|
|
+import com.qmth.themis.business.cache.ExamActivityRecordCacheUtil;
|
|
|
+import com.qmth.themis.business.cache.ExamRecordCacheUtil;
|
|
|
+import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
|
+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.dto.WebsocketDto;
|
|
|
-import com.qmth.themis.business.enums.MonitorVideoSourceEnum;
|
|
|
-import com.qmth.themis.business.enums.WebsocketTypeEnum;
|
|
|
+import com.qmth.themis.business.enums.*;
|
|
|
+import com.qmth.themis.business.service.MqDtoService;
|
|
|
+import com.qmth.themis.business.service.TEExamService;
|
|
|
+import com.qmth.themis.business.service.TEExamStudentService;
|
|
|
+import com.qmth.themis.business.service.TOeExamRecordService;
|
|
|
+import com.qmth.themis.common.contanst.Constants;
|
|
|
import com.qmth.themis.exam.websocket.WebSocketMobileServer;
|
|
|
import com.qmth.themis.exam.websocket.WebSocketOeServer;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
@@ -81,4 +92,47 @@ public class ExamConstant {
|
|
|
webSocketMobileServer.sendMessage(websocketDto);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送断点消息
|
|
|
+ *
|
|
|
+ * @param recordId
|
|
|
+ */
|
|
|
+ public static void sendExamBreakMsg(Long recordId) {
|
|
|
+ Long examId = ExamRecordCacheUtil.getExamId(recordId);
|
|
|
+ Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
|
+ TEExamStudentService teExamStudentService = SpringContextHolder.getBean(TEExamStudentService.class);
|
|
|
+ ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
|
+ TEExamService teExamService = SpringContextHolder.getBean(TEExamService.class);
|
|
|
+ ExamCacheBean ec = teExamService.getExamCacheBean(examId);//考试缓存
|
|
|
+
|
|
|
+ Integer durationSeconds = Objects.isNull(ExamRecordCacheUtil.getDurationSeconds(recordId)) ? 0 : ExamRecordCacheUtil.getDurationSeconds(recordId);
|
|
|
+ Integer alreadyBreakCount = Objects.isNull(ExamRecordCacheUtil.getAlreadyBreakCount(recordId)) ? 0 : ExamRecordCacheUtil.getAlreadyBreakCount(recordId);
|
|
|
+ Integer leftBreakResumeCount = ec.getBreakResumeCount() - alreadyBreakCount;
|
|
|
+ if (leftBreakResumeCount < 0) {
|
|
|
+ teExamService.finish(examStudentCacheBean.getStudentId(), recordId, FinishTypeEnum.AUTO.name(), durationSeconds);
|
|
|
+ } else {
|
|
|
+ alreadyBreakCount++;
|
|
|
+ Long breakId = Constants.idGen.next();
|
|
|
+ ExamRecordCacheUtil.setLastBreakId(recordId, breakId, false);
|
|
|
+ ExamRecordCacheUtil.setStatus(recordId, ExamRecordStatusEnum.BREAK_OFF, false);
|
|
|
+ Date lastBreakTimeNow = new Date();
|
|
|
+ ExamRecordCacheUtil.setLastBreakTime(recordId, lastBreakTimeNow, false);
|
|
|
+ ExamRecordCacheUtil.setAlreadyBreakCount(recordId, alreadyBreakCount, false);
|
|
|
+ Date lastStartTime = new Date();
|
|
|
+ ExamRecordCacheUtil.setLastStartTime(recordId, lastStartTime, false);
|
|
|
+ String[] columns = new String[]{ExamRecordFieldEnum.last_break_id.name(), ExamRecordFieldEnum.status.name(), ExamRecordFieldEnum.last_break_time.name(), ExamRecordFieldEnum.already_break_count.name(), ExamRecordFieldEnum.last_start_time.name()};
|
|
|
+ Object[] values = new Object[]{breakId, ExamRecordStatusEnum.BREAK_OFF, lastBreakTimeNow, alreadyBreakCount, lastStartTime};
|
|
|
+ TOeExamRecordService tOeExamRecordService = SpringContextHolder.getBean(TOeExamRecordService.class);
|
|
|
+ tOeExamRecordService.dataUpdatesMq(recordId, columns, values);
|
|
|
+ sendExamStopMsg(recordId, true);
|
|
|
+ //考试断点异常原因 发送mq start
|
|
|
+ MqDto mqDtoBreak = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_BREAK.name(), ExceptionEnum.EXIT, MqTagEnum.EXAM_BREAK, String.valueOf(recordId), String.valueOf(recordId));
|
|
|
+ MqDtoService mqDtoService = SpringContextHolder.getBean(MqDtoService.class);
|
|
|
+ mqDtoService.assembleSendOneWayMsg(mqDtoBreak);
|
|
|
+ //考试断点异常原因 发送mq end
|
|
|
+ //更新场次-考试记录缓存
|
|
|
+ ExamActivityRecordCacheUtil.setExamRecordStatus(examStudentCacheBean.getExamActivityId(), recordId, ExamRecordCacheUtil.getStatus(recordId));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|