zouxuan 5 éve
szülő
commit
4303c80d20

+ 1 - 0
edu-im/edu-im-server/src/main/java/com/keao/edu/im/dao/StudentAttendanceDao.java

@@ -7,4 +7,5 @@ import org.springframework.stereotype.Repository;
 @Repository
 @Repository
 public interface StudentAttendanceDao extends JpaRepository<StudentAttendance, Long> {
 public interface StudentAttendanceDao extends JpaRepository<StudentAttendance, Long> {
 
 
+    StudentAttendance findByUserIdAndExaminationBasicIdAndExamRoomId(Integer userId,Integer basicId,Long roomId);
 }
 }

+ 1 - 0
edu-im/edu-im-server/src/main/java/com/keao/edu/im/dao/TeacherAttendanceDao.java

@@ -8,4 +8,5 @@ import org.springframework.stereotype.Repository;
 @Repository
 @Repository
 public interface TeacherAttendanceDao extends JpaRepository<TeacherAttendance, Long> {
 public interface TeacherAttendanceDao extends JpaRepository<TeacherAttendance, Long> {
 
 
+    TeacherAttendance findByTeacherIdAndExaminationBasicIdAndExamRoomId(Integer teacherId,Integer basicId,Long roomId);
 }
 }

+ 92 - 12
edu-im/edu-im-server/src/main/java/com/keao/edu/im/service/Impl/RoomServiceImpl.java

@@ -1,5 +1,6 @@
 package com.keao.edu.im.service.Impl;
 package com.keao.edu.im.service.Impl;
 
 
+import com.keao.edu.common.enums.YesOrNoEnum;
 import com.keao.edu.user.api.client.EduUserFeignService;
 import com.keao.edu.user.api.client.EduUserFeignService;
 import com.keao.edu.auth.api.client.SysUserFeignService;
 import com.keao.edu.auth.api.client.SysUserFeignService;
 import com.keao.edu.user.api.entity.ExamRoom;
 import com.keao.edu.user.api.entity.ExamRoom;
@@ -19,6 +20,7 @@ import com.keao.edu.im.utils.CodeUtil;
 import com.keao.edu.im.utils.DateTimeUtils;
 import com.keao.edu.im.utils.DateTimeUtils;
 import com.keao.edu.im.utils.IdentifierUtils;
 import com.keao.edu.im.utils.IdentifierUtils;
 import com.keao.edu.im.whiteboard.WhiteBoardHelper;
 import com.keao.edu.im.whiteboard.WhiteBoardHelper;
+import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,6 +31,8 @@ import org.springframework.transaction.annotation.Transactional;
 import java.util.*;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
+import static com.keao.edu.im.pojo.RoleEnum.Student;
+
 /**
 /**
  * Created by super_zou on 2019/11/28.
  * Created by super_zou on 2019/11/28.
  */
  */
@@ -115,7 +119,14 @@ public class RoomServiceImpl implements RoomService {
             }else if(isAssistant){
             }else if(isAssistant){
                 roleEnum = RoleEnum.AssistantTeacher;
                 roleEnum = RoleEnum.AssistantTeacher;
             }else {
             }else {
-                roleEnum = RoleEnum.Student;
+                ExamRoomStudentRelation examRoomStudentRelation = eduUserFeignService.getExamRoomStudentRelation(examRoom.getExaminationBasicId(), roomId, sysUser.getId());
+                if(examRoomStudentRelation == null){
+                    throw new BizException("学员考试数据异常");
+                }
+                if(examRoomStudentRelation.getClassroomSwitch() == YesOrNoEnum.NO){
+                    throw new BizException("考级入口已关闭");
+                }
+                roleEnum = Student;
             }
             }
             saveRoomMember(userId,sysUser.getAvatar(), realName, roomId, roleEnum.getValue(), !isDisableCamera,!isMusicMode, curTime);
             saveRoomMember(userId,sysUser.getAvatar(), realName, roomId, roleEnum.getValue(), !isDisableCamera,!isMusicMode, curTime);
             IMApiResultInfo resultInfo = imHelper.joinGroup(new String[]{userId}, roomId, roomId);
             IMApiResultInfo resultInfo = imHelper.joinGroup(new String[]{userId}, roomId, roomId);
