wangliang 4 gadi atpakaļ
vecāks
revīzija
789d919091

+ 42 - 20
themis-backend/src/main/java/com/qmth/themis/backend/api/TIeInvigilateCallMobileController.java

@@ -3,12 +3,14 @@ package com.qmth.themis.backend.api;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.common.collect.Sets;
 import com.qmth.themis.backend.config.DictionaryConfig;
 import com.qmth.themis.backend.config.DictionaryConfig;
 import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.bean.mobile.MobileAuthorizationMonitorBean;
 import com.qmth.themis.business.bean.mobile.MobileAuthorizationMonitorBean;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
+import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
 import com.qmth.themis.business.config.SystemConfig;
 import com.qmth.themis.business.config.SystemConfig;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.AuthDto;
 import com.qmth.themis.business.dto.AuthDto;
@@ -16,10 +18,7 @@ import com.qmth.themis.business.dto.MqDto;
 import com.qmth.themis.business.dto.response.TIeExamInvigilateCallDto;
 import com.qmth.themis.business.dto.response.TIeExamInvigilateCallDto;
 import com.qmth.themis.business.entity.*;
 import com.qmth.themis.business.entity.*;
 import com.qmth.themis.business.enums.*;
 import com.qmth.themis.business.enums.*;
-import com.qmth.themis.business.service.MqDtoService;
-import com.qmth.themis.business.service.TEExamService;
-import com.qmth.themis.business.service.TIeExamInvigilateCallService;
-import com.qmth.themis.business.service.TOeExamRecordService;
+import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.business.util.ServletUtil;
 import com.qmth.themis.business.util.ServletUtil;
 import com.qmth.themis.business.util.SessionUtil;
 import com.qmth.themis.business.util.SessionUtil;
@@ -78,6 +77,9 @@ public class TIeInvigilateCallMobileController {
     @Resource
     @Resource
     TOeExamRecordService tOeExamRecordService;
     TOeExamRecordService tOeExamRecordService;
 
 
+    @Resource
+    TEExamStudentService teExamStudentService;
+
     @ApiOperation(value = "监考监控通话查询接口")
     @ApiOperation(value = "监考监控通话查询接口")
     @RequestMapping(value = "/call/list", method = RequestMethod.POST)
     @RequestMapping(value = "/call/list", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "监考监控信息", response = TIeExamInvigilateCallDto.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "监考监控信息", response = TIeExamInvigilateCallDto.class)})
@@ -99,6 +101,11 @@ public class TIeInvigilateCallMobileController {
         IPage<TIeExamInvigilateCallDto> tIeExamInvigilateCallIPage = tIeExamInvigilateCallService.examInvigilateCallQuery(new Page<>(pageNumber, pageSize), examId, userId, tbUser.getOrgId(), MonitorStatusSourceEnum.START.name(), callStatus);
         IPage<TIeExamInvigilateCallDto> tIeExamInvigilateCallIPage = tIeExamInvigilateCallService.examInvigilateCallQuery(new Page<>(pageNumber, pageSize), examId, userId, tbUser.getOrgId(), MonitorStatusSourceEnum.START.name(), callStatus);
         tIeExamInvigilateCallIPage.getRecords().forEach(s -> {
         tIeExamInvigilateCallIPage.getRecords().forEach(s -> {
             s.setBasePhotoPath(systemConfig.getProperty("aliyun.oss.url") + File.separator + s.getBasePhotoPath());
             s.setBasePhotoPath(systemConfig.getProperty("aliyun.oss.url") + File.separator + s.getBasePhotoPath());
+            try {
+                s.setSourceUserId(this.getSourceUserId(s.getExamRecordId()));
+            } catch (NoSuchAlgorithmException e) {
+                e.printStackTrace();
+            }
         });
         });
         return ResultUtil.ok(tIeExamInvigilateCallIPage);
         return ResultUtil.ok(tIeExamInvigilateCallIPage);
     }
     }
