|
@@ -280,6 +280,60 @@ public class TimePeriodExamRoomServiceImpl extends ServiceImpl<TimePeriodExamRoo
|
|
return list(wrapper);
|
|
return list(wrapper);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public int getExamSiteTimePeriodCapacity(Long examSiteId, Long timePeriodId) {
|
|
|
|
+ // 判断考点是否存在
|
|
|
|
+ ExamSiteCacheBean examSiteCacheBean = examSiteCacheService.getExamSiteById(examSiteId);
|
|
|
|
+ if (examSiteCacheBean == null) {
|
|
|
|
+ log.error("[获取考点时段可预约数量]考点不存在,examSiteId:{}", examSiteId);
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 判断时段是否存在
|
|
|
|
+ TimePeriodEntity timePeriod = timePeriodService.getById(timePeriodId);
|
|
|
|
+ if (timePeriod == null) {
|
|
|
|
+ log.error("[获取考点时段可预约数量]时段不存在,timePeriodId:{}", timePeriodId);
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 获取考点对应的所有考场
|
|
|
|
+ List<ExamRoomEntity> examRoomList = examRoomService.listExamRoom(examSiteId);
|
|
|
|
+ if (examRoomList.isEmpty()) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 获取所有考场ids
|
|
|
|
+ List<Long> examRoomIds = examRoomList.stream()
|
|
|
|
+ .map(ExamRoomEntity::getId)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ List<TimePeriodExamRoomEntity> periodList = getBaseMapper().listByExamRoomIdsAndTimePeriodId(examRoomIds, timePeriodId);
|
|
|
|
+
|
|
|
|
+ Map<Long, Boolean> enableMap = new HashMap<>();
|
|
|
|
+ for (TimePeriodExamRoomEntity entity : periodList) {
|
|
|
|
+ enableMap.put(entity.getExamRoomId(), entity.getEnable());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 计算启用状态下的考场总容量
|
|
|
|
+ return examRoomList.stream()
|
|
|
|
+ .filter(examRoom -> {
|
|
|
|
+ Boolean enabled = enableMap.get(examRoom.getId());
|
|
|
|
+ return enabled == null || enabled; // 默认启用
|
|
|
|
+ })
|
|
|
|
+ .mapToInt(ExamRoomEntity::getCapacity)
|
|
|
|
+ .sum();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private TimePeriodExamRoomEntity getTimePeriodExamRoomEntity(Long examRoomId, Long timePeriodId) {
|
|
|
|
+ LambdaQueryWrapper<TimePeriodExamRoomEntity> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.eq(TimePeriodExamRoomEntity::getExamRoomId, examRoomId);
|
|
|
|
+ queryWrapper.eq(TimePeriodExamRoomEntity::getTimePeriodId, timePeriodId);
|
|
|
|
+ return getOne(queryWrapper);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
// 校验是否可编辑
|
|
// 校验是否可编辑
|
|
private void canEdit(List<Long> timePeriodExamRoomList, CurrentApplyTaskVO curApplyTask) {
|
|
private void canEdit(List<Long> timePeriodExamRoomList, CurrentApplyTaskVO curApplyTask) {
|
|
if (CollectionUtils.isNotEmpty(timePeriodExamRoomList)) {
|
|
if (CollectionUtils.isNotEmpty(timePeriodExamRoomList)) {
|