Переглянути джерело

视频通话记录监听回调

wangliang 1 рік тому
батько
коміт
67bbaa727d

+ 50 - 16
themis-admin/src/main/java/com/qmth/themis/admin/api/TENotifyController.java

@@ -4,14 +4,12 @@ import com.alibaba.fastjson.JSONObject;
 import com.qmth.themis.business.bean.admin.TencentEventBean;
 import com.qmth.themis.business.bean.status.MonitorStatusBean;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
+import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.MqDto;
 import com.qmth.themis.business.entity.*;
 import com.qmth.themis.business.enums.*;
-import com.qmth.themis.business.service.ThemisCacheService;
-import com.qmth.themis.business.service.MqDtoService;
-import com.qmth.themis.business.service.TMTencentVideoMessageService;
-import com.qmth.themis.business.service.TOeExamRecordService;
+import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.util.MqUtil;
 import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.business.util.ServletUtil;
@@ -77,6 +75,9 @@ public class TENotifyController {
     @Resource
     ThemisCacheService themisCacheService;
 
+    @Resource
+    TEExamService teExamService;
+
     @ApiOperation(value = "腾讯云视频接口回调")
     @RequestMapping(value = "/record/tencent", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "结果信息")})
@@ -161,11 +162,11 @@ public class TENotifyController {
             Platform platform = null;
             Source source = null;
             //s是客户端和移动端,m是监控端
-            if (Objects.equals(userIds[0], "s")) {
-                tbSession = (TBSession) redisUtil.getUserSession(sessionId);
-                platform = Platform.valueOf(tbSession.getPlatform());
-                source = Source.valueOf(tbSession.getSource());
-            }
+//            if (Objects.equals(userIds[0], "s")) {
+            tbSession = (TBSession) redisUtil.getUserSession(sessionId);
+            platform = Platform.valueOf(tbSession.getPlatform());
+            source = Source.valueOf(tbSession.getSource());
+//            }
             String monitorRecord = ExamRecordCacheUtil.getMonitorVideoSource(recordId);
             if (Objects.isNull(monitorRecord)) {
                 TOeExamRecord tOeExamRecord = SystemConstant.getExamRecord(recordId);
@@ -177,10 +178,18 @@ public class TENotifyController {
                 case EVENT_GROUP_ROOM://房间事件组
                     switch (tencentEventTypeEnum) {
                         case EVENT_TYPE_ENTER_ROOM://进入房间
-                            this.startLogic(userIds[0], source, platform, recordId, monitorRecordMap, eventTime);
+                            if (Objects.equals(userIds[0], "s")) {
+                                this.startLogic(userIds[0], source, platform, recordId, monitorRecordMap, eventTime);
+                            } else if (Objects.equals(userIds[0], "m")) {
+                                this.updateInvigilateCallLog(recordId, MonitorCallStatusSourceEnum.CALLING, eventTime);
+                            }
                             break;
                         case EVENT_TYPE_EXIT_ROOM://退出房间
-                            this.stopLogic(userIds[0], source, platform, recordId, monitorRecordMap, eventTime);
+                            if (Objects.equals(userIds[0], "s")) {
+                                this.stopLogic(userIds[0], source, platform, recordId, monitorRecordMap, eventTime);
+                            } else if (Objects.equals(userIds[0], "m")) {
+                                this.updateInvigilateCallLog(recordId, MonitorCallStatusSourceEnum.STOP, eventTime);
+                            }
                             break;
                         default:
                             break;
@@ -309,18 +318,43 @@ public class TENotifyController {
         ExamRecordCacheUtil.setMonitorStatus(recordId, MonitorVideoSourceEnum.valueOf(source), monitorStatusSourceEnum, eventTime);
         MonitorCallStatusSourceEnum callStatus = Objects.nonNull(ExamRecordCacheUtil.getMonitorCallStatus(recordId, MonitorVideoSourceEnum.valueOf(source))) ? ExamRecordCacheUtil.getMonitorCallStatus(recordId, MonitorVideoSourceEnum.valueOf(source)) : null;
         ExamRecordCacheUtil.setMonitorCallStatus(recordId, MonitorVideoSourceEnum.valueOf(source), callStatus, eventTime);
+    }
 
+    /**
+     * 更新通话记录log
+     *
+     * @param recordId
+     * @param callStatus
+     * @param eventTime
+     */
+    protected void updateInvigilateCallLog(Long recordId, MonitorCallStatusSourceEnum callStatus, Long eventTime) {
         SysConfig sysConfig = themisCacheService.addSysConfigCache(SystemConstant.MONITOR_CONFIG_PREFIX);
         Optional.ofNullable(sysConfig).orElseThrow(() -> new BusinessException("未配置监控前缀"));
-
-        String liveUrl = SystemConstant.setStreamId(sysConfig.getConfigValue(), recordId, MonitorVideoSourceEnum.valueOf(source));
+        ExamCacheBean examCacheBean = teExamService.getExamCacheBean(ExamRecordCacheUtil.getExamId(recordId));
+        String monitorVideoSource = examCacheBean.getMonitorVideoSource();
+        MonitorVideoSourceEnum source = null;
+        if (Objects.nonNull(monitorVideoSource) && (!monitorVideoSource.toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_SCREEN.name())
+                && !monitorVideoSource.toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_CAMERA.name())
+                && monitorVideoSource.toUpperCase().contains(MonitorVideoSourceEnum.MOBILE_FIRST.name()))) {
+            source = MonitorVideoSourceEnum.MOBILE_FIRST;
+        } else if (Objects.nonNull(monitorVideoSource) && (monitorVideoSource.toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_SCREEN.name())
+                || monitorVideoSource.toUpperCase()
+                .contains(MonitorVideoSourceEnum.CLIENT_CAMERA.name()))) {
+            source = MonitorVideoSourceEnum.CLIENT_CAMERA;
+        }
+        String liveUrl = SystemConstant.setStreamId(sysConfig.getConfigValue(), recordId, source);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
-        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, MonitorVideoSourceEnum.valueOf(source), liveUrl, MonitorStatusSourceEnum.START, monitorKey, callStatus);
-
+//        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.START, monitorKey, callStatus, null, null, ExamInvigilateCallCacheUtil.getBatchId(recordId));
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.START, monitorKey, callStatus, null, null);
+        if (callStatus == MonitorCallStatusSourceEnum.CALLING) {
+            tIeExamInvigilateCallLog.setStartTime(eventTime);
+        } else if (callStatus == MonitorCallStatusSourceEnum.STOP) {
+            tIeExamInvigilateCallLog.setEndTime(eventTime);
+        }
         tOeExamRecordService.sendExamRecordDataSaveMqNotIp(recordId, eventTime);
 
         //监考监控通话信息 发送mq start