@@ -208,13 +215,41 @@ public class TIeInvigilateCallMobileController {
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
         String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
         AuthDto authDto = (AuthDto) redisUtil.get(SystemConstant.userOauth + "::" + tbUser.getId());
         AuthDto authDto = (AuthDto) redisUtil.get(SystemConstant.userOauth + "::" + tbUser.getId());
         String monitorUserId = null;
         String monitorUserId = null;
+        String sourceUserId = this.getSourceUserId(recordId);
+        if (Objects.nonNull(authDto) && !authDto.toString().contains(RoleEnum.STUDENT.name())) {
+            monitorUserId = "s_" + tbSession.getId();
+        } else {
+            monitorUserId = "m_" + tbSession.getId();
+        }
+        String monitorUserSig = tencentYunUtil.getSign(monitorUserId, SystemConstant.TENCENT_EXPIRE_TIME);
+        Map<String, Object> map = new HashMap<>();
+        map.put("monitorKey", monitorKey);
+        map.put("monitorUserId", monitorUserId);
+        map.put("sourceUserId", sourceUserId);
+        map.put("monitorUserSig", monitorUserSig);
+        map.put("appId", dictionaryConfig.tencentYunDomain().getAppId());
+        map.put("key", dictionaryConfig.tencentYunDomain().getKey());
+        return ResultUtil.ok(map);
+    }
+
+    /**
+     * 获取来源userId
+     *
+     * @param recordId
+     * @return
+     * @throws NoSuchAlgorithmException
+     */
+    private String getSourceUserId(Long recordId) throws NoSuchAlgorithmException {
         String sourceUserId = null;
         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(examId)) {
             TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(recordId);
             TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(recordId);
             examId = tOeExamRecord.getExamId();
             examId = tOeExamRecord.getExamId();
+            examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
         }
         }
         ExamCacheBean ec = teExamService.getExamCacheBean(examId);//考试缓存
         ExamCacheBean ec = teExamService.getExamCacheBean(examId);//考试缓存
+        ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
         ec.getMonitorVideoSource();
         ec.getMonitorVideoSource();
         List<String> monitorVideoSourceList = null;
         List<String> monitorVideoSourceList = null;
         if (Objects.nonNull(ec.getMonitorVideoSource()) && !Objects.equals(ec.getMonitorVideoSource().toString().trim().replaceAll(" ", ""), "")) {
         if (Objects.nonNull(ec.getMonitorVideoSource()) && !Objects.equals(ec.getMonitorVideoSource().toString().trim().replaceAll(" ", ""), "")) {
@@ -224,7 +259,7 @@ public class TIeInvigilateCallMobileController {
         if (Objects.nonNull(monitorVideoSourceList)) {
         if (Objects.nonNull(monitorVideoSourceList)) {
             if (monitorVideoSourceList.size() == 4 || (ec.getMonitorVideoSource().toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_SCREEN.name()) || ec.getMonitorVideoSource().toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_CAMERA.name()))) {
             if (monitorVideoSourceList.size() == 4 || (ec.getMonitorVideoSource().toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_SCREEN.name()) || ec.getMonitorVideoSource().toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_CAMERA.name()))) {
                 for (Source s : Source.values()) {
                 for (Source s : Source.values()) {
-                    String sessionId = SessionUtil.digest(tbUser.getId(), Math.abs(authDto.getRoleCodes().toString().hashCode()), s.name());
+                    String sessionId = SessionUtil.digest(examStudentCacheBean.getIdentity(), Math.abs(Sets.newHashSet(RoleEnum.STUDENT.name()).toString().hashCode()), s.name());
                     TBSession tbSessionClient = (TBSession) redisUtil.getUserSession(sessionId);
                     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(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.name()))) {
                         if (Objects.nonNull(ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.CLIENT_CAMERA.name()))) {
@@ -238,7 +273,7 @@ public class TIeInvigilateCallMobileController {
                 }
                 }
             } else {
             } else {
                 for (Source s : Source.values()) {
                 for (Source s : Source.values()) {
-                    String sessionId = SessionUtil.digest(tbUser.getId(), Math.abs(authDto.getRoleCodes().toString().hashCode()), s.name());
+                    String sessionId = SessionUtil.digest(examStudentCacheBean.getIdentity(), Math.abs(Sets.newHashSet(RoleEnum.STUDENT.name()).toString().hashCode()), s.name());
                     TBSession tbSessionPhone = (TBSession) redisUtil.getUserSession(sessionId);
                     TBSession tbSessionPhone = (TBSession) redisUtil.getUserSession(sessionId);
                     if (Objects.nonNull(tbSessionPhone) && tbSessionPhone.getExpireTime() > System.currentTimeMillis() && (Objects.equals(tbSessionPhone.getSource(), Source.MOBILE_FIRST.name()) || Objects.equals(tbSessionPhone.getSource(), Source.MOBILE_SECOND.name())) && (Objects.equals(tbSessionPhone.getPlatform(), Platform.ANDROID.name()) || Objects.equals(tbSessionPhone.getPlatform(), Platform.IOS.name()))) {
                     if (Objects.nonNull(tbSessionPhone) && tbSessionPhone.getExpireTime() > System.currentTimeMillis() && (Objects.equals(tbSessionPhone.getSource(), Source.MOBILE_FIRST.name()) || Objects.equals(tbSessionPhone.getSource(), Source.MOBILE_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.name()))) {
                         if (Objects.nonNull(ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.MOBILE_FIRST.name()))) {
@@ -252,19 +287,6 @@ public class TIeInvigilateCallMobileController {
                 }
                 }
             }
             }
         }
         }
-        if (Objects.nonNull(authDto) && authDto.toString().contains(RoleEnum.STUDENT.name())) {
-            monitorUserId = "s_" + tbSession.getId();
-        } else {
-            monitorUserId = "m_" + tbSession.getId();
-        }
-        String monitorUserSig = tencentYunUtil.getSign(monitorUserId, SystemConstant.TENCENT_EXPIRE_TIME);
-        Map<String, Object> map = new HashMap<>();
-        map.put("monitorKey", monitorKey);
-        map.put("monitorUserId", monitorUserId);
-        map.put("sourceUserId", sourceUserId);
-        map.put("monitorUserSig", monitorUserSig);
-        map.put("appId", dictionaryConfig.tencentYunDomain().getAppId());
-        map.put("key", dictionaryConfig.tencentYunDomain().getKey());
-        return ResultUtil.ok(map);
+        return sourceUserId;
     }
     }
 }
 }

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

