wangliang před 4 roky
rodič
revize
b05a3bcf64

+ 4 - 1
themis-backend/src/main/java/com/qmth/themis/backend/api/SysController.java

@@ -102,6 +102,9 @@ public class SysController {
         if (Objects.isNull(file) || Objects.equals(file, "")) {
             throw new BusinessException(ExceptionResultEnum.ATTACHMENT_IS_NULL);
         }
+        if (Objects.isNull(type) || Objects.equals(type, "")) {
+            throw new BusinessException(ExceptionResultEnum.FILE_TYPE_IS_NULL);
+        }
         Map<String, Object> mapParameter = systemConfig.getOssEnv(type.getId());
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
         TBAttachment tbAttachment = tbAttachmentService.saveAttachment(file, ServletUtil.getRequestMd5(), ServletUtil.getRequestPath(), mapParameter, tbUser.getOrgId(), tbUser.getId());
@@ -123,7 +126,7 @@ public class SysController {
             throw new BusinessException(ExceptionResultEnum.TASK_ID_IS_NULL);
         }
         if (Objects.isNull(type) || Objects.equals(type, "")) {
-            throw new BusinessException(ExceptionResultEnum.DOWNLOAD_FILE_TYPE_IS_NULL);
+            throw new BusinessException(ExceptionResultEnum.FILE_TYPE_IS_NULL);
         }
         if (Objects.isNull(DownloadFileEnum.convertToName(type.getId()))) {
             throw new BusinessException(ExceptionResultEnum.DOWNLOAD_FILE_TYPE_ERROR);

+ 2 - 5
themis-backend/src/main/java/com/qmth/themis/backend/api/TIeInvigilateController.java

@@ -72,13 +72,10 @@ public class TIeInvigilateController {
         if (Objects.isNull(mapParameter.get("type")) || Objects.equals(mapParameter.get("type"), "")) {
             throw new BusinessException(ExceptionResultEnum.FINISH_TYPE_IS_NULL);
         }
-        String type = String.valueOf(mapParameter.get("type"));
-        if (Objects.isNull(FinishTypeEnum.valueOf(type.toUpperCase()))) {
-            throw new BusinessException(ExceptionResultEnum.FINISH_TYPE_ERROR);
-        }
+        FinishTypeEnum type = FinishTypeEnum.valueOf(String.valueOf(mapParameter.get("type")));
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
         //发送mq给客户端强制收卷
-        MqDto mqDto = new MqDto(MqTopicEnum.themisTopic.getCode(), MqTagEnum.oe.name(), JacksonUtil.parseJson(examRecordIdList), FinishTypeEnum.valueOf(type).ordinal() == FinishTypeEnum.INTERRUPT.ordinal() ? MqEnum.WEBSOCKET_MONITOR_FINISH_LOG : MqEnum.WEBSOCKET_HAND_FINISH_LOG, String.valueOf(tbUser.getId()), mapParameter, tbUser.getName());
+        MqDto mqDto = new MqDto(MqTopicEnum.themisTopic.getCode(), MqTagEnum.oe.name(), JacksonUtil.parseJson(examRecordIdList), type.ordinal() == FinishTypeEnum.INTERRUPT.ordinal() ? MqEnum.WEBSOCKET_MONITOR_FINISH_LOG : MqEnum.WEBSOCKET_HAND_FINISH_LOG, String.valueOf(tbUser.getId()), mapParameter, tbUser.getName());
         mqDtoService.assembleSendOneWayMsg(mqDto);
         return ResultUtil.ok(SystemConstant.SUCCESS);
     }

+ 0 - 17
themis-backend/src/main/java/com/qmth/themis/backend/websocket/WebSocketAdminServer.java

@@ -139,23 +139,6 @@ public class WebSocketAdminServer implements Concurrently {
             //从set中删除
             subOnlineCount();
             //管理端无需发送延时mq消息
-            //判断是否是正常退出
-//            Date now = new Date();
-//            //大于等于超时时间,说明规定时间内都没有通信,非正常退出,因为期间会有心跳更新updateTime
-//            if ((now.getTime() - this.updateTime) / 1000 >= SystemConstant.WEBSOCKET_MAX_TIME_OUT / 1000) {
-//                log.info("超时退出");
-//                //发送延时mq消息start
-//                MqDtoService mqDtoService = SpringContextHolder.getBean(MqDtoService.class);
-//                String level = "2m";
-//                Integer time = SystemConstant.mqDelayLevel.get(level);
-//                LocalDateTime dt = LocalDateTime.now();
-//                dt = dt.plusMinutes(Long.parseLong(level.replace("m", "")));
-//                tranMap.put("timeOut", time);
-//                tranMap.put("mqExecTime", dt.toInstant(ZoneOffset.of("+8")).toEpochMilli());
-//                MqDto mqDto = new MqDto(MqTopicEnum.themisTopic.getCode(), MqTagEnum.unNormal.name(), SystemOperationEnum.OE_NET_UN_NORMAL, MqEnum.WEBSOCKET_UN_NORMAL_LOG, this.sessionId, this.tranMap, this.sessionId);
-//                mqDtoService.assembleSendAsyncDelayMsg(mqDto);
-//                //发送延时mq消息end
-//            }
         }
         log.info("用户退出:{},当前在线人数为:{},updateTime:{}", this.sessionId, getOnlineCount(), this.updateTime);
     }

+ 4 - 0
themis-business/src/main/java/com/qmth/themis/business/cache/ExamRecordCacheUtil.java

@@ -89,6 +89,10 @@ public class ExamRecordCacheUtil {
 	public static Long getLastBreakId(Long recordId) {
 		return (Long) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "lastBreakId");
 	}
+
+	public static Date getLastBreakTime(Long recordId) {
+		return (Date) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "lastBreakTime");
+	}
 	
 	public static VerifyExceptionEnum getEntryAuthenticationResult(Long recordId) {
 		return (VerifyExceptionEnum) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "entryAuthenticationResult");

