Browse Source

Merge branch 'master' of http://git.dayaedu.com/yonge/edu-saas

zouxuan 5 years ago
parent
commit
16bd621121

+ 22 - 0
edu-task/src/main/java/com/keao/edu/task/jobs/CleanExamRoomTask.java

@@ -0,0 +1,22 @@
+package com.keao.edu.task.jobs;
+
+import com.keao.edu.task.core.BaseTask;
+import com.keao.edu.user.api.client.TaskRemoteService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Author Joburgess
+ * @Date 2020.07.30
+ */
+@Service
+public class CleanExamRoomTask extends BaseTask {
+
+    @Autowired
+    private TaskRemoteService taskRemoteService;
+
+    @Override
+    public void execute() {
+        taskRemoteService.cleanExamRoom();
+    }
+}

+ 8 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dao/ExamRoomDao.java

@@ -92,4 +92,12 @@ public interface ExamRoomDao extends BaseDAO<Long, ExamRoom> {
      */
     List<ExamRoom> getWithExamAndSubject(@Param("examId") Long examId,
                                          @Param("subjectId") Integer subjectId);
+
+    /**
+     * @describe 获取当前时间之前未关闭的考场
+     * @author Joburgess
+     * @date 2020.07.30
+     * @return java.util.List<com.keao.edu.user.api.entity.ExamRoom>
+     */
+    List<ExamRoom> getHistoryOpenExamRoom();
 }

+ 1 - 1
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dto/ExamRegistrationRoomDto.java

