Browse Source

Merge remote-tracking branch 'origin/master'

wangliang 4 years ago
parent
commit
d4211b97ac

+ 22 - 54
themis-backend/src/main/java/com/qmth/themis/backend/api/TIeInvigilateCallMobileController.java

@@ -9,7 +9,6 @@ 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;
@@ -20,7 +19,6 @@ 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.enums.Platform;
 import com.qmth.themis.common.enums.Source;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Result;
@@ -34,10 +32,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.io.File;
 import java.security.NoSuchAlgorithmException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 
 /**
  * @Description: mobile监考监控通话信息 前端控制器
@@ -254,58 +249,31 @@ public class TIeInvigilateCallMobileController {
      */
     private String getSourceUserId(Long recordId) throws NoSuchAlgorithmException {
         String sourceUserId = null;
-        Long examId = ExamRecordCacheUtil.getExamId(recordId);
+        //Long examId = ExamRecordCacheUtil.getExamId(recordId);
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
-        if (Objects.isNull(examId)) {
+        if (Objects.isNull(examStudentId)) {
             TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(recordId);
-            examId = tOeExamRecord.getExamId();
-            examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
+            //examId = tOeExamRecord.getExamId();
+            if (tOeExamRecord == null) {
+                throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD);
+            }
+            examStudentId = tOeExamRecord.getExamStudentId();
         }
-        ExamCacheBean ec = teExamService.getExamCacheBean(examId);//考试缓存
+        //ExamCacheBean ec = teExamService.getExamCacheBean(examId);//考试缓存
         ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
-        if (Objects.nonNull(ec.getMonitorAudioEnable())) {
-            if (ec.getMonitorAudioEnable()) {
-                for (Source s : Source.values()) {
-                    String sessionId = SessionUtil.digest(examStudentCacheBean.getIdentity(),
-                            Math.abs(Sets.newHashSet(RoleEnum.STUDENT.name()).toString().hashCode()), s.name());
-                    TBSession tbSessionClient = (TBSession) redisUtil.getUserSession(sessionId);
-                    if (Objects.nonNull(tbSessionClient) && tbSessionClient.getExpireTime() > System.currentTimeMillis()
-                            && (Objects.equals(tbSessionClient.getSource(), Source.OE_CLIENT.name()) || Objects
-                            .equals(tbSessionClient.getSource(), Source.ADMIN_CLIENT.name())) && (
-                            Objects.equals(tbSessionClient.getPlatform(), Platform.WIN.name()) || Objects
-                                    .equals(tbSessionClient.getPlatform(), Platform.MAC.name()))) {
-                        if (Objects.nonNull(
-                                ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.CLIENT_CAMERA))) {
-                            sourceUserId = "s_" + tbSessionClient.getId();
-                            break;
-                        } else if (Objects.nonNull(
-                                ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.CLIENT_SCREEN))) {
-                            sourceUserId = "s_" + tbSessionClient.getId();
-                            break;
-                        }
-                    }
-                }
-            } else {
-                for (Source s : Source.values()) {
-                    String sessionId = SessionUtil.digest(examStudentCacheBean.getIdentity(),
-                            Math.abs(Sets.newHashSet(RoleEnum.STUDENT.name()).toString().hashCode()), s.name());
-                    TBSession tbSessionPhone = (TBSession) redisUtil.getUserSession(sessionId);
-                    if (Objects.nonNull(tbSessionPhone) && tbSessionPhone.getExpireTime() > System.currentTimeMillis()
-                            && (Objects.equals(tbSessionPhone.getSource(), Source.MOBILE_MONITOR_FIRST.name())
-                            || Objects.equals(tbSessionPhone.getSource(), Source.MOBILE_MONITOR_SECOND.name())) && (
-                            Objects.equals(tbSessionPhone.getPlatform(), Platform.ANDROID.name()) || Objects
-                                    .equals(tbSessionPhone.getPlatform(), Platform.IOS.name()))) {
-                        if (Objects.nonNull(
-                                ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.MOBILE_FIRST))) {
-                            sourceUserId = "s_" + tbSessionPhone.getId();
-                            break;
-                        } else if (Objects.nonNull(
-                                ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.MOBILE_SECOND))) {
-                            sourceUserId = "s_" + tbSessionPhone.getId();
-                            break;
-                        }
-                    }
-                }
+        //只针对客户端摄像头/屏幕、移动端主机位开启监考通话
+        List<MonitorVideoSourceEnum> sourceList = Arrays
+                .asList(MonitorVideoSourceEnum.CLIENT_CAMERA, MonitorVideoSourceEnum.CLIENT_SCREEN,
+                        MonitorVideoSourceEnum.MOBILE_FIRST);
+        for (MonitorVideoSourceEnum source : sourceList) {
+            Source sessionSource = source.getSessionSource();
+            String sessionId = SessionUtil.digest(examStudentCacheBean.getStudentId(),
+                    Math.abs(Sets.newHashSet(RoleEnum.STUDENT.name()).toString().hashCode()), sessionSource.name());
+            TBSession tbSession = (TBSession) redisUtil.getUserSession(sessionId);
+            if (Objects.nonNull(tbSession) && tbSession.getExpireTime() > System.currentTimeMillis() && Objects
+                    .nonNull(ExamRecordCacheUtil.getMonitorStatus(recordId, source))) {
+                sourceUserId = "s_" + tbSession.getId();
+                break;
             }
         }
         return sourceUserId;