@@ -130,6 +141,15 @@ public class RoomServiceImpl implements RoomService {
         } else {
         } else {
             RoomMember roomMember = memberList.get(0);
             RoomMember roomMember = memberList.get(0);
             roleEnum = RoleEnum.getEnumByValue(roomMember.getRole());
             roleEnum = RoleEnum.getEnumByValue(roomMember.getRole());
+            if(roleEnum == Student){
+                ExamRoomStudentRelation examRoomStudentRelation = eduUserFeignService.getExamRoomStudentRelation(examRoom.getExaminationBasicId(), roomId, sysUser.getId());
+                if(examRoomStudentRelation == null){
+                    throw new BizException("学员考试数据异常");
+                }
+                if(examRoomStudentRelation.getClassroomSwitch() == YesOrNoEnum.NO){
+                    throw new BizException("考级入口已关闭");
+                }
+            }
 //            roomMemberDao.updateCameraByRidAndUid(roomId, userId, !isDisableCamera);
 //            roomMemberDao.updateCameraByRidAndUid(roomId, userId, !isDisableCamera);
             userResult.setCamera(roomMember.isCamera());
             userResult.setCamera(roomMember.isCamera());
             userResult.setHandUp(roomMember.isHand());
             userResult.setHandUp(roomMember.isHand());
@@ -196,23 +216,82 @@ public class RoomServiceImpl implements RoomService {
             }
             }
         }
         }
         if(userId.equals(examRoom.getMainTeacherUserId()) || isAssistant){
         if(userId.equals(examRoom.getMainTeacherUserId()) || isAssistant){
+            TeacherAttendance attendance = teacherAttendanceDao.findByTeacherIdAndExaminationBasicIdAndExamRoomId(userId, examRoom.getExaminationBasicId(), examRoom.getId());
+            if(attendance != null){
+                return;
+            }
             TeacherAttendance teacherAttendance = new TeacherAttendance();
             TeacherAttendance teacherAttendance = new TeacherAttendance();
             teacherAttendance.setExamRoomId(examRoom.getId());
             teacherAttendance.setExamRoomId(examRoom.getId());
             teacherAttendance.setSignInTime(date);
             teacherAttendance.setSignInTime(date);
             teacherAttendance.setTeacherId(userId);
             teacherAttendance.setTeacherId(userId);
             teacherAttendance.setTenantId(examRoom.getTenantId());
             teacherAttendance.setTenantId(examRoom.getTenantId());
             teacherAttendance.setCreateTime(date);
             teacherAttendance.setCreateTime(date);
+            teacherAttendance.setExaminationBasicId(examRoom.getExaminationBasicId());
             teacherAttendanceDao.save(teacherAttendance);
             teacherAttendanceDao.save(teacherAttendance);
         }else {
         }else {
+            StudentAttendance attendance = studentAttendanceDao.findByUserIdAndExaminationBasicIdAndExamRoomId(userId, examRoom.getExaminationBasicId(), examRoom.getId());
+            if(attendance != null){
+                return;
+            }
             StudentAttendance studentAttendance = new StudentAttendance();
             StudentAttendance studentAttendance = new StudentAttendance();
             studentAttendance.setExamRoomId(examRoom.getId());
             studentAttendance.setExamRoomId(examRoom.getId());
             studentAttendance.setSignInTime(date);
             studentAttendance.setSignInTime(date);
             studentAttendance.setUserId(userId);
             studentAttendance.setUserId(userId);
             studentAttendance.setCreateTime(date);
             studentAttendance.setCreateTime(date);
+            studentAttendance.setExaminationBasicId(examRoom.getExaminationBasicId());
             studentAttendanceDao.save(studentAttendance);
             studentAttendanceDao.save(studentAttendance);
         }
         }
     }
     }
 
 