-        MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), MonitorVideoSourceEnum.valueOf(source).name());
+        MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
         mqDtoService.assembleSendAsyncMsg(mqDto);
         //监考监控通话信息 发送mq end
     }

+ 40 - 4
themis-admin/src/main/java/com/qmth/themis/admin/api/TIeInvigilateCallMobileController.java

@@ -8,6 +8,7 @@ import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.bean.mobile.MobileAuthorizationMonitorBean;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
+import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.AuthDto;
@@ -79,6 +80,9 @@ public class TIeInvigilateCallMobileController {
     @Resource
     ThemisCacheService themisCacheService;
 
+    @Resource
+    TEExamService teExamService;
+
     @ApiOperation(value = "监考监控通话查询接口")
     @RequestMapping(value = "/call/list", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "监考监控信息", response = TIeExamInvigilateCallDto.class)})
@@ -220,8 +224,9 @@ public class TIeInvigilateCallMobileController {
         tOeExamRecordService.sendExamRecordDataSaveMq(recordId, timestamp);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
         MonitorStatusSourceEnum status = ExamRecordCacheUtil.getMonitorStatus(recordId, source);
-        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl,
-                status, monitorKey, MonitorCallStatusSourceEnum.CALLING);
+        TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
+//        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.CALLING, ExamRecordCacheUtil.getExamStudentId(recordId), tbUser.getId(), ExamInvigilateCallCacheUtil.getBatchId(recordId));
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.CALLING, ExamRecordCacheUtil.getExamStudentId(recordId), tbUser.getId());
         //监考监控通话信息 发送mq start
         MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.MONITOR_LOG.name(),
                 tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()),
