Explorar el Código

移动端接口

wangliang hace 4 años
padre
commit
57404ee399

+ 13 - 0
themis-business/src/main/java/com/qmth/themis/business/entity/TIeExamInvigilateCall.java

@@ -2,6 +2,7 @@ package com.qmth.themis.business.entity;
 
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.qmth.themis.business.base.BaseEntity;
+import com.qmth.themis.business.enums.ExceptionEnum;
 import com.qmth.themis.business.enums.MonitorStatusSourceEnum;
 import com.qmth.themis.business.enums.MonitorVideoSourceEnum;
 import com.qmth.themis.common.contanst.Constants;
@@ -46,6 +47,10 @@ public class TIeExamInvigilateCall extends BaseEntity {
     @TableField(value = "status")
     private MonitorStatusSourceEnum status;
 
+    @ApiModelProperty(value = "异常类型")
+    @TableField(value = "type")
+    private ExceptionEnum type;
+
     public TIeExamInvigilateCall() {
 
     }
@@ -58,6 +63,14 @@ public class TIeExamInvigilateCall extends BaseEntity {
         this.status = status;
     }
 
+    public ExceptionEnum getType() {
+        return type;
+    }
+
+    public void setType(ExceptionEnum type) {
+        this.type = type;
+    }
+
     public Long getExamRecordId() {
         return examRecordId;
     }

+ 47 - 3
themis-exam/src/main/java/com/qmth/themis/exam/api/TIeInvigilateCallMobileController.java

@@ -47,9 +47,6 @@ public class TIeInvigilateCallMobileController {
     @Resource
     MqDtoService mqDtoService;
 
-    @Resource
-    TIeExamInvigilateCallService tIeExamInvigilateCallService;
-
     @ApiOperation(value = "监控观看地址更新接口")
     @RequestMapping(value = "/live_url", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
@@ -132,6 +129,53 @@ public class TIeInvigilateCallMobileController {
         return ResultUtil.ok(SystemConstant.SUCCESS);
     }
 
+    @ApiOperation(value = "监控状态更新接口")
+    @RequestMapping(value = "/status", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    @Transactional
+    public Result status(@ApiJsonObject(name = "statusMobile", value = {
+            @ApiJsonProperty(key = "recordId", type = "long", example = "1", description = "考试记录id", required = true),
+            @ApiJsonProperty(key = "source", description = "监考视频源", required = true),
+            @ApiJsonProperty(key = "status", description = "当前状态", required = true),
+            @ApiJsonProperty(key = "type", description = "异常类型,status=stop时需要传递")
+    }) @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 = 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("status")) || Objects.equals(mapParameter.get("status"), "")) {
+            throw new BusinessException("监考视频状态不能为空");
+        }
+        MonitorStatusSourceEnum status = (MonitorStatusSourceEnum) mapParameter.get("status");
+        if (Objects.equals(status, MonitorStatusSourceEnum.STOP.name()) && (Objects.isNull(mapParameter.get("type")) || Objects.equals(mapParameter.get("type"), ""))) {
+            throw new BusinessException("异常类型不能为空");
+        }
+        //获取考试记录缓存
+        Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examRecordCacheKey(recordId));
+        String liveUrl = null;
+        if (Objects.nonNull(objectMap.get(SystemConstant.MONITOR_LIVE_URL_ + MonitorVideoSourceEnum.MOBILE_FIRST.name()))) {
+            liveUrl = String.valueOf(objectMap.get(SystemConstant.MONITOR_LIVE_URL_ + MonitorVideoSourceEnum.MOBILE_FIRST.name()));
+        } else if (Objects.nonNull(objectMap.get(SystemConstant.MONITOR_LIVE_URL_ + MonitorVideoSourceEnum.MOBILE_SECOND.name()))) {
+            liveUrl = String.valueOf(objectMap.get(SystemConstant.MONITOR_LIVE_URL_ + MonitorVideoSourceEnum.MOBILE_SECOND.name()));
+        }
+        objectMap.put(SystemConstant.MONITOR_STATUS_ + source, status);
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.START);
+        if (Objects.nonNull(mapParameter.get("type")) || !Objects.equals(mapParameter.get("type"), "")) {
+            tIeExamInvigilateCallLog.setType((ExceptionEnum) mapParameter.get("type"));
+        }
+        redisUtil.setForHash(RedisKeyHelper.examRecordCacheKey(recordId), objectMap);
+
+        //监考监控通话信息 发送mq start
+        MqDto mqDto = new MqDto(MqTopicEnum.themisTopic.getCode(), MqTagEnum.monitorLog.name(), tIeExamInvigilateCallLog, MqTagEnum.monitorLog, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
+        mqDtoService.assembleSendOneWayMsg(mqDto);
+        //监考监控通话信息 发送mq end
+        return ResultUtil.ok(SystemConstant.SUCCESS);
+    }
+
     @ApiOperation(value = "撤销通话申请接口")
     @RequestMapping(value = "/call/cancel", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})

+ 48 - 4
themis-exam/src/main/java/com/qmth/themis/exam/api/TIeInvigilateCallOeController.java

