Browse Source

bug修改

wangliang 4 years ago
parent
commit
315a273feb

+ 16 - 2
themis-exam/src/main/java/com/qmth/themis/exam/api/TEExamController.java

@@ -144,7 +144,14 @@ public class TEExamController {
                 //mq发送消息end
             }
             ConcurrentHashMap<String, WebSocketMobileServer> webSocketMap = WebSocketMobileServer.getWebSocketMap();
-            if (Objects.nonNull(webSocketMap.get(param.getRecordId() + MonitorVideoSourceEnum.MOBILE_FIRST.name()))) {
+            if (Objects.nonNull(webSocketMap.get(param.getRecordId() + "-" + MonitorVideoSourceEnum.MOBILE_FIRST.name()))) {
+                WebSocketMobileServer webSocketMobileServer = webSocketMap.get(param.getRecordId());
+                Map map = new HashMap<>();
+                map.put(SystemConstant.RECORD_ID, param.getRecordId());
+                WebsocketDto websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_START.name(), map);
+                webSocketMobileServer.sendMessage(websocketDto);
+            }
+            if (Objects.nonNull(webSocketMap.get(param.getRecordId() + "-" + MonitorVideoSourceEnum.MOBILE_SECOND.name()))) {
                 WebSocketMobileServer webSocketMobileServer = webSocketMap.get(param.getRecordId());
                 Map map = new HashMap<>();
                 map.put(SystemConstant.RECORD_ID, param.getRecordId());
@@ -268,7 +275,14 @@ public class TEExamController {
             }
             Result re = ResultUtil.ok(teExamService.finish(teStudent.getId(), param.getRecordId(), param.getType(), param.getDurationSeconds()));
             ConcurrentHashMap<String, WebSocketMobileServer> webSocketMap = WebSocketMobileServer.getWebSocketMap();
-            if (Objects.nonNull(webSocketMap.get(param.getRecordId()))) {
+            if (Objects.nonNull(webSocketMap.get(param.getRecordId() + "-" + MonitorVideoSourceEnum.MOBILE_FIRST.name()))) {
+                WebSocketMobileServer webSocketMobileServer = webSocketMap.get(param.getRecordId());
+                Map map = new HashMap<>();
+                map.put(SystemConstant.RECORD_ID, param.getRecordId());
+                WebsocketDto websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_STOP.name(), map);
+                webSocketMobileServer.sendMessage(websocketDto);
+            }
+            if (Objects.nonNull(webSocketMap.get(param.getRecordId() + "-" + MonitorVideoSourceEnum.MOBILE_SECOND.name()))) {
                 WebSocketMobileServer webSocketMobileServer = webSocketMap.get(param.getRecordId());
                 Map map = new HashMap<>();
                 map.put(SystemConstant.RECORD_ID, param.getRecordId());

+ 2 - 2
themis-exam/src/main/java/com/qmth/themis/exam/api/TIeInvigilateCallMobileController.java

@@ -75,7 +75,7 @@ public class TIeInvigilateCallMobileController {
                 throw new BusinessException("观看地址不能为空");
             }
             ConcurrentHashMap<String, WebSocketMobileServer> webSocketMap = WebSocketMobileServer.getWebSocketMap();
-            if (Objects.isNull(webSocketMap.get(recordId + source.name()))) {
+            if (Objects.isNull(webSocketMap.get(recordId + "-" + source.name()))) {
                 throw new BusinessException("网络连接失败");
             }
             String liveUrl = String.valueOf(mapParameter.get("liveUrl"));
@@ -168,7 +168,7 @@ public class TIeInvigilateCallMobileController {
             throw new BusinessException("异常类型不能为空");
         }
         ConcurrentHashMap<String, WebSocketMobileServer> mobileWebSocketMap = WebSocketMobileServer.getWebSocketMap();
-        if (Objects.isNull(mobileWebSocketMap.get(recordId + source.name()))) {
+        if (Objects.isNull(mobileWebSocketMap.get(recordId + "-" + source.name()))) {
             throw new BusinessException("网络连接失败");
         }
         //获取考试记录缓存

+ 9 - 5
themis-exam/src/main/java/com/qmth/themis/exam/listener/service/impl/MqOeLogicServiceImpl.java

@@ -10,10 +10,7 @@ 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.enums.FinishTypeEnum;
-import com.qmth.themis.business.enums.MessageTypeEnum;
-import com.qmth.themis.business.enums.MqTagEnum;
-import com.qmth.themis.business.enums.WebsocketTypeEnum;
+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;
@@ -210,7 +207,14 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
         String tag = mqDto.getTag();
         if (Objects.equals(MqTagEnum.EXAM_STOP.name(), tag)) {//考试退出
             Long recordId = Long.parseLong(String.valueOf(mqDto.getBody()));
-            if (Objects.nonNull(webSocketMap.get(recordId))) {
+            if (Objects.nonNull(webSocketMap.get(recordId + "-" + MonitorVideoSourceEnum.MOBILE_FIRST.name()))) {
+                WebSocketMobileServer webSocketMobileServer = webSocketMap.get(recordId);
+                Map map = new HashMap<>();
+                map.put(SystemConstant.RECORD_ID, recordId);
+                WebsocketDto websocketDto = new WebsocketDto(WebsocketTypeEnum.EXAM_STOP.name(), map);
+                webSocketMobileServer.sendMessage(websocketDto);
+            }
+            if (Objects.nonNull(webSocketMap.get(recordId + "-" + MonitorVideoSourceEnum.MOBILE_SECOND.name()))) {
                 WebSocketMobileServer webSocketMobileServer = webSocketMap.get(recordId);
                 Map map = new HashMap<>();
                 map.put(SystemConstant.RECORD_ID, recordId);

+ 8 - 8
themis-exam/src/main/java/com/qmth/themis/exam/websocket/WebSocketMobileServer.java

@@ -103,12 +103,12 @@ public class WebSocketMobileServer implements Concurrently {
                     this.session = session;
                     session.setMaxIdleTimeout(SystemConstant.WEBSOCKET_MAX_TIME_OUT);
                     this.sessionId = tbSession.getId();
-                    if (webSocketMap.containsKey(this.recordId + this.source.name())) {
-                        webSocketMap.remove(this.recordId + this.source.name());
-                        webSocketMap.put(this.recordId + this.source.name(), this);
+                    if (webSocketMap.containsKey(this.recordId + "-" + this.source.name())) {
+                        webSocketMap.remove(this.recordId + "-" + this.source.name());
+                        webSocketMap.put(this.recordId + "-" + this.source.name(), this);
                         //加入set中
                     } else {
-                        webSocketMap.put(this.recordId + this.source.name(), this);
+                        webSocketMap.put(this.recordId + "-" + this.source.name(), this);
                         //加入set中
                         addOnlineCount();
                         //在线数加1
@@ -139,15 +139,15 @@ public class WebSocketMobileServer implements Concurrently {
     @OnClose
     public void onClose() {
         log.info("onClose is come in");
-        if (webSocketMap.containsKey(this.recordId + this.source.name())) {
-            webSocketMap.remove(this.recordId + this.source.name());
+        if (webSocketMap.containsKey(this.recordId + "-" + this.source.name())) {
+            webSocketMap.remove(this.recordId + "-" + this.source.name());
             //从set中删除
             subOnlineCount();
             //判断是否是正常退出
             ExamRecordCacheUtil.setMonitorStatus(recordId, this.source.name(), MonitorStatusSourceEnum.STOP, true);
             ConcurrentHashMap<Long, WebSocketOeServer> webSocketMap = WebSocketOeServer.getWebSocketMap();
-            if (Objects.nonNull(webSocketMap.get(recordId + this.source.name()))) {
-                WebSocketOeServer webSocketOeServer = webSocketMap.get(recordId + this.source.name());
+            if (Objects.nonNull(webSocketMap.get(recordId + "-" + this.source.name()))) {
+                WebSocketOeServer webSocketOeServer = webSocketMap.get(recordId + "-" + this.source.name());
                 Map map = new HashMap<>();
                 map.put(SystemConstant.RECORD_ID, recordId);
                 map.put("monitorVideoSource", this.source.name());