Browse Source

考试记录去掉liveUrl

wangliang 4 years ago
parent
commit
48b0abe29a

+ 7 - 17
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamController.java

@@ -495,23 +495,13 @@ public class TEExamController {
                                     clientWebsocketStatusCount.getAndSet(clientWebsocketStatusCount.get() + 1);
                                 }
                                 //监控端通讯状态
-                                MonitorVideoSourceEnum source = null;
-                                if (Objects.nonNull(ExamRecordCacheUtil.getMonitorLiveUrlClientCamera(recordId))) {
-                                    source = MonitorVideoSourceEnum.CLIENT_CAMERA;
-                                } else if (Objects
-                                        .nonNull(ExamRecordCacheUtil.getMonitorLiveUrlClientScreen(recordId))) {
-                                    source = MonitorVideoSourceEnum.CLIENT_SCREEN;
-                                } else if (Objects
-                                        .nonNull(ExamRecordCacheUtil.getMonitorLiveUrlMobileFirst(recordId))) {
-                                    source = MonitorVideoSourceEnum.MOBILE_FIRST;
-                                } else if (Objects
-                                        .nonNull(ExamRecordCacheUtil.getMonitorLiveUrlMobileSecond(recordId))) {
-                                    source = MonitorVideoSourceEnum.MOBILE_SECOND;
-                                }
-                                MonitorStatusSourceEnum status = Objects.isNull(source) ?
-                                        null :
-                                        ExamRecordCacheUtil.getMonitorStatus(recordId, source);
-                                if (Objects.nonNull(status) && Objects.equals(status, MonitorStatusSourceEnum.STOP)) {
+                                if (Objects.nonNull(ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.CLIENT_CAMERA)) && Objects.equals(ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.CLIENT_CAMERA), MonitorStatusSourceEnum.STOP)) {
+                                    monitorStatusSourceCount.getAndSet(monitorStatusSourceCount.get() + 1);
+                                } else if (Objects.nonNull(ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.CLIENT_SCREEN)) && Objects.equals(ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.CLIENT_SCREEN), MonitorStatusSourceEnum.STOP)) {
+                                    monitorStatusSourceCount.getAndSet(monitorStatusSourceCount.get() + 1);
+                                } else if (Objects.nonNull(ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.MOBILE_FIRST)) && Objects.equals(ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.MOBILE_FIRST), MonitorStatusSourceEnum.STOP)) {
+                                    monitorStatusSourceCount.getAndSet(monitorStatusSourceCount.get() + 1);
+                                } else if (Objects.nonNull(ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.MOBILE_SECOND)) && Objects.equals(ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.MOBILE_SECOND), MonitorStatusSourceEnum.STOP)) {
                                     monitorStatusSourceCount.getAndSet(monitorStatusSourceCount.get() + 1);
                                 }
                             }

+ 8 - 7
themis-admin/src/main/java/com/qmth/themis/admin/api/TIeInvigilateCallMobileController.java

@@ -16,7 +16,10 @@ import com.qmth.themis.business.dto.MqDto;
 import com.qmth.themis.business.dto.response.TIeExamInvigilateCallDto;
 import com.qmth.themis.business.entity.*;
 import com.qmth.themis.business.enums.*;
-import com.qmth.themis.business.service.*;
+import com.qmth.themis.business.service.MqDtoService;
+import com.qmth.themis.business.service.TEExamStudentService;
+import com.qmth.themis.business.service.TIeExamInvigilateCallService;
+import com.qmth.themis.business.service.TOeExamRecordService;
 import com.qmth.themis.business.util.*;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.enums.Source;
@@ -161,16 +164,15 @@ public class TIeInvigilateCallMobileController {
         }
         MonitorVideoSourceEnum source = MonitorVideoSourceEnum.valueOf(String.valueOf(mapParameter.get("source")));
         //获取考试记录缓存
-        String liveUrl = null;
+        String liveUrl = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + source.name().toLowerCase();
         if (Objects.isNull(ExamRecordCacheUtil.getMonitorStatus(recordId, source))) {
             throw new BusinessException("推流状态为空");
         }
         ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, MonitorCallStatusSourceEnum.CALLING);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
         MonitorStatusSourceEnum status = ExamRecordCacheUtil.getMonitorStatus(recordId, source);
-        String streamName = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + ExamRecordCacheUtil.getMonitorVideoSource(recordId);
         TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl,
-                status, monitorKey, MonitorCallStatusSourceEnum.CALLING, streamName);
+                status, monitorKey, MonitorCallStatusSourceEnum.CALLING);
         //监考监控通话信息 发送mq start
         MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.MONITOR_LOG.name(),
                 tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()),