+ 17 - 0
themis-business/src/main/java/com/qmth/themis/business/enums/MonitorVideoSourceEnum.java

@@ -1,5 +1,7 @@
 package com.qmth.themis.business.enums;
 
+import com.qmth.themis.common.enums.Source;
+
 /**
  * @Description: 监控源 enum
  * @Param:
@@ -34,4 +36,19 @@ public enum MonitorVideoSourceEnum {
         }
         return null;
     }
+
+    /**
+     * 根据监控视频源判断设备访问会话来源
+     *
+     * @return
+     */
+    public Source getSessionSource() {
+        if (this == MOBILE_FIRST) {
+            return Source.MOBILE_MONITOR_FIRST;
+        } else if (this == MOBILE_SECOND) {
+            return Source.MOBILE_MONITOR_SECOND;
+        } else {
+            return Source.OE_CLIENT;
+        }
+    }
 }

+ 1 - 15
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEMobileServiceImpl.java

@@ -121,7 +121,7 @@ public class TEMobileServiceImpl implements TEMobileService {
         ret.setMonitorKey(ExamRecordCacheUtil.getMonitorKey(recordId));
         ret.setMonitorVideoSource(monitorVideoSource);
         ret.setMonitorAudioEnable(getMonitorAudioEnable(recordId, monitorVideoSource));
-        Source sourceEnum = getSource(monitorVideoSource);
+        Source sourceEnum = monitorVideoSource.getSessionSource();
         ExamStudentCacheBean es = examStudentService
                 .getExamStudentCacheBean(ExamRecordCacheUtil.getExamStudentId(ret.getRecordId()));
         String userType = MobileAuthCacheUtil.getUserType(mode, code);
@@ -215,18 +215,4 @@ public class TEMobileServiceImpl implements TEMobileService {
         }
     }
 
-    /**
-     * 根据监控视频源判断设备访问会话来源
-     *
-     * @param videoSource
-     * @return
-     */
-    private Source getSource(MonitorVideoSourceEnum videoSource) {
-        if (videoSource == MonitorVideoSourceEnum.MOBILE_FIRST) {
-            return Source.MOBILE_MONITOR_FIRST;
-        } else if (videoSource == MonitorVideoSourceEnum.MOBILE_SECOND) {
-            return Source.MOBILE_MONITOR_SECOND;
-        }
-        return null;
-    }
 }

+ 2 - 2
themis-business/src/main/java/com/qmth/themis/business/util/OssUtil.java