@@ -279,8 +284,9 @@ public class TIeInvigilateCallMobileController {
         tOeExamRecordService.sendExamRecordDataSaveMq(recordId, timestamp);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
         MonitorStatusSourceEnum status = ExamRecordCacheUtil.getMonitorStatus(recordId, source);
-        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl,
-                status, monitorKey, MonitorCallStatusSourceEnum.STOP);
+        TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
+//        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.STOP, ExamRecordCacheUtil.getExamStudentId(recordId), tbUser.getId(), ExamInvigilateCallCacheUtil.getBatchId(recordId));
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.STOP, ExamRecordCacheUtil.getExamStudentId(recordId), tbUser.getId());
         tIeExamInvigilateCallLog.setEndTime(System.currentTimeMillis());
         //监考监控通话信息 发送mq start
         MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.MONITOR_LOG.name(),
@@ -310,6 +316,36 @@ public class TIeInvigilateCallMobileController {
         map.put("monitorUserSig", monitorUserSig);
         map.put("appId", tencentYunUtil.getAppId());
         map.put("key", tencentYunUtil.getKey());
+
+        TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
+        ExamCacheBean examCacheBean = teExamService.getExamCacheBean(ExamRecordCacheUtil.getExamId(recordId));
+        String monitorVideoSource = examCacheBean.getMonitorVideoSource();
+        MonitorVideoSourceEnum source = null;
+        if (Objects.nonNull(monitorVideoSource) && (!monitorVideoSource.toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_SCREEN.name())
+                && !monitorVideoSource.toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_CAMERA.name())
+                && monitorVideoSource.toUpperCase().contains(MonitorVideoSourceEnum.MOBILE_FIRST.name()))) {
+            source = MonitorVideoSourceEnum.MOBILE_FIRST;
+        } else if (Objects.nonNull(monitorVideoSource) && (monitorVideoSource.toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_SCREEN.name())
+                || monitorVideoSource.toUpperCase()
+                .contains(MonitorVideoSourceEnum.CLIENT_CAMERA.name()))) {
+            source = MonitorVideoSourceEnum.CLIENT_CAMERA;
+        }
+        SysConfig sysConfig = themisCacheService.addSysConfigCache(SystemConstant.MONITOR_CONFIG_PREFIX);
+        Optional.ofNullable(sysConfig).orElseThrow(() -> new BusinessException("未配置监控前缀"));
+        String liveUrl = SystemConstant.setStreamId(sysConfig.getConfigValue(), recordId, source);
+//        String batchId = ExamInvigilateCallCacheUtil.getBatchId(recordId);
+//        if (Objects.isNull(batchId)) {
+//            batchId = SystemConstant.getNanoId();
+//            ExamInvigilateCallCacheUtil.expire(recordId, batchId);
+//        }
+//        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.START, monitorKey, MonitorCallStatusSourceEnum.START, tbUser.getId(), ExamRecordCacheUtil.getExamStudentId(recordId), batchId);
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.START, monitorKey, MonitorCallStatusSourceEnum.START, tbUser.getId(), ExamRecordCacheUtil.getExamStudentId(recordId));
+        tIeExamInvigilateCallLog.setStartTime(System.currentTimeMillis());
+
+        //监考监控通话信息 发送mq start
+        MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
+        mqDtoService.assembleSendAsyncMsg(mqDto);
+        //监考监控通话信息 发送mq end
         return ResultUtil.ok(map);
     }
 

+ 34 - 0
themis-business/src/main/java/com/qmth/themis/business/cache/ExamInvigilateCallCacheUtil.java

