浏览代码

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

zouxuan 5 年之前
父节点
当前提交
5f88bac124

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

@@ -69,6 +69,17 @@ public interface ExamRoomDao extends BaseDAO<Long, ExamRoom> {
     List<ExamRoom> getWithExam(@Param("organIds") List<Integer> organIds,
                                 @Param("examId") Long examId);
 
+    /**
+     * @describe 获取指定考级项目及声部下的考场
+     * @author Joburgess
+     * @date 2020.08.06
+     * @param examId:
+     * @param subjectIds:
+     * @return java.util.List<com.keao.edu.user.api.entity.ExamRoom>
+     */
+    List<ExamRoom> getWithExamAndSubjects(@Param("examId") Long examId,
+                                          @Param("subjectIds") List<Integer> subjectIds);
+
     int updateSL(ExamRoom examRoom);
 
     ExamRoom lockRoom(@Param("examRoomId") Long examRoomId);

+ 11 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dao/ExamRoomStudentRelationDao.java

@@ -176,4 +176,15 @@ public interface ExamRoomStudentRelationDao extends BaseDAO<Long, ExamRoomStuden
      * @return int
      */
     int countStudentsWithRoom(Long examRoomId);
+
+    /**
+     * @describe 根据考级项目及声部获取考场学员
+     * @author Joburgess
+     * @date 2020.08.06
+     * @param examId:
+     * @param subjectIds:
+     * @return java.util.List<com.keao.edu.user.api.entity.ExamRoomStudentRelation>
+     */
+    List<ExamRoomStudentRelation> getWithExamAndRoomSubjects(@Param("examId") Long examId,
+                                                             @Param("subjectIds") List<Integer> subjectIds);
 }

+ 16 - 4
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamRoomStudentRelationServiceImpl.java

@@ -255,16 +255,28 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 	}
 
 	@Override
-	public void autoSplitStudentToRoom(Long examRoomId, Integer selfOrganId) {
-		ExaminationBasic examinationBasic = examinationBasicDao.get(examRoomId);
+	public void autoSplitStudentToRoom(Long examId, Integer selfOrganId) {
+		ExaminationBasic examinationBasic = examinationBasicDao.get(examId);
 		if(Objects.isNull(examinationBasic)){
 			throw new BizException("考级项目不存在");
 		}
-		int sendExamPlanRooms = examRoomDao.countSendExamPlanRooms(examRoomId);
+		int sendExamPlanRooms = examRoomDao.countSendExamPlanRooms(examId);
 		if(sendExamPlanRooms>0){
 			throw new BizException("已发送考试安排,请手动处理未排考学员");
 		}
-//		examRegistrationDao.getStuRecordDetail()
+		//未排考学员
+		List<ExamRegistration> notInRoomStudents = examRegistrationDao.getNotInRoomStudents(examId);
+		Map<Integer, List<ExamRegistration>> subjectRegistMap = notInRoomStudents.stream().collect(Collectors.groupingBy(ExamRegistration::getSubjectId));
+		Set<Integer> subjectIds = subjectRegistMap.keySet();
+		//未排考学员可排考考场
+		List<ExamRoom> examRooms = examRoomDao.getWithExamAndSubjects(examId, new ArrayList<>(subjectIds));
+		//未排考学员可排考考场学员
+		List<ExamRoomStudentRelation> examRoomStudents = examRoomStudentRelationDao.getWithExamAndRoomSubjects(examId, new ArrayList<>(subjectIds));
+		Map<Long, List<ExamRoomStudentRelation>> roomStudentsMap = examRoomStudents.stream().collect(Collectors.groupingBy(ExamRoomStudentRelation::getExamRoomId));
+		Set<Long> roomIds = roomStudentsMap.keySet();
+		//考场数量
+		Integer roomNum = roomIds.size();
+
 	}
 
 	@Override

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

@@ -636,6 +636,12 @@
 	</select>
 
     <select id="getNotInRoomStudents" resultMap="ExamRegistration">
-
+		SELECT
+			*
+		FROM
+			exam_registration er
+		WHERE
+			examination_basic_id_ = #{examId}
+			AND NOT EXISTS ( SELECT id_ FROM exam_room_student_relation WHERE examination_basic_id_ = #{examId} AND er.id_ = exam_registration_id_ )
 	</select>
 </mapper>

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

@@ -435,6 +435,7 @@
 			MAX(exam_end_time_) examEndTime
 		FROM exam_room WHERE examination_basic_id_=#{examId}
     </select>
+
     <select id="getHistoryOpenExamRoom" resultMap="ExamRoom">
 		SELECT
 			*
@@ -444,7 +445,17 @@
 			exam_start_time_ &lt; NOW( )
 			AND open_flag_ =1
 	</select>
+
     <select id="countSendExamPlanRooms" resultType="int">
 		SELECT COUNT(id_) FROM exam_room WHERE examination_basic_id_=#{examId} AND exam_plan_push_flag_=1
 	</select>
+
+	<select id="getWithExamAndSubjects" resultMap="ExamRoom">
+		SELECT * FROM exam_room
+		WHERE examination_basic_id_=#{examId}
+		AND subject_id_list_ IN
+		<foreach collection="subjectIds" item="subjectId" separator="," open="(" close=")">
+			#{subjectId}
+		</foreach>
+	</select>
 </mapper>

+ 14 - 0
edu-user/edu-user-biz/src/main/resources/config/mybatis/ExamRoomStudentRelationMapper.xml

@@ -292,4 +292,18 @@
 	<select id="countStudentsWithRoom" resultType="int">
 		SELECT COUNT(DISTINCT exam_registration_id_) FROM exam_room_student_relation WHERE exam_room_id_=#{examRoomId}
 	</select>
+
+    <select id="getWithExamAndRoomSubjects" resultMap="ExamRoomStudentRelation">
+		SELECT
+			ersr.*
+		FROM
+			exam_room_student_relation ersr
+			LEFT JOIN exam_room er ON ersr.exam_room_id_ = er.id_
+		WHERE
+			ersr.examination_basic_id_ = #{examId}
+			AND er.subject_id_list_ IN
+			<foreach collection="subjectIds" item="subjectId" separator="," open="(" close=")">
+				#{subjectId}
+			</foreach>
+	</select>
 </mapper>

+ 0 - 1
edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/entity/ExamRoomStudentRelation.java

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