@@ -221,13 +221,13 @@ public class OssUtil {
     }
 
     /**
-     * 获取私有bucket文件访问url,分钟有效
+     * 获取私有bucket文件访问url,分钟有效
      *
      * @param objectPath
      * @return
      */
     public String getPrivateUrl(String objectPath) {
-        Date expiration = new Date(System.currentTimeMillis() + 60 * 1000);
+        Date expiration = new Date(System.currentTimeMillis() + 5 * 60 * 1000);
         GeneratePresignedUrlRequest generatePresignedUrlRequest;
         generatePresignedUrlRequest = new GeneratePresignedUrlRequest(aliYunOssPrivateDomain.getPrivateBucket(),
                 objectPath);

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

@@ -100,12 +100,12 @@ public class TEStudentController {
 
     @ApiOperation(value = "学生登录接口")
     @RequestMapping(value = "/login", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "学生信息", response = TEExamResultDto.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "学生信息", response = TEExamResultDto.class) })
     public Result login(
-            @ApiJsonObject(name = "loginStudent", value = {@ApiJsonProperty(key = "identity", description = "证件号"),
+            @ApiJsonObject(name = "loginStudent", value = { @ApiJsonProperty(key = "identity", description = "证件号"),
                     @ApiJsonProperty(key = "password", description = "密码"),
                     @ApiJsonProperty(key = "orgId", type = "long", example = "1", description = "机构id"),
-                    @ApiJsonProperty(key = "examId", type = "long", example = "1", description = "批次id")}) @ApiParam(value = "学生信息", required = true) @RequestBody Map<String, Object> mapParameter)
+                    @ApiJsonProperty(key = "examId", type = "long", example = "1", description = "批次id") }) @ApiParam(value = "学生信息", required = true) @RequestBody Map<String, Object> mapParameter)
             throws NoSuchAlgorithmException {
         if (Objects.isNull(mapParameter)) {
             throw new BusinessException(ExceptionResultEnum.STUDENT_IS_NULL);
@@ -212,7 +212,7 @@ public class TEStudentController {
         }
         //添加用户会话缓存
         String sessionId = SessionUtil
-                .digest(teStudent.getIdentity(), Math.abs(authDto.getRoleCodes().toString().hashCode()), source);
+                .digest(teStudent.getId(), Math.abs(authDto.getRoleCodes().toString().hashCode()), source);
 
         ExpireTimeDTO expireTime = SystemConstant.getExpireTime(source, platform);
         TBSession tbSession = new TBSession(sessionId, String.valueOf(teStudent.getId()),
@@ -285,7 +285,7 @@ public class TEStudentController {
 
     @ApiOperation(value = "登出接口")
     @RequestMapping(value = "/logout", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
     public Result logout() throws NoSuchAlgorithmException {
         TEStudentCacheDto teStudent = (TEStudentCacheDto) ServletUtil.getRequestStudentAccount();
         TBSession tbSession = (TBSession) ServletUtil.getRequestSession();
@@ -298,7 +298,7 @@ public class TEStudentController {
         boolean delete = true;
         for (Source s : Source.values()) {
             String sessionId = SessionUtil
-                    .digest(teStudent.getIdentity(), Math.abs(authDto.getRoleCodes().toString().hashCode()), s.name());
+                    .digest(teStudent.getId(), Math.abs(authDto.getRoleCodes().toString().hashCode()), s.name());
             if (Objects.nonNull(redisUtil.getUserSession(sessionId))) {
                 delete = false;
                 break;
@@ -328,7 +328,7 @@ public class TEStudentController {
      * @return
      */
     private ExamUnFinishBean unFinishCommon(Long recordId, ExamCacheBean ec, ExamStudentCacheBean examStudentCacheBean,
-                                            ExamActivityCacheBean examActivityCacheBean, Long examStudentId) {
+            ExamActivityCacheBean examActivityCacheBean, Long examStudentId) {
         ExamCourseCacheBean examCourseCacheBean = teExamCourseService
                 .getExamCourseCacheBean(ec.getId(), examStudentCacheBean.getCourseCode());
         TEExamActivityDto teExamActivityDto = new TEExamActivityDto(ec, examActivityCacheBean, examStudentCacheBean,