@@ -0,0 +1,34 @@
+//package com.qmth.themis.business.cache;
+//
+//import com.qmth.themis.business.constant.SpringContextHolder;
+//import com.qmth.themis.business.util.RedisUtil;
+//
+//import java.util.HashMap;
+//import java.util.Map;
+//import java.util.concurrent.TimeUnit;
+//
+///**
+// * @Description: 监考通话缓存
+// * @Param:
+// * @return:
+// * @Author: wangliang
+// * @Date: 2023/10/25
+// */
+//public class ExamInvigilateCallCacheUtil {
+//    private static RedisUtil redisUtil = SpringContextHolder.getBean(RedisUtil.class);
+//
+//    public static void setBatchId(Long examRecordId, String batchId) {
+//        redisUtil.set(RedisKeyHelper.examInvigilateCallCacheKey(examRecordId), "batchId", batchId);
+//    }
+//
+//    public static String getBatchId(Long examRecordId) {
+//        return (String) redisUtil.get(RedisKeyHelper.examInvigilateCallCacheKey(examRecordId), "batchId");
+//    }
+//
+//    public static void expire(Long examRecordId, String batchId) {
+//        Map<String, Object> map = new HashMap<>();
+//        map.put("batchId", batchId);
+//        redisUtil.setForHash(RedisKeyHelper.examInvigilateCallCacheKey(examRecordId), map);
+//        redisUtil.expire(RedisKeyHelper.examInvigilateCallCacheKey(examRecordId), 5L, TimeUnit.HOURS);//5小时过期
+//    }
+//}

+ 16 - 1
themis-business/src/main/java/com/qmth/themis/business/cache/RedisKeyHelper.java

@@ -77,6 +77,11 @@ public class RedisKeyHelper {
      */
     private static String objectiveAnswerHashKeyPrefix = "paper_id_";
 
+    /**
+     * 监考通话
+     */
+    private static String examInvigilateCallCachePrefix = "exam_invigilate_call:";
+
     /**
      * 场次
      *
@@ -250,6 +255,16 @@ public class RedisKeyHelper {
      * @return
      */
     public static String studentCacheKey(Long studentId) {
-        return SystemConstant.studentAccount + ":" +studentId;
+        return SystemConstant.studentAccount + ":" + studentId;
+    }
+
+    /**
+     * 监考通话缓存大key
+     *
+     * @param id
+     * @return
+     */
+    public static String examInvigilateCallCacheKey(Long id) {
+        return examInvigilateCallCachePrefix + id;
     }
 }

+ 54 - 10
themis-business/src/main/java/com/qmth/themis/business/entity/TIeExamInvigilateCall.java

@@ -78,19 +78,63 @@ public class TIeExamInvigilateCall extends BaseEntity {
     @TableField(exist = false)
     private String sourceUserId;
 
-    public TIeExamInvigilateCall() {
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "发送人id")
+    private Long formUserId;
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "接收人id")
+    private Long receiveUserId;
+
+    @ApiModelProperty(value = "发送人名称")
+    @TableField(exist = false)
+    private String formUserName;
+
+    @ApiModelProperty(value = "接收人名称")
+    @TableField(exist = false)
+    private String receiveUserName;
 
+//    @ApiModelProperty(value = "批次id")
+//    private String batchId;
+//
+//    public String getBatchId() {
+//        return batchId;
+//    }
+//
+//    public void setBatchId(String batchId) {
+//        this.batchId = batchId;
+//    }
+
+    public String getFormUserName() {
+        return formUserName;
     }
 
