|
@@ -125,6 +125,9 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
|
@Autowired
|
|
|
private OrgCacheService orgCacheService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TimePeriodExamRoomService timePeriodExamRoomService;
|
|
|
+
|
|
|
@Override
|
|
|
public PageResult<StudentApplyVO> page(StudentApplyReq req) {
|
|
|
ApplyTaskEntity task = getApplyTask();
|
|
@@ -336,6 +339,12 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
|
msg.append(" 证件号码不能为空");
|
|
|
}
|
|
|
|
|
|
+ //有空行跳出循序-结束执行
|
|
|
+ if (StringUtils.isBlank(studentCode) && StringUtils.isBlank(name) && StringUtils.isBlank(identityNumber)) {
|
|
|
+ failRecords.add(newError(i + 1, "该行数据为空,请检查"));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
//判断考生是否存在
|
|
|
StudentEntity studentEntity = checkStudent(studentCode, name, identityNumber, task.getTaskId());
|
|
|
if (studentEntity == null) {
|
|
@@ -905,13 +914,13 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
|
Map<Long, List<StudentApplyEntity>> timeLayoutStudentMap = studentApplyList.stream()
|
|
|
.collect(Collectors.groupingBy(StudentApplyEntity::getTimePeriodId));
|
|
|
|
|
|
- List<ExamRoomEntity> roomList = listExamRoom(examSiteId);
|
|
|
+ /*List<ExamRoomEntity> roomList = listExamRoom(examSiteId);
|
|
|
if (roomList.isEmpty()) {
|
|
|
log.warn("{}:未设置考场", examSiteId);
|
|
|
return;
|
|
|
- }
|
|
|
+ }*/
|
|
|
ExamSiteEntity examSite = examSiteService.getById(examSiteId);
|
|
|
- layoutStudentByTimePeriod(applyTask.getTaskId(), examSite, roomList, timeLayoutStudentMap);
|
|
|
+ layoutStudentByTimePeriod(applyTask.getTaskId(), examSite, timeLayoutStudentMap);
|
|
|
}
|
|
|
} catch (StatusException e) {
|
|
|
log.error(e.getMessage());
|
|
@@ -928,15 +937,53 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void layoutStudentByTimePeriod(Long taskId, ExamSiteEntity examSite, List<ExamRoomEntity> roomList,
|
|
|
- Map<Long, List<StudentApplyEntity>> timeLayoutStudentMap) {
|
|
|
+ private void layoutStudentByTimePeriod(Long taskId, ExamSiteEntity examSite,Map<Long, List<StudentApplyEntity>> timeLayoutStudentMap) {
|
|
|
+ List<ExamRoomEntity> roomList;
|
|
|
for (Long timePeriodId : timeLayoutStudentMap.keySet()) {
|
|
|
+ // 根据考点和时段查询可用考场
|
|
|
+ roomList = listAvailableExamRoom(examSite.getId(), timePeriodId);
|
|
|
+ if (CollectionUtils.isEmpty(roomList)) {
|
|
|
+ log.error("[autoLayout]考点{}:时段{}:未有可用考场", examSite.getId(), timePeriodId);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
List<StudentApplyEntity> studentApplyList = timeLayoutStudentMap.get(timePeriodId);
|
|
|
TimePeriodEntity timePeriod = timePeriodService.getById(timePeriodId);
|
|
|
layoutStudentToRoom(taskId, examSite, roomList, studentApplyList, timePeriod);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ 查询可用考场列表
|
|
|
+ */
|
|
|
+ private List<ExamRoomEntity> listAvailableExamRoom(Long examSiteId, Long timePeriodId) {
|
|
|
+ // 获取所有考场列表
|
|
|
+ List<ExamRoomEntity> examRoomList = listExamRoom(examSiteId);
|
|
|
+ if (examRoomList == null || examRoomList.isEmpty()) {
|
|
|
+ return Collections.emptyList(); // 如果没有考场,直接返回空列表
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取禁用的考场列表
|
|
|
+ List<ExamRoomEntity> disableExamRoomList = timePeriodExamRoomService.listExamRoom(examSiteId, timePeriodId, false);
|
|
|
+ if (CollectionUtils.isEmpty(disableExamRoomList)) {
|
|
|
+ return examRoomList; // 如果没有禁用考场,直接返回所有考场
|
|
|
+ }
|
|
|
+
|
|
|
+ // 提取禁用考场的 ID 到 Set中
|
|
|
+ Set<Long> disableRoomIdSet = disableExamRoomList.stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(ExamRoomEntity::getId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ // 过滤掉禁用的考场
|
|
|
+ return examRoomList.stream()
|
|
|
+ .filter(room -> room != null && room.getId() != null && !disableRoomIdSet.contains(room.getId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private void layoutStudentToRoom(Long taskId, ExamSiteEntity examSite, List<ExamRoomEntity> roomList,
|
|
|
List<StudentApplyEntity> studentApplyList, TimePeriodEntity timePeriod) {
|
|
|
Integer timePeriodOrder = getTimePeriodOrder(taskId, timePeriod);
|