|
@@ -14,11 +14,9 @@ import com.qmth.themis.common.exception.BusinessException;
|
|
import com.qmth.themis.common.util.Result;
|
|
import com.qmth.themis.common.util.Result;
|
|
import com.qmth.themis.common.util.ResultUtil;
|
|
import com.qmth.themis.common.util.ResultUtil;
|
|
import com.qmth.themis.exam.config.DictionaryConfig;
|
|
import com.qmth.themis.exam.config.DictionaryConfig;
|
|
-import com.qmth.themis.exam.websocket.WebSocketMobileServer;
|
|
|
|
import io.swagger.annotations.*;
|
|
import io.swagger.annotations.*;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
-import org.springframework.dao.DuplicateKeyException;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -30,7 +28,6 @@ import java.util.Collections;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
-import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description: mobile监考监控通话信息 前端控制器
|
|
* @Description: mobile监考监控通话信息 前端控制器
|
|
@@ -54,58 +51,58 @@ public class TIeInvigilateCallMobileController {
|
|
@Resource
|
|
@Resource
|
|
DictionaryConfig dictionaryConfig;
|
|
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 = "发送通话申请接口")
|
|
@ApiOperation(value = "发送通话申请接口")
|
|
@RequestMapping(value = "/call/apply", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/call/apply", method = RequestMethod.POST)
|
|
@@ -124,7 +121,6 @@ public class TIeInvigilateCallMobileController {
|
|
}
|
|
}
|
|
MonitorVideoSourceEnum source = MonitorVideoSourceEnum.valueOf(String.valueOf(mapParameter.get("source")));
|
|
MonitorVideoSourceEnum source = MonitorVideoSourceEnum.valueOf(String.valueOf(mapParameter.get("source")));
|
|
//获取考试记录缓存
|
|
//获取考试记录缓存
|
|
- String liveUrl = null;
|
|
|
|
if (Objects.isNull(source) || Objects.isNull(ExamRecordCacheUtil.getMonitorStatus(recordId, source))) {
|
|
if (Objects.isNull(source) || Objects.isNull(ExamRecordCacheUtil.getMonitorStatus(recordId, source))) {
|
|
throw new BusinessException("推流状态为空");
|
|
throw new BusinessException("推流状态为空");
|
|
}
|
|
}
|
|
@@ -132,10 +128,10 @@ public class TIeInvigilateCallMobileController {
|
|
if (!Objects.equals(status, MonitorStatusSourceEnum.START)) {
|
|
if (!Objects.equals(status, MonitorStatusSourceEnum.START)) {
|
|
throw new BusinessException("推流状态不正常");
|
|
throw new BusinessException("推流状态不正常");
|
|
}
|
|
}
|
|
|
|
+ String liveUrl = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + source.name().toLowerCase();
|
|
ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, MonitorCallStatusSourceEnum.START);
|
|
ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, MonitorCallStatusSourceEnum.START);
|
|
String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
|
|
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());
|
|
tIeExamInvigilateCallLog.setStartTime(System.currentTimeMillis());
|
|
//监考监控通话信息 发送mq start
|
|
//监考监控通话信息 发送mq start
|
|
MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
|
|
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("异常类型不能为空");
|
|
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;
|
|
MonitorCallStatusSourceEnum callStatus = Objects.nonNull(ExamRecordCacheUtil.getMonitorCallStatus(recordId, source)) ? ExamRecordCacheUtil.getMonitorCallStatus(recordId, source) : null;
|
|
ExamRecordCacheUtil.setMonitorStatus(recordId, source, status, true);
|
|
ExamRecordCacheUtil.setMonitorStatus(recordId, source, status, true);
|
|
ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, callStatus);
|
|
ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, callStatus);
|
|
String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
|
|
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"), "")) {
|
|
if (Objects.nonNull(mapParameter.get("type")) && !Objects.equals(mapParameter.get("type"), "")) {
|
|
tIeExamInvigilateCallLog.setType(ExceptionEnum.valueOf(String.valueOf(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")));
|
|
MonitorVideoSourceEnum source = MonitorVideoSourceEnum.valueOf(String.valueOf(mapParameter.get("source")));
|
|
//获取考试记录缓存
|
|
//获取考试记录缓存
|
|
- String liveUrl = null;
|
|
|
|
ExamRecordStatusEnum statusEnum = ExamRecordCacheUtil.getStatus(recordId);
|
|
ExamRecordStatusEnum statusEnum = ExamRecordCacheUtil.getStatus(recordId);
|
|
if (Objects.isNull(statusEnum) || Objects.equals(statusEnum, ExamRecordStatusEnum.FINISHED) || Objects.equals(statusEnum, ExamRecordStatusEnum.PERSISTED)) {
|
|
if (Objects.isNull(statusEnum) || Objects.equals(statusEnum, ExamRecordStatusEnum.FINISHED) || Objects.equals(statusEnum, ExamRecordStatusEnum.PERSISTED)) {
|
|
return ResultUtil.ok(Collections.singletonMap("updateTime", System.currentTimeMillis()));
|
|
return ResultUtil.ok(Collections.singletonMap("updateTime", System.currentTimeMillis()));
|
|
} else if (Objects.isNull(ExamRecordCacheUtil.getMonitorStatus(recordId, source))) {
|
|
} else if (Objects.isNull(ExamRecordCacheUtil.getMonitorStatus(recordId, source))) {
|
|
throw new BusinessException("推流状态为空");
|
|
throw new BusinessException("推流状态为空");
|
|
}
|
|
}
|
|
|
|
+ String liveUrl = dictionaryConfig.monitorDomain().getPrefix() + "_" + recordId + "_" + source.name().toLowerCase();
|
|
ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, MonitorCallStatusSourceEnum.STOP);
|
|
ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, MonitorCallStatusSourceEnum.STOP);
|
|
String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
|
|
String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
|
|
MonitorStatusSourceEnum status = ExamRecordCacheUtil.getMonitorStatus(recordId, source);
|
|
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());
|
|
tIeExamInvigilateCallLog.setEndTime(System.currentTimeMillis());
|
|
//监考监控通话信息 发送mq start
|
|
//监考监控通话信息 发送mq start
|
|
MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
|
|
MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
|