-    public TIeExamInvigilateCall(Long examRecordId, MonitorVideoSourceEnum source, String liveUrl,
-                                 MonitorStatusSourceEnum status, String monitorKey
-    ) {
-        setId(UidUtil.nextId());
-        this.examRecordId = examRecordId;
-        this.source = source;
-        this.liveUrl = liveUrl;
-        this.status = status;
-        this.monitorKey = monitorKey;
+    public void setFormUserName(String formUserName) {
+        this.formUserName = formUserName;
+    }
+
+    public String getReceiveUserName() {
+        return receiveUserName;
+    }
+
+    public void setReceiveUserName(String receiveUserName) {
+        this.receiveUserName = receiveUserName;
+    }
+
+    public Long getFormUserId() {
+        return formUserId;
+    }
+
+    public void setFormUserId(Long formUserId) {
+        this.formUserId = formUserId;
+    }
+
+    public Long getReceiveUserId() {
+        return receiveUserId;
+    }
+
+    public void setReceiveUserId(Long receiveUserId) {
+        this.receiveUserId = receiveUserId;
     }
 
     public String getSourceUserId() {

+ 55 - 14
themis-business/src/main/java/com/qmth/themis/business/entity/TIeExamInvigilateCallLog.java

@@ -70,31 +70,31 @@ public class TIeExamInvigilateCallLog extends BaseEntity {
     @TableField(value = "remark")
     private String remark;
 
-    @TableField(exist = false)
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "发送人id")
+    private Long formUserId;
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "接收人id")
+    private Long receiveUserId;
+
+    @TableField(value = "start_time")
     @ApiModelProperty(value = "开始通话时间")
     private Long startTime;
 
-    @TableField(exist = false)
+    @TableField(value = "end_time")
     @ApiModelProperty(value = "结束通话时间")
     private Long endTime;
 
-    public TIeExamInvigilateCallLog() {
+//    @ApiModelProperty(value = "批次id")
+//    private String batchId;
 
-    }
+    public TIeExamInvigilateCallLog() {
 
-    public TIeExamInvigilateCallLog(Long examRecordId, MonitorVideoSourceEnum source, String liveUrl,
-                                    MonitorStatusSourceEnum status, String monitorKey
-    ) {
-        setId(UidUtil.nextId());
-        setExamRecordId(examRecordId);
-        setSource(source);
-        setLiveUrl(liveUrl);
-        setStatus(status);
-        setMonitorKey(monitorKey);
     }
 
     public TIeExamInvigilateCallLog(Long examRecordId, MonitorVideoSourceEnum source, String liveUrl,
-                                    MonitorStatusSourceEnum status, String monitorKey, MonitorCallStatusSourceEnum callStatus
+                                    MonitorStatusSourceEnum status, String monitorKey, MonitorCallStatusSourceEnum callStatus, Long formUserId, Long receiveUserId
     ) {
         setId(UidUtil.nextId());
         setExamRecordId(examRecordId);
@@ -103,6 +103,47 @@ public class TIeExamInvigilateCallLog extends BaseEntity {
         setStatus(status);
         setCallStatus(callStatus);
         setMonitorKey(monitorKey);
+        this.formUserId = formUserId;
+        this.receiveUserId = receiveUserId;
+    }
+//
+//    public TIeExamInvigilateCallLog(Long examRecordId, MonitorVideoSourceEnum source, String liveUrl,
+//                                    MonitorStatusSourceEnum status, String monitorKey, MonitorCallStatusSourceEnum callStatus, Long formUserId, Long receiveUserId, String batchId
+//    ) {
+//        setId(UidUtil.nextId());
+//        setExamRecordId(examRecordId);
+//        setSource(source);
+//        setLiveUrl(liveUrl);
+//        setStatus(status);
+//        setCallStatus(callStatus);
+//        setMonitorKey(monitorKey);
+//        this.formUserId = formUserId;
+//        this.receiveUserId = receiveUserId;
+//        this.batchId = batchId;
+//    }
+
+//    public String getBatchId() {
+//        return batchId;
+//    }
+//
+//    public void setBatchId(String batchId) {
+//        this.batchId = batchId;
+//    }
+
+    public Long getFormUserId() {
+        return formUserId;
+    }
+
+    public void setFormUserId(Long formUserId) {
+        this.formUserId = formUserId;
+    }
+
+    public Long getReceiveUserId() {
+        return receiveUserId;
+    }
+
+    public void setReceiveUserId(Long receiveUserId) {
+        this.receiveUserId = receiveUserId;
     }
 
     public Long getStartTime() {

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

@@ -160,13 +160,13 @@ public class TEExamController {
             }
             ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, updateCallStatus, timestamp);
             tOeExamRecordService.sendExamRecordDataSaveMq(recordId, timestamp);
-            String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
-            TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, updateCallStatus);
-            tIeExamInvigilateCallLog.setEndTime(System.currentTimeMillis());
-            //监考监控通话信息 发送mq start
-            MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
-            mqDtoService.assembleSendAsyncMsg(mqDto);
-            //监考监控通话信息 发送mq end
+//            String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
+//            TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, updateCallStatus, null, null);
+//            tIeExamInvigilateCallLog.setEndTime(System.currentTimeMillis());
+//            //监考监控通话信息 发送mq start
+//            MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
+//            mqDtoService.assembleSendAsyncMsg(mqDto);
+//            //监考监控通话信息 发送mq end
         }
 
         ConcurrentHashMap<String, WebSocketOeServer> webSocketMap = WebSocketOeServer.getWebSocketMap();

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

@@ -9,9 +9,9 @@ import com.qmth.themis.business.entity.SysConfig;
 import com.qmth.themis.business.entity.TIeExamInvigilateCallLog;
 import com.qmth.themis.business.entity.TOeExamRecord;
 import com.qmth.themis.business.enums.*;
-import com.qmth.themis.business.service.ThemisCacheService;
 import com.qmth.themis.business.service.MqDtoService;
 import com.qmth.themis.business.service.TOeExamRecordService;
+import com.qmth.themis.business.service.ThemisCacheService;
 import com.qmth.themis.business.util.MqUtil;
 import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
@@ -159,8 +159,10 @@ public class TIeInvigilateCallMobileController {
         ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, MonitorCallStatusSourceEnum.START, timestamp);
         tOeExamRecordService.sendExamRecordDataSaveMq(recordId, timestamp);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
-        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.START);
+//        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.START, ExamRecordCacheUtil.getExamStudentId(recordId), null, SystemConstant.getNanoId());
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.START, ExamRecordCacheUtil.getExamStudentId(recordId), null);
         tIeExamInvigilateCallLog.setStartTime(System.currentTimeMillis());
