ソースを参照

Merge remote-tracking branch 'origin/master'

Joburgess 5 年 前
コミット
cbb6142e3c

+ 9 - 1
edu-im/edu-im-api/src/main/java/com/keao/edu/im/api/client/ImFeignService.java

@@ -96,7 +96,7 @@ public interface ImFeignService {
 	Object privateSend(@RequestBody ImPrivateMessage privateMessage);
 
 	/**
-	 * 发送私聊消息
+	 * 退出教室
 	 * @param reqUserData
 	 * @return
 	 */
@@ -104,6 +104,14 @@ public interface ImFeignService {
 	void leaveRoom(@RequestBody ReqUserData reqUserData);
 
 	/**
+	 * 踢出教室
+	 * @param reqUserData
+	 * @return
+	 */
+	@PostMapping(value = "room/kick")
+	void kickRoom(@RequestBody ReqUserData reqUserData);
+
+	/**
 	 * 加群
 	 * @param userIds
 	 * @param groupId

+ 4 - 1
edu-im/edu-im-api/src/main/java/com/keao/edu/im/api/client/callback/ImFeignServiceFallback.java

@@ -61,7 +61,10 @@ public class ImFeignServiceFallback implements ImFeignService {
     }
 
     @Override
-    public void leaveRoom(ReqUserData reqUserData) {
+    public void leaveRoom(ReqUserData reqUserData) {}
+
+    @Override
+    public void kickRoom(ReqUserData reqUserData) {
 
     }
 

+ 2 - 1
edu-im/edu-im-api/src/main/java/com/keao/edu/im/api/entity/ReqUserData.java

@@ -11,8 +11,9 @@ public class ReqUserData {
 	private boolean disableCamera;
 	private boolean musicMode;
 
-	public ReqUserData(Long registrationId) {
+	public ReqUserData(Long registrationId,String userId) {
 		this.registrationId = registrationId;
+		this.userId = userId;
 	}
 
 	public ReqUserData() {

+ 10 - 9
edu-im/edu-im-server/src/main/java/com/keao/edu/im/service/Impl/RoomServiceImpl.java

@@ -759,6 +759,7 @@ public class RoomServiceImpl implements RoomService {
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Boolean kickMember(ReqUserData data) throws ApiException, Exception {
         StudentExamResultApiDto examResult = eduUserFeignService.getExamResult(data.getRegistrationId());
         String roomId = examResult.getRoomId();
@@ -768,14 +769,14 @@ public class RoomServiceImpl implements RoomService {
         CheckUtils.checkArgument(userId != null, "userId must't be null");
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
 
-        List<RoomMember> kickedUsers = roomMemberDao.findByRidAndUid(roomId, userId);
-        int result = roomMemberDao.deleteUserByRidAndUid(roomId, userId);
+        List<RoomMember> kickedUsers = roomMemberDao.findByRidAndUid(roomId, data.getUserId());
+        int result = roomMemberDao.deleteUserByRidAndUid(roomId, data.getUserId());
         log.info("kickMember: roomId={}, userId={}, result = {}", roomId, userId, result);
         if (result == 0) {
             throw new ApiException(ErrorEnum.ERR_USER_NOT_EXIST_IN_ROOM);
         } else {
-            MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Action_Kick, userId, kickedUsers.get(0).getRole());
-            List<UserInfo> userInfoList = userDao.findByUid(userId);
+            MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Action_Kick, data.getUserId(), kickedUsers.get(0).getRole());
+            List<UserInfo> userInfoList = userDao.findByUid(data.getUserId());
             if (!userInfoList.isEmpty()) {
                 msg.setUserName(userInfoList.get(0).getName());
             }/*
@@ -786,17 +787,17 @@ public class RoomServiceImpl implements RoomService {
             if (!apiResultInfo.isSuccess()) {
                 throw new ApiException(ErrorEnum.ERR_MESSAGE_ERROR);
             }
-            Thread.sleep(50);
+//            Thread.sleep(50);
             log.info("published msg: msg={}", msg);
-            List<Room> roomList = roomDao.findByRid(roomId);
+            /*List<Room> roomList = roomDao.findByRid(roomId);
             if (kickedUsers.get(0).getRole() != Student.getValue() && isUserDisplay(roomList.get(0), userId)) {
                 updateDisplay(roomId, userId, "", 1);
             } else {
                 log.info("don't update display: room={}, userRole={}", roomId, RoleEnum.getEnumByValue(kickedUsers.get(0).getRole()));
-            }
+            }*/
         }
-        userDao.deleteByUid(userId);
-        IMApiResultInfo apiResultInfo = imHelper.quit(new String[]{userId}, roomId);
+        userDao.deleteByUid(data.getUserId());
+        IMApiResultInfo apiResultInfo = imHelper.quit(new String[]{data.getUserId()}, roomId);
         if (!apiResultInfo.isSuccess()) {
             throw new ApiException(ErrorEnum.ERR_EXIT_ROOM_ERROR, apiResultInfo.getErrorMessage());
         }

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamRoomStudentRelationService.java

@@ -75,7 +75,7 @@ public interface ExamRoomStudentRelationService extends BaseService<Long, ExamRo
      */
     void nextBit(Integer examStatus,Long roomId);
 
-    public void publishMessage(ExamRoomStudentRelation examRoomStudentRelation,Integer action,Boolean isPush);
+    public void publishMessage(ExamRoomStudentRelation examRoomStudentRelation,Integer action,Boolean isPush,Integer operator);
 
     public PublishMessageDto getPublishMessage(Long examRegistrationId);
 

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRoomServiceImpl.java

@@ -718,7 +718,7 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 			publishMessageDto.setRoomId(examRoomId.toString());
 			MemberChangedMessage msg = new MemberChangedMessage(5, sysUser.getId().toString(),3);
 			msg.setWaitNum(0);
-			msg.setClassroomSwitch(1);
+			msg.setClassroomSwitch(0);
 			msg.setOpenFlag(openFlag);
 			Map<String,Object> paramMap = new HashMap<>(1);
 			paramMap.put("studentQueue",examRoomStudentRelationService.queryNeedCheckingList(examRoomId));

+ 22 - 22
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRoomStudentRelationServiceImpl.java

@@ -296,6 +296,7 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 	public void recorded(Long roomId) {
 		List<RoomStudentListDto> roomStudentListDtos = examRoomStudentRelationDao.queryStudentList(roomId);
 		if(roomStudentListDtos != null && roomStudentListDtos.size() > 0){
+			SysUser sysUser = sysUserFeignService.queryUserInfo();
 			RoomStudentListDto roomStudentListDto = roomStudentListDtos.get(0);
 			if(roomStudentListDto.getFinishedExam() != 0){
 				throw new BizException("操作失败:当前学员状态不支持录播");
@@ -310,15 +311,15 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 			//关闭学员房间入口
 			examRoomStudentRelation.setClassroomSwitch(0);
 			examRoomStudentRelationDao.update(examRoomStudentRelation);
-			publishMessage(examRoomStudentRelation,MemberChangedMessage.Action_Recorded,true);
+			publishMessage(examRoomStudentRelation,MemberChangedMessage.Action_Recorded,true,sysUser.getId());
 			if(roomStudentListDtos.size() > 1){
 				RoomStudentListDto roomStudentListDto1 = roomStudentListDtos.get(1);
 				if(roomStudentListDto1.getFinishedExam() == 2){
-					nextStudent(roomStudentListDto1.getExamRoomStudentRelationId(),false);
+					nextStudent(roomStudentListDto1.getExamRoomStudentRelationId(),false,sysUser.getId());
 				}
 			}
-			//将当前学员退出教室
-			imFeignService.leaveRoom(new ReqUserData(examRoomStudentRelation.getExamRegistrationId()));
+			//将当前学员退出教室
+			imFeignService.kickRoom(new ReqUserData(examRoomStudentRelation.getExamRegistrationId(),roomStudentListDto.getStudentId().toString()));
 		}
 	}
 
@@ -388,7 +389,7 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 		int recordMinutes = Integer.parseInt(sysConfigService.findByParamName("record_minutes").getParanValue());
 		Date date = DateUtil.addMinutes(stuRecordDetailDto.getRecordStartTime(),recordMinutes);
 		stuRecordDetailDto.setExamEndTime(date);
-		int secondsBetween = DateUtil.secondsBetween(stuRecordDetailDto.getRecordStartTime(), new Date());
+		int secondsBetween = DateUtil.secondsBetween(new Date(),date);
 		if(secondsBetween <= 0){
 			throw new BizException("操作失败:录制超时");
 		}
@@ -431,26 +432,27 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 		List<RoomStudentListDto> roomStudentListDtos = examRoomStudentRelationDao.queryStudentList(examRoomId);
 		if(roomStudentListDtos != null && roomStudentListDtos.size() > 0){
 			RoomStudentListDto roomStudentListDto = roomStudentListDtos.get(0);
+			SysUser sysUser = sysUserFeignService.queryUserInfo();
 			if(roomStudentListDto.getFinishedExam() == 0 || roomStudentListDto.getFinishedExam() == 1){
 				//考试中
-				currentStudent(roomStudentListDto.getExamRoomStudentRelationId(),true,examStatus);
+				currentStudent(roomStudentListDto.getExamRoomStudentRelationId(),true,examStatus,sysUser.getId());
 				if(roomStudentListDtos.size() > 1){
 					RoomStudentListDto roomStudentListDto1 = roomStudentListDtos.get(1);
 					if(roomStudentListDto1.getFinishedExam() == 2){
-						nextStudent(roomStudentListDto1.getExamRoomStudentRelationId(),false);
+						nextStudent(roomStudentListDto1.getExamRoomStudentRelationId(),false,sysUser.getId());
 					}
 				}
 			}else if(roomStudentListDto.getFinishedExam() == 2){
 				//未开始
-				nextStudent(roomStudentListDto.getExamRoomStudentRelationId(),true);
+				nextStudent(roomStudentListDto.getExamRoomStudentRelationId(),true,sysUser.getId());
 			}
 		}
 	}
 
-	private void currentStudent(Long examRoomStudentRelationId,Boolean isPush,Integer examStatus){
+	private void currentStudent(Long examRoomStudentRelationId,Boolean isPush,Integer examStatus,Integer operator){
 		ExamRoomStudentRelation examRoomStudentRelation = examRoomStudentRelationDao.get(examRoomStudentRelationId);
 		//将当前学员退出教室并添加参考状态,如果考试未完成,清除签到时间,重新签到
-		imFeignService.leaveRoom(new ReqUserData(examRoomStudentRelation.getExamRegistrationId()));
+		imFeignService.kickRoom(new ReqUserData(examRoomStudentRelation.getExamRegistrationId(),examRoomStudentRelation.getStudentId().toString()));
 		if(examStatus != null && examStatus == 0){
 			//未完成
 			examRoomStudentRelationDao.cleanSignInTime(examRoomStudentRelation.getExamRegistrationId());
@@ -462,35 +464,33 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 		//关闭学员房间入口
 		examRoomStudentRelation.setClassroomSwitch(0);
 		examRoomStudentRelationDao.update(examRoomStudentRelation);
-		publishMessage(examRoomStudentRelation,MemberChangedMessage.Student_Queue,isPush);
+		publishMessage(examRoomStudentRelation,MemberChangedMessage.Student_Queue,isPush,operator);
 	}
 
-	private void nextStudent(Long nextExamRoomStudentRelationId,Boolean isPush){
+	private void nextStudent(Long nextExamRoomStudentRelationId,Boolean isPush,Integer operator){
 		if(nextExamRoomStudentRelationId != null){
 			ExamRoomStudentRelation examRoomStudentRelation = examRoomStudentRelationDao.get(nextExamRoomStudentRelationId);
 			//开启学员房间入口
 			examRoomStudentRelation.setClassroomSwitch(1);
 			examRoomStudentRelationDao.update(examRoomStudentRelation);
-			publishMessage(examRoomStudentRelation,MemberChangedMessage.Student_Queue,isPush);
+			publishMessage(examRoomStudentRelation,MemberChangedMessage.Student_Queue,isPush,operator);
 		}
 	}
 
 	@Override
-	public void publishMessage(ExamRoomStudentRelation examRoomStudentRelation,Integer action,Boolean isPush){
-		SysUser sysUser = sysUserFeignService.queryUserInfo();
+	public void publishMessage(ExamRoomStudentRelation examRoomStudentRelation,Integer action,Boolean isPush,Integer operator){
 		if (!isPush){
 			return;
 		}
 		PublishMessageDto publishMessageDto = new PublishMessageDto();
-		String userId = sysUser.getId().toString();
-		publishMessageDto.setUserId(userId);
+		publishMessageDto.setUserId(operator.toString());
 		publishMessageDto.setRoomId(examRoomStudentRelation.getExamRoomId().toString());
-		MemberChangedMessage msg;
-		if(action == 3 || action == 4){
+		MemberChangedMessage msg = new MemberChangedMessage(action, examRoomStudentRelation.getStudentId().toString(),3);
+		/*if(action == 3 || action == 4){
 			msg = new MemberChangedMessage(action, examRoomStudentRelation.getStudentId().toString(),3);
 		}else {
-			msg = new MemberChangedMessage(action, userId,3);
-		}
+			msg = new MemberChangedMessage(action, examRoomStudentRelation.getStudentId(),3);
+		}*/
 //		String jsonString = JSONObject.toJSONString(examCertificationService.needCheckingDetail(examRoomStudentRelation.getExamRegistrationId()));
 		NeedCheckingDetailDto needCheckingDetailDto = examCertificationService.needCheckingDetail(examRoomStudentRelation.getExamRegistrationId());
 		msg.setWaitNum(needCheckingDetailDto.getWaitNum());
@@ -513,7 +513,7 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 		String userId = sysUser.getId().toString();
 		publishMessageDto.setUserId(userId);
 		publishMessageDto.setRoomId(examRoomStudentRelation.getExamRoomId().toString());
-		MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Student_Queue, userId,3);
+		MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Student_Queue, examRoomStudentRelation.getStudentId().toString(),3);
 //		String jsonString = JSONObject.toJSONString(examCertificationService.needCheckingDetail(examRoomStudentRelation.getExamRegistrationId()));
 //		msg.setAppParamJson(jsonString);
 		NeedCheckingDetailDto needCheckingDetailDto = examCertificationService.needCheckingDetail(examRoomStudentRelation.getExamRegistrationId());