deason 4 жил өмнө
parent
commit
1b8900e640

+ 24 - 6
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamControlServiceImpl.java

@@ -818,7 +818,10 @@ public class ExamControlServiceImpl implements ExamControlService {
 
         ExamingSession examSessionInfo = examingSessionService.getExamingSession(examStudent.getStudentId());
         String clientId;
-        String userId = key.substring(key.lastIndexOf("_") + 1);
+
+        Map<String, Long> values = this.parseUserKey(str);
+        Long rootOrgId = values.get("rootOrgId");
+        Long userId = values.get("userId");
 
         // 未开启环境检测,才进行如下校验
         if (!isTestDev(Long.valueOf(examRecordDataId))) {
@@ -834,7 +837,7 @@ public class ExamControlServiceImpl implements ExamControlService {
             }
         } else {
             // 环境检测时,clientId即用户id
-            clientId = userId;
+            clientId = userId.toString();
         }
 
         // 校验通过
@@ -872,16 +875,31 @@ public class ExamControlServiceImpl implements ExamControlService {
         res.setQuestionMainNumber(eqe.getMainNumber());
         res.setSubNumber(getSubNumber(examRecordQuestions, Integer.valueOf(order)));
         try {
-            ExamRecordData examRecordData = examRecordDataService
-                    .getExamRecordDataCache(Long.valueOf(examRecordDataId));
-            this.sendScanQrCodeToWebSocket(clientId, Long.valueOf(examRecordDataId), Integer.valueOf(order),
-                    Long.valueOf(userId), examRecordData.getRootOrgId());
+            // ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(Long.valueOf(examRecordDataId));
+            this.sendScanQrCodeToWebSocket(clientId, Long.valueOf(examRecordDataId), Integer.valueOf(order), userId, rootOrgId);
         } catch (Exception e) {
             throw new StatusException("100011", "消息通知失败", e);
         }
         return res;
     }
 
+    private Map<String, Long> parseUserKey(String key) {
+        Map<String, Long> result = new HashMap<>();
+
+        if (StringUtils.isEmpty(key)) {
+            return result;
+        }
+
+        // 格式:U_S_111_111
+        String[] values = key.trim().split("_");
+        if (values.length == 4) {
+            result.put("rootOrgId", Long.valueOf(values[2]));
+            result.put("userId", Long.valueOf(values[3]));
+        }
+
+        return result;
+    }
+
     /**
      * 发送消息到websocket
      *