Browse Source

websocketId修改

wangliang 4 years ago
parent
commit
a313dffc9c

+ 13 - 19
themis-admin/src/main/java/com/qmth/themis/admin/websocket/WebSocketAdminServer.java

@@ -8,10 +8,7 @@ import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.WebsocketDto;
 import com.qmth.themis.business.dto.WebsocketDto;
 import com.qmth.themis.business.entity.TBSession;
 import com.qmth.themis.business.entity.TBSession;
 import com.qmth.themis.business.enums.WebsocketTypeEnum;
 import com.qmth.themis.business.enums.WebsocketTypeEnum;
-import com.qmth.themis.business.util.AuthUtil;
-import com.qmth.themis.business.util.JacksonUtil;
-import com.qmth.themis.business.util.RedisUtil;
-import com.qmth.themis.business.util.WebsocketUtil;
+import com.qmth.themis.business.util.*;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.enums.Platform;
 import com.qmth.themis.common.enums.Platform;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.exception.BusinessException;
@@ -47,14 +44,10 @@ public class WebSocketAdminServer
      * 与某个客户端的连接会话,需要通过它来给客户端发送数据
      * 与某个客户端的连接会话,需要通过它来给客户端发送数据
      */
      */
     private Session session = null;
     private Session session = null;
-    private String sessionId = null, ip = null;
-    private Long userId = null;
-    private String platform = null, deviceId = null, authorization = null;
-    private Long time = null;
+    private String sessionId = null, ip = null, platform = null, deviceId = null, authorization = null, url = "/ws/admin", websocketSessionId = null;
+    private Long time = null, userId = null, updateTime = null;
     private RedisUtil redisUtil;
     private RedisUtil redisUtil;
-    private Long updateTime = null;
     private Map<String, Object> tranMap = null;
     private Map<String, Object> tranMap = null;
-    private String url = "/ws/admin";
 
 
     /**
     /**
      * 连接建立成功调用的方法
      * 连接建立成功调用的方法
@@ -84,6 +77,7 @@ public class WebSocketAdminServer
         this.session = session;
         this.session = session;
         session.setMaxIdleTimeout(SystemConstant.WEBSOCKET_MAX_TIME_OUT);
         session.setMaxIdleTimeout(SystemConstant.WEBSOCKET_MAX_TIME_OUT);
         this.sessionId = tbSession.getId();
         this.sessionId = tbSession.getId();
+        websocketSessionId = String.valueOf(UidUtil.nextId());
         if (webSocketMap.containsKey(this.userId)) {
         if (webSocketMap.containsKey(this.userId)) {
             webSocketMap.remove(this.userId);
             webSocketMap.remove(this.userId);
             webSocketMap.put(this.userId, this);
             webSocketMap.put(this.userId, this);
@@ -91,7 +85,7 @@ public class WebSocketAdminServer
             webSocketMap.put(this.userId, this);
             webSocketMap.put(this.userId, this);
             addOnlineCount();
             addOnlineCount();
         }
         }
-        log.info("用户连接:{},当前在线人数为:{}", this.sessionId, getOnlineCount());
+        log.info("用户连接:{},当前在线人数为:{}", this.websocketSessionId, getOnlineCount());
         InetSocketAddress addr = (InetSocketAddress) WebsocketUtil.getFieldInstance(this.session.getAsyncRemote(), "base#socketWrapper#socket#sc#remoteAddress");
         InetSocketAddress addr = (InetSocketAddress) WebsocketUtil.getFieldInstance(this.session.getAsyncRemote(), "base#socketWrapper#socket#sc#remoteAddress");
         this.ip = addr.toString().replace("/", "").split(":")[0];
         this.ip = addr.toString().replace("/", "").split(":")[0];
         log.info("ip[:{}]连接成功", this.ip);
         log.info("ip[:{}]连接成功", this.ip);
@@ -111,7 +105,7 @@ public class WebSocketAdminServer
             subOnlineCount();
             subOnlineCount();
             //管理端无需发送延时mq消息
             //管理端无需发送延时mq消息
         }
         }
-        log.info("用户退出:{},当前在线人数为:{},updateTime:{}", this.sessionId, getOnlineCount(), this.updateTime);
+        log.info("用户退出:{},当前在线人数为:{},updateTime:{}", this.websocketSessionId, getOnlineCount(), this.updateTime);
     }
     }
 
 
     /**
     /**
@@ -151,7 +145,7 @@ public class WebSocketAdminServer
      */
      */
     @OnError
     @OnError
     public void onError(Session session, Throwable error) {
     public void onError(Session session, Throwable error) {
-        log.error("用户错误:{},原因:{}", this.sessionId, error);
+        log.error("用户错误:{},原因:{}", this.websocketSessionId, error);
         throw new BusinessException(error.getMessage());
         throw new BusinessException(error.getMessage());
     }
     }
 
 
