|
@@ -265,6 +265,9 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
|
|
|
Set<Integer> subjectIds = subjectRegistMap.keySet();
|
|
|
//未排考学员可排考考场
|
|
|
List<ExamRoom> examRooms = examRoomDao.getWithExamAndSubjects(examId, new ArrayList<>(subjectIds));
|
|
|
+ if(CollectionUtils.isEmpty(examRooms)){
|
|
|
+ throw new BizException("请先建立考场");
|
|
|
+ }
|
|
|
Set<Long> roomIds = examRooms.stream().map(ExamRoom::getId).collect(Collectors.toSet());
|
|
|
//未排考学员可排考考场学员
|
|
|
List<ExamRoomStudentRelation> examRoomStudents = examRoomStudentRelationDao.getWithExamRooms(new ArrayList<>(roomIds));
|
|
@@ -275,15 +278,17 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
|
|
|
//每个考场可分配学员数
|
|
|
Integer roomStudentNum=allStudentNum/roomNum;
|
|
|
|
|
|
+ Integer existRoomStudentAvgNum = examRoomStudents.size()/roomNum;
|
|
|
+
|
|
|
Set<Long> inRoomRegistIds=new HashSet<>();
|
|
|
|
|
|
List<ExamRoomStudentRelation> newRoomStudents = new ArrayList<>();
|
|
|
Map<Long, Integer> roomStudentNumMap = examRooms.stream().collect(Collectors.toMap(ExamRoom::getId, e->Objects.isNull(e.getExamRoomStudentNum())?0:e.getExamRoomStudentNum()));
|
|
|
|
|
|
- if(roomStudentNum>0){
|
|
|
+ if(roomStudentNum>existRoomStudentAvgNum){
|
|
|
int startIndex=0;
|
|
|
for (ExamRoom examRoom : examRooms) {
|
|
|
- List<ExamRegistration> examRegistrations = notInRoomStudents.subList(startIndex, roomStudentNum - examRoom.getExamRoomStudentNum());
|
|
|
+ List<ExamRegistration> examRegistrations = notInRoomStudents.subList(startIndex, startIndex + roomStudentNum - examRoom.getExamRoomStudentNum());
|
|
|
startIndex = startIndex+examRegistrations.size();
|
|
|
for (ExamRegistration examRegistration : examRegistrations) {
|
|
|
ExamRoomStudentRelation e=new ExamRoomStudentRelation();
|
|
@@ -299,7 +304,7 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- List<ExamRegistration> surplusRegist = notInRoomStudents.stream().filter(e -> !inRoomRegistIds.contains(e.getId())).collect(Collectors.toList());
|
|
|
+ List<ExamRegistration> surplusRegist = notInRoomStudents.stream().filter(e -> !inRoomRegistIds.contains(e.getId().longValue())).collect(Collectors.toList());
|
|
|
|
|
|
for (ExamRegistration examRegistration : surplusRegist) {
|
|
|
List<Long> sortedRoomIds=new LinkedList<>();
|
|
@@ -312,6 +317,7 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
|
|
|
e.setStudentId(examRegistration.getStudentId());
|
|
|
e.setTenantId(examinationBasic.getTenantId());
|
|
|
newRoomStudents.add(e);
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|