Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

Joburgess 5 gadi atpakaļ
vecāks
revīzija
630897e9fb

+ 11 - 1
edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/entity/ExamRoom.java

@@ -52,6 +52,8 @@ public class ExamRoom {
 
 	private Integer organId;
 
+	private Integer openFlag;
+
 	private YesOrNoEnum examPlanPushFlag;
 
 	private Integer examRoomStudentNum;
@@ -66,7 +68,15 @@ public class ExamRoom {
 	
 	/**  */
 	private String tenantId;
-	
+
+	public Integer getOpenFlag() {
+		return openFlag;
+	}
+
+	public void setOpenFlag(Integer openFlag) {
+		this.openFlag = openFlag;
+	}
+
 	public void setId(Long id){
 		this.id = id;
 	}

+ 18 - 4
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRoomController.java

@@ -9,9 +9,11 @@ import com.keao.edu.user.api.entity.ExamRoom;
 import com.keao.edu.user.dto.ExamRoomDto;
 import com.keao.edu.user.dto.ExamRoomStatisticsDto;
 import com.keao.edu.user.entity.Employee;
+import com.keao.edu.user.entity.Teacher;
 import com.keao.edu.user.page.ExamRoomQueryInfo;
 import com.keao.edu.user.service.EmployeeService;
 import com.keao.edu.user.service.ExamRoomService;
+import com.keao.edu.user.service.TeacherService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,17 +33,19 @@ public class ExamRoomController extends BaseController {
     private SysUserFeignService sysUserFeignService;
     @Autowired
     private EmployeeService employeeService;
+    @Autowired
+    private TeacherService teacherService;
 
     @ApiOperation("分页查询监考列表")
     @GetMapping(value = "/list")
     public HttpResponseResult<PageInfo<ExamRoomDto>> getList(ExamRoomQueryInfo queryInfo) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
-        if(!sysUser.getIsSuperAdmin()&&Objects.isNull(queryInfo.getOrganId())){
-            Employee employee = employeeService.get(sysUser.getId());
-            if(Objects.isNull(employee)){
+        if(!sysUser.getIsSuperAdmin() && Objects.isNull(queryInfo.getOrganId())){
+            Teacher teacher = teacherService.get(sysUser.getId());
+            if(Objects.isNull(teacher)){
                 return failed("用户信息异常");
             }
-            queryInfo.setOrganId(employee.getOrganId());
+            queryInfo.setOrganId(teacher.getOrganId());
         }
         return succeed(examRoomService.queryExamRoomPage(queryInfo));
     }
@@ -110,6 +114,16 @@ public class ExamRoomController extends BaseController {
         return succeed(examRoomService.updateExamRoom(examRoom));
     }
 
+    @ApiOperation("教室状态变更")
+    @PostMapping(value = "/openExamRoom")
+    public HttpResponseResult<ExamRoom> openExamRoom(Long examRoomId,Integer openFlag){
+        ExamRoom examRoom = new ExamRoom();
+        examRoom.setId(examRoomId);
+        examRoom.setOpenFlag(openFlag);
+        examRoomService.update(examRoom);
+        return succeed();
+    }
+
     @ApiOperation("删除教室")
     @PostMapping(value = "/deleteExamRooms")
     public HttpResponseResult deleteExamRooms(String examRoomIds){

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

@@ -33,17 +33,17 @@ public class ExamRoomStudentRelationController extends BaseController {
     @Autowired
     private EmployeeService employeeService;
 
-    @ApiOperation("开启/关闭教室")
+    /*@ApiOperation("开启/关闭教室")
     @GetMapping(value = "/switchClassRoom")
     public HttpResponseResult switchClassRoom(Integer openFlag,Integer examinationBasicId,Integer studentId) {
         examRoomStudentRelationService.switchClassRoom(openFlag,examinationBasicId,studentId);
         return succeed();
-    }
+    }*/
 
     @ApiOperation("下一位")
     @PostMapping(value = "/nextBit")
-    public HttpResponseResult nextBit(Integer currentUserId,Integer nextStudentId,Long roomId,Integer examStatus) {
-        examRoomStudentRelationService.nextBit(currentUserId,nextStudentId,roomId,examStatus);
+    public HttpResponseResult nextBit(Long nextExamRoomStudentRelationId,Long examRoomStudentRelationId,Integer examStatus) {
+        examRoomStudentRelationService.nextBit(nextExamRoomStudentRelationId,examRoomStudentRelationId,examStatus);
         return succeed();
     }
 

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

@@ -89,8 +89,7 @@ public interface ExamRoomStudentRelationDao extends BaseDAO<Long, ExamRoomStuden
 
     /**
      * 清除签到时间
-     * @param roomId
-     * @param currentUserId
+     * @param examRegistrationId
      */
-    void cleanSignInTime(@Param("roomId") Long roomId, @Param("currentUserId") Integer currentUserId);
+    void cleanSignInTime(Long examRegistrationId);
 }

+ 6 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/StudentExamResultDao.java

@@ -40,4 +40,10 @@ public interface StudentExamResultDao extends BaseDAO<Long, StudentExamResult> {
      * @return
      */
     List<Map<Integer, Integer>> countExamNum(@Param("studentIds") List<Integer> studentIds, @Param("tenantId") String tenantId);
+
+    /**
+     * 更改考试状态
+     * @param examRegistrationId
+     */
+    void endExam(Long examRegistrationId);
 }

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

@@ -66,10 +66,9 @@ public interface ExamRoomStudentRelationService extends BaseService<Long, ExamRo
 
     /**
      * 下一位
-     * @param currentUserId 当前学员
-     * @param nextStudentId 下一位学员
-     * @param roomId 考试编号
+     * @param nextExamRoomStudentRelationId 下一位学员
+     * @param examRoomStudentRelationId 学员考场关联
      * @param examStatus 是否完成考试1是0否
      */
-    void nextBit(Integer currentUserId, Integer nextStudentId, Long roomId, Integer examStatus);
+    void nextBit(Long nextExamRoomStudentRelationId, Long examRoomStudentRelationId, Integer examStatus);
 }

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

@@ -250,17 +250,29 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 	}
 
 	@Override
-	public void nextBit(Integer currentUserId, Integer nextStudentId, Long roomId, Integer examStatus) {
-//		ExamRoomStudentRelation byStudentIdAndRoomId = examRoomStudentRelationDao.findByStudentIdAndRoomId(roomId, currentUserId);
-		if(currentUserId != null){
+	public void nextBit(Long nextExamRoomStudentRelationId, Long currentExamRoomStudentRelationId, Integer examStatus) {
+		if(currentExamRoomStudentRelationId != null){
+			ExamRoomStudentRelation examRoomStudentRelation = examRoomStudentRelationDao.get(currentExamRoomStudentRelationId);
+			Long roomId = examRoomStudentRelation.getExamRoomId();
 			//将当前学员退出教室并添加参考状态,如果考试未完成,清除签到时间,重新签到
-			imFeignService.leaveRoom(new ReqUserData(roomId.toString(),currentUserId.toString()));
+			imFeignService.leaveRoom(new ReqUserData(roomId.toString(),examRoomStudentRelation.getStudentId().toString()));
 			if(examStatus == 0){
 				//未完成
-				examRoomStudentRelationDao.cleanSignInTime(roomId, currentUserId);
+				examRoomStudentRelationDao.cleanSignInTime(examRoomStudentRelation.getExamRegistrationId());
 			}else {
-//				examRoomStudentRelationDao.endExam();
+				//结束考试
+				studentExamResultDao.endExam(examRoomStudentRelation.getExamRegistrationId());
 			}
+			//关闭学员房间入口
+			examRoomStudentRelation.setClassroomSwitch(YesOrNoEnum.NO);
+			examRoomStudentRelationDao.update(examRoomStudentRelation);
+		}
+		if(nextExamRoomStudentRelationId != null){
+			ExamRoomStudentRelation examRoomStudentRelation = examRoomStudentRelationDao.get(nextExamRoomStudentRelationId);
+			//开启学员房间入口
+			examRoomStudentRelation.setClassroomSwitch(YesOrNoEnum.YES);
+			examRoomStudentRelationDao.update(examRoomStudentRelation);
+			//推送消息
 
 		}
 	}

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

@@ -87,7 +87,7 @@
 	</update>
 	<update id="cleanSignInTime">
 		UPDATE exam_room_student_relation SET sign_in_time_ = NULL,update_time_ = NOW()
-		WHERE exam_room_id_ = #{roomId} AND student_id_ = #{currentUserId}
+		WHERE exam_registration_id_ = #{examRegistrationId}
 	</update>
 
 	<!-- 根据主键删除一条记录 -->

+ 5 - 2
edu-user/edu-user-server/src/main/resources/config/mybatis/StudentExamResultMapper.xml

@@ -92,8 +92,11 @@
 				update_time_ = NOW()
 		</set> WHERE id_ = #{id}
 	</update>
-	
-	<!-- 根据主键删除一条记录 -->
+    <update id="endExam">
+		UPDATE student_exam_result SET is_finished_exam_ = 1 AND update_time_ = NOW() WHERE exam_registration_id_ = #{examRegistrationId}
+	</update>
+
+    <!-- 根据主键删除一条记录 -->
 	<delete id="delete" >
 		DELETE FROM student_exam_result WHERE id_ = #{id} 
 	</delete>