@@ -181,7 +175,7 @@ public class WebSocketAdminServer
      * 在线人数加一
      * 在线人数加一
      */
      */
     public synchronized void addOnlineCount() {
     public synchronized void addOnlineCount() {
-        if (redisUtil.lock(SystemConstant.REDIS_LOCK_WEBSOCKET_PREFIX + this.sessionId, SystemConstant.REDIS_LOCK_WEBSOCKET_TIME_OUT)) {
+        if (redisUtil.lock(SystemConstant.REDIS_LOCK_WEBSOCKET_PREFIX + this.websocketSessionId, SystemConstant.REDIS_LOCK_WEBSOCKET_TIME_OUT)) {
             try {
             try {
                 Object o = redisUtil.get(SystemConstant.WEBSOCKET_ADMIN_ONLINE_COUNT);
                 Object o = redisUtil.get(SystemConstant.WEBSOCKET_ADMIN_ONLINE_COUNT);
                 int count = 0;
                 int count = 0;
@@ -191,8 +185,8 @@ public class WebSocketAdminServer
                 count++;
                 count++;
                 redisUtil.set(SystemConstant.WEBSOCKET_ADMIN_ONLINE_COUNT, count);
                 redisUtil.set(SystemConstant.WEBSOCKET_ADMIN_ONLINE_COUNT, count);
             } finally {
             } finally {
-                if (Objects.nonNull(this.sessionId)) {
-                    redisUtil.releaseLock(SystemConstant.REDIS_LOCK_WEBSOCKET_PREFIX + this.sessionId);
+                if (Objects.nonNull(this.websocketSessionId)) {
+                    redisUtil.releaseLock(SystemConstant.REDIS_LOCK_WEBSOCKET_PREFIX + this.websocketSessionId);
                 }
                 }
             }
             }
         }
         }
@@ -202,7 +196,7 @@ public class WebSocketAdminServer
      * 在线人数减一
      * 在线人数减一
      */
      */
     public synchronized void subOnlineCount() {
     public synchronized void subOnlineCount() {
-        if (redisUtil.lock(SystemConstant.REDIS_LOCK_WEBSOCKET_PREFIX + this.sessionId, SystemConstant.REDIS_LOCK_WEBSOCKET_TIME_OUT)) {
+        if (redisUtil.lock(SystemConstant.REDIS_LOCK_WEBSOCKET_PREFIX + this.websocketSessionId, SystemConstant.REDIS_LOCK_WEBSOCKET_TIME_OUT)) {
             try {
             try {
                 Object o = redisUtil.get(SystemConstant.WEBSOCKET_ADMIN_ONLINE_COUNT);
                 Object o = redisUtil.get(SystemConstant.WEBSOCKET_ADMIN_ONLINE_COUNT);
                 int count = 0;
                 int count = 0;
@@ -212,8 +206,8 @@ public class WebSocketAdminServer
                 count--;
                 count--;
                 redisUtil.set(SystemConstant.WEBSOCKET_ADMIN_ONLINE_COUNT, count < 0 ? 0 : count);
                 redisUtil.set(SystemConstant.WEBSOCKET_ADMIN_ONLINE_COUNT, count < 0 ? 0 : count);
             } finally {
             } finally {
-                if (Objects.nonNull(this.sessionId)) {
-                    redisUtil.releaseLock(SystemConstant.REDIS_LOCK_WEBSOCKET_PREFIX + this.sessionId);
+                if (Objects.nonNull(this.websocketSessionId)) {
+                    redisUtil.releaseLock(SystemConstant.REDIS_LOCK_WEBSOCKET_PREFIX + this.websocketSessionId);
                 }
                 }
             }
             }
         }
         }

+ 4 - 4
themis-business/src/main/java/com/qmth/themis/business/util/WebsocketUtil.java

@@ -75,17 +75,17 @@ public class WebsocketUtil {
      *
      *
      * @param recordId
      * @param recordId
      * @param ip
      * @param ip
-     * @param sessionId
+     * @param websocketSessionId
      * @param websocketStatusEnum
      * @param websocketStatusEnum
      */
      */
-    public static void updateExamRecordWebsocketStatus(Long recordId, String ip, String sessionId, WebsocketStatusEnum websocketStatusEnum) {
+    public static void updateExamRecordWebsocketStatus(Long recordId, String ip, String websocketSessionId, WebsocketStatusEnum websocketStatusEnum) {
         ExamRecordCacheUtil.setClientWebsocketStatus(recordId, websocketStatusEnum, false);
         ExamRecordCacheUtil.setClientWebsocketStatus(recordId, websocketStatusEnum, false);
         ExamRecordCacheUtil.setClientCurrentIp(recordId, ip, false);
         ExamRecordCacheUtil.setClientCurrentIp(recordId, ip, false);
-        ExamRecordCacheUtil.setClientWebsocketId(recordId, sessionId, false);
+        ExamRecordCacheUtil.setClientWebsocketId(recordId, websocketSessionId, false);
         Long clientLastSyncTime = System.currentTimeMillis();
         Long clientLastSyncTime = System.currentTimeMillis();
         ExamRecordCacheUtil.setClientLastSyncTime(recordId, clientLastSyncTime, false);
         ExamRecordCacheUtil.setClientLastSyncTime(recordId, clientLastSyncTime, false);
         String[] columns = new String[]{ExamRecordFieldEnum.client_websocket_status.name(), ExamRecordFieldEnum.client_current_ip.name(), ExamRecordFieldEnum.client_websocket_id.name(), ExamRecordFieldEnum.client_last_sync_time.name()};
         String[] columns = new String[]{ExamRecordFieldEnum.client_websocket_status.name(), ExamRecordFieldEnum.client_current_ip.name(), ExamRecordFieldEnum.client_websocket_id.name(), ExamRecordFieldEnum.client_last_sync_time.name()};
-        Object[] values = new Object[]{websocketStatusEnum, ip, sessionId, clientLastSyncTime};
+        Object[] values = new Object[]{websocketStatusEnum, ip, websocketSessionId, clientLastSyncTime};
         TOeExamRecordService tOeExamRecordService = SpringContextHolder.getBean(TOeExamRecordService.class);
         TOeExamRecordService tOeExamRecordService = SpringContextHolder.getBean(TOeExamRecordService.class);
         tOeExamRecordService.dataUpdatesMq(recordId, columns, values);
         tOeExamRecordService.dataUpdatesMq(recordId, columns, values);
     }
     }

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

@@ -11,10 +11,7 @@ import com.qmth.themis.business.entity.TBSession;
 import com.qmth.themis.business.enums.MonitorStatusSourceEnum;
 import com.qmth.themis.business.enums.MonitorStatusSourceEnum;
 import com.qmth.themis.business.enums.MonitorVideoSourceEnum;
 import com.qmth.themis.business.enums.MonitorVideoSourceEnum;
 import com.qmth.themis.business.enums.WebsocketTypeEnum;
 import com.qmth.themis.business.enums.WebsocketTypeEnum;
-import com.qmth.themis.business.util.AuthUtil;
-import com.qmth.themis.business.util.JacksonUtil;
-import com.qmth.themis.business.util.RedisUtil;
-import com.qmth.themis.business.util.WebsocketUtil;
+import com.qmth.themis.business.util.*;
 import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.enums.Platform;
 import com.qmth.themis.common.enums.Platform;
@@ -56,15 +53,11 @@ public class WebSocketMobileServer implements Concurrently {
      * 与某个客户端的连接会话,需要通过它来给客户端发送数据
      * 与某个客户端的连接会话,需要通过它来给客户端发送数据
      */
      */
     private Session session = null;
     private Session session = null;
-    private String sessionId = null, ip = null;
-    private Long recordId = null;
-    private String platform = null, deviceId = null, authorization = null;
-    private Long time = null;
+    private String sessionId = null, ip = null, platform = null, deviceId = null, authorization = null, url = "/ws/mobile", websocketSessionId = null;
+    private Long time = null, recordId = null, updateTime = null;
     private RedisUtil redisUtil;
     private RedisUtil redisUtil;
-    private Long updateTime = null;
     private Map<String, Object> tranMap = null;
     private Map<String, Object> tranMap = null;
     private MonitorVideoSourceEnum source = null;
     private MonitorVideoSourceEnum source = null;
-    private String url = "/ws/mobile";
 
 
     /**
     /**
      * 连接建立成功调用的方法
      * 连接建立成功调用的方法
@@ -90,21 +83,22 @@ public class WebSocketMobileServer implements Concurrently {
         this.recordId = Long.parseLong(String.valueOf(mapParameter.get("recordId").get(0)));
         this.recordId = Long.parseLong(String.valueOf(mapParameter.get("recordId").get(0)));
         this.source = MonitorVideoSourceEnum.valueOf(mapParameter.get("source").get(0));
         this.source = MonitorVideoSourceEnum.valueOf(mapParameter.get("source").get(0));
 
 
-        redisUtil = SpringContextHolder.getBean(RedisUtil.class);
+        this.redisUtil = SpringContextHolder.getBean(RedisUtil.class);
         TBSession tbSession = AuthUtil.websocketAuthInterceptor(Platform.valueOf(platform), deviceId, authorization, String.valueOf(mapParameter.get("time").get(0)), SystemConstant.GET, url);
         TBSession tbSession = AuthUtil.websocketAuthInterceptor(Platform.valueOf(platform), deviceId, authorization, String.valueOf(mapParameter.get("time").get(0)), SystemConstant.GET, url);
         WebsocketUtil.checkExamStatus(this.recordId);
         WebsocketUtil.checkExamStatus(this.recordId);
         this.session = session;
         this.session = session;
         session.setMaxIdleTimeout(SystemConstant.WEBSOCKET_MAX_TIME_OUT);
         session.setMaxIdleTimeout(SystemConstant.WEBSOCKET_MAX_TIME_OUT);
         this.sessionId = tbSession.getId();
         this.sessionId = tbSession.getId();
-        if (webSocketMap.containsKey(this.session.getId() + "-" + this.source.name())) {
-            webSocketMap.remove(this.session.getId() + "-" + this.source.name());
-            webSocketMap.put(this.session.getId() + "-" + this.source.name(), this);
+        this.websocketSessionId = String.valueOf(UidUtil.nextId());
+        if (webSocketMap.containsKey(this.websocketSessionId + "-" + this.source.name())) {
+            webSocketMap.remove(this.websocketSessionId + "-" + this.source.name());
+            webSocketMap.put(this.websocketSessionId + "-" + this.source.name(), this);
         } else {
         } else {
-            webSocketMap.put(this.session.getId() + "-" + this.source.name(), this);
+            webSocketMap.put(this.websocketSessionId + "-" + this.source.name(), this);
 //            addOnlineCount();
 //            addOnlineCount();
         }
         }
 //        log.info("用户连接:{},当前在线人数为:{}", this.sessionId, getOnlineCount());
 //        log.info("用户连接:{},当前在线人数为:{}", this.sessionId, getOnlineCount());
-        log.info("用户连接:{}", this.sessionId);
+        log.info("用户连接:{}", this.websocketSessionId);
         InetSocketAddress addr = (InetSocketAddress) WebsocketUtil.getFieldInstance(this.session.getAsyncRemote(), "base#socketWrapper#socket#sc#remoteAddress");
         InetSocketAddress addr = (InetSocketAddress) WebsocketUtil.getFieldInstance(this.session.getAsyncRemote(), "base#socketWrapper#socket#sc#remoteAddress");
         this.ip = addr.toString().replace("/", "").split(":")[0];
         this.ip = addr.toString().replace("/", "").split(":")[0];
         log.info("ip[:{}]连接成功", this.ip);
         log.info("ip[:{}]连接成功", this.ip);
@@ -118,8 +112,8 @@ public class WebSocketMobileServer implements Concurrently {
     @OnClose
     @OnClose
     public void onClose() {
     public void onClose() {
         log.info("onClose is come in");
         log.info("onClose is come in");
-        if (webSocketMap.containsKey(this.session.getId() + "-" + this.source.name())) {
-            webSocketMap.remove(this.session.getId() + "-" + this.source.name());
+        if (webSocketMap.containsKey(this.websocketSessionId + "-" + this.source.name())) {
+            webSocketMap.remove(this.websocketSessionId + "-" + this.source.name());
             //从set中删除
             //从set中删除
 //            subOnlineCount();
 //            subOnlineCount();
             //判断是否是正常退出
             //判断是否是正常退出
@@ -128,9 +122,9 @@ public class WebSocketMobileServer implements Concurrently {
             String clientWebsocketId = ExamRecordCacheUtil.getClientWebsocketId(recordId);
             String clientWebsocketId = ExamRecordCacheUtil.getClientWebsocketId(recordId);
             if (Objects.nonNull(webSocketMap.get(clientWebsocketId))) {
             if (Objects.nonNull(webSocketMap.get(clientWebsocketId))) {
                 WebSocketOeServer webSocketOeServer = webSocketMap.get(clientWebsocketId);
                 WebSocketOeServer webSocketOeServer = webSocketMap.get(clientWebsocketId);
-                if (Objects.nonNull(webSocketOeServer.getRecordId()) && webSocketOeServer.getRecordId().longValue() == recordId.longValue()) {
+                if (Objects.nonNull(webSocketOeServer.getRecordId()) && webSocketOeServer.getRecordId().longValue() == this.recordId.longValue()) {
                     Map map = new HashMap<>();
                     Map map = new HashMap<>();
-                    map.put(SystemConstant.RECORD_ID, recordId);
+                    map.put(SystemConstant.RECORD_ID, this.recordId);
                     map.put("monitorVideoSource", this.source.name());
                     map.put("monitorVideoSource", this.source.name());
                     WebsocketDto websocketDto = new WebsocketDto(WebsocketTypeEnum.MOBILE_MONITOR_STOP.name(), map);
                     WebsocketDto websocketDto = new WebsocketDto(WebsocketTypeEnum.MOBILE_MONITOR_STOP.name(), map);
                     webSocketOeServer.sendMessage(websocketDto);
                     webSocketOeServer.sendMessage(websocketDto);
@@ -138,7 +132,7 @@ public class WebSocketMobileServer implements Concurrently {
             }
             }
         }
         }
 //        log.info("用户退出:{},当前在线人数为:{},updateTime:{}", this.sessionId, getOnlineCount(), this.updateTime);
 //        log.info("用户退出:{},当前在线人数为:{},updateTime:{}", this.sessionId, getOnlineCount(), this.updateTime);
-        log.info("用户退出:{},updateTime:{}", this.sessionId, this.updateTime);
+        log.info("用户退出:{},updateTime:{}", this.websocketSessionId, this.updateTime);
     }
     }
 
 
     /**
     /**
@@ -180,7 +174,7 @@ public class WebSocketMobileServer implements Concurrently {
      */
      */
     @OnError
     @OnError
     public void onError(Session session, Throwable error) {
     public void onError(Session session, Throwable error) {
-        log.error("用户错误:{},原因:{}", this.sessionId, error);
+        log.error("用户错误:{},原因:{}", this.websocketSessionId, error);
         throw new BusinessException(error.getMessage());
         throw new BusinessException(error.getMessage());
     }
     }
 
 

+ 22 - 25
themis-exam/src/main/java/com/qmth/themis/exam/websocket/WebSocketOeServer.java

@@ -56,14 +56,10 @@ public class WebSocketOeServer implements Concurrently {
      * 与某个客户端的连接会话,需要通过它来给客户端发送数据
      * 与某个客户端的连接会话,需要通过它来给客户端发送数据
      */
      */
     private Session session = null;
     private Session session = null;
-    private String sessionId = null, ip = null;
-    private Long recordId = null;
-    private String platform = null, deviceId = null, authorization = null;
-    private Long time = null;
+    private String sessionId = null, ip = null, platform = null, deviceId = null, authorization = null, url = "/ws/oe", websocketSessionId = null;
+    private Long recordId = null, time = null, updateTime = null;
     private RedisUtil redisUtil;
     private RedisUtil redisUtil;
-    private Long updateTime = null;
     private Map<String, Object> tranMap = null;
     private Map<String, Object> tranMap = null;
-    private String url = "/ws/oe";
 
 
     /**
     /**
      * 连接建立成功调用的方法
      * 连接建立成功调用的方法
@@ -94,20 +90,21 @@ public class WebSocketOeServer implements Concurrently {
         this.session = session;
         this.session = session;
         session.setMaxIdleTimeout(SystemConstant.WEBSOCKET_MAX_TIME_OUT);
         session.setMaxIdleTimeout(SystemConstant.WEBSOCKET_MAX_TIME_OUT);
         this.sessionId = tbSession.getId();
         this.sessionId = tbSession.getId();
-        if (webSocketMap.containsKey(this.session.getId())) {
-            webSocketMap.remove(this.session.getId());
-            webSocketMap.put(this.session.getId(), this);
+        websocketSessionId = String.valueOf(UidUtil.nextId());
+        if (webSocketMap.containsKey(this.websocketSessionId)) {
+            webSocketMap.remove(this.websocketSessionId);
+            webSocketMap.put(this.websocketSessionId, this);
         } else {
         } else {
-            webSocketMap.put(this.session.getId(), this);
+            webSocketMap.put(this.websocketSessionId, this);
             addOnlineCount();
             addOnlineCount();
         }
         }
-        log.info("用户连接:{},当前在线人数为:{}", this.sessionId, getOnlineCount());
+        log.info("用户连接:{},当前在线人数为:{}", this.websocketSessionId, getOnlineCount());
         InetSocketAddress addr = (InetSocketAddress) WebsocketUtil.getFieldInstance(this.session.getAsyncRemote(), "base#socketWrapper#socket#sc#remoteAddress");
         InetSocketAddress addr = (InetSocketAddress) WebsocketUtil.getFieldInstance(this.session.getAsyncRemote(), "base#socketWrapper#socket#sc#remoteAddress");
         this.ip = addr.toString().replace("/", "").split(":")[0];
         this.ip = addr.toString().replace("/", "").split(":")[0];
         log.info("ip[:{}]连接成功", this.ip);
         log.info("ip[:{}]连接成功", this.ip);
-        WebsocketUtil.updateExamRecordWebsocketStatus(recordId, ip, this.session.getId(), WebsocketStatusEnum.ON_LINE);
+        WebsocketUtil.updateExamRecordWebsocketStatus(this.recordId, this.ip, this.websocketSessionId, WebsocketStatusEnum.ON_LINE);
         this.updateTime = System.currentTimeMillis();
         this.updateTime = System.currentTimeMillis();
-        tranMap = WebsocketUtil.initWebsocket(recordId, null, deviceId, ip, updateTime);
+        tranMap = WebsocketUtil.initWebsocket(this.recordId, null, this.deviceId, this.ip, this.updateTime);
     }
     }
 
 
     /**
     /**
@@ -116,12 +113,12 @@ public class WebSocketOeServer implements Concurrently {
     @OnClose
     @OnClose
     public void onClose() {
     public void onClose() {
         log.info("onClose is come in");
         log.info("onClose is come in");
-        if (webSocketMap.containsKey(this.session.getId())) {
-            webSocketMap.remove(this.session.getId());
+        if (webSocketMap.containsKey(this.websocketSessionId)) {
+            webSocketMap.remove(this.websocketSessionId);
             //从set中删除
             //从set中删除
             subOnlineCount();
             subOnlineCount();
             //判断是否是正常退出
             //判断是否是正常退出
-            ExamRecordCacheUtil.setClientWebsocketStatus(recordId, WebsocketStatusEnum.OFF_LINE, true);
+            ExamRecordCacheUtil.setClientWebsocketStatus(this.recordId, WebsocketStatusEnum.OFF_LINE, true);
             ExamRecordStatusEnum status = ExamRecordCacheUtil.getStatus(this.recordId);
             ExamRecordStatusEnum status = ExamRecordCacheUtil.getStatus(this.recordId);
             if (Objects.equals(status, ExamRecordStatusEnum.ANSWERING)) {
             if (Objects.equals(status, ExamRecordStatusEnum.ANSWERING)) {
                 //大于等于超时时间,说明规定时间内都没有通信,非正常退出,因为期间会有心跳更新updateTime
                 //大于等于超时时间,说明规定时间内都没有通信,非正常退出,因为期间会有心跳更新updateTime
@@ -131,7 +128,7 @@ public class WebSocketOeServer implements Concurrently {
                     MqDtoService mqDtoService = SpringContextHolder.getBean(MqDtoService.class);
                     MqDtoService mqDtoService = SpringContextHolder.getBean(MqDtoService.class);
                     tranMap = mqDtoService.buildMqDelayMsg("2m");
                     tranMap = mqDtoService.buildMqDelayMsg("2m");
                     MqUtil mqUtil = SpringContextHolder.getBean(MqUtil.class);
                     MqUtil mqUtil = SpringContextHolder.getBean(MqUtil.class);
-                    MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.OE_UN_NORMAL.name(), MqTagEnum.OE_UN_NORMAL, MqTagEnum.OE_UN_NORMAL, String.valueOf(this.recordId), this.tranMap, this.sessionId);
+                    MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.OE_UN_NORMAL.name(), MqTagEnum.OE_UN_NORMAL, MqTagEnum.OE_UN_NORMAL, String.valueOf(this.recordId), this.tranMap, this.websocketSessionId);
                     mqDtoService.assembleSendAsyncDelayMsg(mqDto);
                     mqDtoService.assembleSendAsyncDelayMsg(mqDto);
                     //发送延时mq消息end
                     //发送延时mq消息end
                 } else {
                 } else {
@@ -142,7 +139,7 @@ public class WebSocketOeServer implements Concurrently {
                 }
                 }
             }
             }
         }
         }
-        log.info("用户退出:{},当前在线人数为:{},updateTime:{}", this.sessionId, getOnlineCount(), this.updateTime);
+        log.info("用户退出:{},当前在线人数为:{},updateTime:{}", this.websocketSessionId, getOnlineCount(), this.updateTime);
     }
     }
 
 
     /**
     /**
@@ -187,7 +184,7 @@ public class WebSocketOeServer implements Concurrently {
      */
      */
     @OnError
     @OnError
     public void onError(Session session, Throwable error) {
     public void onError(Session session, Throwable error) {
-        log.error("用户错误:{},原因:{}", this.sessionId, error);
+        log.error("用户错误:{},原因:{}", this.websocketSessionId, error);
         throw new BusinessException(error.getMessage());
         throw new BusinessException(error.getMessage());
     }
     }
 
 
@@ -217,7 +214,7 @@ public class WebSocketOeServer implements Concurrently {
      * 在线人数加一
      * 在线人数加一
      */
      */
     public synchronized void addOnlineCount() {
     public synchronized void addOnlineCount() {
-        if (redisUtil.lock(SystemConstant.REDIS_LOCK_WEBSOCKET_PREFIX + this.sessionId, SystemConstant.REDIS_LOCK_WEBSOCKET_TIME_OUT)) {
+        if (redisUtil.lock(SystemConstant.REDIS_LOCK_WEBSOCKET_PREFIX + this.websocketSessionId, SystemConstant.REDIS_LOCK_WEBSOCKET_TIME_OUT)) {
             try {
             try {
                 Object o = redisUtil.get(SystemConstant.WEBSOCKET_OE_ONLINE_COUNT);
                 Object o = redisUtil.get(SystemConstant.WEBSOCKET_OE_ONLINE_COUNT);
                 int count = 0;
                 int count = 0;
@@ -227,8 +224,8 @@ public class WebSocketOeServer implements Concurrently {
                 count++;
                 count++;
                 redisUtil.set(SystemConstant.WEBSOCKET_OE_ONLINE_COUNT, count);
                 redisUtil.set(SystemConstant.WEBSOCKET_OE_ONLINE_COUNT, count);
             } finally {
             } finally {
-                if (Objects.nonNull(this.sessionId)) {
-                    redisUtil.releaseLock(SystemConstant.REDIS_LOCK_WEBSOCKET_PREFIX + this.sessionId);
+                if (Objects.nonNull(this.websocketSessionId)) {
+                    redisUtil.releaseLock(SystemConstant.REDIS_LOCK_WEBSOCKET_PREFIX + this.websocketSessionId);
                 }
                 }
             }
             }
         }
         }
@@ -238,7 +235,7 @@ public class WebSocketOeServer implements Concurrently {
      * 在线人数减一
      * 在线人数减一
      */
      */
     public synchronized void subOnlineCount() {
     public synchronized void subOnlineCount() {
-        if (redisUtil.lock(SystemConstant.REDIS_LOCK_WEBSOCKET_PREFIX + this.sessionId, SystemConstant.REDIS_LOCK_WEBSOCKET_TIME_OUT)) {
+        if (redisUtil.lock(SystemConstant.REDIS_LOCK_WEBSOCKET_PREFIX + this.websocketSessionId, SystemConstant.REDIS_LOCK_WEBSOCKET_TIME_OUT)) {
             try {
             try {
                 Object o = redisUtil.get(SystemConstant.WEBSOCKET_OE_ONLINE_COUNT);
                 Object o = redisUtil.get(SystemConstant.WEBSOCKET_OE_ONLINE_COUNT);
                 int count = 0;
                 int count = 0;
@@ -248,8 +245,8 @@ public class WebSocketOeServer implements Concurrently {
                 count--;
                 count--;
                 redisUtil.set(SystemConstant.WEBSOCKET_OE_ONLINE_COUNT, count < 0 ? 0 : count);
                 redisUtil.set(SystemConstant.WEBSOCKET_OE_ONLINE_COUNT, count < 0 ? 0 : count);
             } finally {
             } finally {
-                if (Objects.nonNull(this.sessionId)) {
-                    redisUtil.releaseLock(SystemConstant.REDIS_LOCK_WEBSOCKET_PREFIX + this.sessionId);
+                if (Objects.nonNull(this.websocketSessionId)) {
+                    redisUtil.releaseLock(SystemConstant.REDIS_LOCK_WEBSOCKET_PREFIX + this.websocketSessionId);
                 }
                 }
             }
             }
         }
         }