@@ -196,7 +198,7 @@ public class TIeInvigilateCallMobileController {
         }
         MonitorVideoSourceEnum source = MonitorVideoSourceEnum.valueOf(String.valueOf(mapParameter.get("source")));
         //获取考试记录缓存
-        String liveUrl = null;
+        String liveUrl = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + source.name().toLowerCase();
         ExamRecordStatusEnum statusEnum = ExamRecordCacheUtil.getStatus(recordId);
         if (Objects.isNull(statusEnum) || Objects.equals(statusEnum, ExamRecordStatusEnum.FINISHED) || Objects
                 .equals(statusEnum, ExamRecordStatusEnum.PERSISTED)) {
@@ -207,9 +209,8 @@ public class TIeInvigilateCallMobileController {
         ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, MonitorCallStatusSourceEnum.STOP);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
         MonitorStatusSourceEnum status = ExamRecordCacheUtil.getMonitorStatus(recordId, source);
-        String streamName = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + ExamRecordCacheUtil.getMonitorVideoSource(recordId);
         TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl,
-                status, monitorKey, MonitorCallStatusSourceEnum.STOP, streamName);
+                status, monitorKey, MonitorCallStatusSourceEnum.STOP);
         tIeExamInvigilateCallLog.setEndTime(System.currentTimeMillis());
         //监考监控通话信息 发送mq start
         MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.MONITOR_LOG.name(),

+ 7 - 5
themis-admin/src/main/java/com/qmth/themis/admin/api/TIeInvigilateController.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.themis.admin.config.DictionaryConfig;
 import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.bean.admin.*;
@@ -96,6 +97,9 @@ public class TIeInvigilateController {
     @Resource
     MqUtil mqUtil;
 
+    @Resource
+    DictionaryConfig dictionaryConfig;
+
     @ApiOperation(value = "实时监控台视频列表接口")
     @RequestMapping(value = "/list/video", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "监考监控信息", response = InvigilateListVideoBean.class)})
@@ -157,10 +161,8 @@ public class TIeInvigilateController {
                     if (Objects.nonNull(monitorVideoSource)) {
                         source = MonitorVideoSourceEnum.valueOf(monitorVideoSource);
                     }
-                    String monitorLiveUrl = ExamRecordCacheUtil.getMonitorLiveUrl(s.getExamRecordId(), source);
-                    if (Objects.nonNull(monitorLiveUrl)) {
-                        s.setMonitorLiveUrl(monitorLiveUrl);
-                    }
+                    String monitorLiveUrl = dictionaryConfig.monitorDomain().getPrefix() + "_" + s.getExamRecordId() + "_" + source.name().toLowerCase();
+                    s.setMonitorLiveUrl(monitorLiveUrl);
                     WebsocketStatusEnum websocketStatusEnum = ExamRecordCacheUtil.getClientWebsocketStatus(s.getExamRecordId());
                     if (Objects.nonNull(websocketStatusEnum)) {
                         s.setClientWebsocketStatus(websocketStatusEnum);
@@ -201,7 +203,7 @@ public class TIeInvigilateController {
             }
             ExamCacheBean finalExamCacheBean = examCacheBean;
             invigilateListVideoBeanList.forEach(s -> {
-                String monitorLiveUrl = ExamRecordCacheUtil.getMonitorLiveUrl(s.getExamRecordId(), MonitorVideoSourceEnum.CLIENT_CAMERA);
+                String monitorLiveUrl = dictionaryConfig.monitorDomain().getPrefix() + "_" + s.getExamRecordId() + "_" + MonitorVideoSourceEnum.CLIENT_CAMERA.name().toLowerCase();
                 if (Objects.nonNull(monitorLiveUrl)) {
                     s.setMonitorLiveUrl(monitorLiveUrl);
                 }

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

@@ -190,37 +190,6 @@ public class ExamRecordCacheUtil {
         return (String) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), ExamRecordFieldEnum.monitor_key.getCode());
     }
 
-    public static String getMonitorLiveUrl(Long recordId, MonitorVideoSourceEnum source) {
-        return (String) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), SystemConstant.MONITOR_LIVE_URL_ + source.name());
-    }
-
-    public static String getMonitorLiveUrlMobileFirst(Long recordId) {
-        return (String) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), SystemConstant.MONITOR_LIVE_URL_ + MonitorVideoSourceEnum.MOBILE_FIRST.name());
-    }
-
-    public static String getMonitorLiveUrlMobileSecond(Long recordId) {
-        return (String) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), SystemConstant.MONITOR_LIVE_URL_ + MonitorVideoSourceEnum.MOBILE_SECOND.name());
-    }
-
-    public static String getMonitorLiveUrlClientCamera(Long recordId) {
-        return (String) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), SystemConstant.MONITOR_LIVE_URL_ + MonitorVideoSourceEnum.CLIENT_CAMERA.name());
-    }
-
-    public static String getMonitorLiveUrlClientScreen(Long recordId) {
-        return (String) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), SystemConstant.MONITOR_LIVE_URL_ + MonitorVideoSourceEnum.CLIENT_SCREEN.name());
-    }
-
-    public static void setMonitorLiveUrl(Long recordId, MonitorVideoSourceEnum source, String liveUrl, boolean update) {
-        redisUtil.set(RedisKeyHelper.examRecordCacheKey(recordId), SystemConstant.MONITOR_LIVE_URL_ + source.name(), liveUrl);
-        if (update) {
-            examRecordService.dataUpdateMq(recordId, ExamRecordFieldEnum.monitor_live_url.name(), liveUrl);
-        }
-    }
-
-//    public static void setStreamName(Long recordId, MonitorVideoSourceEnum source, String streamName) {
-//        redisUtil.set(RedisKeyHelper.examRecordCacheKey(recordId), SystemConstant.STREAM_NAME + source.name(), streamName);
-//    }
-
     public static MonitorStatusSourceEnum getMonitorStatus(Long recordId, MonitorVideoSourceEnum source) {
         return Objects.nonNull(redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), SystemConstant.MONITOR_STATUS_ + source.name())) ? MonitorStatusSourceEnum.valueOf((String) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), SystemConstant.MONITOR_STATUS_ + source.name())) : null;
     }