@@ -75,6 +75,10 @@ public class TIeExamInvigilateCall extends BaseEntity {
     @ApiModelProperty(value = "结束通话时间")
     @ApiModelProperty(value = "结束通话时间")
     private Long endTime;
     private Long endTime;
 
 
+    @ApiModelProperty(value = "来源userId")
+    @TableField(exist = false)
+    private String sourceUserId;
+
     public TIeExamInvigilateCall() {
     public TIeExamInvigilateCall() {
 
 
     }
     }
@@ -88,6 +92,14 @@ public class TIeExamInvigilateCall extends BaseEntity {
         this.monitorKey = monitorKey;
         this.monitorKey = monitorKey;
     }
     }
 
 
+    public String getSourceUserId() {
+        return sourceUserId;
+    }
+
+    public void setSourceUserId(String sourceUserId) {
+        this.sourceUserId = sourceUserId;
+    }
+
     public Long getStartTime() {
     public Long getStartTime() {
         return startTime;
         return startTime;
     }
     }

+ 3 - 0
themis-business/src/main/resources/mapper/TOeExamRecordMapper.xml

@@ -277,6 +277,9 @@
 			<if test="examId != null and examId != ''">
 			<if test="examId != null and examId != ''">
 				and t.exam_id = #{examId}
 				and t.exam_id = #{examId}
 			</if>
 			</if>
+			<if test="orgId != null and orgId != ''">
+				and tee.org_id = #{orgId}
+			</if>
 			and (t.status = 'FIRST_PREPARE' or t.status = 'ANSWERING' or t.status = 'BREAK_OFF' or t.status = 'RESUME_PREPARE')
 			and (t.status = 'FIRST_PREPARE' or t.status = 'ANSWERING' or t.status = 'BREAK_OFF' or t.status = 'RESUME_PREPARE')
 		</where>
 		</where>
 		ORDER BY RAND() LIMIT #{randomNum}
 		ORDER BY RAND() LIMIT #{randomNum}