|
@@ -242,6 +242,12 @@ public class TimePeriodExamRoomServiceImpl extends ServiceImpl<TimePeriodExamRoo
|
|
|
throw new StatusException("保存失败,未找到考点");
|
|
|
}
|
|
|
|
|
|
+ String lockKey = String.format(CacheConstants.LOCK_EXAM_SITE_CAPACITY, examRoom.getExamSiteId());
|
|
|
+ if (concurrentService.isLocked(lockKey)) {
|
|
|
+ log.warn("[考场保存]考点剩余可约数量更新中,不允许考生操作修改!lockKey:{}", lockKey);
|
|
|
+ throw new StatusException("系统正在更新可预约数量,不允许保存");
|
|
|
+ }
|
|
|
+
|
|
|
// 获取考场对应的所有时段
|
|
|
List<TimePeriodExamSiteBean> timePeriodList = timePeriodService.listTimePeriodByExamRoomId(curApplyTask.getTaskId(), examRoomId);
|
|
|
|
|
@@ -402,91 +408,45 @@ public class TimePeriodExamRoomServiceImpl extends ServiceImpl<TimePeriodExamRoo
|
|
|
}
|
|
|
|
|
|
private void refreshDisableTimePeriodCache(List<TimePeriodExamRoomEntity> disableList, ExamRoomEntity examRoom) {
|
|
|
- String examSiteTimePeriodLockKey = String.format(CacheConstants.LOCK_EXAM_SITE_TIME_PERIOD, examRoom.getExamSiteId());
|
|
|
- RLock examSiteTimePeriodLock = (RLock) concurrentService.getLock(examSiteTimePeriodLockKey);
|
|
|
-
|
|
|
- try {
|
|
|
- if (!examSiteTimePeriodLock.tryLock()) {
|
|
|
- log.warn("[考场排班设置] 获取锁失败,不能同时修改考场排班设置, lockKey:{}", examSiteTimePeriodLock);
|
|
|
- throw new StatusException("考场排班保存失败,请稍后再试");
|
|
|
- } else {
|
|
|
- disableList.stream()
|
|
|
- .filter(item -> !item.getEnable())
|
|
|
- .forEach(item -> {
|
|
|
- // 更新容量缓存,禁用需要减考场容量
|
|
|
- applyTaskCacheService.refreshApplyAvailableCountCache(
|
|
|
- examRoom.getExamSiteId(),
|
|
|
- item.getTimePeriodId(),
|
|
|
- examRoom.getCapacity(),
|
|
|
- 0
|
|
|
- );
|
|
|
- });
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("[考场排班设置] 考场排班失败, msg:{}", e.getMessage());
|
|
|
- throw new StatusException("考场排班保存失败,请稍后再试");
|
|
|
- } finally {
|
|
|
- try {
|
|
|
- if (examSiteTimePeriodLock.isLocked() && examSiteTimePeriodLock.isHeldByCurrentThread()) {
|
|
|
- examSiteTimePeriodLock.unlock();
|
|
|
- log.info("[考场排班设置] 解锁成功,lockKey:{}", examSiteTimePeriodLock);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.warn(e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ disableList.stream()
|
|
|
+ .filter(item -> !item.getEnable())
|
|
|
+ .forEach(item -> {
|
|
|
+ // 更新容量缓存,禁用需要减考场容量
|
|
|
+ applyTaskCacheService.refreshApplyAvailableCountCache(
|
|
|
+ examRoom.getExamSiteId(),
|
|
|
+ item.getTimePeriodId(),
|
|
|
+ examRoom.getCapacity(),
|
|
|
+ 0
|
|
|
+ );
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
private void refreshUpdatedTimePeriodCache(List<TimePeriodExamRoomEntity> updateList,
|
|
|
Map<Long, TimePeriodExamSiteBean> timePeriodMap, ExamRoomEntity examRoom) {
|
|
|
- String examSiteTimePeriodLockKey = String.format(CacheConstants.LOCK_EXAM_SITE_TIME_PERIOD, examRoom.getExamSiteId());
|
|
|
- RLock examSiteTimePeriodLock = (RLock) concurrentService.getLock(examSiteTimePeriodLockKey);
|
|
|
-
|
|
|
- try {
|
|
|
- if (!examSiteTimePeriodLock.tryLock()) {
|
|
|
- log.warn("[考场排班设置] 获取锁失败,不能同时修改考场排班设置, lockKey:{}", examSiteTimePeriodLock);
|
|
|
- throw new StatusException("考场排班保存失败,请稍后再试");
|
|
|
- } else {
|
|
|
- updateList.forEach(item -> {
|
|
|
- TimePeriodExamSiteBean timePeriod = timePeriodMap.get(item.getId());
|
|
|
- //由启用变为禁用,缓存容量=-考场的容量
|
|
|
- if (timePeriod != null && Boolean.TRUE.equals(timePeriod.getEnable()) && !item.getEnable()) {
|
|
|
- // 更新容量缓存
|
|
|
- applyTaskCacheService.refreshApplyAvailableCountCache(
|
|
|
- examRoom.getExamSiteId(),
|
|
|
- timePeriod.getTimePeriodId(),
|
|
|
- examRoom.getCapacity(),
|
|
|
- 0
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- //由禁用变为启用,缓存容量=+考场的容量
|
|
|
- if (timePeriod != null && Boolean.FALSE.equals(timePeriod.getEnable()) && item.getEnable()) {
|
|
|
- //更新容量缓存
|
|
|
- applyTaskCacheService.refreshApplyAvailableCountCache(
|
|
|
- examRoom.getExamSiteId(),
|
|
|
- timePeriod.getTimePeriodId(),
|
|
|
- 0,
|
|
|
- examRoom.getCapacity()
|
|
|
- );
|
|
|
- }
|
|
|
- });
|
|
|
+ updateList.forEach(item -> {
|
|
|
+ TimePeriodExamSiteBean timePeriod = timePeriodMap.get(item.getId());
|
|
|
+ //由启用变为禁用,缓存容量=-考场的容量
|
|
|
+ if (timePeriod != null && Boolean.TRUE.equals(timePeriod.getEnable()) && !item.getEnable()) {
|
|
|
+ // 更新容量缓存
|
|
|
+ applyTaskCacheService.refreshApplyAvailableCountCache(
|
|
|
+ examRoom.getExamSiteId(),
|
|
|
+ timePeriod.getTimePeriodId(),
|
|
|
+ examRoom.getCapacity(),
|
|
|
+ 0
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("[考场排班设置] 考场排班失败, msg:{}", e.getMessage());
|
|
|
- throw new StatusException("考场排班保存失败,请稍后再试");
|
|
|
- } finally {
|
|
|
- try {
|
|
|
- if (examSiteTimePeriodLock.isLocked() && examSiteTimePeriodLock.isHeldByCurrentThread()) {
|
|
|
- examSiteTimePeriodLock.unlock();
|
|
|
- log.info("[考场排班设置] 解锁成功,lockKey:{}", examSiteTimePeriodLock);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.warn(e.getMessage());
|
|
|
+ //由禁用变为启用,缓存容量=+考场的容量
|
|
|
+ if (timePeriod != null && Boolean.FALSE.equals(timePeriod.getEnable()) && item.getEnable()) {
|
|
|
+ //更新容量缓存
|
|
|
+ applyTaskCacheService.refreshApplyAvailableCountCache(
|
|
|
+ examRoom.getExamSiteId(),
|
|
|
+ timePeriod.getTimePeriodId(),
|
|
|
+ 0,
|
|
|
+ examRoom.getCapacity()
|
|
|
+ );
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
|