|
@@ -1,20 +1,22 @@
|
|
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.*;
|
|
|
|
|
|
+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.enums.*;
|
|
import com.qmth.themis.business.enums.*;
|
|
-import com.qmth.themis.business.service.*;
|
|
|
|
|
|
+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.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;
|
|
@@ -24,10 +26,8 @@ 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,21 +56,6 @@ 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;
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 强制离线交卷持久化逻辑
|
|
* 强制离线交卷持久化逻辑
|
|
*
|
|
*
|
|
@@ -404,108 +389,19 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
|
|
if (Objects.equals(MqTagEnum.EXAM_STOP.name(), tag)//考试退出
|
|
if (Objects.equals(MqTagEnum.EXAM_STOP.name(), tag)//考试退出
|
|
|| Objects.equals(MqTagEnum.EXAM_START.name(), tag)//考试开始
|
|
|| Objects.equals(MqTagEnum.EXAM_START.name(), tag)//考试开始
|
|
|| Objects.equals(MqTagEnum.EXAM_AUDIO_MOBILE.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;
|
|
|
|
-
|
|
|
|
- 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);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- tmRocketMessageService.saveMqMessageSuccess(mqDto, key);
|
|
|
|
- }
|
|
|
|
|
|
+ examStartAndStopAndAudioLogic(mqDto, key);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
- * 考试开始和停止逻辑
|
|
|
|
|
|
+ * 考试开始和停止和语音逻辑
|
|
*
|
|
*
|
|
* @param mqDto
|
|
* @param mqDto
|
|
* @param key
|
|
* @param key
|
|
* @throws NoSuchAlgorithmException
|
|
* @throws NoSuchAlgorithmException
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
- public void examStartAndStopLogic(MqDto mqDto, String key) throws NoSuchAlgorithmException, IOException {
|
|
|
|
|
|
+ public void examStartAndStopAndAudioLogic(MqDto mqDto, String key) throws NoSuchAlgorithmException, IOException {
|
|
ConcurrentHashMap<String, WebSocketMobileServer> webSocketMap = WebSocketMobileServer.getWebSocketMap();
|
|
ConcurrentHashMap<String, WebSocketMobileServer> webSocketMap = WebSocketMobileServer.getWebSocketMap();
|
|
String tag = mqDto.getTag();
|
|
String tag = mqDto.getTag();
|
|
Long recordId = Long.parseLong(String.valueOf(mqDto.getBody()));
|
|
Long recordId = Long.parseLong(String.valueOf(mqDto.getBody()));
|
|
@@ -560,6 +456,13 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
|
|
webSocketFirstMobileServer.sendMessage(websocketDto);
|
|
webSocketFirstMobileServer.sendMessage(websocketDto);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+ case "EXAM_AUDIO_MOBILE":
|
|
|
|
+ if (!Objects.equals(ExamRecordStatusEnum.PERSISTED, examRecordStatusEnum)
|
|
|
|
+ && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum)) {
|
|
|
|
+ websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_AUDIO.name(), mqDto.getProperties());
|
|
|
|
+ webSocketFirstMobileServer.sendMessage(websocketDto);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -599,6 +502,13 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
|
|
webSocketSecondMobileServer.sendMessage(websocketDto);
|
|
webSocketSecondMobileServer.sendMessage(websocketDto);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+ case "EXAM_AUDIO_MOBILE":
|
|
|
|
+ if (!Objects.equals(ExamRecordStatusEnum.PERSISTED, examRecordStatusEnum)
|
|
|
|
+ && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum)) {
|
|
|
|
+ websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_AUDIO.name(), mqDto.getProperties());
|
|
|
|
+ webSocketSecondMobileServer.sendMessage(websocketDto);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|