Joburgess 5 سال پیش
والد
کامیت
4e4e671677

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

@@ -48,8 +48,8 @@ public class ExamRoomStudentRelationController extends BaseController {
 
     @ApiOperation("给教室分配学员")
     @PostMapping(value = "/addStudentForRoom")
-    public HttpResponseResult addStudentForRoom(Long examRoomId, String studentIds){
-        examRoomStudentRelationService.addStudentForRoom(examRoomId, studentIds);
+    public HttpResponseResult addStudentForRoom(Long examRoomId, String registIds){
+        examRoomStudentRelationService.addStudentForRoom(examRoomId, registIds);
         return succeed();
     }
 

+ 9 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamRegistrationDao.java

@@ -74,6 +74,15 @@ public interface ExamRegistrationDao extends BaseDAO<Long, ExamRegistration> {
                                                   @Param("studentIds") List<Integer> studentIds);
 
     /**
+     * @describe 获取指定报名记录
+     * @author Joburgess
+     * @date 2020.07.12
+     * @param registIds:
+     * @return java.util.List<com.keao.edu.user.entity.ExamRegistration>
+     */
+    List<ExamRegistration> getRegists(@Param("registIds") List<Long> registIds);
+
+    /**
      * COUNT学员报考记录
      *
      * @param params

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

@@ -21,10 +21,10 @@ public interface ExamRoomStudentRelationService extends BaseService<Long, ExamRo
      * @author Joburgess
      * @date 2020.06.24
      * @param examRoomId:
-     * @param studentIds:
+     * @param registIds:
      * @return void
      */
-    void addStudentForRoom(Long examRoomId, String studentIds);
+    void addStudentForRoom(Long examRoomId, String registIds);
 
     /**
      * @describe 更换学员考场

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

@@ -62,12 +62,12 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 
 	@Override
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-	public void addStudentForRoom(Long examRoomId, String studentIdsStr) {
+	public void addStudentForRoom(Long examRoomId, String registIdsStr) {
 		if(Objects.isNull(examRoomId)){
 			throw new BizException("请指定教室");
 		}
-		if(StringUtils.isBlank(studentIdsStr)){
-			throw new BizException("请指定学员");
+		if(StringUtils.isBlank(registIdsStr)){
+			throw new BizException("请指定学员报名编号");
 		}
 		ExamRoom examRoom = examRoomDao.lockRoom(examRoomId);
 		if(Objects.isNull(examRoom)){
@@ -76,20 +76,21 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 		ExamLocation examLocation = examLocationDao.get(examRoom.getExamLocationId());
 
 		List<ExamRoomStudentRelation> studentsWithExamRoom = examRoomStudentRelationDao.findStudentsWithExamRoom(examRoomId);
-		Set<Integer> existStudentIds = studentsWithExamRoom.stream().map(ExamRoomStudentRelation::getStudentId).collect(Collectors.toSet());
-		String[] studentIds = studentIdsStr.split(",");
+		Set<Long> existRegistIds = studentsWithExamRoom.stream().map(ExamRoomStudentRelation::getExamRegistrationId).collect(Collectors.toSet());
+
+		String[] registIds = registIdsStr.split(",");
 
-		List<ExamRegistration> examRegistrations = examRegistrationDao.getWithExamAndStudents(examRoom.getExaminationBasicId(), Arrays.asList(studentIds).stream().map(e -> Integer.valueOf(e)).collect(Collectors.toList()));
-		Map<Integer, ExamRegistration> studentRegistMap = examRegistrations.stream().collect(Collectors.toMap(ExamRegistration::getStudentId, e -> e));
+		List<ExamRegistration> examRegistrations = examRegistrationDao.getRegists(Arrays.asList(registIds).stream().map(e -> Long.valueOf(e)).collect(Collectors.toList()));
+		Map<Integer, ExamRegistration> studentRegistMap = examRegistrations.stream().collect(Collectors.toMap(ExamRegistration::getId, e -> e));
 
 		List<ExamRoomStudentRelation> examRoomStudentRelations=new ArrayList<>();
 		List<StudentExamResult> studentExamResults=new ArrayList<>();
 		List<ExamCertification> examCertifications=new ArrayList<>();
-		for (String studentId : studentIds) {
-			if(existStudentIds.contains(Integer.valueOf(studentId))){
+		for (String registId : registIds) {
+			if(existRegistIds.contains(Integer.valueOf(registId))){
 				continue;
 			}
-			ExamRegistration examRegistration = studentRegistMap.get(Integer.valueOf(studentId));
+			ExamRegistration examRegistration = studentRegistMap.get(Integer.valueOf(registId));
 			if(Objects.isNull(examRegistration)){
 				throw new BizException("学员信息错误");
 			}
@@ -97,21 +98,23 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 			ExamRoomStudentRelation e=new ExamRoomStudentRelation();
 			e.setExaminationBasicId(examRoom.getExaminationBasicId());
 			e.setExamRoomId(examRoom.getId());
-			e.setStudentId(Integer.valueOf(studentId));
+			e.setStudentId(Integer.valueOf(registId));
 			e.setTenantId(TenantContextHolder.getTenantId());
 			examRoomStudentRelations.add(e);
 
 			StudentExamResult ser = new StudentExamResult();
+			ser.setExamRegistrationId(examRegistration.getId().longValue());
 			ser.setExaminationBasicId(examRoom.getExaminationBasicId());
-			ser.setStudentId(Integer.valueOf(studentId));
+			ser.setStudentId(examRegistration.getStudentId());
 			ser.setIsFinishedExam(0);
 			ser.setConfirmStatus(0);
 			ser.setTenantId(TenantContextHolder.getTenantId());
 			studentExamResults.add(ser);
 
 			ExamCertification ec=new ExamCertification();
+			ec.setExamRegistrationId(examRegistration.getId().longValue());
 			ec.setExaminationBasicId(examRoom.getExaminationBasicId());
-			ec.setStudentId(Integer.valueOf(studentId));
+			ec.setStudentId(examRegistration.getStudentId());
 			ec.setCardNo(String.valueOf(idGeneratorService.generatorId()));
 			ec.setSubjectId(examRegistration.getSubjectId());
 			ec.setLevel(examRegistration.getLevel());

+ 9 - 0
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamRegistrationMapper.xml

@@ -323,12 +323,21 @@
 		AND er.examination_basic_id_ = #{examId}
 		AND er.status_ != ''
 	</select>
+
     <select id="getWithExamAndStudents" resultMap="ExamRegistration">
 		SELECT * FROM exam_registration WHERE examination_basic_id_=#{examId} AND student_id_ IN
 		<foreach collection="studentIds" item="studentId" separator="," open="(" close=")">
 			#{studentId}
 		</foreach>
 	</select>
+
+	<select id="getRegists" resultMap="ExamRegistration">
+		SELECT * FROM exam_registration WHERE id_ IN
+		<foreach collection="registIds" item="registId" separator="," open="(" close=")">
+			#{registId}
+		</foreach>
+	</select>
+
 	<resultMap id="ExamRegistrationDtoMap" type="com.keao.edu.user.dto.ExamRegistrationDto" extends="ExamRegistration">
 		<result property="studentName" column="studentName"/>
 		<result property="subjectName" column="subjectName"/>