+ 1 - 14
themis-business/src/main/java/com/qmth/themis/business/entity/TIeExamInvigilateCall.java

@@ -78,16 +78,12 @@ public class TIeExamInvigilateCall extends BaseEntity {
     @TableField(exist = false)
     private String sourceUserId;
 
-    @ApiModelProperty(value = "流名称")
-    @TableField(value = "stream_name")
-    private String streamName;
-
     public TIeExamInvigilateCall() {
 
     }
 
     public TIeExamInvigilateCall(Long examRecordId, MonitorVideoSourceEnum source, String liveUrl,
-                                 MonitorStatusSourceEnum status, String monitorKey, String streamName
+                                 MonitorStatusSourceEnum status, String monitorKey
     ) {
         setId(UidUtil.nextId());
         this.examRecordId = examRecordId;
@@ -95,15 +91,6 @@ public class TIeExamInvigilateCall extends BaseEntity {
         this.liveUrl = liveUrl;
         this.status = status;
         this.monitorKey = monitorKey;
-        this.streamName = streamName;
-    }
-
-    public String getStreamName() {
-        return streamName;
-    }
-
-    public void setStreamName(String streamName) {
-        this.streamName = streamName;
     }
 
     public String getSourceUserId() {

+ 2 - 16
themis-business/src/main/java/com/qmth/themis/business/entity/TIeExamInvigilateCallLog.java

@@ -78,16 +78,12 @@ public class TIeExamInvigilateCallLog extends BaseEntity {
     @ApiModelProperty(value = "结束通话时间")
     private Long endTime;
 
-    @ApiModelProperty(value = "流名称")
-    @TableField(value = "stream_name")
-    private String streamName;
-
     public TIeExamInvigilateCallLog() {
 
     }
 
     public TIeExamInvigilateCallLog(Long examRecordId, MonitorVideoSourceEnum source, String liveUrl,
-                                    MonitorStatusSourceEnum status, String monitorKey, String streamName
+                                    MonitorStatusSourceEnum status, String monitorKey
     ) {
         setId(UidUtil.nextId());
         setExamRecordId(examRecordId);
@@ -95,11 +91,10 @@ public class TIeExamInvigilateCallLog extends BaseEntity {
         setLiveUrl(liveUrl);
         setStatus(status);
         setMonitorKey(monitorKey);
-        setStreamName(streamName);
     }
 
     public TIeExamInvigilateCallLog(Long examRecordId, MonitorVideoSourceEnum source, String liveUrl,
-                                    MonitorStatusSourceEnum status, String monitorKey, MonitorCallStatusSourceEnum callStatus, String streamName
+                                    MonitorStatusSourceEnum status, String monitorKey, MonitorCallStatusSourceEnum callStatus
     ) {
         setId(UidUtil.nextId());
         setExamRecordId(examRecordId);
@@ -108,15 +103,6 @@ public class TIeExamInvigilateCallLog extends BaseEntity {
         setStatus(status);
         setCallStatus(callStatus);
         setMonitorKey(monitorKey);
-        setStreamName(streamName);
-    }
-
-    public String getStreamName() {
-        return streamName;
-    }
-
-    public void setStreamName(String streamName) {
-        this.streamName = streamName;
     }
 
     public Long getStartTime() {

+ 0 - 12
themis-business/src/main/java/com/qmth/themis/business/entity/TOeExamRecord.java

@@ -174,10 +174,6 @@ public class TOeExamRecord implements Serializable {
     @TableField(value = "monitor_status_source")
     private MonitorStatusSourceEnum monitorStatusSource;
 
-    @ApiModelProperty(value = "监控观看地址")
-    @TableField(value = "monitor_live_url")
-    private String monitorLiveUrl;
-
     @ApiModelProperty(value = "算分状态,never:从未算分,calculating:正在算分,finish:算分完成")
     @TableField(value = "score_status")
     private ScoreStatusEnum scoreStatus;
@@ -330,14 +326,6 @@ public class TOeExamRecord implements Serializable {
         this.monitorStatusSource = monitorStatusSource;
     }
 
-    public String getMonitorLiveUrl() {
-        return monitorLiveUrl;
-    }
-
-    public void setMonitorLiveUrl(String monitorLiveUrl) {
-        this.monitorLiveUrl = monitorLiveUrl;
-    }
-
     public static long getSerialVersionUID() {
         return serialVersionUID;
     }

+ 0 - 2
themis-business/src/main/java/com/qmth/themis/business/enums/ExamRecordFieldEnum.java

@@ -83,8 +83,6 @@ public enum ExamRecordFieldEnum {
 
     monitor_status_source("monitorStatusSource"),
 
-    monitor_live_url("monitorLiveUrl"),
-
     score_status("scoreStatus"),
 
     start_time("startTime"),

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

@@ -14,11 +14,9 @@ import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import com.qmth.themis.exam.config.DictionaryConfig;
-import com.qmth.themis.exam.websocket.WebSocketMobileServer;
 import io.swagger.annotations.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.dao.DuplicateKeyException;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -30,7 +28,6 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * @Description: mobile监考监控通话信息 前端控制器
@@ -54,58 +51,58 @@ public class TIeInvigilateCallMobileController {
     @Resource
     DictionaryConfig dictionaryConfig;
 
-    @Deprecated
-    @ApiOperation(value = "监控观看地址更新接口")
-    @RequestMapping(value = "/live_url", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
-    @Transactional
-    public Result liveUrl(@ApiJsonObject(name = "liveUrlMobile", value = {
-            @ApiJsonProperty(key = "recordId", type = "long", example = "1", description = "考试记录id", required = true),
-            @ApiJsonProperty(key = "source", description = "监考视频源", required = true),
-            @ApiJsonProperty(key = "liveUrl", description = "观看地址", required = true)
-    }) @ApiParam(value = "监控信息", required = true) @RequestBody Map<String, Object> mapParameter) {
-        if (Objects.isNull(mapParameter.get("recordId")) || Objects.equals(mapParameter.get("recordId"), "")) {
-            throw new BusinessException(ExceptionResultEnum.RECORD_ID_IS_NULL);
-        }
-        Long recordId = null;
-        try {
-            recordId = Long.parseLong(String.valueOf(mapParameter.get("recordId")));
-            if (Objects.isNull(mapParameter.get("source")) || Objects.equals(mapParameter.get("source"), "")) {
-                throw new BusinessException("监考视频源不能为空");
-            }
-            MonitorVideoSourceEnum source = MonitorVideoSourceEnum.valueOf(String.valueOf(mapParameter.get("source")).toUpperCase());
-            if (Objects.isNull(mapParameter.get("liveUrl")) || Objects.equals(mapParameter.get("liveUrl"), "")) {
-                throw new BusinessException("观看地址不能为空");
-            }
-            ConcurrentHashMap<String, WebSocketMobileServer> webSocketMap = WebSocketMobileServer.getWebSocketMap();
-            String clientWebsocketId = ExamRecordCacheUtil.getClientWebsocketId(recordId);
-            if (Objects.isNull(webSocketMap.get(clientWebsocketId + "-" + source.name()))) {
-                throw new BusinessException("网络连接失败");
-            }
-            String liveUrl = String.valueOf(mapParameter.get("liveUrl"));
-            String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
-            TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.INIT, monitorKey, null);
-            //获取考试记录缓存
-            ExamRecordCacheUtil.setMonitorLiveUrl(recordId, source, liveUrl, true);
-
-            //监考监控通话信息 发送mq start
-            MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
-            mqDtoService.assembleSendOneWayMsg(mqDto);
-            //监考监控通话信息 发送mq end
-        } catch (Exception e) {
-            log.error("请求出错", e);
-            if (e instanceof DuplicateKeyException) {
-                String errorColumn = e.getCause().toString();
-                String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
-                throw new BusinessException("考试记录id[" + recordId + "]下的" + FieldUniqueEnum.convertToCode(columnStr) + "数据不允许重复插入");
-            } else if (e instanceof BusinessException) {
-                throw new BusinessException(e.getMessage());
-            } else {
-                throw new RuntimeException(e);
-            }
-        }
-        return ResultUtil.ok(Collections.singletonMap("updateTime", System.currentTimeMillis()));
-    }
+//    @Deprecated
+//    @ApiOperation(value = "监控观看地址更新接口")
+//    @RequestMapping(value = "/live_url", method = RequestMethod.POST)
+//    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+//    @Transactional
+//    public Result liveUrl(@ApiJsonObject(name = "liveUrlMobile", value = {
+//            @ApiJsonProperty(key = "recordId", type = "long", example = "1", description = "考试记录id", required = true),
+//            @ApiJsonProperty(key = "source", description = "监考视频源", required = true),
+//            @ApiJsonProperty(key = "liveUrl", description = "观看地址", required = true)
+//    }) @ApiParam(value = "监控信息", required = true) @RequestBody Map<String, Object> mapParameter) {
+//        if (Objects.isNull(mapParameter.get("recordId")) || Objects.equals(mapParameter.get("recordId"), "")) {
+//            throw new BusinessException(ExceptionResultEnum.RECORD_ID_IS_NULL);
+//        }
+//        Long recordId = null;
+//        try {
+//            recordId = Long.parseLong(String.valueOf(mapParameter.get("recordId")));
+//            if (Objects.isNull(mapParameter.get("source")) || Objects.equals(mapParameter.get("source"), "")) {
+//                throw new BusinessException("监考视频源不能为空");
+//            }
+//            MonitorVideoSourceEnum source = MonitorVideoSourceEnum.valueOf(String.valueOf(mapParameter.get("source")).toUpperCase());
+//            if (Objects.isNull(mapParameter.get("liveUrl")) || Objects.equals(mapParameter.get("liveUrl"), "")) {
+//                throw new BusinessException("观看地址不能为空");
+//            }
+//            ConcurrentHashMap<String, WebSocketMobileServer> webSocketMap = WebSocketMobileServer.getWebSocketMap();
+//            String clientWebsocketId = ExamRecordCacheUtil.getClientWebsocketId(recordId);
+//            if (Objects.isNull(webSocketMap.get(clientWebsocketId + "-" + source.name()))) {
+//                throw new BusinessException("网络连接失败");
+//            }
+//            String liveUrl = String.valueOf(mapParameter.get("liveUrl"));
+//            String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
+//            TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.INIT, monitorKey, null);
+//            //获取考试记录缓存
+//            ExamRecordCacheUtil.setMonitorLiveUrl(recordId, source, liveUrl, true);
+//
+//            //监考监控通话信息 发送mq start
+//            MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
+//            mqDtoService.assembleSendOneWayMsg(mqDto);
+//            //监考监控通话信息 发送mq end
+//        } catch (Exception e) {
+//            log.error("请求出错", e);
+//            if (e instanceof DuplicateKeyException) {
+//                String errorColumn = e.getCause().toString();
+//                String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
+//                throw new BusinessException("考试记录id[" + recordId + "]下的" + FieldUniqueEnum.convertToCode(columnStr) + "数据不允许重复插入");
+//            } else if (e instanceof BusinessException) {
+//                throw new BusinessException(e.getMessage());
+//            } else {
+//                throw new RuntimeException(e);
+//            }
+//        }
+//        return ResultUtil.ok(Collections.singletonMap("updateTime", System.currentTimeMillis()));
+//    }
 
     @ApiOperation(value = "发送通话申请接口")
     @RequestMapping(value = "/call/apply", method = RequestMethod.POST)
@@ -124,7 +121,6 @@ public class TIeInvigilateCallMobileController {
         }
         MonitorVideoSourceEnum source = MonitorVideoSourceEnum.valueOf(String.valueOf(mapParameter.get("source")));
         //获取考试记录缓存
-        String liveUrl = null;
         if (Objects.isNull(source) || Objects.isNull(ExamRecordCacheUtil.getMonitorStatus(recordId, source))) {
             throw new BusinessException("推流状态为空");
         }
@@ -132,10 +128,10 @@ public class TIeInvigilateCallMobileController {
         if (!Objects.equals(status, MonitorStatusSourceEnum.START)) {
             throw new BusinessException("推流状态不正常");
         }
+        String liveUrl = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + source.name().toLowerCase();
         ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, MonitorCallStatusSourceEnum.START);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
-        String streamName = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + ExamRecordCacheUtil.getMonitorVideoSource(recordId);
-        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.START, streamName);
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.START);
         tIeExamInvigilateCallLog.setStartTime(System.currentTimeMillis());
         //监考监控通话信息 发送mq start
         MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
@@ -170,16 +166,12 @@ public class TIeInvigilateCallMobileController {
             throw new BusinessException("异常类型不能为空");
         }
         //获取考试记录缓存
-        String liveUrl = null;
-        if (Objects.nonNull(ExamRecordCacheUtil.getMonitorLiveUrl(recordId, source))) {
-            liveUrl = ExamRecordCacheUtil.getMonitorLiveUrl(recordId, source);
-        }
+        String liveUrl = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + source.name().toLowerCase();
         MonitorCallStatusSourceEnum callStatus = Objects.nonNull(ExamRecordCacheUtil.getMonitorCallStatus(recordId, source)) ? ExamRecordCacheUtil.getMonitorCallStatus(recordId, source) : null;
         ExamRecordCacheUtil.setMonitorStatus(recordId, source, status, true);
         ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, callStatus);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
-        String streamName = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + ExamRecordCacheUtil.getMonitorVideoSource(recordId);
-        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.START, monitorKey, callStatus, streamName);
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.START, monitorKey, callStatus);
         if (Objects.nonNull(mapParameter.get("type")) && !Objects.equals(mapParameter.get("type"), "")) {
             tIeExamInvigilateCallLog.setType(ExceptionEnum.valueOf(String.valueOf(mapParameter.get("type"))));
         }
@@ -224,18 +216,17 @@ public class TIeInvigilateCallMobileController {
         }
         MonitorVideoSourceEnum source = MonitorVideoSourceEnum.valueOf(String.valueOf(mapParameter.get("source")));
         //获取考试记录缓存
-        String liveUrl = null;
         ExamRecordStatusEnum statusEnum = ExamRecordCacheUtil.getStatus(recordId);
         if (Objects.isNull(statusEnum) || Objects.equals(statusEnum, ExamRecordStatusEnum.FINISHED) || Objects.equals(statusEnum, ExamRecordStatusEnum.PERSISTED)) {
             return ResultUtil.ok(Collections.singletonMap("updateTime", System.currentTimeMillis()));
         } else if (Objects.isNull(ExamRecordCacheUtil.getMonitorStatus(recordId, source))) {
             throw new BusinessException("推流状态为空");
         }
+        String liveUrl = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + source.name().toLowerCase();
         ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, MonitorCallStatusSourceEnum.STOP);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
         MonitorStatusSourceEnum status = ExamRecordCacheUtil.getMonitorStatus(recordId, source);
-        String streamName = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + ExamRecordCacheUtil.getMonitorVideoSource(recordId);
-        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.STOP, streamName);
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.STOP);
         tIeExamInvigilateCallLog.setEndTime(System.currentTimeMillis());
         //监考监控通话信息 发送mq start
         MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());

+ 59 - 71
themis-exam/src/main/java/com/qmth/themis/exam/api/TIeInvigilateCallOeController.java

@@ -17,7 +17,6 @@ import com.qmth.themis.exam.config.DictionaryConfig;
 import io.swagger.annotations.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.dao.DuplicateKeyException;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -55,57 +54,57 @@ public class TIeInvigilateCallOeController {
     @Resource
     DictionaryConfig dictionaryConfig;
 
-    @Deprecated
-    @ApiOperation(value = "监控观看地址更新接口")
-    @RequestMapping(value = "/live_url", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
-    @Transactional
-    public Result liveUrl(@ApiJsonObject(name = "liveUrlOe", value = {
-            @ApiJsonProperty(key = "recordId", type = "long", example = "1", description = "考试记录id", required = true),
-            @ApiJsonProperty(key = "source", description = "监考视频源", required = true),
-            @ApiJsonProperty(key = "liveUrl", description = "观看地址", required = true)
-    }) @ApiParam(value = "监控信息", required = true) @RequestBody Map<String, Object> mapParameter) {
-        if (Objects.isNull(mapParameter.get("recordId")) || Objects.equals(mapParameter.get("recordId"), "")) {
-            throw new BusinessException(ExceptionResultEnum.RECORD_ID_IS_NULL);
-        }
-        Long recordId = null;
-        try {
-            recordId = Long.parseLong(String.valueOf(mapParameter.get("recordId")));
-            if (Objects.isNull(mapParameter.get("source")) || Objects.equals(mapParameter.get("source"), "")) {
-                throw new BusinessException("监考视频源不能为空");
-            }
-            MonitorVideoSourceEnum source = MonitorVideoSourceEnum.valueOf(String.valueOf(mapParameter.get("source")).toUpperCase());
-            if (Objects.isNull(mapParameter.get("liveUrl")) || Objects.equals(mapParameter.get("liveUrl"), "")) {
-                throw new BusinessException("观看地址不能为空");
-            }
-            String liveUrl = String.valueOf(mapParameter.get("liveUrl"));
-            String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
-            TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.INIT, monitorKey,null);
-            //获取考试记录缓存
-            ExamRecordCacheUtil.setMonitorLiveUrl(recordId, source, liveUrl, false);
-            ExamRecordCacheUtil.setMonitorStatus(recordId, source, tIeExamInvigilateCallLog.getStatus(), false);
-            String[] columns = new String[]{ExamRecordFieldEnum.monitor_live_url.name(), ExamRecordFieldEnum.monitor_status_source.name()};
-            Object[] values = new Object[]{liveUrl, tIeExamInvigilateCallLog.getStatus()};
-            tOeExamRecordService.dataUpdatesMq(recordId, columns, values);
-
-            //监考监控通话信息 发送mq start
-            MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
-            mqDtoService.assembleSendOneWayMsg(mqDto);
-            //监考监控通话信息 发送mq end
-        } catch (Exception e) {
-            log.error("请求出错", e);
-            if (e instanceof DuplicateKeyException) {
-                String errorColumn = e.getCause().toString();
-                String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
-                throw new BusinessException("考试记录id[" + recordId + "]下的" + FieldUniqueEnum.convertToCode(columnStr) + "数据不允许重复插入");
-            } else if (e instanceof BusinessException) {
-                throw new BusinessException(e.getMessage());
-            } else {
-                throw new RuntimeException(e);
-            }
-        }
-        return ResultUtil.ok(Collections.singletonMap("updateTime", System.currentTimeMillis()));
-    }
+//    @Deprecated
+//    @ApiOperation(value = "监控观看地址更新接口")
+//    @RequestMapping(value = "/live_url", method = RequestMethod.POST)
+//    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+//    @Transactional
+//    public Result liveUrl(@ApiJsonObject(name = "liveUrlOe", value = {
+//            @ApiJsonProperty(key = "recordId", type = "long", example = "1", description = "考试记录id", required = true),
+//            @ApiJsonProperty(key = "source", description = "监考视频源", required = true),
+//            @ApiJsonProperty(key = "liveUrl", description = "观看地址", required = true)
+//    }) @ApiParam(value = "监控信息", required = true) @RequestBody Map<String, Object> mapParameter) {
+//        if (Objects.isNull(mapParameter.get("recordId")) || Objects.equals(mapParameter.get("recordId"), "")) {
+//            throw new BusinessException(ExceptionResultEnum.RECORD_ID_IS_NULL);
+//        }
+//        Long recordId = null;
+//        try {
+//            recordId = Long.parseLong(String.valueOf(mapParameter.get("recordId")));
+//            if (Objects.isNull(mapParameter.get("source")) || Objects.equals(mapParameter.get("source"), "")) {
+//                throw new BusinessException("监考视频源不能为空");
+//            }
+//            MonitorVideoSourceEnum source = MonitorVideoSourceEnum.valueOf(String.valueOf(mapParameter.get("source")).toUpperCase());
+//            if (Objects.isNull(mapParameter.get("liveUrl")) || Objects.equals(mapParameter.get("liveUrl"), "")) {
+//                throw new BusinessException("观看地址不能为空");
+//            }
+//            String liveUrl = String.valueOf(mapParameter.get("liveUrl"));
+//            String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
+//            TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.INIT, monitorKey,null);
+//            //获取考试记录缓存
+//            ExamRecordCacheUtil.setMonitorLiveUrl(recordId, source, liveUrl, false);
+//            ExamRecordCacheUtil.setMonitorStatus(recordId, source, tIeExamInvigilateCallLog.getStatus(), false);
+//            String[] columns = new String[]{ExamRecordFieldEnum.monitor_live_url.name(), ExamRecordFieldEnum.monitor_status_source.name()};
+//            Object[] values = new Object[]{liveUrl, tIeExamInvigilateCallLog.getStatus()};
+//            tOeExamRecordService.dataUpdatesMq(recordId, columns, values);
+//
+//            //监考监控通话信息 发送mq start
+//            MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
+//            mqDtoService.assembleSendOneWayMsg(mqDto);
+//            //监考监控通话信息 发送mq end
+//        } catch (Exception e) {
+//            log.error("请求出错", e);
+//            if (e instanceof DuplicateKeyException) {
+//                String errorColumn = e.getCause().toString();
+//                String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
+//                throw new BusinessException("考试记录id[" + recordId + "]下的" + FieldUniqueEnum.convertToCode(columnStr) + "数据不允许重复插入");
+//            } else if (e instanceof BusinessException) {
+//                throw new BusinessException(e.getMessage());
+//            } else {
+//                throw new RuntimeException(e);
+//            }
+//        }
+//        return ResultUtil.ok(Collections.singletonMap("updateTime", System.currentTimeMillis()));
+//    }
 
     @ApiOperation(value = "监控状态更新接口")
     @RequestMapping(value = "/status", method = RequestMethod.POST)
@@ -133,13 +132,12 @@ public class TIeInvigilateCallOeController {
             throw new BusinessException("异常类型不能为空");
         }
         //获取考试记录缓存
-        String liveUrl = Objects.nonNull(ExamRecordCacheUtil.getMonitorLiveUrl(recordId, source)) ? ExamRecordCacheUtil.getMonitorLiveUrl(recordId, source) : null;
+        String liveUrl = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + source.name().toLowerCase();
         MonitorCallStatusSourceEnum callStatus = Objects.nonNull(ExamRecordCacheUtil.getMonitorCallStatus(recordId, source)) ? ExamRecordCacheUtil.getMonitorCallStatus(recordId, source) : null;
         ExamRecordCacheUtil.setMonitorStatus(recordId, source, status, true);
         ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, callStatus);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
-        String streamName = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + ExamRecordCacheUtil.getMonitorVideoSource(recordId);
-        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.START, monitorKey, callStatus, streamName);
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.START, monitorKey, callStatus);
         if (Objects.nonNull(mapParameter.get("type")) && !Objects.equals(mapParameter.get("type"), "")) {
             tIeExamInvigilateCallLog.setType(ExceptionEnum.valueOf(String.valueOf(mapParameter.get("type"))));
         }
