wangliang 4 lat temu
rodzic
commit
7e5d4c1ccd

+ 8 - 0
themis-business/src/main/java/com/qmth/themis/business/domain/MonitorDomain.java

@@ -13,6 +13,14 @@ public class MonitorDomain implements Serializable {
 
     String prefix;
 
+    public MonitorDomain() {
+
+    }
+
+    public MonitorDomain(String prefix) {
+        this.prefix = prefix;
+    }
+
     public String getPrefix() {
         return prefix;
     }

+ 47 - 0
themis-business/src/main/java/com/qmth/themis/business/dto/response/StreamDto.java

@@ -0,0 +1,47 @@
+package com.qmth.themis.business.dto.response;
+
+import com.qmth.themis.business.enums.MonitorVideoSourceEnum;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * @Description: stream dto
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/2/19
+ */
+public class StreamDto implements Serializable {
+
+    @ApiModelProperty(name = "videoSource")
+    private MonitorVideoSourceEnum name;
+
+    @ApiModelProperty(name = "streamId")
+    private String streamId;
+
+    public StreamDto() {
+
+    }
+
+    public StreamDto(MonitorVideoSourceEnum name, String streamId) {
+        this.name = name;
+        this.streamId = streamId;
+    }
+
+    public MonitorVideoSourceEnum getName() {
+        return name;
+    }
+
+    public void setName(MonitorVideoSourceEnum name) {
+        this.name = name;
+    }
+
+    public String getStreamId() {
+        return streamId;
+    }
+
+    public void setStreamId(String streamId) {
+        this.streamId = streamId;
+    }
+}

+ 14 - 6
themis-business/src/main/java/com/qmth/themis/business/dto/response/TEExamActivityDto.java

@@ -7,7 +7,10 @@ import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamCourseCacheBean;
 import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
-import com.qmth.themis.business.enums.*;
+import com.qmth.themis.business.enums.EntryAuthenticationPolicyEnum;
+import com.qmth.themis.business.enums.ExamModeEnum;
+import com.qmth.themis.business.enums.HardwareTestEnum;
+import com.qmth.themis.business.enums.MonitorVideoSourceEnum;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
@@ -58,7 +61,7 @@ public class TEExamActivityDto implements Serializable {
     private String monitorVideoSourceStr;
 
     @ApiModelProperty(name = "监控源集合")
-    private List<String> monitorVideoSource;
+    private List<StreamDto> monitorVideoSource;
 
     @ApiModelProperty(name = "允许开考开放时长,相当于迟到时间")
     private Integer openingSeconds;//允许开考开放时长(分钟),相当于迟到时间
@@ -147,7 +150,7 @@ public class TEExamActivityDto implements Serializable {
     }
 
     public TEExamActivityDto(ExamCacheBean ec, ExamActivityCacheBean examActivityCacheBean, ExamStudentCacheBean examStudentCacheBean, Long examStudentId, ExamCourseCacheBean examCourseCacheBean,
-                             Long recordId) {
+                             Long recordId, String prefix) {
         Long startTime = ExamRecordCacheUtil.getStartTime(recordId);
         Long endTime = ExamRecordCacheUtil.getEndTime(recordId);
         Integer openingSeconds = ExamRecordCacheUtil.getOpeningSeconds(recordId);
@@ -192,7 +195,12 @@ public class TEExamActivityDto implements Serializable {
         this.cameraPhotoUpload = cameraPhotoUpload;
         this.entryAuthenticationPolicy = entryAuthenticationPolicy;
         if (Objects.nonNull(monitorVideoSource) && !Objects.equals(monitorVideoSource.trim().replaceAll(" ", ""), "")) {
-            this.setMonitorVideoSource(Arrays.asList(monitorVideoSource.trim().toUpperCase().split(",")));
+            List<String> videoSources = Arrays.asList(monitorVideoSource.trim().toUpperCase().split(","));
+            List<StreamDto> streamDtoList = new ArrayList<>();
+            videoSources.forEach(s -> {
+                streamDtoList.add(new StreamDto(MonitorVideoSourceEnum.valueOf(s), prefix + "_" + recordId + "_" + MonitorVideoSourceEnum.valueOf(s).name().toLowerCase()));
+            });
+            this.setMonitorVideoSource(streamDtoList);
             //加入monitorAudioEnable逻辑
             if (monitorVideoSource.toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_SCREEN.name()) || monitorVideoSource.toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_CAMERA.name())) {
                 this.monitorAudioEnable = true;
@@ -395,11 +403,11 @@ public class TEExamActivityDto implements Serializable {
         this.maxFinishTime = maxFinishTime;
     }
 
-    public List<String> getMonitorVideoSource() {
+    public List<StreamDto> getMonitorVideoSource() {
         return monitorVideoSource;
     }
 
-    public void setMonitorVideoSource(List<String> monitorVideoSource) {
+    public void setMonitorVideoSource(List<StreamDto> monitorVideoSource) {
         this.monitorVideoSource = monitorVideoSource;
     }
 

+ 9 - 7
themis-business/src/main/java/com/qmth/themis/business/service/TEExamActivityService.java

@@ -1,9 +1,5 @@
 package com.qmth.themis.business.service;
 
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
@@ -12,6 +8,10 @@ import com.qmth.themis.business.dto.response.TEExamActivityQueryDto;
 import com.qmth.themis.business.dto.response.TEExamActivityWaitDto;
 import com.qmth.themis.business.entity.TEExamActivity;
 
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 /**
  * @Description: 考试场次 服务类
  * @Param:
@@ -90,9 +90,11 @@ public interface TEExamActivityService extends IService<TEExamActivity> {
      * @param examActivityId
      * @param examStudentId
      * @param courseCode
+     * @param prefix
+     * @param recordId
      * @return
      */
-    public TEExamActivityDto getWaitingExam(Long examActivityId, Long examStudentId, String courseCode);
+    public TEExamActivityDto getWaitingExam(Long examActivityId, Long examStudentId, String courseCode, String prefix, Long recordId);
 
     /**
      * 获取场次缓存
@@ -119,7 +121,7 @@ public interface TEExamActivityService extends IService<TEExamActivity> {
 
     public List<TEExamActivity> findByExamIdAndOrgId(Long examId, Long orgId);
 
-	void saveExamActivity(List<TEExamActivity> teExamActivityList);
+    void saveExamActivity(List<TEExamActivity> teExamActivityList);
 
-	List<Long> findExamIdToday();
+    List<Long> findExamIdToday();
 }

+ 40 - 55
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamActivityServiceImpl.java

@@ -1,25 +1,5 @@
 package com.qmth.themis.business.service.impl;
 
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-import javax.annotation.Resource;
-
-import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.cache.annotation.CachePut;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.dao.DuplicateKeyException;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
@@ -28,30 +8,29 @@ import com.qmth.themis.business.cache.bean.ExamCourseCacheBean;
 import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
 import com.qmth.themis.business.dao.TEExamActivityMapper;
 import com.qmth.themis.business.dto.MqDto;
+import com.qmth.themis.business.dto.response.StreamDto;
 import com.qmth.themis.business.dto.response.TEExamActivityDto;
 import com.qmth.themis.business.dto.response.TEExamActivityQueryDto;
 import com.qmth.themis.business.dto.response.TEExamActivityWaitDto;
 import com.qmth.themis.business.entity.TBUser;
 import com.qmth.themis.business.entity.TEExam;
 import com.qmth.themis.business.entity.TEExamActivity;
-import com.qmth.themis.business.enums.EntryAuthenticationPolicyEnum;
-import com.qmth.themis.business.enums.FieldUniqueEnum;
-import com.qmth.themis.business.enums.HardwareTestEnum;
-import com.qmth.themis.business.enums.InvigilateMonitorStatusEnum;
-import com.qmth.themis.business.enums.MonitorVideoSourceEnum;
-import com.qmth.themis.business.enums.MqTagEnum;
-import com.qmth.themis.business.service.MqDtoService;
-import com.qmth.themis.business.service.TEExamActivityService;
-import com.qmth.themis.business.service.TEExamCourseService;
-import com.qmth.themis.business.service.TEExamService;
-import com.qmth.themis.business.service.TEExamStudentService;
-import com.qmth.themis.business.util.JacksonUtil;
-import com.qmth.themis.business.util.MqUtil;
-import com.qmth.themis.business.util.RedisUtil;
-import com.qmth.themis.business.util.ServletUtil;
-import com.qmth.themis.business.util.UidUtil;
+import com.qmth.themis.business.enums.*;
+import com.qmth.themis.business.service.*;
+import com.qmth.themis.business.util.*;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.CachePut;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.dao.DuplicateKeyException;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 /**
  * @Description: 考试场次 服务实现类
@@ -86,6 +65,7 @@ public class TEExamActivityServiceImpl extends ServiceImpl<TEExamActivityMapper,
 
     @Resource
     private MqUtil mqUtil;
+
     /**
      * 表是否存在
      *
@@ -175,10 +155,11 @@ public class TEExamActivityServiceImpl extends ServiceImpl<TEExamActivityMapper,
      * @param examActivityId
      * @param examStudentId
      * @param courseCode
+     * @param prefix
      * @return
      */
     @Override
-    public TEExamActivityDto getWaitingExam(Long examActivityId, Long examStudentId, String courseCode) {
+    public TEExamActivityDto getWaitingExam(Long examActivityId, Long examStudentId, String courseCode, String prefix, Long recordId) {
         TEExamActivityDto teExamActivityDto = teExamActivityMapper.getWaitingExamByExamActivityId(examActivityId);
         ExamCacheBean examCache = teExamService.getExamCacheBean(teExamActivityDto.getExamId());
         ExamStudentCacheBean examStudentCacheBean = teExamStudentService
@@ -204,8 +185,12 @@ public class TEExamActivityServiceImpl extends ServiceImpl<TEExamActivityMapper,
         }
         if (Objects.nonNull(teExamActivityDto.getMonitorVideoSourceStr()) && !Objects
                 .equals(teExamActivityDto.getMonitorVideoSourceStr().toString().trim().replaceAll(" ", ""), "")) {
-            teExamActivityDto.setMonitorVideoSource(Arrays.asList(
-                    teExamActivityDto.getMonitorVideoSourceStr().trim().toUpperCase().replaceAll(" ", "").split(",")));
+            List<String> videoSources = Arrays.asList(teExamActivityDto.getMonitorVideoSourceStr().trim().toUpperCase().replaceAll(" ", "").split(","));
+            List<StreamDto> streamDtoList = new ArrayList<>();
+            videoSources.forEach(s -> {
+                streamDtoList.add(new StreamDto(MonitorVideoSourceEnum.valueOf(s), prefix + "_" + recordId + "_" + MonitorVideoSourceEnum.valueOf(s).name().toLowerCase()));
+            });
+            teExamActivityDto.setMonitorVideoSource(streamDtoList);
             teExamActivityDto.setMonitorAudioEnable(examCache.getMonitorAudioEnable());
             //加入hardwareTest逻辑
             if (teExamActivityDto.getMonitorVideoSourceStr().toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_CAMERA.name())
@@ -296,11 +281,11 @@ public class TEExamActivityServiceImpl extends ServiceImpl<TEExamActivityMapper,
     public List<TEExamActivity> findByExamIdAndOrgId(Long examId, Long orgId) {
         return teExamActivityMapper.findByExamIdAndOrgId(examId, orgId);
     }
-    
+
     @Transactional
     @Override
     public void saveExamActivity(List<TEExamActivity> teExamActivityList) {
-    	if (Objects.isNull(teExamActivityList) || teExamActivityList.size() == 0) {
+        if (Objects.isNull(teExamActivityList) || teExamActivityList.size() == 0) {
             throw new BusinessException(ExceptionResultEnum.EXAM_INFO_IS_NULL);
         }
         Long examId = null;
@@ -356,20 +341,20 @@ public class TEExamActivityServiceImpl extends ServiceImpl<TEExamActivityMapper,
             }
         }
     }
-    
+
     @Override
-    public List<Long> findExamIdToday(){
-    	try {
-			Date now=new Date();
-			SimpleDateFormat sdf1=new SimpleDateFormat("yyyy-MM-dd");
-			String today=sdf1.format(now);
-			SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-			Long start=sdf2.parse(today+" 00:00:00").getTime();
-			Long end=sdf2.parse(today+" 23:59:59").getTime();
-			return teExamActivityMapper.findExamIdToday(start, end);
-		} catch (ParseException e) {
-			e.printStackTrace();
-		}
-    	return null;
+    public List<Long> findExamIdToday() {
+        try {
+            Date now = new Date();
+            SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
+            String today = sdf1.format(now);
+            SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            Long start = sdf2.parse(today + " 00:00:00").getTime();
+            Long end = sdf2.parse(today + " 23:59:59").getTime();
+            return teExamActivityMapper.findExamIdToday(start, end);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return null;
     }
 }

+ 6 - 3
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java

@@ -107,6 +107,9 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
     @Resource
     TOeExamBreakHistoryService tOeExamBreakHistoryService;
 
+    @Resource
+    MonitorUtil monitorUtil;
+
     /**
      * 查询考试批次
      *
@@ -234,7 +237,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
                         , tencentYunUtil.getTencentYunDomain().getAppId());
                 ExamRecordCacheUtil.updateExamRecordCache(recordId, examCache, ac);
                 TEExamActivityDto teExamActivityDto = new TEExamActivityDto(examCache, ac, examStudentCacheBean,
-                        examStudentId, ec, recordId);
+                        examStudentId, ec, recordId, monitorUtil.getMonitorDomain().getPrefix());
                 prepare.setTeExamActivityDto(teExamActivityDto);
                 return prepare;
             }
@@ -299,7 +302,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
                 , ep.getAudioPlayCount(), ExamRecordCacheUtil.getMonitorKey(recordId), monitorUserId
                 , tencentYunUtil.getSign(monitorUserId, SystemConstant.TENCENT_EXPIRE_TIME)
                 , tencentYunUtil.getTencentYunDomain().getAppId());
-        TEExamActivityDto teExamActivityDto = teExamActivityService.getWaitingExam(activityId, examStudentId, es.getCourseCode());
+        TEExamActivityDto teExamActivityDto = teExamActivityService.getWaitingExam(activityId, examStudentId, es.getCourseCode(), monitorUtil.getMonitorDomain().getPrefix(), recordId);
         prepare.setTeExamActivityDto(teExamActivityDto);
 
         // 更新考生缓存
@@ -890,7 +893,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         ExamActivityCacheBean ac = teExamActivityService.getExamActivityCacheBean(es.getExamActivityId());
         ExamCourseCacheBean examCourseCacheBean = teExamCourseService.getExamCourseCacheBean(es.getExamId(), es.getCourseCode());
         TEExamActivityDto teExamActivityDto = new TEExamActivityDto(ec, ac, es,
-                examStudentId, examCourseCacheBean, recordId);
+                examStudentId, examCourseCacheBean, recordId, monitorUtil.getMonitorDomain().getPrefix());
         ret.setTeExamActivityDto(teExamActivityDto);
 
         ExamStudentPaperStructCacheBean struct = (ExamStudentPaperStructCacheBean) redisUtil

+ 28 - 0
themis-business/src/main/java/com/qmth/themis/business/util/MonitorUtil.java

@@ -0,0 +1,28 @@
+package com.qmth.themis.business.util;
+
+import com.qmth.themis.business.domain.MonitorDomain;
+import org.springframework.context.annotation.Bean;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description: monitorutil
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/8/21
+ */
+@Component
+public class MonitorUtil {
+
+    private MonitorDomain monitorDomain;
+
+    @Bean
+    public MonitorDomain monitorEnv(MonitorDomain monitorDomain) {
+        this.monitorDomain = new MonitorDomain(monitorDomain.getPrefix());
+        return this.monitorDomain;
+    }
+
+    public MonitorDomain getMonitorDomain() {
+        return monitorDomain;
+    }
+}