+//        ExamInvigilateCallCacheUtil.expire(recordId, tIeExamInvigilateCallLog.getBatchId());
         //监考监控通话信息 发送mq start
         MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
         mqDtoService.assembleSendAsyncMsg(mqDto);
@@ -293,7 +295,8 @@ public class TIeInvigilateCallMobileController {
         tOeExamRecordService.sendExamRecordDataSaveMq(recordId, timestamp);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
         MonitorStatusSourceEnum status = ExamRecordCacheUtil.getMonitorStatus(recordId, source);
-        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.CANCEL);
+//        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.CANCEL, ExamRecordCacheUtil.getExamStudentId(recordId), null, ExamInvigilateCallCacheUtil.getBatchId(recordId));
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.CANCEL, ExamRecordCacheUtil.getExamStudentId(recordId), null);
         tIeExamInvigilateCallLog.setEndTime(System.currentTimeMillis());
         //监考监控通话信息 发送mq start
         MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());

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

@@ -11,9 +11,9 @@ import com.qmth.themis.business.entity.SysConfig;
 import com.qmth.themis.business.entity.TIeExamInvigilateCallLog;
 import com.qmth.themis.business.entity.TOeExamRecord;
 import com.qmth.themis.business.enums.*;
-import com.qmth.themis.business.service.ThemisCacheService;
 import com.qmth.themis.business.service.MqDtoService;
 import com.qmth.themis.business.service.TOeExamRecordService;
+import com.qmth.themis.business.service.ThemisCacheService;
 import com.qmth.themis.business.util.MqUtil;
 import com.qmth.themis.business.util.ServletUtil;
 import com.qmth.themis.common.contanst.Constants;
@@ -171,7 +171,8 @@ public class TIeInvigilateCallOeController {
         ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, callStatus, timestamp);
         tOeExamRecordService.sendExamRecordDataSaveMq(recordId, timestamp);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