+ 25 - 6
themis-business/src/main/java/com/qmth/themis/business/dto/response/TEExamActivityDto.java

@@ -2,6 +2,7 @@ package com.qmth.themis.business.dto.response;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @Description: 考试场次dto
@@ -21,7 +22,8 @@ public class TEExamActivityDto implements Serializable {
     private Long minStartTime;
     private Long maxStartTime;
     private Long maxFinishTime;
-    private String monitorVideoSource;
+    private String monitorVideoSourceStr;
+    private List<String> monitorVideoSource;
     private Long openingSeconds;//允许开考开放时长(分钟),相当于迟到时间
     private Long activityOpeningSeconds;//允许开考开放时长(分钟),相当于迟到时间
     private Long prepareSeconds;//提前多长时间开始候考(分钟)
@@ -35,7 +37,8 @@ public class TEExamActivityDto implements Serializable {
     private Integer inProcessFaceVerify;//考试过程中人脸检测是否开启,0:不开启,1:开启
     private Integer inProcessFaceStrangerIgnore;//考试过程中人脸检测是否忽略陌生人 ,0:不忽略,1:忽略
     private Integer inProcessLivenessVerify;//考试过程中是否启用活体检测 ,0:不启用,1:启用
-    private String inProcessLivenessFixedRange;//考试过程中活体检测间隔时间
+    private String inProcessLivenessFixedRangeStr;
+    private List<Long> inProcessLivenessFixedRange;//考试过程中活体检测间隔时间
     private String inProcessLivenessJudgePolicy;//考试过程中活体检测结果判定规则,any:任意一次通过,all:全部都要通过,more:通过次数大于失败次数
     private Integer inProcessLivenessRetryCount;//考试过程中活体检测重试次数
     private Integer clientVideoPush;//是否开启/强制客户端视频监控,0:不开启,1:开启,2:强制开启
@@ -46,6 +49,22 @@ public class TEExamActivityDto implements Serializable {
     private Date startTime;//考场开始时间
     private Date finishTime;//考场结束时间
 
+    public String getMonitorVideoSourceStr() {
+        return monitorVideoSourceStr;
+    }
+
+    public void setMonitorVideoSourceStr(String monitorVideoSourceStr) {
+        this.monitorVideoSourceStr = monitorVideoSourceStr;
+    }
+
+    public String getInProcessLivenessFixedRangeStr() {
+        return inProcessLivenessFixedRangeStr;
+    }
+
+    public void setInProcessLivenessFixedRangeStr(String inProcessLivenessFixedRangeStr) {
+        this.inProcessLivenessFixedRangeStr = inProcessLivenessFixedRangeStr;
+    }
+
     public Long getPrepareTime() {
         return prepareTime;
     }
@@ -78,11 +97,11 @@ public class TEExamActivityDto implements Serializable {
         this.maxFinishTime = maxFinishTime;
     }
 
-    public String getMonitorVideoSource() {
+    public List<String> getMonitorVideoSource() {
         return monitorVideoSource;
     }
 
-    public void setMonitorVideoSource(String monitorVideoSource) {
+    public void setMonitorVideoSource(List<String> monitorVideoSource) {
         this.monitorVideoSource = monitorVideoSource;
     }
 
@@ -230,11 +249,11 @@ public class TEExamActivityDto implements Serializable {
         this.inProcessLivenessVerify = inProcessLivenessVerify;
     }
 
-    public String getInProcessLivenessFixedRange() {
+    public List<Long> getInProcessLivenessFixedRange() {
         return inProcessLivenessFixedRange;
     }
 
-    public void setInProcessLivenessFixedRange(String inProcessLivenessFixedRange) {
+    public void setInProcessLivenessFixedRange(List<Long> inProcessLivenessFixedRange) {
         this.inProcessLivenessFixedRange = inProcessLivenessFixedRange;
     }
 

+ 40 - 35
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java

@@ -3,14 +3,7 @@ package com.qmth.themis.business.service.impl;
 import java.io.IOException;
 import java.io.InputStream;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.UUID;
+import java.util.*;
 
 import javax.annotation.Resource;
 
@@ -85,7 +78,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
 
     @Resource
     TOeExamRecordService toeExamRecordService;
-    
+
     @Resource
     TEExamStudentService examStudentService;
 
@@ -125,6 +118,16 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         if (Objects.nonNull(list) && list.size() > 0) {
             list.forEach(s -> {
                 List<TEExamActivityDto> teExamActivityList = teExamActivityService.getWaitingExam(studentId, s.getId(), s.getExamActivityId());
+                teExamActivityList.forEach(v -> {
+                    String[] longs = v.getInProcessLivenessFixedRangeStr().split(",");
+                    List inProcessLivenessFixedRange = new ArrayList();
+                    for (int i = 0; i < longs.length; i++) {
+                        Long l = Long.valueOf(longs[i]);
+                        inProcessLivenessFixedRange.add(l);
+                    }
+                    v.setInProcessLivenessFixedRange(inProcessLivenessFixedRange);
+                    v.setMonitorVideoSource(Arrays.asList(v.getMonitorVideoSourceStr()));
+                });
                 s.setActivities(teExamActivityList);
             });
         }
@@ -142,7 +145,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
 //    }
 
     /**
-     *开始候考
+     * 开始候考
      */
     @Transactional
     @Override
@@ -249,7 +252,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
     }
 
     /**
-     *开始候考
+     * 开始候考
      */
     @Override
     public ExamStartBean start(Long studentId, Long recordId) {
@@ -303,7 +306,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
     }
 
     /**
-     *上传个人试卷结构
+     * 上传个人试卷结构
      */
     @Override
     public Long studentPaperStruct(Long studentId, Long recordId, String content) {
@@ -331,7 +334,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
     }
 
     /**
-     *提交作答结果
+     * 提交作答结果
      */
     @Override
     public Long answerSubmit(Long studentId, Long recordId, Integer mainNumber, Integer subNumber, Integer subIndex,
@@ -381,7 +384,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
     }
 
     /**
-     *更新音频剩余播放次数
+     * 更新音频剩余播放次数
      */
     @Override
     public Integer audioLeftPlayCountSubmit(Long studentId, Long recordId, String key, Integer count) {
@@ -407,7 +410,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
     }
 
     /**
-     *文件上传
+     * 文件上传
      */
     @Override
     public ExamFileUploadBean fileUpload(Long studentId, Long recordId, MultipartFile file, String suffix, String md5) {
@@ -457,7 +460,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
     }
 
     /**
-     *断点恢复
+     * 断点恢复
      */
     @SuppressWarnings("unchecked")
     @Override
@@ -510,7 +513,9 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         return ret;
     }
 
-    /**作答排序
+    /**
+     * 作答排序
+     *
      * @param answers
      * @return
      */
@@ -550,7 +555,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
     }
 
     /**
-     *结束考试
+     * 结束考试
      */
     @Override
     public ExamFinishBean finish(Long studentId, Long recordId, String type, Integer durationSeconds) {
@@ -598,31 +603,31 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
     }
 
     /**
-     *查询交卷结果
+     * 查询交卷结果
      */
     @Override
     public ExamResultBean result(Long recordId) {
-    	ExamResultBean ret = new ExamResultBean();
-    	TOeExamRecord er=null;
+        ExamResultBean ret = new ExamResultBean();
+        TOeExamRecord er = null;
         if (ExamRecordCacheUtil.getId(recordId) == null) {
-        	er=toeExamRecordService.getById(recordId);
-        	if(er==null) {
-        		throw new BusinessException("未找到考试记录");
-        	}
-        	ret.setDurationSeconds(er.getDurationSeconds());
-        	ret.setFinishTime(er.getFinishTime().getTime());
-        	ret.setFinishType(er.getFinishType());
-        	ret.setObjectiveScore(er.getObjectiveScore());
-        }else {
-        	ret.setDurationSeconds(ExamRecordCacheUtil.getDurationSeconds(recordId));
-        	ret.setFinishTime(ExamRecordCacheUtil.getFinishTime(recordId));
-        	ret.setFinishType(ExamRecordCacheUtil.getFinishType(recordId));
-        	ret.setObjectiveScore(ExamRecordCacheUtil.getObjectiveScore(recordId));
+            er = toeExamRecordService.getById(recordId);
+            if (er == null) {
+                throw new BusinessException("未找到考试记录");
+            }
+            ret.setDurationSeconds(er.getDurationSeconds());
+            ret.setFinishTime(er.getFinishTime().getTime());
+            ret.setFinishType(er.getFinishType());
+            ret.setObjectiveScore(er.getObjectiveScore());
+        } else {
+            ret.setDurationSeconds(ExamRecordCacheUtil.getDurationSeconds(recordId));
+            ret.setFinishTime(ExamRecordCacheUtil.getFinishTime(recordId));
+            ret.setFinishType(ExamRecordCacheUtil.getFinishType(recordId));
+            ret.setObjectiveScore(ExamRecordCacheUtil.getObjectiveScore(recordId));
         }
 
         //TODO
         ret.setReviewResult("");
         return ret;
     }
-    
+
 }

+ 3 - 3
themis-business/src/main/resources/mapper/TEExamActivityMapper.xml

@@ -91,7 +91,7 @@
             UNIX_TIMESTAMP(date_add(teea.start_time, interval tee.min_duration_seconds second)) * 1000 as minStartTime,
             UNIX_TIMESTAMP(date_add(teea.start_time, interval IFNULL(teea.max_duration_seconds, tee.max_duration_seconds) second)) * 1000 as maxStartTime,
             UNIX_TIMESTAMP(IFNULL(teea.finish_time , tee.end_time)) * 1000 as maxFinishTime,
-            tee.monitor_video_source as monitorVideoSource,
+            tee.monitor_video_source as monitorVideoSourceStr,
             tee.prepare_seconds as prepareSeconds,
             teea.prepare_seconds as activityPrepareSeconds,
             tee.min_duration_seconds as minDurationSeconds,
@@ -103,7 +103,7 @@
             tee.in_process_face_verify as inProcessFaceVerify,
             tee.in_process_face_stranger_ignore as inProcessFaceStrangerIgnore,
             tee.in_process_liveness_verify as inProcessLivenessVerify,
-            tee.in_process_liveness_fixed_range as inProcessLivenessFixedRange,
+            tee.in_process_liveness_fixed_range as inProcessLivenessFixedRangeStr,
             tee.in_process_liveness_judge_policy as inProcessLivenessJudgePolicy,
             tee.in_process_liveness_retry_count as inProcessLivenessRetryCount,
             tee.client_video_push as clientVideoPush,
@@ -134,7 +134,7 @@
             and tee.enable = 1
             and teea.enable = 1
             and tees.enable = 1
-            and teea.start_time <![CDATA[ >= ]]> date_add(now(), interval IFNULL(teea.opening_seconds, tee.opening_seconds) second)
+            and teea.start_time <![CDATA[ >= ]]> date_sub(now(), interval IFNULL(teea.opening_seconds, tee.opening_seconds) second)
         </where>
     </select>
 </mapper>

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

@@ -52,7 +52,7 @@
                 <if test="examId != null and examId != ''">
                     and tee.id = #{examId}
                 </if>
-                and teea.start_time <![CDATA[ >= ]]> date_add(now(), interval IFNULL(teea.opening_seconds, tee.opening_seconds) second)
+                and teea.start_time <![CDATA[ >= ]]> date_sub(now(), interval IFNULL(teea.opening_seconds, tee.opening_seconds) second)
         </where>
             ) t
         <where>

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

@@ -80,7 +80,7 @@ public enum ExceptionResultEnum {
 
     ATTACHMENT_TYPE_IS_NULL(400, 400026, "请上传文件类型"),
 
-    DOWNLOAD_FILE_TYPE_IS_NULL(400, 400027, "下载文件类型不能为空"),
+    FILE_TYPE_IS_NULL(400, 400027, "文件类型不能为空"),
 
     NAME_IS_NULL(400, 400028, "姓名不能为空"),
 

+ 33 - 35
themis-exam/src/main/java/com/qmth/themis/exam/listener/service/impl/MqOeLogicServiceImpl.java

@@ -23,6 +23,7 @@ import javax.annotation.Resource;
 import java.lang.reflect.InvocationTargetException;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -77,7 +78,7 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
     public void execMqOeLogic(MqDto mqDto, String key) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
         Gson gson = new Gson();
         MqEnum mqEnum = mqDto.getType();
-        ConcurrentHashMap<String, WebSocketOeServer> webSocketMap = WebSocketOeServer.getWebSocketMap();
+        ConcurrentHashMap<Long, WebSocketOeServer> webSocketMap = WebSocketOeServer.getWebSocketMap();
 //        if (MqEnum.WEBSOCKET_OFFLINE_LOG.ordinal() == mqEnum.ordinal()) {//下线
 //            JSONArray jsonArray = JSONArray.parseArray(String.valueOf(mqDto.getBody()));
 //            Set<String> examStudentIdentitySet = jsonArray.toJavaObject(Set.class);
@@ -95,76 +96,73 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
 //        } else
         if (MqEnum.WEBSOCKET_MONITOR_FINISH_LOG.ordinal() == mqEnum.ordinal()) {//强制离线交卷
             Set examRecordId = JacksonUtil.readJson(String.valueOf(mqDto.getBody()), Set.class);
-            webSocketMap.forEach((k, v) -> {
                 examRecordId.forEach(s -> {
                     Long recordId = Long.parseLong(String.valueOf(s));
-                    if (v.getRecordId().longValue() == recordId.longValue()) {
+                    if (Objects.nonNull(webSocketMap.get(recordId))) {
+                        WebSocketOeServer webSocketOeServer = webSocketMap.get(recordId);
                         Map map = new HashMap<>();
                         map.put("form", mqDto.getObjName());
                         map.put(SystemConstant.RECORD_ID, recordId);
                         map.put(SystemConstant.MESSAGE, FinishTypeEnum.valueOf(String.valueOf(mqDto.getProperties().get("type"))).getCode());
                         WebsocketDto websocketDto = new WebsocketDto(WebsocketTypeEnum.invigilate_stop_exam.name(), map);
-                        v.sendMessage(websocketDto);
+                        webSocketOeServer.sendMessage(websocketDto);
                     }
                 });
-            });
         } else if (MqEnum.WEBSOCKET_HAND_FINISH_LOG.ordinal() == mqEnum.ordinal()) {//手动交卷
             Set examRecordId = JacksonUtil.readJson(String.valueOf(mqDto.getBody()), Set.class);
-            webSocketMap.forEach((k, v) -> {
                 examRecordId.forEach(s -> {
                     Long recordId = Long.parseLong(String.valueOf(s));
-                    if (v.getRecordId().longValue() == recordId.longValue()) {
+                    if (Objects.nonNull(webSocketMap.get(recordId))) {
+                        WebSocketOeServer webSocketOeServer = webSocketMap.get(recordId);
                         Map map = new HashMap<>();
                         map.put(SystemConstant.RECORD_ID, recordId);
-                        map.put(SystemConstant.MESSAGE, recordId);
+                        map.put(SystemConstant.MESSAGE, FinishTypeEnum.valueOf(String.valueOf(mqDto.getProperties().get("type"))).getCode());
                         WebsocketDto websocketDto = new WebsocketDto(WebsocketTypeEnum.invigilate_stop_exam.name(), map);
-                        v.sendMessage(websocketDto);
+                        webSocketOeServer.sendMessage(websocketDto);
                     }
                 });
-            });
         } else if (MqEnum.WEBSOCKET_WARNING_FINISH_LOG.ordinal() == mqEnum.ordinal()) {//预警交卷
             Set examRecordId = JacksonUtil.readJson(String.valueOf(mqDto.getBody()), Set.class);
-            webSocketMap.forEach((k, v) -> {
                 examRecordId.forEach(s -> {
                     Long recordId = Long.parseLong(String.valueOf(s));
-                    if (v.getRecordId().longValue() == recordId.longValue()) {
+                    if (Objects.nonNull(webSocketMap.get(recordId))) {
+                        WebSocketOeServer webSocketOeServer = webSocketMap.get(recordId);
                         Map map = new HashMap<>();
                         map.put(SystemConstant.RECORD_ID, recordId);
                         map.put(SystemConstant.BREACH_STATUS, recordId);
                         WebsocketDto websocketDto = new WebsocketDto(WebsocketTypeEnum.invigilate_stop_exam.name(), map);
-                        v.sendMessage(websocketDto);
+                        webSocketOeServer.sendMessage(websocketDto);
                     }
                 });
-            });
         } else if (MqEnum.WEBSOCKET_IM_CLUSTERING_LOG.ordinal() == mqEnum.ordinal()) {//点对点消息
             JSONArray jsonArray = JSONArray.parseArray(String.valueOf(mqDto.getBody()));
             Set<String> examStudentIdentitySet = jsonArray.toJavaObject(Set.class);
             log.info("examStudentIdentitySet:{}", JacksonUtil.parseJson(examStudentIdentitySet));
-            webSocketMap.forEach((k, v) -> {
-                examStudentIdentitySet.forEach(s -> {
-                    if (k.contains(s)) {
-                        Map map = new HashMap<>();
-                        map.put("message", k);
-                        WebsocketDto websocketDto = new WebsocketDto("message", map);
-                        v.sendMessage(websocketDto);
-                        return;
-                    }
-                });
-            });
+//            webSocketMap.forEach((k, v) -> {
+//                examStudentIdentitySet.forEach(s -> {
+//                    if (k.contains(s)) {
+//                        Map map = new HashMap<>();
+//                        map.put("message", k);
+//                        WebsocketDto websocketDto = new WebsocketDto("message", map);
+//                        v.sendMessage(websocketDto);
+//                        return;
+//                    }
+//                });
+//            });
         } else if (MqEnum.WEBSOCKET_IM_BROADCASTING_LOG.ordinal() == mqEnum.ordinal()) {//广播消息
             JSONArray jsonArray = JSONArray.parseArray(String.valueOf(mqDto.getBody()));
             Set<String> examStudentIdentitySet = jsonArray.toJavaObject(Set.class);
             log.info("examStudentIdentitySet:{}", JacksonUtil.parseJson(examStudentIdentitySet));
-            webSocketMap.forEach((k, v) -> {
-                examStudentIdentitySet.forEach(s -> {
-                    if (k.contains(s)) {
-                        Map map = new HashMap<>();
-                        map.put("message", k);
-                        WebsocketDto websocketDto = new WebsocketDto("message", map);
-                        v.sendMessage(websocketDto);
-                    }
-                });
-            });
+//            webSocketMap.forEach((k, v) -> {
+//                examStudentIdentitySet.forEach(s -> {
+//                    if (k.contains(s)) {
+//                        Map map = new HashMap<>();
+//                        map.put("message", k);
+//                        WebsocketDto websocketDto = new WebsocketDto("message", map);
+//                        v.sendMessage(websocketDto);
+//                    }
+//                });
+//            });
         }
         mqDto.setAck(SystemConstant.STANDARD_ACK_TYPE);
         TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);

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

@@ -52,7 +52,7 @@ import java.util.concurrent.ConcurrentHashMap;
 @Component
 public class WebSocketOeServer implements Concurrently {
     private final static Logger log = LoggerFactory.getLogger(WebSocketOeServer.class);
-    private volatile static ConcurrentHashMap<String, WebSocketOeServer> webSocketMap = new ConcurrentHashMap<>();
+    private volatile static ConcurrentHashMap<Long, WebSocketOeServer> webSocketMap = new ConcurrentHashMap<>();
     /**
      * 与某个客户端的连接会话,需要通过它来给客户端发送数据
      */
@@ -102,12 +102,12 @@ public class WebSocketOeServer implements Concurrently {
                     this.session = session;
                     session.setMaxIdleTimeout(SystemConstant.WEBSOCKET_MAX_TIME_OUT);
                     this.sessionId = tbSession.getId();
-                    if (webSocketMap.containsKey(tbSession.getId())) {
-                        webSocketMap.remove(sessionId);
-                        webSocketMap.put(sessionId, this);
+                    if (webSocketMap.containsKey(this.recordId)) {
+                        webSocketMap.remove(this.recordId);
+                        webSocketMap.put(this.recordId, this);
                         //加入set中
                     } else {
-                        webSocketMap.put(sessionId, this);
+                        webSocketMap.put(this.recordId, this);
                         //加入set中
                         addOnlineCount();
                         //在线数加1
@@ -136,8 +136,8 @@ public class WebSocketOeServer implements Concurrently {
     @OnClose
     public void onClose() {
         log.info("onClose is come in");
-        if (webSocketMap.containsKey(this.sessionId)) {
-            webSocketMap.remove(this.sessionId);
+        if (webSocketMap.containsKey(this.recordId)) {
+            webSocketMap.remove(this.recordId);
             //从set中删除
             subOnlineCount();
             //判断是否是正常退出
@@ -297,7 +297,7 @@ public class WebSocketOeServer implements Concurrently {
         return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;//成功
     }
 
-    public static ConcurrentHashMap<String, WebSocketOeServer> getWebSocketMap() {
+    public static ConcurrentHashMap<Long, WebSocketOeServer> getWebSocketMap() {
         return webSocketMap;
     }