@@ -166,12 +164,8 @@ public class TIeInvigilateCallOeController {
         }
         Long recordId = Long.parseLong(String.valueOf(mapParameter.get("recordId")));
         //获取考试记录缓存
-        String liveUrl = null;
-        MonitorVideoSourceEnum source = null;
-        if (Objects.nonNull(ExamRecordCacheUtil.getMonitorLiveUrlClientCamera(recordId))) {
-            source = MonitorVideoSourceEnum.CLIENT_CAMERA;
-            liveUrl = ExamRecordCacheUtil.getMonitorLiveUrlClientCamera(recordId);
-        }
+        MonitorVideoSourceEnum source = MonitorVideoSourceEnum.CLIENT_CAMERA;
+        String liveUrl = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + source.name().toLowerCase();
         if (Objects.isNull(source) || Objects.isNull(ExamRecordCacheUtil.getMonitorStatus(recordId, source))) {
             throw new BusinessException("推流状态为空");
         }
@@ -181,8 +175,7 @@ public class TIeInvigilateCallOeController {
         }
         ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, MonitorCallStatusSourceEnum.START);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
-        String streamName = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + ExamRecordCacheUtil.getMonitorVideoSource(recordId);
-        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.START, streamName);
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.START);
         tIeExamInvigilateCallLog.setStartTime(System.currentTimeMillis());
         //监考监控通话信息 发送mq start
         MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