@@ -35,7 +35,7 @@ import java.util.Objects;
  * @Author: wangliang
  * @Date: 2020/6/25
  */
-@Api(tags = "mobile监考监控通话信息Controller")
+@Api(tags = "oe监考监控通话信息Controller")
 @RestController
 @RequestMapping("/${prefix.url.exam}/monitor")
 public class TIeInvigilateCallOeController {
@@ -47,9 +47,6 @@ public class TIeInvigilateCallOeController {
     @Resource
     MqDtoService mqDtoService;
 
-    @Resource
-    TIeExamInvigilateCallService tIeExamInvigilateCallService;
-
     @ApiOperation(value = "监控观看地址更新接口")
     @RequestMapping(value = "/live_url", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
@@ -99,6 +96,53 @@ public class TIeInvigilateCallOeController {
         return ResultUtil.ok(SystemConstant.SUCCESS);
     }
 
+    @ApiOperation(value = "监控状态更新接口")
+    @RequestMapping(value = "/status", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    @Transactional
+    public Result status(@ApiJsonObject(name = "statusOe", value = {
+            @ApiJsonProperty(key = "recordId", type = "long", example = "1", description = "考试记录id", required = true),
+            @ApiJsonProperty(key = "source", description = "监考视频源", required = true),
+            @ApiJsonProperty(key = "status", description = "当前状态", required = true),
+            @ApiJsonProperty(key = "type", description = "异常类型,status=stop时需要传递")
+    }) @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 = 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("status")) || Objects.equals(mapParameter.get("status"), "")) {
+            throw new BusinessException("监考视频状态不能为空");
+        }
+        MonitorStatusSourceEnum status = (MonitorStatusSourceEnum) mapParameter.get("status");
+        if (Objects.equals(status, MonitorStatusSourceEnum.STOP.name()) && (Objects.isNull(mapParameter.get("type")) || Objects.equals(mapParameter.get("type"), ""))) {
+            throw new BusinessException("异常类型不能为空");
+        }
+        //获取考试记录缓存
+        Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examRecordCacheKey(recordId));
+        String liveUrl = null;
+        if (Objects.nonNull(objectMap.get(SystemConstant.MONITOR_LIVE_URL_ + MonitorVideoSourceEnum.CLIENT_CAMERA.name()))) {
+            liveUrl = String.valueOf(objectMap.get(SystemConstant.MONITOR_LIVE_URL_ + MonitorVideoSourceEnum.CLIENT_CAMERA.name()));
+        } else if (Objects.nonNull(objectMap.get(SystemConstant.MONITOR_LIVE_URL_ + MonitorVideoSourceEnum.CLIENT_SCREEN.name()))) {
+            liveUrl = String.valueOf(objectMap.get(SystemConstant.MONITOR_LIVE_URL_ + MonitorVideoSourceEnum.CLIENT_SCREEN.name()));
+        }
+        objectMap.put(SystemConstant.MONITOR_STATUS_ + source, status);
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.START);
+        if (Objects.nonNull(mapParameter.get("type")) || !Objects.equals(mapParameter.get("type"), "")) {
+            tIeExamInvigilateCallLog.setType((ExceptionEnum) mapParameter.get("type"));
+        }
+        redisUtil.setForHash(RedisKeyHelper.examRecordCacheKey(recordId), objectMap);
+
+        //监考监控通话信息 发送mq start
+        MqDto mqDto = new MqDto(MqTopicEnum.themisTopic.getCode(), MqTagEnum.monitorLog.name(), tIeExamInvigilateCallLog, MqTagEnum.monitorLog, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
+        mqDtoService.assembleSendOneWayMsg(mqDto);
+        //监考监控通话信息 发送mq end
+        return ResultUtil.ok(SystemConstant.SUCCESS);
+    }
+
     @ApiOperation(value = "发送通话申请接口")
     @RequestMapping(value = "/call/apply", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})

+ 1 - 1
themis-exam/src/main/resources/application.properties

@@ -150,4 +150,4 @@ wxapp.upload.url=http://wxapp2.qmth.com.cn
 
 #\u65E0\u9700\u9274\u6743\u7684url
 no.auth.urls=/webjars/**,/druid/**,/swagger-ui.html,/doc.html,/swagger-resources/**,/v2/api-docs,/webjars/springfox-swagger-ui/**,/api/oe/student/login,/api/oe/sys/env,/file/**,/upload/**,/client/**,/base_photo/**,/frontend/**,/api/oe/exam/short_code,/api/oe/monitor/live_url,/api/oe/monitor/call/apply,/api/oe/monitor/call/cancel,/api/mobile/monitor/live_url,/api/mobile/monitor/call/apply,/api/mobile/monitor/call/cancel,/api/mobile/authorization
-common.system.urls=/api/oe/student/logout,/api/oe/exam/file/upload,/api/oe/qrcode/mobile_monitor,/api/oe/qrcode/photo_upload,/api/oe/qrcode/audio_upload
+common.system.urls=/api/oe/student/logout,/api/oe/exam/file/upload