-        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.START, monitorKey, callStatus);
+//        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.START, monitorKey, callStatus, null, null, ExamInvigilateCallCacheUtil.getBatchId(recordId));
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, MonitorStatusSourceEnum.START, monitorKey, callStatus, null, null);
         if (Objects.nonNull(mapParameter.get(SystemConstant.TYPE)) && !Objects.equals(mapParameter.get(SystemConstant.TYPE), "")) {
             tIeExamInvigilateCallLog.setType(ExceptionEnum.valueOf(String.valueOf(mapParameter.get(SystemConstant.TYPE))));
         }
@@ -239,8 +240,10 @@ public class TIeInvigilateCallOeController {
         ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, MonitorCallStatusSourceEnum.START, timestamp);
         tOeExamRecordService.sendExamRecordDataSaveMq(recordId, timestamp);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
-        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.START);
+//        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.START, ExamRecordCacheUtil.getExamStudentId(recordId), null, SystemConstant.getNanoId());
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.START, ExamRecordCacheUtil.getExamStudentId(recordId), null);
         tIeExamInvigilateCallLog.setStartTime(System.currentTimeMillis());
+//        ExamInvigilateCallCacheUtil.expire(recordId, tIeExamInvigilateCallLog.getBatchId());
         //监考监控通话信息 发送mq start
         MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());
         mqDtoService.assembleSendAsyncMsg(mqDto);
@@ -301,7 +304,8 @@ public class TIeInvigilateCallOeController {
         ExamRecordCacheUtil.setMonitorCallStatus(recordId, source, MonitorCallStatusSourceEnum.CANCEL, timestamp);
         tOeExamRecordService.sendExamRecordDataSaveMq(recordId, timestamp);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
-        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.CANCEL);
+//        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.CANCEL, ExamRecordCacheUtil.getExamStudentId(recordId), null, ExamInvigilateCallCacheUtil.getBatchId(recordId));
+        TIeExamInvigilateCallLog tIeExamInvigilateCallLog = new TIeExamInvigilateCallLog(recordId, source, liveUrl, status, monitorKey, MonitorCallStatusSourceEnum.CANCEL, ExamRecordCacheUtil.getExamStudentId(recordId), null);
         tIeExamInvigilateCallLog.setEndTime(System.currentTimeMillis());
         //监考监控通话信息 发送mq start
         MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.MONITOR_LOG.name(), tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()), source.name());

+ 19 - 10
themis-mq/src/main/java/com/qmth/themis/mq/service/impl/MqLogicServiceImpl.java