+    @Override
+    @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
+    public void signOut(Long roomId) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        Integer userId = sysUser.getId();
+        log.info("roomSignIn: roomId={}, userId={}", roomId, userId);
+        ExamRoom examRoom = eduUserFeignService.getExamRoom(roomId.intValue());
+        Date date = new Date();
+        boolean isAssistant = false;
+        if (StringUtils.isNotEmpty(examRoom.getAssistantTeacherUserIdList())){
+            List<String> list = Arrays.asList(examRoom.getAssistantTeacherUserIdList().split(","));
+            if(list.contains(userId)){
+                isAssistant = true;
+            }
+        }
+        if(userId.equals(examRoom.getMainTeacherUserId()) || isAssistant){
+            TeacherAttendance attendance = teacherAttendanceDao.findByTeacherIdAndExaminationBasicIdAndExamRoomId(userId, examRoom.getExaminationBasicId(), examRoom.getId());
+            if(attendance == null){
+                attendance = new TeacherAttendance();
+                attendance.setExamRoomId(examRoom.getId());
+                attendance.setSignInTime(date);
+                attendance.setSignOutTime(date);
+                attendance.setTeacherId(userId);
+                attendance.setTenantId(examRoom.getTenantId());
+                attendance.setCreateTime(date);
+                attendance.setExaminationBasicId(examRoom.getExaminationBasicId());
+                teacherAttendanceDao.save(attendance);
+            }else {
+                attendance.setSignOutTime(date);
+                teacherAttendanceDao.saveAndFlush(attendance);
+            }
+        }else {
+            StudentAttendance attendance = studentAttendanceDao.findByUserIdAndExaminationBasicIdAndExamRoomId(userId, examRoom.getExaminationBasicId(), examRoom.getId());
+            if(attendance == null){
+                attendance = new StudentAttendance();
+                attendance.setExamRoomId(examRoom.getId());
+                attendance.setSignInTime(date);
+                attendance.setSignOutTime(date);
+                attendance.setUserId(userId);
+                attendance.setCreateTime(date);
+                attendance.setExaminationBasicId(examRoom.getExaminationBasicId());
+                studentAttendanceDao.save(attendance);
+            }else {
+                attendance.setSignOutTime(date);
+                studentAttendanceDao.saveAndFlush(attendance);
+            }
+        }
+    }
+
     private void saveRoom(String roomId, String roomName, Date createTime, String display) {
     private void saveRoom(String roomId, String roomName, Date createTime, String display) {
         Room room = new Room();
         Room room = new Room();
         room.setRid(roomId);
         room.setRid(roomId);
@@ -313,6 +392,7 @@ public class RoomServiceImpl implements RoomService {
             }
             }
         }
         }
         userDao.deleteByUid(userId);
         userDao.deleteByUid(userId);
+        this.signOut(Long.parseLong(roomId));
         return true;
         return true;
     }
     }
 
 
@@ -381,7 +461,7 @@ public class RoomServiceImpl implements RoomService {
                         log.info("change the role: {}, {}, {}, result: {}", roomId, userId, changedRole, r);
                         log.info("change the role: {}, {}, {}, result: {}", roomId, userId, changedRole, r);
                         result = true;
                         result = true;
                     }*/
                     }*/
