|
@@ -12,12 +12,10 @@ import com.qmth.themis.business.entity.TEExamStudentLog;
|
|
import com.qmth.themis.business.entity.TIeExamInvigilateNotice;
|
|
import com.qmth.themis.business.entity.TIeExamInvigilateNotice;
|
|
import com.qmth.themis.business.entity.TMRocketMessage;
|
|
import com.qmth.themis.business.entity.TMRocketMessage;
|
|
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.RedisUtil;
|
|
import com.qmth.themis.business.util.RedisUtil;
|
|
|
|
+import com.qmth.themis.common.exception.BusinessException;
|
|
import com.qmth.themis.exam.listener.service.MqOeLogicService;
|
|
import com.qmth.themis.exam.listener.service.MqOeLogicService;
|
|
import com.qmth.themis.exam.websocket.WebSocketMobileServer;
|
|
import com.qmth.themis.exam.websocket.WebSocketMobileServer;
|
|
import com.qmth.themis.exam.websocket.WebSocketOeServer;
|
|
import com.qmth.themis.exam.websocket.WebSocketOeServer;
|
|
@@ -27,6 +25,7 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
@@ -56,6 +55,9 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
|
|
@Resource
|
|
@Resource
|
|
TIeExamInvigilateNoticeService tIeExamInvigilateNoticeService;
|
|
TIeExamInvigilateNoticeService tIeExamInvigilateNoticeService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ CacheService cacheService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* oe逻辑
|
|
* oe逻辑
|
|
*
|
|
*
|
|
@@ -64,7 +66,7 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public void execMqOeLogic(MqDto mqDto, String key) {
|
|
|
|
|
|
+ public void execMqOeLogic(MqDto mqDto, String key) throws NoSuchAlgorithmException {
|
|
Gson gson = new Gson();
|
|
Gson gson = new Gson();
|
|
ConcurrentHashMap<String, WebSocketOeServer> webSocketMap = WebSocketOeServer.getWebSocketMap();
|
|
ConcurrentHashMap<String, WebSocketOeServer> webSocketMap = WebSocketOeServer.getWebSocketMap();
|
|
String tag = mqDto.getTag();
|
|
String tag = mqDto.getTag();
|
|
@@ -203,6 +205,14 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
|
|
case "OE_WEBSOCKET_EXAM_STOP":
|
|
case "OE_WEBSOCKET_EXAM_STOP":
|
|
if (!Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum)) {
|
|
if (!Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum)) {
|
|
websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_STOP.name(), prop);
|
|
websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_STOP.name(), prop);
|
|
|
|
+ SystemConstant.clientMonitorStatusStop(recordId);
|
|
|
|
+ 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) {
|
|
|
|
+ WebSocketOeServer.close(webSocketOeServer);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case "MONITOR_START":
|
|
case "MONITOR_START":
|
|
@@ -221,6 +231,26 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
|
|
&& Objects.nonNull(monitorStatusBean.getTimestamp())
|
|
&& Objects.nonNull(monitorStatusBean.getTimestamp())
|
|
&& mqDto.getTimestamp().longValue() >= monitorStatusBean.getTimestamp().longValue()) {
|
|
&& mqDto.getTimestamp().longValue() >= monitorStatusBean.getTimestamp().longValue()) {
|
|
websocketDto = new WebsocketDto(WebsocketTypeEnum.MOBILE_MONITOR_STOP.name(), prop);
|
|
websocketDto = new WebsocketDto(WebsocketTypeEnum.MOBILE_MONITOR_STOP.name(), prop);
|
|
|
|
+ ConcurrentHashMap<String, WebSocketMobileServer> webSocketMobileMap = WebSocketMobileServer.getWebSocketMap();
|
|
|
|
+
|
|
|
|
+ String mobileWebsocketId = null;
|
|
|
|
+ WebsocketStatusEnum websocketStatusEnum = null;
|
|
|
|
+ if (source == MonitorVideoSourceEnum.MOBILE_FIRST) {
|
|
|
|
+ mobileWebsocketId = ExamRecordCacheUtil.getMobileFirstWebsocketId(recordId);
|
|
|
|
+ websocketStatusEnum = ExamRecordCacheUtil.getMobileFirstWebsocketStatus(recordId);
|
|
|
|
+ } else if (source == MonitorVideoSourceEnum.MOBILE_SECOND) {
|
|
|
|
+ mobileWebsocketId = ExamRecordCacheUtil.getMobileSecondWebsocketId(recordId);
|
|
|
|
+ websocketStatusEnum = ExamRecordCacheUtil.getMobileSecondWebsocketStatus(recordId);
|
|
|
|
+ }
|
|
|
|
+ if (Objects.nonNull(websocketStatusEnum) && websocketStatusEnum == WebsocketStatusEnum.ON_LINE) {
|
|
|
|
+ WebSocketMobileServer webSocketMobileServer = webSocketMobileMap.get(mobileWebsocketId + "-" + source.name());
|
|
|
|
+ Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
|
|
+ ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
|
|
+ Optional.ofNullable(examStudentCacheBean).orElseThrow(() -> new BusinessException("考生数据为空"));
|
|
|
|
+
|
|
|
|
+ SystemConstant.mobileMonitorStatusStop(examStudentCacheBean.getStudentId(), recordId, true);
|
|
|
|
+ WebSocketMobileServer.close(webSocketMobileServer);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case "OE_WEBSOCKET_MOBILE_MONITOR_STATUS":
|
|
case "OE_WEBSOCKET_MOBILE_MONITOR_STATUS":
|
|
@@ -261,30 +291,35 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public void execMqOeMobileLogic(MqDto mqDto, String key) {
|
|
|
|
|
|
+ public void execMqOeMobileLogic(MqDto mqDto, String key) throws NoSuchAlgorithmException {
|
|
Gson gson = new Gson();
|
|
Gson gson = new Gson();
|
|
String tag = mqDto.getTag();
|
|
String tag = mqDto.getTag();
|
|
ConcurrentHashMap<String, WebSocketMobileServer> webSocketMap = WebSocketMobileServer.getWebSocketMap();
|
|
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)) {//考试开始
|
|
|| Objects.equals(MqTagEnum.EXAM_START.name(), tag)) {//考试开始
|
|
Long recordId = Long.parseLong(String.valueOf(mqDto.getBody()));
|
|
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("考生数据为空"));
|
|
|
|
+
|
|
String mobileFirstWebsocketId = ExamRecordCacheUtil.getMobileFirstWebsocketId(recordId);
|
|
String mobileFirstWebsocketId = ExamRecordCacheUtil.getMobileFirstWebsocketId(recordId);
|
|
if (Objects.nonNull(mobileFirstWebsocketId) && Objects.nonNull(webSocketMap.get(mobileFirstWebsocketId + "-" + MonitorVideoSourceEnum.MOBILE_FIRST.name()))) {
|
|
if (Objects.nonNull(mobileFirstWebsocketId) && Objects.nonNull(webSocketMap.get(mobileFirstWebsocketId + "-" + MonitorVideoSourceEnum.MOBILE_FIRST.name()))) {
|
|
- WebSocketMobileServer webSocketMobileServer = webSocketMap.get(mobileFirstWebsocketId + "-" + MonitorVideoSourceEnum.MOBILE_FIRST.name());
|
|
|
|
- ExamRecordStatusEnum examRecordStatusEnum = ExamRecordCacheUtil.getStatus(recordId);
|
|
|
|
|
|
+ WebSocketMobileServer webSocketFirstMobileServer = webSocketMap.get(mobileFirstWebsocketId + "-" + MonitorVideoSourceEnum.MOBILE_FIRST.name());
|
|
if (Objects.nonNull(examRecordStatusEnum)
|
|
if (Objects.nonNull(examRecordStatusEnum)
|
|
- && Objects.nonNull(webSocketMobileServer.getRecordId())
|
|
|
|
- && webSocketMobileServer.getRecordId().longValue() == recordId.longValue()) {
|
|
|
|
|
|
+ && Objects.nonNull(webSocketFirstMobileServer.getRecordId())
|
|
|
|
+ && webSocketFirstMobileServer.getRecordId().longValue() == recordId.longValue()) {
|
|
WebsocketDto websocketDto = null;
|
|
WebsocketDto websocketDto = null;
|
|
switch (tag.toUpperCase()) {
|
|
switch (tag.toUpperCase()) {
|
|
case "EXAM_STOP":
|
|
case "EXAM_STOP":
|
|
if (!Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum)) {
|
|
if (!Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum)) {
|
|
websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_STOP.name(), mqDto.getProperties());
|
|
websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_STOP.name(), mqDto.getProperties());
|
|
|
|
+ SystemConstant.mobileMonitorStatusStop(examStudentCacheBean.getStudentId(), recordId, false);
|
|
Map<String, Object> properties = mqDto.getProperties();
|
|
Map<String, Object> properties = mqDto.getProperties();
|
|
if (Objects.nonNull(properties) && properties.size() > 0) {
|
|
if (Objects.nonNull(properties) && properties.size() > 0) {
|
|
- Boolean mobileRemoveWebsocket = (Boolean) properties.get(SystemConstant.MOBILE_REMOVE_WEBSOCKET);
|
|
|
|
- if (Objects.nonNull(mobileRemoveWebsocket) && mobileRemoveWebsocket) {
|
|
|
|
- webSocketMap.remove(mobileFirstWebsocketId);
|
|
|
|
|
|
+ Boolean removeWebsocket = (Boolean) properties.get(SystemConstant.REMOVE_WEBSOCKET);
|
|
|
|
+ if (Objects.nonNull(removeWebsocket) && removeWebsocket) {
|
|
|
|
+ WebSocketMobileServer.close(webSocketFirstMobileServer);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -298,26 +333,26 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- webSocketMobileServer.sendMessage(websocketDto);
|
|
|
|
|
|
+ webSocketFirstMobileServer.sendMessage(websocketDto);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
String mobileSecondWebsocketId = ExamRecordCacheUtil.getMobileSecondWebsocketId(recordId);
|
|
String mobileSecondWebsocketId = ExamRecordCacheUtil.getMobileSecondWebsocketId(recordId);
|
|
if (Objects.nonNull(mobileSecondWebsocketId) && Objects.nonNull(webSocketMap.get(mobileSecondWebsocketId + "-" + MonitorVideoSourceEnum.MOBILE_SECOND.name()))) {
|
|
if (Objects.nonNull(mobileSecondWebsocketId) && Objects.nonNull(webSocketMap.get(mobileSecondWebsocketId + "-" + MonitorVideoSourceEnum.MOBILE_SECOND.name()))) {
|
|
- WebSocketMobileServer webSocketMobileServer = webSocketMap.get(mobileSecondWebsocketId + "-" + MonitorVideoSourceEnum.MOBILE_SECOND.name());
|
|
|
|
- ExamRecordStatusEnum examRecordStatusEnum = ExamRecordCacheUtil.getStatus(recordId);
|
|
|
|
|
|
+ WebSocketMobileServer webSocketSecondMobileServer = webSocketMap.get(mobileSecondWebsocketId + "-" + MonitorVideoSourceEnum.MOBILE_SECOND.name());
|
|
if (Objects.nonNull(examRecordStatusEnum)
|
|
if (Objects.nonNull(examRecordStatusEnum)
|
|
- && Objects.nonNull(webSocketMobileServer.getRecordId())
|
|
|
|
- && webSocketMobileServer.getRecordId().longValue() == recordId.longValue()) {
|
|
|
|
|
|
+ && Objects.nonNull(webSocketSecondMobileServer.getRecordId())
|
|
|
|
+ && webSocketSecondMobileServer.getRecordId().longValue() == recordId.longValue()) {
|
|
WebsocketDto websocketDto = null;
|
|
WebsocketDto websocketDto = null;
|
|
switch (tag.toUpperCase()) {
|
|
switch (tag.toUpperCase()) {
|
|
case "EXAM_STOP":
|
|
case "EXAM_STOP":
|
|
if (!Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum)) {
|
|
if (!Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum)) {
|
|
websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_STOP.name(), mqDto.getProperties());
|
|
websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_STOP.name(), mqDto.getProperties());
|
|
|
|
+ SystemConstant.mobileMonitorStatusStop(examStudentCacheBean.getStudentId(), recordId, false);
|
|
Map<String, Object> properties = mqDto.getProperties();
|
|
Map<String, Object> properties = mqDto.getProperties();
|
|
if (Objects.nonNull(properties) && properties.size() > 0) {
|
|
if (Objects.nonNull(properties) && properties.size() > 0) {
|
|
- Boolean mobileRemoveWebsocket = (Boolean) properties.get(SystemConstant.MOBILE_REMOVE_WEBSOCKET);
|
|
|
|
|
|
+ Boolean mobileRemoveWebsocket = (Boolean) properties.get(SystemConstant.REMOVE_WEBSOCKET);
|
|
if (Objects.nonNull(mobileRemoveWebsocket) && mobileRemoveWebsocket) {
|
|
if (Objects.nonNull(mobileRemoveWebsocket) && mobileRemoveWebsocket) {
|
|
- webSocketMap.remove(mobileSecondWebsocketId);
|
|
|
|
|
|
+ WebSocketMobileServer.close(webSocketSecondMobileServer);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -331,7 +366,7 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- webSocketMobileServer.sendMessage(websocketDto);
|
|
|
|
|
|
+ webSocketSecondMobileServer.sendMessage(websocketDto);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|