@@ -714,8 +714,7 @@ public class MqLogicServiceImpl implements MqLogicService {
     public void execMqLogLogic(MqDto mqDto, String key) {
         String tag = mqDto.getTag();
         if (Objects.equals(MqTagEnum.MONITOR_LOG.name(), tag)) {//监考日志
-            TIeExamInvigilateCallLog tIeExamInvigilateCallLog = JacksonUtil
-                    .readJson(JacksonUtil.parseJson(mqDto.getBody()), TIeExamInvigilateCallLog.class);
+            TIeExamInvigilateCallLog tIeExamInvigilateCallLog = JacksonUtil.readJson(JacksonUtil.parseJson(mqDto.getBody()), TIeExamInvigilateCallLog.class);
             Long recordId = tIeExamInvigilateCallLog.getExamRecordId();
             Long examId = null, examActivityId = null, examStudentId = null;
             //有缓存则从缓存取
@@ -737,23 +736,29 @@ public class MqLogicServiceImpl implements MqLogicService {
             tIeExamInvigilateCallQueryWrapper.lambda()
                     .eq(TIeExamInvigilateCall::getExamRecordId, tIeExamInvigilateCallLog.getExamRecordId())
                     .eq(TIeExamInvigilateCall::getSource, tIeExamInvigilateCallLog.getSource());
-            TIeExamInvigilateCall tIeExamInvigilateCall = tIeExamInvigilateCallService
-                    .getOne(tIeExamInvigilateCallQueryWrapper);
+//                    .eq(TIeExamInvigilateCall::getBatchId, tIeExamInvigilateCallLog.getBatchId());
+            TIeExamInvigilateCall tIeExamInvigilateCall = tIeExamInvigilateCallService.getOne(tIeExamInvigilateCallQueryWrapper);
             //根据examRecordId和source取TIeExamInvigilateCall记录
             if (Objects.isNull(tIeExamInvigilateCall)) {//没有新增
-                tIeExamInvigilateCall = GsonUtil
-                        .fromJson(GsonUtil.toJson(tIeExamInvigilateCallLog), TIeExamInvigilateCall.class);
+                tIeExamInvigilateCall = GsonUtil.fromJson(GsonUtil.toJson(tIeExamInvigilateCallLog), TIeExamInvigilateCall.class);
                 tIeExamInvigilateCall.setId(uidUtil.getId());
             } else {//否则更新
                 tIeExamInvigilateCall.setLiveUrl(tIeExamInvigilateCallLog.getLiveUrl());
                 tIeExamInvigilateCall.setStatus(tIeExamInvigilateCallLog.getStatus());
                 tIeExamInvigilateCall.setCallStatus(tIeExamInvigilateCallLog.getCallStatus());
                 tIeExamInvigilateCall.setType(tIeExamInvigilateCallLog.getType());
-                if (Objects.equals(tIeExamInvigilateCallLog.getCallStatus(), MonitorCallStatusSourceEnum.START)) {
+                if (Objects.nonNull(tIeExamInvigilateCallLog.getFormUserId())) {
+                    tIeExamInvigilateCall.setFormUserId(tIeExamInvigilateCallLog.getFormUserId());
+                }
+                if (Objects.nonNull(tIeExamInvigilateCallLog.getReceiveUserId())) {
+                    tIeExamInvigilateCall.setReceiveUserId(tIeExamInvigilateCallLog.getReceiveUserId());
+                }
+                if (Objects.equals(tIeExamInvigilateCallLog.getCallStatus(), MonitorCallStatusSourceEnum.CALLING)) {
                     tIeExamInvigilateCall.setStartTime(tIeExamInvigilateCallLog.getStartTime());
                 }
                 if (Objects.equals(tIeExamInvigilateCallLog.getCallStatus(), MonitorCallStatusSourceEnum.STOP)) {
                     tIeExamInvigilateCall.setEndTime(tIeExamInvigilateCallLog.getEndTime());
+                    redisUtil.delete(RedisKeyHelper.examInvigilateCallCacheKey(recordId));
                 }
             }
             if (Objects.nonNull(tIeExamInvigilateCall.getUpdateTime())) {
@@ -761,13 +766,17 @@ public class MqLogicServiceImpl implements MqLogicService {
                         tIeExamInvigilateCall.getUpdateTime() :
                         0L;
                 //如果mq时间大于则更新
-                if (mqDto.getTimestamp() > dbtimestamp) {
-                    tIeExamInvigilateCallService.updateById(tIeExamInvigilateCall);
-                }
+//                if (mqDto.getTimestamp() > dbtimestamp && Objects.nonNull(tIeExamInvigilateCall.getBatchId())) {
+                tIeExamInvigilateCallService.updateById(tIeExamInvigilateCall);
+//                }
             } else {//否则新增
+//                if (Objects.nonNull(tIeExamInvigilateCall.getBatchId())) {
                 tIeExamInvigilateCallService.saveOrUpdate(tIeExamInvigilateCall);
+//                }
             }
+//            if (Objects.nonNull(tIeExamInvigilateCallLog.getBatchId())) {
             tIeExamInvigilateCallLogService.saveOrUpdate(tIeExamInvigilateCallLog);
+//            }
         } else if (Objects.equals(MqTagEnum.EXCEPTION_LOG.name(), tag)) {//考试断点异常日志
             JSONObject jsonObject = JSONObject.parseObject(String.valueOf(mqDto.getBody()));
 //            ExceptionEnum exceptionEnum = ExceptionEnum.valueOf(