|
@@ -1,22 +1,20 @@
|
|
package com.qmth.themis.exam.listener.service.impl;
|
|
package com.qmth.themis.exam.listener.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.qmth.themis.business.bean.status.MonitorStatusBean;
|
|
import com.qmth.themis.business.bean.status.MonitorStatusBean;
|
|
import com.qmth.themis.business.cache.ExamRecordCacheUtil;
|
|
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.cache.bean.ExamStudentCacheBean;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.dto.MqDto;
|
|
import com.qmth.themis.business.dto.MqDto;
|
|
import com.qmth.themis.business.dto.WebsocketDto;
|
|
import com.qmth.themis.business.dto.WebsocketDto;
|
|
-import com.qmth.themis.business.entity.TEExamStudent;
|
|
|
|
-import com.qmth.themis.business.entity.TEExamStudentLog;
|
|
|
|
-import com.qmth.themis.business.entity.TIeExamInvigilateNotice;
|
|
|
|
-import com.qmth.themis.business.entity.TOeExamRecord;
|
|
|
|
|
|
+import com.qmth.themis.business.entity.*;
|
|
import com.qmth.themis.business.enums.*;
|
|
import com.qmth.themis.business.enums.*;
|
|
-import com.qmth.themis.business.service.TEExamStudentLogService;
|
|
|
|
-import com.qmth.themis.business.service.TEExamStudentService;
|
|
|
|
-import com.qmth.themis.business.service.TIeExamInvigilateNoticeService;
|
|
|
|
-import com.qmth.themis.business.service.TMRocketMessageService;
|
|
|
|
|
|
+import com.qmth.themis.business.service.*;
|
|
import com.qmth.themis.business.util.JacksonUtil;
|
|
import com.qmth.themis.business.util.JacksonUtil;
|
|
|
|
+import com.qmth.themis.business.util.OssUtil;
|
|
import com.qmth.themis.common.contanst.Constants;
|
|
import com.qmth.themis.common.contanst.Constants;
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
import com.qmth.themis.exam.listener.service.MqOeLogicService;
|
|
import com.qmth.themis.exam.listener.service.MqOeLogicService;
|
|
@@ -26,8 +24,10 @@ import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -56,6 +56,21 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
|
|
@Resource
|
|
@Resource
|
|
TIeExamInvigilateNoticeService tIeExamInvigilateNoticeService;
|
|
TIeExamInvigilateNoticeService tIeExamInvigilateNoticeService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ TEExamActivityService teExamActivityService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ TEExamService teExamService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ CacheService cacheService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ TOeExamRecordService tOeExamRecordService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ OssUtil ossUtil;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 强制离线交卷持久化逻辑
|
|
* 强制离线交卷持久化逻辑
|
|
*
|
|
*
|
|
@@ -170,8 +185,8 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
|
|
map.put("from", mqDto.getObjName());
|
|
map.put("from", mqDto.getObjName());
|
|
map.put(SystemConstant.WEB_SOCKET_OE_SERVER, webSocketOeServer);
|
|
map.put(SystemConstant.WEB_SOCKET_OE_SERVER, webSocketOeServer);
|
|
map.put(SystemConstant.TYPE, prop.get(SystemConstant.TYPE));
|
|
map.put(SystemConstant.TYPE, prop.get(SystemConstant.TYPE));
|
|
- map.put("content", prop.get("content"));
|
|
|
|
- TIeExamInvigilateNotice tIeExamInvigilateNotice = new TIeExamInvigilateNotice(examId, examActivityId, recordId, Long.parseLong(String.valueOf(prop.get("formUserId"))), examStudentId, MessageTypeEnum.valueOf(String.valueOf(prop.get(SystemConstant.TYPE)).toUpperCase()), String.valueOf(prop.get("content")));
|
|
|
|
|
|
+ map.put(SystemConstant.CONTENT, prop.get(SystemConstant.CONTENT));
|
|
|
|
+ TIeExamInvigilateNotice tIeExamInvigilateNotice = new TIeExamInvigilateNotice(examId, examActivityId, recordId, Long.parseLong(String.valueOf(prop.get(SystemConstant.FORM_USER_ID))), examStudentId, MessageTypeEnum.valueOf(String.valueOf(prop.get(SystemConstant.TYPE)).toUpperCase()), String.valueOf(prop.get(SystemConstant.CONTENT)));
|
|
tIeExamInvigilateNoticeService.saveOrUpdate(tIeExamInvigilateNotice);
|
|
tIeExamInvigilateNoticeService.saveOrUpdate(tIeExamInvigilateNotice);
|
|
|
|
|
|
tmRocketMessageService.saveMqMessageSuccess(mqDto, key);
|
|
tmRocketMessageService.saveMqMessageSuccess(mqDto, key);
|
|
@@ -386,105 +401,208 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
|
|
@Override
|
|
@Override
|
|
public void execMqOeMobileLogic(MqDto mqDto, String key) throws NoSuchAlgorithmException, IOException {
|
|
public void execMqOeMobileLogic(MqDto mqDto, String key) throws NoSuchAlgorithmException, IOException {
|
|
String tag = mqDto.getTag();
|
|
String tag = mqDto.getTag();
|
|
- ConcurrentHashMap<String, WebSocketMobileServer> webSocketMap = WebSocketMobileServer.getWebSocketMap();
|
|
|
|
if (Objects.equals(MqTagEnum.EXAM_STOP.name(), tag)//考试退出
|
|
if (Objects.equals(MqTagEnum.EXAM_STOP.name(), tag)//考试退出
|
|
- || Objects.equals(MqTagEnum.EXAM_START.name(), tag)) {//考试开始
|
|
|
|
- Long recordId = Long.parseLong(String.valueOf(mqDto.getBody()));
|
|
|
|
- TOeExamRecord tOeExamRecord = null;
|
|
|
|
- ExamRecordStatusEnum examRecordStatusEnum = ExamRecordCacheUtil.getStatus(recordId);
|
|
|
|
- if (Objects.isNull(examRecordStatusEnum)) {
|
|
|
|
- tOeExamRecord = SystemConstant.getExamRecord(recordId);
|
|
|
|
- examRecordStatusEnum = tOeExamRecord.getStatus();
|
|
|
|
- }
|
|
|
|
- Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
|
|
- Long studentId = null;
|
|
|
|
- if (Objects.isNull(examStudentId)) {
|
|
|
|
- tOeExamRecord = Objects.isNull(tOeExamRecord) ? SystemConstant.getExamRecord(recordId) : tOeExamRecord;
|
|
|
|
- TEExamStudent teExamStudent = teExamStudentService.getById(tOeExamRecord.getExamStudentId());
|
|
|
|
- studentId = teExamStudent.getStudentId();
|
|
|
|
- } else {
|
|
|
|
- ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
|
|
- Optional.ofNullable(examStudentCacheBean).orElseThrow(() -> new BusinessException("考生数据为空"));
|
|
|
|
- studentId = examStudentCacheBean.getStudentId();
|
|
|
|
- }
|
|
|
|
|
|
+ || Objects.equals(MqTagEnum.EXAM_START.name(), tag)//考试开始
|
|
|
|
+ || Objects.equals(MqTagEnum.EXAM_AUDIO_MOBILE.name(), tag)) {//考试语音
|
|
|
|
+ if (Objects.equals(MqTagEnum.EXAM_STOP.name(), tag) || Objects.equals(MqTagEnum.EXAM_START.name(), tag)) {
|
|
|
|
+ examStartAndStopLogic(mqDto, key);
|
|
|
|
+ } else if (Objects.equals(MqTagEnum.EXAM_AUDIO_MOBILE.name(), tag)) {
|
|
|
|
+ Map<String, Object> properties = mqDto.getProperties();
|
|
|
|
+ if (!CollectionUtils.isEmpty(properties) && Objects.nonNull(properties.get(SystemConstant.CONTENT))) {
|
|
|
|
+ List<String> list = (List<String>) properties.get(SystemConstant.CONTENT);
|
|
|
|
+ Long teAudioId = Long.parseLong(list.get(0));
|
|
|
|
+ Long examActivityId = Long.parseLong(list.get(1));
|
|
|
|
+ Long examId = Long.parseLong(list.get(2));
|
|
|
|
+ Long execTime = Long.parseLong(list.get(3));
|
|
|
|
+ if (Objects.nonNull(teAudioId)) {
|
|
|
|
+ List<TOeExamRecord> tOeExamRecordList = tOeExamRecordService.findExamRecordByExamIdAndExamActivityId(examId, examActivityId);
|
|
|
|
+ if (!CollectionUtils.isEmpty(tOeExamRecordList)) {
|
|
|
|
+ ConcurrentHashMap<String, WebSocketMobileServer> webSocketMap = WebSocketMobileServer.getWebSocketMap();
|
|
|
|
+ for (TOeExamRecord t : tOeExamRecordList) {
|
|
|
|
+ ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);
|
|
|
|
+ ExamActivityCacheBean examActivityCacheBean = teExamActivityService.getExamActivityCacheBean(examActivityId);
|
|
|
|
+ TEAudio teAudio = cacheService.examAudioCache(teAudioId);
|
|
|
|
+ if (Objects.nonNull(examCacheBean) && Objects.nonNull(examActivityCacheBean) && Objects.nonNull(teAudio)
|
|
|
|
+ && Objects.nonNull(examCacheBean.getForceFinish()) && examCacheBean.getForceFinish().intValue() == 1
|
|
|
|
+ && Objects.nonNull(examCacheBean.getEnable()) && examCacheBean.getEnable() == 1
|
|
|
|
+ && Objects.nonNull(examActivityCacheBean.getEnable()) && examActivityCacheBean.getEnable() == 1
|
|
|
|
+ && Objects.nonNull(teAudio.getEnable()) && teAudio.getEnable()
|
|
|
|
+ && Objects.nonNull(t.getMonitorRecord())
|
|
|
|
+ && (t.getMonitorRecord().contains(MonitorVideoSourceEnum.MOBILE_FIRST.name())
|
|
|
|
+ || t.getMonitorRecord().contains(MonitorVideoSourceEnum.MOBILE_SECOND.name()))) {
|
|
|
|
+ ExamRecordStatusEnum examRecordStatusEnum = ExamRecordCacheUtil.getStatus(t.getId());
|
|
|
|
+ examRecordStatusEnum = Objects.isNull(examRecordStatusEnum) ? t.getStatus() : examRecordStatusEnum;
|
|
|
|
|
|
- String mobileFirstWebsocketId = ExamRecordCacheUtil.getMobileFirstWebsocketId(recordId);
|
|
|
|
- if (Objects.isNull(mobileFirstWebsocketId)) {
|
|
|
|
- tOeExamRecord = Objects.isNull(tOeExamRecord) ? SystemConstant.getExamRecord(recordId) : tOeExamRecord;
|
|
|
|
- mobileFirstWebsocketId = tOeExamRecord.getMobileFirstWebsocketId();
|
|
|
|
- }
|
|
|
|
- if (Objects.nonNull(mobileFirstWebsocketId) && Objects.nonNull(webSocketMap.get(mobileFirstWebsocketId))) {
|
|
|
|
- WebSocketMobileServer webSocketFirstMobileServer = webSocketMap.get(mobileFirstWebsocketId);
|
|
|
|
- if (Objects.nonNull(examRecordStatusEnum)
|
|
|
|
- && Objects.nonNull(webSocketFirstMobileServer.getRecordId())
|
|
|
|
- && webSocketFirstMobileServer.getRecordId().longValue() == recordId.longValue()) {
|
|
|
|
- WebsocketDto websocketDto = null;
|
|
|
|
- switch (tag.toUpperCase()) {
|
|
|
|
- case "EXAM_STOP":
|
|
|
|
- if (!Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum)) {
|
|
|
|
- websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_STOP.name(), mqDto.getProperties());
|
|
|
|
- webSocketFirstMobileServer.sendMessage(websocketDto);
|
|
|
|
- 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);
|
|
|
|
- if (Objects.nonNull(removeWebsocket) && removeWebsocket) {
|
|
|
|
- WebSocketMobileServer.close(webSocketFirstMobileServer);
|
|
|
|
|
|
+ if (Objects.nonNull(t.getMonitorRecord()) && t.getMonitorRecord().contains(MonitorVideoSourceEnum.MOBILE_FIRST.name())) {
|
|
|
|
+ //第一机位
|
|
|
|
+ String mobileFirstWebsocketId = ExamRecordCacheUtil.getMobileFirstWebsocketId(t.getId());
|
|
|
|
+ mobileFirstWebsocketId = Objects.isNull(mobileFirstWebsocketId) ? t.getMobileFirstWebsocketId() : mobileFirstWebsocketId;
|
|
|
|
+ if (Objects.nonNull(mobileFirstWebsocketId) && Objects.nonNull(webSocketMap.get(mobileFirstWebsocketId))) {
|
|
|
|
+ WebSocketMobileServer webSocketFirstMobileServer = webSocketMap.get(mobileFirstWebsocketId);
|
|
|
|
+ if (Objects.nonNull(examRecordStatusEnum)
|
|
|
|
+ && Objects.nonNull(webSocketFirstMobileServer.getRecordId())
|
|
|
|
+ && webSocketFirstMobileServer.getRecordId().longValue() == t.getId().longValue()) {
|
|
|
|
+ if (!Objects.equals(ExamRecordStatusEnum.PERSISTED, examRecordStatusEnum)
|
|
|
|
+ && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum)) {
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put(SystemConstant.RECORD_ID, t.getId());
|
|
|
|
+ map.put(SystemConstant.EXEC_TIME, execTime);
|
|
|
|
+ TBAttachment tbAttachment = cacheService.attachmentCache(teAudio.getAttachmentId());
|
|
|
|
+ if (Objects.nonNull(tbAttachment) && Objects.nonNull(tbAttachment.getRemark())) {
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(tbAttachment.getRemark());
|
|
|
|
+ map.put(SystemConstant.PATH, ossUtil.getAliYunOssPublicDomain().getPublicUrl() + File.separator + jsonObject.getString(SystemConstant.PATH));
|
|
|
|
+ map.put(SystemConstant.NAME, tbAttachment.getName() + tbAttachment.getType());
|
|
|
|
+ }
|
|
|
|
+ WebsocketDto websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_AUDIO.name(), map);
|
|
|
|
+ webSocketFirstMobileServer.sendMessage(websocketDto);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (Objects.nonNull(t.getMonitorRecord()) && t.getMonitorRecord().contains(MonitorVideoSourceEnum.MOBILE_SECOND.name())) {
|
|
|
|
+ //第二机位
|
|
|
|
+ String mobileSecondWebsocketId = ExamRecordCacheUtil.getMobileSecondWebsocketId(t.getId());
|
|
|
|
+ mobileSecondWebsocketId = Objects.isNull(mobileSecondWebsocketId) ? t.getMobileSecondWebsocketId() : mobileSecondWebsocketId;
|
|
|
|
+ if (Objects.nonNull(mobileSecondWebsocketId) && Objects.nonNull(webSocketMap.get(mobileSecondWebsocketId))) {
|
|
|
|
+ WebSocketMobileServer webSocketSecondMobileServer = webSocketMap.get(mobileSecondWebsocketId);
|
|
|
|
+ if (Objects.nonNull(examRecordStatusEnum)
|
|
|
|
+ && Objects.nonNull(webSocketSecondMobileServer.getRecordId())
|
|
|
|
+ && webSocketSecondMobileServer.getRecordId().longValue() == t.getId().longValue()) {
|
|
|
|
+ if (!Objects.equals(ExamRecordStatusEnum.PERSISTED, examRecordStatusEnum)
|
|
|
|
+ && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum)) {
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put(SystemConstant.RECORD_ID, t.getId());
|
|
|
|
+ map.put(SystemConstant.EXEC_TIME, execTime);
|
|
|
|
+ TBAttachment tbAttachment = cacheService.attachmentCache(teAudio.getAttachmentId());
|
|
|
|
+ if (Objects.nonNull(tbAttachment) && Objects.nonNull(tbAttachment.getRemark())) {
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(tbAttachment.getRemark());
|
|
|
|
+ map.put(SystemConstant.PATH, ossUtil.getAliYunOssPublicDomain().getPublicUrl() + File.separator + jsonObject.getString(SystemConstant.PATH));
|
|
|
|
+ map.put(SystemConstant.NAME, tbAttachment.getName() + tbAttachment.getType());
|
|
|
|
+ }
|
|
|
|
+ WebsocketDto websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_AUDIO.name(), map);
|
|
|
|
+ webSocketSecondMobileServer.sendMessage(websocketDto);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- break;
|
|
|
|
- case "EXAM_START":
|
|
|
|
- if (!Objects.equals(ExamRecordStatusEnum.PERSISTED, examRecordStatusEnum)
|
|
|
|
- && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum)) {
|
|
|
|
- websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_START.name(), mqDto.getProperties());
|
|
|
|
- webSocketFirstMobileServer.sendMessage(websocketDto);
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- break;
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- tmRocketMessageService.saveMqMessageSuccess(mqDto, key);
|
|
|
|
}
|
|
}
|
|
|
|
+ tmRocketMessageService.saveMqMessageSuccess(mqDto, key);
|
|
}
|
|
}
|
|
- String mobileSecondWebsocketId = ExamRecordCacheUtil.getMobileSecondWebsocketId(recordId);
|
|
|
|
- if (Objects.isNull(mobileSecondWebsocketId)) {
|
|
|
|
- tOeExamRecord = Objects.isNull(tOeExamRecord) ? SystemConstant.getExamRecord(recordId) : tOeExamRecord;
|
|
|
|
- mobileSecondWebsocketId = tOeExamRecord.getMobileSecondWebsocketId();
|
|
|
|
- }
|
|
|
|
- if (Objects.nonNull(mobileSecondWebsocketId) && Objects.nonNull(webSocketMap.get(mobileSecondWebsocketId))) {
|
|
|
|
- WebSocketMobileServer webSocketSecondMobileServer = webSocketMap.get(mobileSecondWebsocketId);
|
|
|
|
- if (Objects.nonNull(examRecordStatusEnum)
|
|
|
|
- && Objects.nonNull(webSocketSecondMobileServer.getRecordId())
|
|
|
|
- && webSocketSecondMobileServer.getRecordId().longValue() == recordId.longValue()) {
|
|
|
|
- WebsocketDto websocketDto = null;
|
|
|
|
- switch (tag.toUpperCase()) {
|
|
|
|
- case "EXAM_STOP":
|
|
|
|
- if (!Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum)) {
|
|
|
|
- websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_STOP.name(), mqDto.getProperties());
|
|
|
|
- webSocketSecondMobileServer.sendMessage(websocketDto);
|
|
|
|
- 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);
|
|
|
|
- if (Objects.nonNull(mobileRemoveWebsocket) && mobileRemoveWebsocket) {
|
|
|
|
- WebSocketMobileServer.close(webSocketSecondMobileServer);
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 考试开始和停止逻辑
|
|
|
|
+ *
|
|
|
|
+ * @param mqDto
|
|
|
|
+ * @param key
|
|
|
|
+ * @throws NoSuchAlgorithmException
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ public void examStartAndStopLogic(MqDto mqDto, String key) throws NoSuchAlgorithmException, IOException {
|
|
|
|
+ ConcurrentHashMap<String, WebSocketMobileServer> webSocketMap = WebSocketMobileServer.getWebSocketMap();
|
|
|
|
+ String tag = mqDto.getTag();
|
|
|
|
+ Long recordId = Long.parseLong(String.valueOf(mqDto.getBody()));
|
|
|
|
+ TOeExamRecord tOeExamRecord = null;
|
|
|
|
+ ExamRecordStatusEnum examRecordStatusEnum = ExamRecordCacheUtil.getStatus(recordId);
|
|
|
|
+ if (Objects.isNull(examRecordStatusEnum)) {
|
|
|
|
+ tOeExamRecord = SystemConstant.getExamRecord(recordId);
|
|
|
|
+ examRecordStatusEnum = tOeExamRecord.getStatus();
|
|
|
|
+ }
|
|
|
|
+ Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
|
|
+ Long studentId = null;
|
|
|
|
+ if (Objects.isNull(examStudentId)) {
|
|
|
|
+ tOeExamRecord = Objects.isNull(tOeExamRecord) ? SystemConstant.getExamRecord(recordId) : tOeExamRecord;
|
|
|
|
+ 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.isNull(mobileFirstWebsocketId)) {
|
|
|
|
+ tOeExamRecord = Objects.isNull(tOeExamRecord) ? SystemConstant.getExamRecord(recordId) : tOeExamRecord;
|
|
|
|
+ mobileFirstWebsocketId = tOeExamRecord.getMobileFirstWebsocketId();
|
|
|
|
+ }
|
|
|
|
+ if (Objects.nonNull(mobileFirstWebsocketId) && Objects.nonNull(webSocketMap.get(mobileFirstWebsocketId))) {
|
|
|
|
+ WebSocketMobileServer webSocketFirstMobileServer = webSocketMap.get(mobileFirstWebsocketId);
|
|
|
|
+ if (Objects.nonNull(examRecordStatusEnum)
|
|
|
|
+ && Objects.nonNull(webSocketFirstMobileServer.getRecordId())
|
|
|
|
+ && webSocketFirstMobileServer.getRecordId().longValue() == recordId.longValue()) {
|
|
|
|
+ WebsocketDto websocketDto = null;
|
|
|
|
+ switch (tag.toUpperCase()) {
|
|
|
|
+ case "EXAM_STOP":
|
|
|
|
+ if (!Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum)) {
|
|
|
|
+ websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_STOP.name(), mqDto.getProperties());
|
|
|
|
+ webSocketFirstMobileServer.sendMessage(websocketDto);
|
|
|
|
+ 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);
|
|
|
|
+ if (Objects.nonNull(removeWebsocket) && removeWebsocket) {
|
|
|
|
+ WebSocketMobileServer.close(webSocketFirstMobileServer);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- break;
|
|
|
|
- case "EXAM_START":
|
|
|
|
- if (!Objects.equals(ExamRecordStatusEnum.PERSISTED, examRecordStatusEnum)
|
|
|
|
- && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum)) {
|
|
|
|
- websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_START.name(), mqDto.getProperties());
|
|
|
|
- webSocketSecondMobileServer.sendMessage(websocketDto);
|
|
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "EXAM_START":
|
|
|
|
+ if (!Objects.equals(ExamRecordStatusEnum.PERSISTED, examRecordStatusEnum)
|
|
|
|
+ && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum)) {
|
|
|
|
+ websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_START.name(), mqDto.getProperties());
|
|
|
|
+ webSocketFirstMobileServer.sendMessage(websocketDto);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ tmRocketMessageService.saveMqMessageSuccess(mqDto, key);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ String mobileSecondWebsocketId = ExamRecordCacheUtil.getMobileSecondWebsocketId(recordId);
|
|
|
|
+ if (Objects.isNull(mobileSecondWebsocketId)) {
|
|
|
|
+ tOeExamRecord = Objects.isNull(tOeExamRecord) ? SystemConstant.getExamRecord(recordId) : tOeExamRecord;
|
|
|
|
+ mobileSecondWebsocketId = tOeExamRecord.getMobileSecondWebsocketId();
|
|
|
|
+ }
|
|
|
|
+ if (Objects.nonNull(mobileSecondWebsocketId) && Objects.nonNull(webSocketMap.get(mobileSecondWebsocketId))) {
|
|
|
|
+ WebSocketMobileServer webSocketSecondMobileServer = webSocketMap.get(mobileSecondWebsocketId);
|
|
|
|
+ if (Objects.nonNull(examRecordStatusEnum)
|
|
|
|
+ && Objects.nonNull(webSocketSecondMobileServer.getRecordId())
|
|
|
|
+ && webSocketSecondMobileServer.getRecordId().longValue() == recordId.longValue()) {
|
|
|
|
+ WebsocketDto websocketDto = null;
|
|
|
|
+ switch (tag.toUpperCase()) {
|
|
|
|
+ case "EXAM_STOP":
|
|
|
|
+ if (!Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum)) {
|
|
|
|
+ websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_STOP.name(), mqDto.getProperties());
|
|
|
|
+ webSocketSecondMobileServer.sendMessage(websocketDto);
|
|
|
|
+ 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);
|
|
|
|
+ if (Objects.nonNull(mobileRemoveWebsocket) && mobileRemoveWebsocket) {
|
|
|
|
+ WebSocketMobileServer.close(webSocketSecondMobileServer);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- tmRocketMessageService.saveMqMessageSuccess(mqDto, key);
|
|
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "EXAM_START":
|
|
|
|
+ if (!Objects.equals(ExamRecordStatusEnum.PERSISTED, examRecordStatusEnum)
|
|
|
|
+ && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum)) {
|
|
|
|
+ websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_START.name(), mqDto.getProperties());
|
|
|
|
+ webSocketSecondMobileServer.sendMessage(websocketDto);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
+ tmRocketMessageService.saveMqMessageSuccess(mqDto, key);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|