@@ -20,7 +20,7 @@ public class ExamRegistrationRoomDto extends ExamRegistration {
     @ApiModelProperty(value = "考试结束时间")
     private Date examEndTime;
 
-    @ApiModelProperty(value = "是否完成考试")
+    @ApiModelProperty(value = "考试状态")
     private Integer isFinishedExam;
 
     public Long getExamRoomId() {

+ 11 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/page/ExamRegistrationQueryInfo.java

@@ -37,6 +37,9 @@ public class ExamRegistrationQueryInfo extends QueryInfo {
     @ApiModelProperty(value = "是否已排考:0否,1已排考")
     private Integer inRoom;
 
+    @ApiModelProperty(value = "学员考试状态")
+    private Integer isFinishedExam;
+
     public Integer getExamRegistrationId() {
         return examRegistrationId;
     }
@@ -101,6 +104,14 @@ public class ExamRegistrationQueryInfo extends QueryInfo {
         this.status = status;
     }
 
+    public Integer getIsFinishedExam() {
+        return isFinishedExam;
+    }
+
+    public void setIsFinishedExam(Integer isFinishedExam) {
+        this.isFinishedExam = isFinishedExam;
+    }
+
     public Integer getInRoom() {
         return inRoom;
     }

+ 17 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/ExamRoomService.java

@@ -107,4 +107,21 @@ public interface ExamRoomService extends BaseService<Long, ExamRoom> {
      * @param openFlag
      */
     void changeExamRoom(Long examRoomId, Integer openFlag);
+
+    /**
+     * @describe 强制关闭考场
+     * @author Joburgess
+     * @date 2020.07.30
+     * @param examRoomId: 考场编号
+     * @return com.keao.edu.common.entity.HttpResponseResult
+     */
+    HttpResponseResult forceCloseExamRoom(Long examRoomId);
+
+    /**
+     * @describe 清理未关闭考场
+     * @author Joburgess
+     * @date 2020.07.30
+     * @return void
+     */
+    void cleanExamRoom();
 }

+ 32 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamRoomServiceImpl.java

@@ -843,4 +843,36 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 			imFeignService.destroyRoom(examRoomId);
 		}
 	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public HttpResponseResult forceCloseExamRoom(Long examRoomId) {
+		if(Objects.isNull(examRoomId)){
+			throw new BizException("请指定考场");
+		}
+		ExamRoom examRoom = examRoomDao.get(examRoomId);
+		if(Objects.isNull(examRoom)){
+			throw new BizException("考场不存在");
+		}
+		examRoom.setOpenFlag(0);
+		examRoomDao.update(examRoom);
+		imFeignService.dismissGroup(examRoom.getMainTeacherUserId().toString(),examRoomId.toString());
+		imFeignService.destroyRoom(examRoomId);
+		return BaseController.succeed();
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void cleanExamRoom() {
+		List<ExamRoom> examRooms = examRoomDao.getHistoryOpenExamRoom();
+		if(CollectionUtils.isEmpty(examRooms)){
+			return;
+		}
+		for (ExamRoom examRoom : examRooms) {
+			examRoom.setOpenFlag(0);
+			imFeignService.dismissGroup(examRoom.getMainTeacherUserId().toString(),examRoom.getId().toString());
+			imFeignService.destroyRoom(examRoom.getId());
+		}
+		examRoomDao.batchUpdate(examRooms);
+	}
 }

+ 6 - 0
edu-user/edu-user-biz/src/main/resources/config/mybatis/ExamRegistrationMapper.xml

@@ -38,6 +38,7 @@
 		<result column="exam_room_id_" property="examRoomId"/>
 		<result column="exam_start_time_" property="examStartTime"/>
 		<result column="exam_end_time_" property="examEndTime"/>
+		<result column="is_finished_exam_" property="isFinishedExam"/>
 	</resultMap>
 
 	<!-- 根据主键查询一条记录 -->
@@ -233,6 +234,9 @@
 			<if test="status!=null">
 				AND er.status_ = #{status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
 			</if>
+			<if test="isFinishedExam!=null">
+				AND ser.is_finished_exam_ = #{isFinishedExam}
+			</if>
 			<if test="search!=null and search!=''">
 				AND (er.student_id_=#{search} OR su.phone_ LIKE CONCAT('%', #{search}, '%') OR su.real_name_ LIKE CONCAT('%', #{search}, '%') OR eb.name_ LIKE CONCAT('%', #{search}, '%'))
 			</if>
@@ -336,6 +340,7 @@
 			LEFT JOIN exam_room_student_relation ersr ON ersr.exam_registration_id_ = er.id_
 			LEFT JOIN exam_room ero ON ero.id_ = ersr.exam_room_id_
 			LEFT JOIN examination_basic eb ON er.examination_basic_id_ = eb.id_
+			LEFT JOIN student_exam_result ser ON ser.exam_registration_id_=er.id_
 		<include refid="queryCondition"/>
 		ORDER BY er.id_ DESC
 		<include refid="global.limit"/>
@@ -346,6 +351,7 @@
 		LEFT JOIN sys_user su ON er.student_id_ = su.id_
 		LEFT JOIN exam_room_student_relation ersr ON ersr.exam_registration_id_ = er.id_
 		LEFT JOIN examination_basic eb ON er.examination_basic_id_ = eb.id_
+		LEFT JOIN student_exam_result ser ON ser.exam_registration_id_=er.id_
 		<include refid="queryCondition"/>
 	</select>
 

+ 9 - 0
edu-user/edu-user-biz/src/main/resources/config/mybatis/ExamRoomMapper.xml

@@ -428,4 +428,13 @@
 			MAX(exam_end_time_) examEndTime
 		FROM exam_room WHERE examination_basic_id_=#{examId}
     </select>
+    <select id="getHistoryOpenExamRoom" resultMap="ExamRoom">
+		SELECT
+			*
+		FROM
+			exam_room
+		WHERE
+			exam_start_time_ &lt; NOW( )
+			AND open_flag_ =1
+	</select>
 </mapper>

+ 1 - 1
edu-user/edu-user-biz/src/main/resources/config/mybatis/TeacherAttendanceMapper.xml

@@ -68,6 +68,6 @@
 		SELECT COUNT(*) FROM teacher_attendance
 	</select>
     <select id="findByRoomIdAndTeacher" resultMap="TeacherAttendance">
-		SELECT * FROM teacher_attendance WHERE exam_room_id = #{roomId} AND teacher_id = #{userId} LIMIT 1
+		SELECT * FROM teacher_attendance WHERE exam_room_id_ = #{roomId} AND teacher_id = #{userId} LIMIT 1
 	</select>
 </mapper>

+ 9 - 0
edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/client/TaskRemoteService.java

@@ -39,4 +39,13 @@ public interface TaskRemoteService {
 	@GetMapping("/examEndRemind")
 	void examEndRemind();
 
+	/**
+	 * @describe 清理历史未关闭考场
+	 * @author Joburgess
+	 * @date 2020.07.30
+	 * @return void
+	 */
+	@GetMapping("/cleanExamRoom")
+	void cleanExamRoom();
+
 }

+ 5 - 0
edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/client/fallback/TaskRemoteServiceFallback.java

@@ -29,4 +29,9 @@ public class TaskRemoteServiceFallback implements TaskRemoteService {
 	public void examEndRemind() {
 		return;
 	}
+
+	@Override
+	public void cleanExamRoom() {
+		return;
+	}
 }

+ 6 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRoomController.java

@@ -170,4 +170,10 @@ public class ExamRoomController extends BaseController {
     public HttpResponseResult<List<ExamRoom>> getStudentEnableJoinRoom(Long registId){
         return succeed(examRoomService.getStudentEnableJoinRoom(registId));
     }
+
+    @ApiOperation("强制关闭考场")
+    @GetMapping(value = "/forceCloseExamRoom")
+    public HttpResponseResult forceCloseExamRoom(Long examRoomId){
+        return examRoomService.forceCloseExamRoom(examRoomId);
+    }
 }

+ 6 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/TaskController.java

@@ -47,4 +47,10 @@ public class TaskController extends BaseController {
     public void examEndRemind(){
         examinationBasicService.examEndRemind();
     }
+
+    //清理历史未关闭教室
+    @GetMapping("/cleanExamRoom")
+    public void cleanExamRoom(){
+        examRoomService.cleanExamRoom();
+    }
 }