瀏覽代碼

Merge remote-tracking branch 'origin/master'

Joburgess 5 年之前
父節點
當前提交
f723681a38

+ 7 - 9
edu-im/edu-im-server/src/main/java/com/keao/edu/im/mec/im/IMHelper.java

@@ -252,11 +252,14 @@ public class IMHelper {
         jsonObject.put("hostUserId",hostUserId);
         jsonObject.put("hostStreamId",hostUserId);
         JSONObject json = new JSONObject();
-        json.put("sessionId",roomQuery(roomId));
+        String sessionId = redisTemplate.opsForValue().get("sessionId:" + roomId);
+        if(StringUtils.isEmpty(sessionId)){
+            sessionId = roomQuery(roomId);
+            redisTemplate.opsForValue().set("sessionId:" + roomId,sessionId);
+        }
+        json.put("sessionId",sessionId);
         json.put("config",jsonObject);
 
-
-
         /*JSONObject jsonObject = new JSONObject();
         jsonObject.put("mode",3);
         jsonObject.put("videoFormat","mp4");
@@ -293,12 +296,6 @@ public class IMHelper {
         JSONObject jsonObject1 = new JSONObject();
         jsonObject1.put("video",jsonArray);
         jsonObject.put("input",jsonObject1);*/
-
-
-        json.put("sessionId",roomQuery(roomId));
-        json.put("config",jsonObject);
-
-
         String body = json.toJSONString();
 
         Thread.sleep(1000l);
@@ -421,6 +418,7 @@ public class IMHelper {
         if("200".equals(code)){
             return resultObject.get("sessionId").toString();
         }else {
+            log.error("获取sessionId失败 returnResult:{}",returnResult);
             throw new BizException("获取sessionId失败");
         }
     }

+ 5 - 2
edu-im/edu-im-server/src/main/java/com/keao/edu/im/service/Impl/RoomServiceImpl.java

@@ -28,11 +28,10 @@ import com.keao.edu.user.api.client.EduUserFeignService;
 import com.keao.edu.user.api.entity.ExamRoom;
 import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import com.keao.edu.user.api.enums.StudentExamResultApiDto;
-import com.keao.edu.util.date.DateUtil;
-import io.swagger.models.auth.In;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
@@ -78,6 +77,9 @@ public class RoomServiceImpl implements RoomService {
     @Autowired
     private EduUserFeignService eduUserFeignService;
 
+    @Autowired
+    private RedisTemplate<String,String> redisTemplate;
+
     @Override
     public void roomQuery(String roomId) throws Exception {
         imHelper.roomQuery(roomId);
@@ -584,6 +586,7 @@ public class RoomServiceImpl implements RoomService {
             });
             roomDao.deleteByRid(roomId.toString());
             imHelper.dismiss(userId,roomId.toString());
+            redisTemplate.delete("sessionId:" + roomId);
         }
     }
 

+ 2 - 12
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamRoomStudentRelationServiceImpl.java

@@ -1,6 +1,5 @@
 package com.keao.edu.user.service.impl;
 
-import com.alibaba.fastjson.JSONObject;
 import com.keao.edu.auth.api.client.SysUserFeignService;
 import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.common.dal.BaseDAO;
@@ -648,14 +647,7 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 			SysUser sysUser = sysUserFeignService.queryUserInfo();
 			//当前用户是呼叫中或者考试中
 			if(roomStudentListDto.getFinishedExam() == 0 || roomStudentListDto.getFinishedExam() == 1){
-				boolean isPush = true;
-				if(roomStudentListDtos.size() > 1){
-					RoomStudentListDto roomStudentListDto1 = roomStudentListDtos.get(1);
-					if(roomStudentListDto1.getFinishedExam() == 2){
-						isPush = false;
-					}
-				}
-				currentStudent(roomStudentListDto.getExamRoomStudentRelationId(),isPush,examStatus,sysUser.getId());
+				currentStudent(roomStudentListDto.getExamRoomStudentRelationId(),true,examStatus,sysUser.getId());
 				//考试中
 				if(roomStudentListDtos.size() > 1){
 					RoomStudentListDto roomStudentListDto1 = roomStudentListDtos.get(1);
@@ -688,13 +680,12 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 	private void currentStudent(Long examRoomStudentRelationId,Boolean isPush,Integer examStatus,Integer operator){
 		ExamRoomStudentRelation examRoomStudentRelation = examRoomStudentRelationDao.get(examRoomStudentRelationId);
 		//将当前学员退出教室并添加参考状态,如果考试未完成,清除签到时间,重新签到
-//
 		if(examStatus != null && examStatus == 0){
 			//未完成
 			examRoomStudentRelationDao.cleanSignInTime(examRoomStudentRelation.getExamRegistrationId());
 			examRoomStudentRelation.setSignInTime(null);
 			studentExamResultDao.updateFinishedExam(examRoomStudentRelation.getExamRegistrationId(),3);
-			publishMessage(examRoomStudentRelation,MemberChangedMessage.Not_Finish,isPush,operator);
+			publishMessage(examRoomStudentRelation,MemberChangedMessage.Not_Finish,true,operator);
 			HashMap<Integer, String> map = new HashMap<>(1);
 			map.put(examRoomStudentRelation.getStudentId(),examRoomStudentRelation.getStudentId().toString());
 			ExaminationBasic examinationBasic = examinationBasicDao.get(examRoomStudentRelation.getExaminationBasicId());
@@ -719,7 +710,6 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 		map.put(examRoomStudentRelation.getStudentId(),examRoomStudentRelation.getStudentId().toString());
 		String url = "3?examRegistrationId=" + examRoomStudentRelation.getExamRegistrationId();
 		sysMessageService.batchSendMessage(MessageTypeEnum.EXAM_STARTED_PUSH,map,null,0,url,JiguangPushPlugin.PLUGIN_NAME);
-
 		//状态变更为呼叫中
 		studentExamResultDao.updateFinishedExam(examRoomStudentRelation.getExamRegistrationId(),1);
 		publishMessage(examRoomStudentRelation,MemberChangedMessage.Student_Queue,isPush,operator);