|
@@ -82,6 +82,11 @@ public class ExamRoomServiceImpl extends ServiceImpl<ExamRoomDao, ExamRoomEntity
|
|
log.warn("[考场保存]系统自动预约中,不允许修改考场!lockKey:{}", CacheConstants.LOCK_AUTO_APPLY);
|
|
log.warn("[考场保存]系统自动预约中,不允许修改考场!lockKey:{}", CacheConstants.LOCK_AUTO_APPLY);
|
|
throw new StatusException("系统正在自动预约中,不允许修改考场");
|
|
throw new StatusException("系统正在自动预约中,不允许修改考场");
|
|
}
|
|
}
|
|
|
|
+ String lockKey = String.format(CacheConstants.LOCK_EXAM_SITE_CAPACITY, req.getExamSiteId());
|
|
|
|
+ if (concurrentService.isLocked(lockKey)) {
|
|
|
|
+ log.warn("[考场保存]考点剩余可约数量更新中,不允许考生操作修改!lockKey:{}", lockKey);
|
|
|
|
+ throw new StatusException("系统正在更新可预约数量,不允许修改考场");
|
|
|
|
+ }
|
|
|
|
|
|
checkExamRoom(req);
|
|
checkExamRoom(req);
|
|
ExamRoomEntity examRoomEntity = new ExamRoomEntity();
|
|
ExamRoomEntity examRoomEntity = new ExamRoomEntity();
|
|
@@ -97,7 +102,6 @@ public class ExamRoomServiceImpl extends ServiceImpl<ExamRoomDao, ExamRoomEntity
|
|
} else {
|
|
} else {
|
|
beforeUpdateRoom = getById(req.getId());
|
|
beforeUpdateRoom = getById(req.getId());
|
|
updateById(examRoomEntity);
|
|
updateById(examRoomEntity);
|
|
-// refreshApplyCountCache(examRoomEntity.getId(), examRoomEntity.getExamSiteId(), beforeUpdateRoom.getCapacity(), examRoomEntity.getCapacity());
|
|
|
|
}
|
|
}
|
|
//更新考点容量和教学点容量
|
|
//更新考点容量和教学点容量
|
|
updateExamSiteAndTeachingCapacity(req.getExamSiteId());
|
|
updateExamSiteAndTeachingCapacity(req.getExamSiteId());
|
|
@@ -122,8 +126,13 @@ public class ExamRoomServiceImpl extends ServiceImpl<ExamRoomDao, ExamRoomEntity
|
|
log.warn("[考场禁用/启用]系统自动预约中,不允许修改考场!lockKey:{}", CacheConstants.LOCK_AUTO_APPLY);
|
|
log.warn("[考场禁用/启用]系统自动预约中,不允许修改考场!lockKey:{}", CacheConstants.LOCK_AUTO_APPLY);
|
|
throw new StatusException("系统正在自动预约中,不允许启用/禁用考场");
|
|
throw new StatusException("系统正在自动预约中,不允许启用/禁用考场");
|
|
}
|
|
}
|
|
-
|
|
|
|
ExamRoomEntity examRoom = getById(id);
|
|
ExamRoomEntity examRoom = getById(id);
|
|
|
|
+ String lockKey = String.format(CacheConstants.LOCK_EXAM_SITE_CAPACITY, examRoom.getExamSiteId());
|
|
|
|
+ if (concurrentService.isLocked(lockKey)) {
|
|
|
|
+ log.warn("[考场保存]考点剩余可约数量更新中,不允许考生操作修改!lockKey:{}", lockKey);
|
|
|
|
+ throw new StatusException("系统正在更新可预约数量,不允许启用/禁用考场");
|
|
|
|
+ }
|
|
|
|
+
|
|
//考点容量
|
|
//考点容量
|
|
ExamSiteEntity examSite = examSiteService.getById(examRoom.getExamSiteId());
|
|
ExamSiteEntity examSite = examSiteService.getById(examRoom.getExamSiteId());
|
|
int oldCapacity = examSite.getCapacity();
|
|
int oldCapacity = examSite.getCapacity();
|
|
@@ -264,12 +273,18 @@ public class ExamRoomServiceImpl extends ServiceImpl<ExamRoomDao, ExamRoomEntity
|
|
}
|
|
}
|
|
|
|
|
|
private void saveRoom(ExamRoomEntity room) {
|
|
private void saveRoom(ExamRoomEntity room) {
|
|
|
|
+ String lockKey = String.format(CacheConstants.LOCK_EXAM_SITE_CAPACITY, room.getExamSiteId());
|
|
|
|
+ if (concurrentService.isLocked(lockKey)) {
|
|
|
|
+ log.warn("[考场保存]考点剩余可约数量更新中,不允许考生操作修改!lockKey:{}", lockKey);
|
|
|
|
+ throw new StatusException("系统正在更新可预约数量,不允许导入考场");
|
|
|
|
+ }
|
|
|
|
+
|
|
ExamRoomEntity examRoom = getExamRoom(room.getExamSiteId(), room.getCode());
|
|
ExamRoomEntity examRoom = getExamRoom(room.getExamSiteId(), room.getCode());
|
|
int oldCapacity = 0;
|
|
int oldCapacity = 0;
|
|
ExamSiteEntity examSite;
|
|
ExamSiteEntity examSite;
|
|
if (examRoom != null) {
|
|
if (examRoom != null) {
|
|
examSite = examSiteService.getById(examRoom.getExamSiteId());
|
|
examSite = examSiteService.getById(examRoom.getExamSiteId());
|
|
- if(examSite == null) {
|
|
|
|
|
|
+ if (examSite == null) {
|
|
throw new StatusException("找不到考点");
|
|
throw new StatusException("找不到考点");
|
|
}
|
|
}
|
|
oldCapacity = examSite.getCapacity();
|
|
oldCapacity = examSite.getCapacity();
|
|
@@ -316,34 +331,13 @@ public class ExamRoomServiceImpl extends ServiceImpl<ExamRoomDao, ExamRoomEntity
|
|
Map<Long, TimePeriodExamRoomEntity> timePeriodExamRoomMap = timePeriodExamRooms.stream().collect(
|
|
Map<Long, TimePeriodExamRoomEntity> timePeriodExamRoomMap = timePeriodExamRooms.stream().collect(
|
|
Collectors.toMap(TimePeriodExamRoomEntity::getTimePeriodId, Function.identity()));
|
|
Collectors.toMap(TimePeriodExamRoomEntity::getTimePeriodId, Function.identity()));
|
|
|
|
|
|
- String examSiteTimePeriodLockKey = String.format(CacheConstants.LOCK_EXAM_SITE_TIME_PERIOD, examSiteId);
|
|
|
|
- RLock examSiteTimePeriodLock = (RLock) concurrentService.getLock(examSiteTimePeriodLockKey);
|
|
|
|
- try {
|
|
|
|
- if (!examSiteTimePeriodLock.tryLock()) {
|
|
|
|
- log.warn("[考场容量更新] 获取锁失败,不能同时修改考点考场容量, lockKey:{}", examSiteTimePeriodLock);
|
|
|
|
- throw new StatusException("考场保存失败,请稍后再试");
|
|
|
|
- } else {
|
|
|
|
- for (TimePeriodEntity timePeriod : timePeriods) {
|
|
|
|
- //刷新缓存
|
|
|
|
- TimePeriodExamRoomEntity timePeriodExamRoomEntity = timePeriodExamRoomMap.get(timePeriod.getId());
|
|
|
|
- if (timePeriodExamRoomEntity == null || timePeriodExamRoomEntity.getEnable()) {
|
|
|
|
- cacheService.refreshApplyAvailableCountCache(examSiteId, timePeriod.getId(), oldCapacity, newCapacity);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- } 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());
|
|
|
|
|
|
+ for (TimePeriodEntity timePeriod : timePeriods) {
|
|
|
|
+ //刷新缓存
|
|
|
|
+ TimePeriodExamRoomEntity timePeriodExamRoomEntity = timePeriodExamRoomMap.get(timePeriod.getId());
|
|
|
|
+ if (timePeriodExamRoomEntity == null || timePeriodExamRoomEntity.getEnable()) {
|
|
|
|
+ cacheService.refreshApplyAvailableCountCache(examSiteId, timePeriod.getId(), oldCapacity, newCapacity);
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|