@@ -203,12 +196,8 @@ public class TIeInvigilateCallOeController {
         }
         Long recordId = Long.parseLong(String.valueOf(mapParameter.get("recordId")));
         //获取考试记录缓存
-        String liveUrl = null;
-        MonitorVideoSourceEnum source = null;
-        if (Objects.nonNull(ExamRecordCacheUtil.getMonitorLiveUrlClientCamera(recordId))) {
-            source = MonitorVideoSourceEnum.CLIENT_CAMERA;
-            liveUrl = ExamRecordCacheUtil.getMonitorLiveUrlClientCamera(recordId);
-        }
+        MonitorVideoSourceEnum source = MonitorVideoSourceEnum.CLIENT_CAMERA;
+        String liveUrl = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + source.name().toLowerCase();
         ExamRecordStatusEnum statusEnum = ExamRecordCacheUtil.getStatus(recordId);
         if (Objects.isNull(statusEnum) || Objects.equals(statusEnum, ExamRecordStatusEnum.FINISHED) || Objects.equals(statusEnum, ExamRecordStatusEnum.PERSISTED)) {
             return ResultUtil.ok(Collections.singletonMap("updateTime", System.currentTimeMillis()));
@@ -218,8 +207,7 @@ public class TIeInvigilateCallOeController {
         MonitorStatusSourceEnum status = ExamRecordCacheUtil.getMonitorStatus(recordId, source);
         ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, MonitorCallStatusSourceEnum.STOP);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
-        String streamName = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + ExamRecordCacheUtil.getMonitorVideoSource(recordId);
-        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.STOP, streamName);
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.STOP);
         tIeExamInvigilateCallLog.setEndTime(System.currentTimeMillis());
         //监考监控通话信息 发送mq start
         MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());