-                    if (oldUsers.get(0).getRole() != RoleEnum.Student.getValue() && isUserDisplay(roomList.get(0), oldUsers.get(0).getUid())) {
+                    if (oldUsers.get(0).getRole() != Student.getValue() && isUserDisplay(roomList.get(0), oldUsers.get(0).getUid())) {
                         updateDisplay(roomId, userId, "", 1);
                         updateDisplay(roomId, userId, "", 1);
                     } else {
                     } else {
                         log.info("don't update display: room={}, userRole={}", roomList.get(0), RoleEnum.getEnumByValue(oldUsers.get(0).getRole()));
                         log.info("don't update display: room={}, userRole={}", roomList.get(0), RoleEnum.getEnumByValue(oldUsers.get(0).getRole()));
@@ -424,7 +504,7 @@ public class RoomServiceImpl implements RoomService {
             Thread.sleep(50);
             Thread.sleep(50);
             log.info("published msg: msg={}", msg);
             log.info("published msg: msg={}", msg);
             List<Room> roomList = roomDao.findByRid(roomId);
             List<Room> roomList = roomDao.findByRid(roomId);
-            if (kickedUsers.get(0).getRole() != RoleEnum.Student.getValue() && isUserDisplay(roomList.get(0), userId)) {
+            if (kickedUsers.get(0).getRole() != Student.getValue() && isUserDisplay(roomList.get(0), userId)) {
                 updateDisplay(roomId, userId, "", 1);
                 updateDisplay(roomId, userId, "", 1);
             } else {
             } else {
                 log.info("don't update display: room={}, userRole={}", roomId, RoleEnum.getEnumByValue(kickedUsers.get(0).getRole()));
                 log.info("don't update display: room={}, userRole={}", roomId, RoleEnum.getEnumByValue(kickedUsers.get(0).getRole()));
@@ -671,7 +751,7 @@ public class RoomServiceImpl implements RoomService {
                 roomMembers.add(new RoomMember(split[i]));
                 roomMembers.add(new RoomMember(split[i]));
             }
             }
         }else {
         }else {
-            roomMembers = roomMemberDao.findByRidAndRole(data.getRoomId(),RoleEnum.Student.getValue());
+            roomMembers = roomMemberDao.findByRidAndRole(data.getRoomId(), Student.getValue());
         }
         }
         if(roomMembers.size() == 0){
         if(roomMembers.size() == 0){
             return false;
             return false;
@@ -823,7 +903,7 @@ public class RoomServiceImpl implements RoomService {
 
 
         ScheduledTaskInfo taskInfo = scheduleManager.executeTask(ticket);
         ScheduledTaskInfo taskInfo = scheduleManager.executeTask(ticket);
         log.info("approveSpeech: task = {}", taskInfo);
         log.info("approveSpeech: task = {}", taskInfo);
-        roomMemberDao.updateRoleByRidAndUid(roomId, taskInfo.getApplyUserId(), RoleEnum.Student.getValue());
+        roomMemberDao.updateRoleByRidAndUid(roomId, taskInfo.getApplyUserId(), Student.getValue());
 
 
         SpeechResultMessage msg = new SpeechResultMessage(SpeechResultMessage.Action_Approve);
         SpeechResultMessage msg = new SpeechResultMessage(SpeechResultMessage.Action_Approve);
         List<UserInfo> userInfoList = userDao.findByUid(taskInfo.getApplyUserId());
         List<UserInfo> userInfoList = userDao.findByUid(taskInfo.getApplyUserId());
@@ -833,7 +913,7 @@ public class RoomServiceImpl implements RoomService {
         if (!userInfoList.isEmpty()) {
         if (!userInfoList.isEmpty()) {
             msg.setReqUserName(userInfoList.get(0).getName());
             msg.setReqUserName(userInfoList.get(0).getName());
         }
         }
-        msg.setRole(RoleEnum.Student.getValue());
+        msg.setRole(Student.getValue());
         IMApiResultInfo resultInfo = imHelper.publishMessage(userId, taskInfo.getApplyUserId(), roomId, msg);
         IMApiResultInfo resultInfo = imHelper.publishMessage(userId, taskInfo.getApplyUserId(), roomId, msg);
         if (!resultInfo.isSuccess()) {
         if (!resultInfo.isSuccess()) {
             throw new ApiException(ErrorEnum.ERR_MESSAGE_ERROR, resultInfo.getErrorMessage());
             throw new ApiException(ErrorEnum.ERR_MESSAGE_ERROR, resultInfo.getErrorMessage());
@@ -841,7 +921,7 @@ public class RoomServiceImpl implements RoomService {
 
 
         RoleChangedMessage rcMsg = new RoleChangedMessage(userId);
         RoleChangedMessage rcMsg = new RoleChangedMessage(userId);
         List<RoleChangedMessage.ChangedUser> changedUserList = new ArrayList<>();
         List<RoleChangedMessage.ChangedUser> changedUserList = new ArrayList<>();
-        RoleChangedMessage.ChangedUser user = new RoleChangedMessage.ChangedUser(taskInfo.getApplyUserId(), RoleEnum.Student.getValue());
+        RoleChangedMessage.ChangedUser user = new RoleChangedMessage.ChangedUser(taskInfo.getApplyUserId(), Student.getValue());
         if (!userInfoList.isEmpty()) {
         if (!userInfoList.isEmpty()) {
             user.setUserName(userInfoList.get(0).getName());
             user.setUserName(userInfoList.get(0).getName());
         }
         }
@@ -864,7 +944,7 @@ public class RoomServiceImpl implements RoomService {
         SpeechResultMessage msg = new SpeechResultMessage(SpeechResultMessage.Action_Reject);
         SpeechResultMessage msg = new SpeechResultMessage(SpeechResultMessage.Action_Reject);
         msg.setOpUserId(userId);
         msg.setOpUserId(userId);
         msg.setOpUserName(authUser.getUsername());
         msg.setOpUserName(authUser.getUsername());
-        msg.setRole(RoleEnum.Student.getValue());
+        msg.setRole(Student.getValue());
         IMApiResultInfo resultInfo = imHelper.publishMessage(userId, taskInfo.getApplyUserId(), roomId, msg);
         IMApiResultInfo resultInfo = imHelper.publishMessage(userId, taskInfo.getApplyUserId(), roomId, msg);
         if (resultInfo.isSuccess()) {
         if (resultInfo.isSuccess()) {
             return true;
             return true;
@@ -910,7 +990,7 @@ public class RoomServiceImpl implements RoomService {
             log.info("don't update display: room={}", roomList.get(0));
             log.info("don't update display: room={}", roomList.get(0));
         }
         }
 
 
-        roomMemberDao.updateRoleByRidAndUid(roomId, userId, RoleEnum.Student.getValue());
+        roomMemberDao.updateRoleByRidAndUid(roomId, userId, Student.getValue());
 //        roomMemberDao.updateRoleByRidAndUid(roomId, userId, RoleEnum.RoleAssistant.getValue());
 //        roomMemberDao.updateRoleByRidAndUid(roomId, userId, RoleEnum.RoleAssistant.getValue());
 
 
         AssistantTransferMessage msg = new AssistantTransferMessage();
         AssistantTransferMessage msg = new AssistantTransferMessage();
@@ -1040,7 +1120,7 @@ public class RoomServiceImpl implements RoomService {
         if (targetUser.isEmpty()) {
         if (targetUser.isEmpty()) {
             throw new ApiException(ErrorEnum.ERR_USER_NOT_EXIST_IN_ROOM);
             throw new ApiException(ErrorEnum.ERR_USER_NOT_EXIST_IN_ROOM);
         } else {
         } else {
-            if (!RoleEnum.getEnumByValue(targetUser.get(0).getRole()).equals(RoleEnum.Student)) {
+            if (!RoleEnum.getEnumByValue(targetUser.get(0).getRole()).equals(Student)) {
                 log.error("change role error: targetUserId={}, targetRole = {}", targetUser, RoleEnum.getEnumByValue(targetRole));
                 log.error("change role error: targetUserId={}, targetRole = {}", targetUser, RoleEnum.getEnumByValue(targetRole));
                 throw new ApiException(ErrorEnum.ERR_CHANGE_ROLE);
                 throw new ApiException(ErrorEnum.ERR_CHANGE_ROLE);
             }
             }
@@ -1052,8 +1132,8 @@ public class RoomServiceImpl implements RoomService {
 
 
         List<RoomMember> teachers = roomMemberDao.findByRidAndRole(roomId, RoleEnum.MainTeacher.getValue());
         List<RoomMember> teachers = roomMemberDao.findByRidAndRole(roomId, RoleEnum.MainTeacher.getValue());
         if (!teachers.isEmpty()) {
         if (!teachers.isEmpty()) {
-            roomMemberDao.updateRoleByRidAndUid(roomId, teachers.get(0).getUid(), RoleEnum.Student.getValue());
-            RoleChangedMessage.ChangedUser user = new RoleChangedMessage.ChangedUser(teachers.get(0).getUid(), RoleEnum.Student.getValue());
+            roomMemberDao.updateRoleByRidAndUid(roomId, teachers.get(0).getUid(), Student.getValue());
+            RoleChangedMessage.ChangedUser user = new RoleChangedMessage.ChangedUser(teachers.get(0).getUid(), Student.getValue());
             List<UserInfo> userInfoList = userDao.findByUid(teachers.get(0).getUid());
             List<UserInfo> userInfoList = userDao.findByUid(teachers.get(0).getUid());
             if (!userInfoList.isEmpty()) {
             if (!userInfoList.isEmpty()) {
                 user.setUserName(userInfoList.get(0).getName());
                 user.setUserName(userInfoList.get(0).getName());

+ 2 - 0
edu-im/edu-im-server/src/main/java/com/keao/edu/im/service/RoomService.java

@@ -19,6 +19,8 @@ public interface RoomService {
 
 
     void signIn(Long roomId);
     void signIn(Long roomId);
 
 
+    void signOut(Long roomId);
+
     public Boolean leaveRoom(String roomId) throws ApiException, Exception;
     public Boolean leaveRoom(String roomId) throws ApiException, Exception;
 
 
     //only host
     //only host

+ 23 - 0
edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/client/EduUserFeignService.java

@@ -1,18 +1,41 @@
 package com.keao.edu.user.api.client;
 package com.keao.edu.user.api.client;
 
 
 
 
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.keao.edu.common.config.FeignConfiguration;
 import com.keao.edu.common.config.FeignConfiguration;
 import com.keao.edu.user.api.client.fallback.EduUserFeignServiceFallback;
 import com.keao.edu.user.api.client.fallback.EduUserFeignServiceFallback;
 import com.keao.edu.user.api.entity.ExamRoom;
 import com.keao.edu.user.api.entity.ExamRoom;
+import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
 @FeignClient(contextId = "eduUserFeignService", name = "user-server", configuration = { FeignConfiguration.class }, fallback = EduUserFeignServiceFallback.class)
 @FeignClient(contextId = "eduUserFeignService", name = "user-server", configuration = { FeignConfiguration.class }, fallback = EduUserFeignServiceFallback.class)
 public interface EduUserFeignService {
 public interface EduUserFeignService {
 
 
+	/**
+	 * 获取考场信息
+	 * @param id
+	 * @return
+	 */
 	@GetMapping(value = "examRoom/get")
 	@GetMapping(value = "examRoom/get")
 	ExamRoom getExamRoom(@RequestParam("id") Integer id);
 	ExamRoom getExamRoom(@RequestParam("id") Integer id);
 
 
+	/**
+	 * 学生报名
+	 * @param organId
+	 * @param phone
+	 * @return
+	 */
 	@PostMapping(value = "student/apply")
 	@PostMapping(value = "student/apply")
 	Object studentApply(@RequestParam("organId") Integer organId, @RequestParam("phone") String phone);
 	Object studentApply(@RequestParam("organId") Integer organId, @RequestParam("phone") String phone);
+
+	/**
+	 * 获取考场与学生关联
+	 * @param basicId
+	 * @param roomId
+	 * @param studentId
+	 * @return
+	 */
+	@GetMapping(value = "roomStudentRelation/get")
+	ExamRoomStudentRelation getExamRoomStudentRelation(@RequestParam("basicId") Integer basicId, @RequestParam("roomId") String roomId, @RequestParam("studentId") Integer studentId);
 }
 }

+ 6 - 0
edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/client/fallback/EduUserFeignServiceFallback.java

@@ -2,6 +2,7 @@ package com.keao.edu.user.api.client.fallback;
 
 
 import com.keao.edu.user.api.client.EduUserFeignService;
 import com.keao.edu.user.api.client.EduUserFeignService;
 import com.keao.edu.user.api.entity.ExamRoom;
 import com.keao.edu.user.api.entity.ExamRoom;
+import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import com.keao.edu.user.api.entity.Student;
 import com.keao.edu.user.api.entity.Student;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -19,4 +20,9 @@ public class EduUserFeignServiceFallback implements EduUserFeignService {
 		return null;
 		return null;
 	}
 	}
 
 
+	@Override
+	public ExamRoomStudentRelation getExamRoomStudentRelation(Integer basicId, String roomId, Integer studentId) {
+		return null;
+	}
+
 }
 }

+ 2 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/ExamRoomStudentRelation.java → edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/entity/ExamRoomStudentRelation.java

@@ -1,6 +1,6 @@
-package com.keao.edu.user.entity;
+package com.keao.edu.user.api.entity;
 
 
-import com.keao.edu.user.enums.YesOrNoEnum;
+import com.keao.edu.common.enums.YesOrNoEnum;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 

+ 7 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRoomStudentRelationController.java

@@ -5,6 +5,7 @@ import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.common.controller.BaseController;
 import com.keao.edu.common.controller.BaseController;
 import com.keao.edu.common.entity.HttpResponseResult;
 import com.keao.edu.common.entity.HttpResponseResult;
 import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.page.PageInfo;
+import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
 import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
 import com.keao.edu.user.page.ExamRoomStudentRelationQueryInfo;
 import com.keao.edu.user.page.ExamRoomStudentRelationQueryInfo;
 import com.keao.edu.user.service.ExamRoomStudentRelationService;
 import com.keao.edu.user.service.ExamRoomStudentRelationService;
@@ -33,6 +34,12 @@ public class ExamRoomStudentRelationController extends BaseController {
         return succeed();
         return succeed();
     }
     }
 
 
+    @ApiOperation("获取教室学员关联")
+    @GetMapping(value = "/getExamRoomStudentRelation")
+    public ExamRoomStudentRelation getExamRoomStudentRelation(Integer basicId, String roomId, Integer studentId) {
+        return examRoomStudentRelationService.getExamRoomStudentRelation(basicId,roomId,studentId);
+    }
+
     @ApiOperation("给教室分配学员")
     @ApiOperation("给教室分配学员")
     @PostMapping(value = "/addStudentForRoom")
     @PostMapping(value = "/addStudentForRoom")
     public HttpResponseResult addStudentForRoom(Long examRoomId, String studentIds){
     public HttpResponseResult addStudentForRoom(Long examRoomId, String studentIds){

+ 10 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamRoomStudentRelationDao.java

@@ -2,7 +2,7 @@ package com.keao.edu.user.dao;
 
 
 import com.keao.edu.common.dal.BaseDAO;
 import com.keao.edu.common.dal.BaseDAO;
 import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
 import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
-import com.keao.edu.user.entity.ExamRoomStudentRelation;
+import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 
 
 import java.util.List;
 import java.util.List;
@@ -28,7 +28,7 @@ public interface ExamRoomStudentRelationDao extends BaseDAO<Long, ExamRoomStuden
      * @author Joburgess
      * @author Joburgess
      * @date 2020.06.24
      * @date 2020.06.24
      * @param examRoomId:
      * @param examRoomId:
-     * @return java.util.List<com.keao.edu.user.entity.ExamRoomStudentRelation>
+     * @return java.util.List<com.keao.edu.user.api.entity.ExamRoomStudentRelation>
      */
      */
     List<ExamRoomStudentRelation> findStudentsWithExamRoom(@Param("examRoomId") Long examRoomId);
     List<ExamRoomStudentRelation> findStudentsWithExamRoom(@Param("examRoomId") Long examRoomId);
 
 
@@ -52,4 +52,12 @@ public interface ExamRoomStudentRelationDao extends BaseDAO<Long, ExamRoomStuden
      */
      */
     int deleteWithExamRooms(@Param("examRoomIds") List<Long> examRoomIds);
     int deleteWithExamRooms(@Param("examRoomIds") List<Long> examRoomIds);
 
 
+    /**
+     * 获取教室学员关联
+     * @param basicId
+     * @param roomId
+     * @param studentId
+     * @return
+     */
+    ExamRoomStudentRelation getExamRoomStudentRelation(@Param("basicId") Integer basicId, @Param("roomId") String roomId, @Param("studentId") Integer studentId);
 }
 }

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dto/ExamRoomStudentRelationDto.java

@@ -2,7 +2,7 @@ package com.keao.edu.user.dto;
 
 
 import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.user.entity.ExamRegistration;
 import com.keao.edu.user.entity.ExamRegistration;
-import com.keao.edu.user.entity.ExamRoomStudentRelation;
+import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import com.keao.edu.user.entity.Subject;
 import com.keao.edu.user.entity.Subject;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 
 

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

@@ -3,7 +3,7 @@ package com.keao.edu.user.service;
 import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.service.BaseService;
 import com.keao.edu.common.service.BaseService;
 import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
 import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
-import com.keao.edu.user.entity.ExamRoomStudentRelation;
+import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import com.keao.edu.user.page.ExamRoomStudentRelationQueryInfo;
 import com.keao.edu.user.page.ExamRoomStudentRelationQueryInfo;
 
 
 public interface ExamRoomStudentRelationService extends BaseService<Long, ExamRoomStudentRelation> {
 public interface ExamRoomStudentRelationService extends BaseService<Long, ExamRoomStudentRelation> {
@@ -44,4 +44,13 @@ public interface ExamRoomStudentRelationService extends BaseService<Long, ExamRo
      * @return void
      * @return void
      */
      */
     void deleteStudentFromRoom(Long examRoomId, String studentIds);
     void deleteStudentFromRoom(Long examRoomId, String studentIds);
+
+    /**
+     * 获取教室学员关联
+     * @param basicId
+     * @param roomId
+     * @param studentId
+     * @return
+     */
+    ExamRoomStudentRelation getExamRoomStudentRelation(Integer basicId, String roomId, Integer studentId);
 }
 }

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

@@ -10,7 +10,7 @@ import com.keao.edu.user.api.entity.ExamRoom;
 import com.keao.edu.user.dao.ExamRoomDao;
 import com.keao.edu.user.dao.ExamRoomDao;
 import com.keao.edu.user.dao.ExamRoomStudentRelationDao;
 import com.keao.edu.user.dao.ExamRoomStudentRelationDao;
 import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
 import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
-import com.keao.edu.user.entity.ExamRoomStudentRelation;
+import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import com.keao.edu.user.entity.Subject;
 import com.keao.edu.user.entity.Subject;
 import com.keao.edu.user.page.ExamRoomStudentRelationQueryInfo;
 import com.keao.edu.user.page.ExamRoomStudentRelationQueryInfo;
 import com.keao.edu.user.service.ExamRoomStudentRelationService;
 import com.keao.edu.user.service.ExamRoomStudentRelationService;
@@ -115,4 +115,9 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 		List<Integer> studentIds = Arrays.asList(studentIdsStr.split(",")).stream().map(e -> Integer.valueOf(e)).collect(Collectors.toList());
 		List<Integer> studentIds = Arrays.asList(studentIdsStr.split(",")).stream().map(e -> Integer.valueOf(e)).collect(Collectors.toList());
 		examRoomStudentRelationDao.deleteStudentsFromExamRoom(examRoomId, studentIds);
 		examRoomStudentRelationDao.deleteStudentsFromExamRoom(examRoomId, studentIds);
 	}
 	}
+
+	@Override
+	public ExamRoomStudentRelation getExamRoomStudentRelation(Integer basicId, String roomId, Integer studentId) {
+		return examRoomStudentRelationDao.getExamRoomStudentRelation(basicId,roomId,studentId);
+	}
 }
 }

+ 7 - 4
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamRoomStudentRelationMapper.xml

@@ -6,7 +6,7 @@
 -->
 -->
 <mapper namespace="com.keao.edu.user.dao.ExamRoomStudentRelationDao">
 <mapper namespace="com.keao.edu.user.dao.ExamRoomStudentRelationDao">
 	
 	
-	<resultMap type="com.keao.edu.user.entity.ExamRoomStudentRelation" id="ExamRoomStudentRelation">
+	<resultMap type="com.keao.edu.user.api.entity.ExamRoomStudentRelation" id="ExamRoomStudentRelation">
 		<result column="id_" property="id" />
 		<result column="id_" property="id" />
 		<result column="examination_basic_id_" property="examinationBasicId" />
 		<result column="examination_basic_id_" property="examinationBasicId" />
 		<result column="exam_room_id_" property="examRoomId" />
 		<result column="exam_room_id_" property="examRoomId" />
@@ -34,12 +34,12 @@
 	</select>
 	</select>
 	
 	
 	<!-- 向数据库增加一条记录 -->
 	<!-- 向数据库增加一条记录 -->
-	<insert id="insert" parameterType="com.keao.edu.user.entity.ExamRoomStudentRelation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+	<insert id="insert" parameterType="com.keao.edu.user.api.entity.ExamRoomStudentRelation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 		INSERT INTO exam_room_student_relation (id_,examination_basic_id_,exam_room_id_,student_id_,create_time_,update_time_,tenant_id_)
 		INSERT INTO exam_room_student_relation (id_,examination_basic_id_,exam_room_id_,student_id_,create_time_,update_time_,tenant_id_)
 		VALUES(#{id},#{examinationBasicId},#{examRoomId},#{studentId},NOW(),NOW(),#{tenantId})
 		VALUES(#{id},#{examinationBasicId},#{examRoomId},#{studentId},NOW(),NOW(),#{tenantId})
 	</insert>
 	</insert>
 
 
-	<insert id="batchInsert" parameterType="com.keao.edu.user.entity.ExamRoomStudentRelation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+	<insert id="batchInsert" parameterType="com.keao.edu.user.api.entity.ExamRoomStudentRelation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 		INSERT INTO exam_room_student_relation (examination_basic_id_,exam_room_id_,student_id_,create_time_,update_time_,tenant_id_)
 		INSERT INTO exam_room_student_relation (examination_basic_id_,exam_room_id_,student_id_,create_time_,update_time_,tenant_id_)
 		VALUES
 		VALUES
 		<foreach collection="roomStudents" item="roomStudent" separator=",">
 		<foreach collection="roomStudents" item="roomStudent" separator=",">
@@ -48,7 +48,7 @@
 	</insert>
 	</insert>
 	
 	
 	<!-- 根据主键查询一条记录 -->
 	<!-- 根据主键查询一条记录 -->
-	<update id="update" parameterType="com.keao.edu.user.entity.ExamRoomStudentRelation">
+	<update id="update" parameterType="com.keao.edu.user.api.entity.ExamRoomStudentRelation">
 		UPDATE exam_room_student_relation
 		UPDATE exam_room_student_relation
 		<set>
 		<set>
 			<if test="examinationBasicId != null">
 			<if test="examinationBasicId != null">
@@ -151,4 +151,7 @@
 	<select id="findStudentsWithExamRoom" resultMap="ExamRoomStudentRelation">
 	<select id="findStudentsWithExamRoom" resultMap="ExamRoomStudentRelation">
 		SELECT id_, examination_basic_id_, exam_room_id_, student_id_ FROM exam_room_student_relation WHERE exam_room_id_=#{examRoomId}
 		SELECT id_, examination_basic_id_, exam_room_id_, student_id_ FROM exam_room_student_relation WHERE exam_room_id_=#{examRoomId}
 	</select>
 	</select>
+	<select id="getExamRoomStudentRelation" resultMap="ExamRoomStudentRelation">
+		SELECT * FROM exam_room_student_relation WHERE exam_room_id_ = #{roomId} AND examination_basic_id_ = #{basicId} AND student_id_ = #{studentId} LIMIT 1
+	</select>
 </mapper>
 </mapper>