wangliang vor 3 Jahren
Ursprung
Commit
14af57d5d0

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

@@ -14,6 +14,7 @@ import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.business.util.UidUtil;
 import com.qmth.themis.business.util.WebsocketUtil;
 import com.qmth.themis.common.contanst.Constants;
+import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -64,8 +65,7 @@ public class WebSocketAdminServer
         this.sessionId = tbSession.getId();
         websocketSessionId = String.valueOf(UidUtil.nextId());
         if (webSocketMap.containsKey(this.userId)) {
-            webSocketMap.remove(this.userId);
-            webSocketMap.put(this.userId, this);
+            throw new BusinessException(ExceptionResultEnum.REPEAT_CONNECT_ERROR);
         } else {
             webSocketMap.put(this.userId, this);
             addOnlineCount();

+ 17 - 1
themis-business/src/main/java/com/qmth/themis/business/dto/response/TEExamWaitDto.java

@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * @Description: 考试候考dto
@@ -27,9 +28,20 @@ public class TEExamWaitDto implements Serializable {
     @ApiModelProperty(name = "考试名称")
     private String name;//考试名称
 
+    @ApiModelProperty(name = "考试编码")
+    private String code;//考试编码
+
     @ApiModelProperty(name = "考试场次集合")
     private List<TEExamActivityWaitDto> activities;
 
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
     public Long getExamActivityId() {
         return examActivityId;
     }
@@ -47,7 +59,11 @@ public class TEExamWaitDto implements Serializable {
     }
 
     public String getName() {
-        return name;
+        if (Objects.nonNull(code)) {
+            return name + "(" + code + ")";
+        } else {
+            return name;
+        }
     }
 
     public void setName(String name) {

+ 1 - 0
themis-business/src/main/resources/mapper/TEExamMapper.xml

@@ -148,6 +148,7 @@
         select
         distinct tee.id,
         tee.name,
+        tee.code,
         teea.id as examActivityId,
         <!--FLOOR((teea.finish_time - teea.start_time) / (24*60*60*1000)) as diffSum1,
         FLOOR(((teea.finish_time - teea.start_time) / (24*60*60*1000) - (unix_timestamp(current_timestamp()) * 1000 - teea.start_time) / (24*60*60*1000))) as reallyTime1,-->

+ 3 - 1
themis-common/src/main/java/com/qmth/themis/common/enums/ExceptionResultEnum.java

@@ -263,7 +263,9 @@ public enum ExceptionResultEnum {
 
     EXAM_STATUS_ALREADY_UPDATE(500, 5000023, "考试状态已被修改"),
 
-    EXAM_FINISH(500, 5000024, "考试已结束");
+    EXAM_FINISH(500, 5000024, "考试已结束"),
+
+    REPEAT_CONNECT_ERROR(500, 5000025, "不允许重复连接");
 
     private int statusCode;
     private int code;

+ 10 - 0
themis-exam/src/main/java/com/qmth/themis/exam/api/TEExamController.java

@@ -238,6 +238,16 @@ public class TEExamController {
 //        MqDto mqDtoStop = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.MONITOR_STOP.name(), param.getRecordId(), MqTagEnum.MONITOR_STOP, String.valueOf(param.getRecordId()), mqMap, String.valueOf(param.getRecordId()));
 //        mqDtoService.assembleSendOneOrderMsg(mqDtoStop);
 
+//        ExamRecordCacheUtil.setStatus(param.getRecordId(), ExamRecordStatusEnum.FINISHED, System.currentTimeMillis());
+//        ConcurrentHashMap<String, WebSocketOeServer> webSocketMap = WebSocketOeServer.getWebSocketMap();
+//        String clientWebsocketId = ExamRecordCacheUtil.getClientWebsocketId(param.getRecordId());
+//        WebSocketOeServer webSocketOeServer = webSocketMap.get(clientWebsocketId);
+//        try {
+//            WebSocketOeServer.close(webSocketOeServer);
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        }
+
         AnswerSubmitBean ret = teExamService.answerSubmit(teStudent.getId(), param.getRecordId(), param.getMainNumber(),
                 param.getSubNumber(), param.getSubIndex(), param.getAnswer(), param.getVersion(),
                 param.getDurationSeconds());

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

@@ -13,6 +13,7 @@ import com.qmth.themis.business.service.MqDtoService;
 import com.qmth.themis.business.service.TOeExamRecordService;
 import com.qmth.themis.business.util.*;
 import com.qmth.themis.common.contanst.Constants;
+import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.exam.listener.service.MqOeLogicService;
 import com.qmth.themis.exam.websocket.interceptor.WebSocketMobileHandshakeInterceptor;
@@ -73,8 +74,7 @@ public class WebSocketMobileServer implements Concurrently {
         this.sessionId = tbSession.getId();
         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);
+            throw new BusinessException(ExceptionResultEnum.REPEAT_CONNECT_ERROR);
         } else {
             webSocketMap.put(this.websocketSessionId + "-" + this.source.name(), this);
             addOnlineCount();

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

@@ -16,6 +16,7 @@ import com.qmth.themis.business.service.MqDtoService;
 import com.qmth.themis.business.service.TOeExamRecordService;
 import com.qmth.themis.business.util.*;
 import com.qmth.themis.common.contanst.Constants;
+import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.exam.config.ExamConstant;
 import com.qmth.themis.exam.listener.service.MqOeLogicService;
@@ -76,8 +77,7 @@ public class WebSocketOeServer implements Concurrently {
         this.sessionId = tbSession.getId();
         websocketSessionId = String.valueOf(UidUtil.nextId());
         if (webSocketMap.containsKey(this.websocketSessionId)) {
-            webSocketMap.remove(this.websocketSessionId);
-            webSocketMap.put(this.websocketSessionId, this);
+            throw new BusinessException(ExceptionResultEnum.REPEAT_CONNECT_ERROR);
         } else {
             webSocketMap.put(this.websocketSessionId, this);
             addOnlineCount();