Kaynağa Gözat

视频通话记录增加轨迹

wangliang 1 yıl önce
ebeveyn
işleme
a040574c73

+ 0 - 2
themis-admin/src/main/java/com/qmth/themis/admin/api/TIeInvigilateCallMobileController.java

@@ -287,7 +287,6 @@ public class TIeInvigilateCallMobileController {
         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(),
                 tIeExamInvigilateCallLog, MqTagEnum.MONITOR_LOG, String.valueOf(tIeExamInvigilateCallLog.getId()),
@@ -340,7 +339,6 @@ public class TIeInvigilateCallMobileController {
 //        }
 //        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());

+ 11 - 3
themis-admin/src/main/java/com/qmth/themis/admin/api/TIeInvigilateController.java

@@ -4,7 +4,6 @@ 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.google.common.reflect.TypeToken;
 import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.annotation.RedisLimitAnnotation;
@@ -18,7 +17,6 @@ import com.qmth.themis.business.dto.AuthDto;
 import com.qmth.themis.business.dto.MqDto;
 import com.qmth.themis.business.dto.cache.TEStudentCacheDto;
 import com.qmth.themis.business.dto.response.TBExamInvigilateUserDto;
-import com.qmth.themis.business.dto.response.TEExamQueryDto;
 import com.qmth.themis.business.entity.*;
 import com.qmth.themis.business.enums.*;
 import com.qmth.themis.business.excel.ExportUtils;
@@ -29,7 +27,6 @@ import com.qmth.themis.business.util.OssUtil;
 import com.qmth.themis.business.util.ServletUtil;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
-import com.qmth.themis.common.util.GsonUtil;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import io.swagger.annotations.*;
@@ -353,6 +350,17 @@ public class TIeInvigilateController {
         //                .and(w -> w.ne(TEExamStudentLog::getType, SystemOperationEnum.BREACH_HANDLE.name()).or().ne(TEExamStudentLog::getType, SystemOperationEnum.BREACH_REVOKE.name()));
         List<TEExamStudentLog> teExamStudentLogList = teExamStudentLogService.list(teExamStudentLogQueryWrapper);
         if (!CollectionUtils.isEmpty(teExamStudentLogList)) {
+            for (TEExamStudentLog t : teExamStudentLogList) {
+                if (Objects.equals(t.getType(), MessageTypeEnum.MEDIA.name())) {
+                    t.setMsgType(MessageTypeEnum.MEDIA);
+                    t.setMsgTypeStr(MessageTypeEnum.MEDIA.getCode());
+                    t.setContent(t.getRemark());
+                    t.setFormUserName(t.getInfo());
+                    t.setType(null);
+                    t.setInfo(null);
+                    t.setRemark(null);
+                }
+            }
             teExamStudentLogList = teExamStudentLogList.get(0).ipChange(teExamStudentLogList);
         }
 

+ 45 - 46
themis-business/src/main/java/com/qmth/themis/business/cache/RedisKeyHelper.java

@@ -1,15 +1,14 @@
 package com.qmth.themis.business.cache;
 
-import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.enums.MobileModeEnum;
 
 public class RedisKeyHelper {
     private static String underLine = "_";
 
-    /**
-     * 场次
-     */
-    private static String examActivityKeyPrefix = "exam_activity:";
+//    /**
+//     * 场次
+//     */
+//    private static String examActivityKeyPrefix = "exam_activity:";
     /**
      * 考生
      */
@@ -77,20 +76,20 @@ public class RedisKeyHelper {
      */
     private static String objectiveAnswerHashKeyPrefix = "paper_id_";
 
-    /**
-     * 监考通话
-     */
-    private static String examInvigilateCallCachePrefix = "exam_invigilate_call:";
-
-    /**
-     * 场次
-     *
-     * @param activityId
-     * @return
-     */
-    public static String examActivityCacheKey(Long activityId) {
-        return examActivityKeyPrefix + activityId;
-    }
+//    /**
+//     * 监考通话
+//     */
+//    private static String examInvigilateCallCachePrefix = "exam_invigilate_call:";
+//
+//    /**
+//     * 场次
+//     *
+//     * @param activityId
+//     * @return
+//     */
+//    public static String examActivityCacheKey(Long activityId) {
+//        return examActivityKeyPrefix + activityId;
+//    }
 
     /**
      * 考生
@@ -188,14 +187,14 @@ public class RedisKeyHelper {
         return examBreakKeyPrefix + id;
     }
 
-    /**
-     * 场次-考试记录大key
-     *
-     * @return
-     */
-    public static String examActivityRecordCacheKey(Long activityId) {
-        return examActivityRecordKeyPrefix + activityId;
-    }
+//    /**
+//     * 场次-考试记录大key
+//     *
+//     * @return
+//     */
+//    public static String examActivityRecordCacheKey(Long activityId) {
+//        return examActivityRecordKeyPrefix + activityId;
+//    }
 
     /**
      * 移动端临时认证大key
@@ -248,23 +247,23 @@ public class RedisKeyHelper {
         return objectiveAnswerHashKeyPrefix + paperId;
     }
 
-    /**
-     * 学生记录id key
-     *
-     * @param studentId
-     * @return
-     */
-    public static String studentCacheKey(Long studentId) {
-        return SystemConstant.studentAccount + ":" + studentId;
-    }
-
-    /**
-     * 监考通话缓存大key
-     *
-     * @param id
-     * @return
-     */
-    public static String examInvigilateCallCacheKey(Long id) {
-        return examInvigilateCallCachePrefix + id;
-    }
+//    /**
+//     * 学生记录id key
+//     *
+//     * @param studentId
+//     * @return
+//     */
+//    public static String studentCacheKey(Long studentId) {
+//        return SystemConstant.studentAccount + ":" + studentId;
+//    }
+
+//    /**
+//     * 监考通话缓存大key
+//     *
+//     * @param id
+//     * @return
+//     */
+//    public static String examInvigilateCallCacheKey(Long id) {
+//        return examInvigilateCallCachePrefix + id;
+//    }
 }

+ 11 - 0
themis-business/src/main/java/com/qmth/themis/business/entity/TEExamStudentLog.java

@@ -189,6 +189,17 @@ public class TEExamStudentLog implements Serializable, Comparable<TEExamStudentL
         this.isp = isp;
     }
 
+    public TEExamStudentLog(Long studentId, Long examStudentId, Long examRecordId, String type, String info, String remark) {
+        this.id = UidUtil.nextId();
+        this.type = type;
+        this.info = info;
+        this.remark = remark;
+        this.studentId = studentId;
+        this.examStudentId = examStudentId;
+        this.examRecordId = examRecordId;
+        this.createTime = createTime;
+    }
+
     public String getFormUserName() {
         return formUserName;
     }

+ 3 - 1
themis-business/src/main/java/com/qmth/themis/business/enums/MessageTypeEnum.java

@@ -11,7 +11,9 @@ public enum MessageTypeEnum {
 
     TEXT("文本消息"),
 
-    AUDIO("语音消息");
+    AUDIO("语音消息"),
+
+    MEDIA("多媒体消息");
 
     private String code;
 

+ 0 - 2
themis-exam/src/main/java/com/qmth/themis/exam/api/TIeInvigilateCallMobileController.java

@@ -161,7 +161,6 @@ public class TIeInvigilateCallMobileController {
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
 //        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());
@@ -297,7 +296,6 @@ public class TIeInvigilateCallMobileController {
         MonitorStatusSourceEnum status = ExamRecordCacheUtil.getMonitorStatus(recordId, source);
 //        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());
         mqDtoService.assembleSendAsyncMsg(mqDto);

+ 0 - 2
themis-exam/src/main/java/com/qmth/themis/exam/api/TIeInvigilateCallOeController.java

@@ -242,7 +242,6 @@ public class TIeInvigilateCallOeController {
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
 //        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());
@@ -306,7 +305,6 @@ public class TIeInvigilateCallOeController {
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
 //        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());
         mqDtoService.assembleSendAsyncMsg(mqDto);

+ 27 - 12
themis-mq/src/main/java/com/qmth/themis/mq/service/impl/MqLogicServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.themis.mq.service.impl;
 
+import cn.hutool.core.date.BetweenFormater;
 import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -44,10 +45,7 @@ import javax.annotation.Resource;
 import java.io.IOException;
 import java.lang.reflect.Method;
 import java.security.NoSuchAlgorithmException;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 
 /**
@@ -131,6 +129,9 @@ public class MqLogicServiceImpl implements MqLogicService {
     @Resource
     TEExamStudentOnlineLogService teExamStudentOnlineLogService;
 
+    @Resource
+    TBUserService tbUserService;
+
     /**
      * mq最大重试次数逻辑
      *
@@ -753,12 +754,30 @@ public class MqLogicServiceImpl implements MqLogicService {
                 if (Objects.nonNull(tIeExamInvigilateCallLog.getReceiveUserId())) {
                     tIeExamInvigilateCall.setReceiveUserId(tIeExamInvigilateCallLog.getReceiveUserId());
                 }
+                if (Objects.equals(tIeExamInvigilateCallLog.getCallStatus(), MonitorCallStatusSourceEnum.START)) {
+                    tIeExamInvigilateCall.setStartTime(System.currentTimeMillis());
+                }
                 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));
+                    //往studentLog表里插数据
+                    String formUserName = null, receiveUserName = null;
+                    ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
+                    TBUser formTbUser = tbUserService.getById(tIeExamInvigilateCall.getFormUserId());
+                    formUserName = Objects.isNull(formTbUser) ? examStudentCacheBean.getName() : formTbUser.getName();
+                    TBUser receiveTbUser = tbUserService.getById(tIeExamInvigilateCall.getReceiveUserId());
+                    receiveUserName = Objects.isNull(receiveTbUser) ? examStudentCacheBean.getName() : receiveTbUser.getName();
+                    Date startDate = new Date(tIeExamInvigilateCall.getStartTime());
+                    Date endDate = new Date(tIeExamInvigilateCall.getEndTime());
+                    StringJoiner stringJoiner = new StringJoiner("");
+                    stringJoiner.add("发起人:").add(formUserName).add("\r\n").add("接收人:").add(receiveUserName).add("\r\n")
+                            .add("通话时间段:").add(DateUtil.format(startDate, Constants.DEFAULT_DATE_PATTERN)).add("~").add(DateUtil.format(endDate, Constants.DEFAULT_DATE_PATTERN)).add("\r\n")
+                            .add("持续时长约:").add(DateUtil.formatBetween(startDate, endDate, BetweenFormater.Level.SECOND));
+                    TEExamStudentLog teExamStudentLog = new TEExamStudentLog(examStudentCacheBean.getStudentId(), examStudentId,
+                            recordId, MessageTypeEnum.MEDIA.name(), formUserName, stringJoiner.toString());
+                    teExamStudentLogService.saveOrUpdate(teExamStudentLog);
                 }
             }
             if (Objects.nonNull(tIeExamInvigilateCall.getUpdateTime())) {
@@ -766,17 +785,13 @@ public class MqLogicServiceImpl implements MqLogicService {
                         tIeExamInvigilateCall.getUpdateTime() :
                         0L;
                 //如果mq时间大于则更新
-//                if (mqDto.getTimestamp() > dbtimestamp && Objects.nonNull(tIeExamInvigilateCall.getBatchId())) {
-                tIeExamInvigilateCallService.updateById(tIeExamInvigilateCall);
-//                }
+                if (mqDto.getTimestamp() > dbtimestamp) {
+                    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(