|
@@ -402,65 +402,60 @@ public class TimePeriodExamRoomServiceImpl extends ServiceImpl<TimePeriodExamRoo
|
|
|
}
|
|
|
|
|
|
private void refreshDisableTimePeriodCache(List<TimePeriodExamRoomEntity> disableList, ExamRoomEntity examRoom) {
|
|
|
- disableList.stream()
|
|
|
- .filter(item -> !item.getEnable())
|
|
|
- .forEach(item -> {
|
|
|
- String examSiteTimePeriodLockKey = String.format(CacheConstants.LOCK_EXAM_SITE_TIME_PERIOD, examRoom.getExamSiteId(),
|
|
|
- item.getTimePeriodId());
|
|
|
- RLock examSiteTimePeriodLock = (RLock) concurrentService.getLock(examSiteTimePeriodLockKey);
|
|
|
- try {
|
|
|
- if (!examSiteTimePeriodLock.tryLock()) {
|
|
|
- log.warn("[考场排班设置] 获取锁失败,不能同时修改考场排班设置, lockKey:{}", examSiteTimePeriodLock);
|
|
|
- throw new StatusException("考场排班保存失败,请稍后再试");
|
|
|
- } else {
|
|
|
+ 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(),
|
|
|
-// examSite.getCapacity(),
|
|
|
-// examSite.getCapacity()- examRoom.getCapacity()
|
|
|
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());
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void refreshUpdatedTimePeriodCache(List<TimePeriodExamRoomEntity> updateList,
|
|
|
Map<Long, TimePeriodExamSiteBean> timePeriodMap, ExamRoomEntity examRoom) {
|
|
|
- updateList.forEach(item -> {
|
|
|
- TimePeriodExamSiteBean timePeriod = timePeriodMap.get(item.getId());
|
|
|
- String examSiteTimePeriodLockKey = String.format(CacheConstants.LOCK_EXAM_SITE_TIME_PERIOD, examRoom.getExamSiteId(),
|
|
|
- item.getTimePeriodId());
|
|
|
- RLock examSiteTimePeriodLock = (RLock) concurrentService.getLock(examSiteTimePeriodLockKey);
|
|
|
+ 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 {
|
|
|
+ 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(),
|
|
|
- // examSite.getCapacity(),
|
|
|
- // examSite.getCapacity() - examRoom.getCapacity()
|
|
|
examRoom.getCapacity(),
|
|
|
0
|
|
|
);
|
|
@@ -472,28 +467,27 @@ public class TimePeriodExamRoomServiceImpl extends ServiceImpl<TimePeriodExamRoo
|
|
|
applyTaskCacheService.refreshApplyAvailableCountCache(
|
|
|
examRoom.getExamSiteId(),
|
|
|
timePeriod.getTimePeriodId(),
|
|
|
- // examSite.getCapacity(),
|
|
|
- // examSite.getCapacity() + examRoom.getCapacity()
|
|
|
0,
|
|
|
examRoom.getCapacity()
|
|
|
);
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- } 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());
|
|
|
+ } 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());
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|