|
@@ -205,29 +205,20 @@ public class ApplyTaskCacheService implements CacheConstants {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- // 总容量变化时,则更新
|
|
|
+ // 总容量变化时,则更新(注意:在所有操作减少某个考场容量时,缩减后的实际容量不能低于考生已预约数量)
|
|
|
RAtomicLong atomic = redisClient.getRedissonClient().getAtomicLong(cacheKey);
|
|
|
long curAvailableCount = atomic.get();
|
|
|
- if (diffCapacity > 0 && curAvailableCount == 0) {
|
|
|
- // 容量变大 且 剩余可约数量为0 时,可能存在已约记录,需计算去掉。
|
|
|
- int finishCount = studentApplyService.countApplyFinishForExamSiteAndTimePeriod(examSiteId, timePeriod.getId());
|
|
|
- long newAvailableCount = Math.max(diffCapacity - finishCount, 0);
|
|
|
- atomic.set(newAvailableCount);
|
|
|
- log.warn("考点时段剩余可约数量从{}更新为{} oldCapacity:{} newCapacity:{} finishCount:{} {}",
|
|
|
- curAvailableCount, newAvailableCount, oldCapacity, newCapacity, finishCount, cacheKey);
|
|
|
- } else {
|
|
|
- // 容量变小时,不允许超减,最小减到0
|
|
|
- long newAvailableCount = Math.max(curAvailableCount + diffCapacity, 0);
|
|
|
- atomic.set(newAvailableCount);
|
|
|
- log.warn("考点时段剩余可约数量从{}更新为{} oldCapacity:{} newCapacity:{} {}",
|
|
|
- curAvailableCount, newAvailableCount, oldCapacity, newCapacity, cacheKey);
|
|
|
- }
|
|
|
+ long newAvailableCount = Math.max(curAvailableCount + diffCapacity, 0);
|
|
|
+ atomic.set(newAvailableCount);
|
|
|
+ log.warn("考点时段剩余可约数量从{}更新为{} oldCapacity:{} newCapacity:{} {}",
|
|
|
+ curAvailableCount, newAvailableCount, oldCapacity, newCapacity, cacheKey);
|
|
|
} else {
|
|
|
RAtomicLong atomic = redisClient.getRedissonClient().getAtomicLong(cacheKey);
|
|
|
int finishCount = studentApplyService.countApplyFinishForExamSiteAndTimePeriod(examSiteId, timePeriod.getId());
|
|
|
long newAvailableCount = Math.max(newCapacity - finishCount, 0);
|
|
|
atomic.set(newAvailableCount);
|
|
|
- log.warn("初始考点时段剩余可约数量:{} {}", newAvailableCount, cacheKey);
|
|
|
+ log.warn("缓存不存在,初始考点时段剩余可约数量:{} oldCapacity:{} newCapacity:{} finishCount:{} {}",
|
|
|
+ newAvailableCount, oldCapacity, newCapacity, finishCount, cacheKey);
|
|
|
}
|
|
|
}
|
|
|
} finally {
|
|
@@ -260,29 +251,20 @@ public class ApplyTaskCacheService implements CacheConstants {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 总容量变化时,则更新
|
|
|
+ // 总容量变化时,则更新(注意:在所有操作减少某个考场容量时,缩减后的实际容量不能低于考生已预约数量)
|
|
|
RAtomicLong atomic = redisClient.getRedissonClient().getAtomicLong(cacheKey);
|
|
|
long curAvailableCount = atomic.get();
|
|
|
- if (diffCapacity > 0 && curAvailableCount == 0) {
|
|
|
- // 容量变大 且 剩余可约数量为0 时,可能存在已约记录,需计算去掉。
|
|
|
- int finishCount = studentApplyService.countApplyFinishForExamSiteAndTimePeriod(examSiteId, timePeriodId);
|
|
|
- long newAvailableCount = Math.max(diffCapacity - finishCount, 0);
|
|
|
- atomic.set(newAvailableCount);
|
|
|
- log.warn("考点时段剩余可约数量从{}更新为{} oldCapacity:{} newCapacity:{} finishCount:{} {}",
|
|
|
- curAvailableCount, newAvailableCount, oldCapacity, newCapacity, finishCount, cacheKey);
|
|
|
- } else {
|
|
|
- // 容量变小时,不允许超减,最小减到0
|
|
|
- long newAvailableCount = Math.max(curAvailableCount + diffCapacity, 0);
|
|
|
- atomic.set(newAvailableCount);
|
|
|
- log.warn("考点时段剩余可约数量从{}更新为{} oldCapacity:{} newCapacity:{} {}",
|
|
|
- curAvailableCount, newAvailableCount, oldCapacity, newCapacity, cacheKey);
|
|
|
- }
|
|
|
+ long newAvailableCount = Math.max(curAvailableCount + diffCapacity, 0);
|
|
|
+ atomic.set(newAvailableCount);
|
|
|
+ log.warn("考点时段剩余可约数量从{}更新为{} oldCapacity:{} newCapacity:{} {}",
|
|
|
+ curAvailableCount, newAvailableCount, oldCapacity, newCapacity, cacheKey);
|
|
|
} else {
|
|
|
RAtomicLong atomic = redisClient.getRedissonClient().getAtomicLong(cacheKey);
|
|
|
int finishCount = studentApplyService.countApplyFinishForExamSiteAndTimePeriod(examSiteId, timePeriodId);
|
|
|
long newAvailableCount = Math.max(newCapacity - finishCount, 0);
|
|
|
atomic.set(newAvailableCount);
|
|
|
- log.warn("初始考点时段剩余可约数量:{} {}", newAvailableCount, cacheKey);
|
|
|
+ log.warn("缓存不存在,初始考点时段剩余可约数量:{} oldCapacity:{} newCapacity:{} finishCount:{} {}",
|
|
|
+ newAvailableCount, oldCapacity, newCapacity, finishCount, cacheKey);
|
|
|
}
|
|
|
} finally {
|
|
|
try {
|
|
@@ -329,12 +311,13 @@ public class ApplyTaskCacheService implements CacheConstants {
|
|
|
|
|
|
// 获取某考点某时段的“已预约数量”(仅查数据库会有误差,需等预约队列中全部完成数据库持久化后再执行!!!)
|
|
|
int finishCount = studentApplyService.countApplyFinishForExamSiteAndTimePeriod(examSite.getExamSiteId(), timePeriod.getId());
|
|
|
- int capacity = examSiteService.getExamSiteTimePeriodCapacity(examSite.getExamSiteId(), timePeriod.getId());
|
|
|
+ int curCapacity = examSiteService.getExamSiteTimePeriodCapacity(examSite.getExamSiteId(), timePeriod.getId());
|
|
|
// 剩余可约数量
|
|
|
- int availableCount = Math.max(capacity - finishCount, 0);
|
|
|
+ int availableCount = Math.max(curCapacity - finishCount, 0);
|
|
|
RAtomicLong atomic = redisClient.getRedissonClient().getAtomicLong(cacheKey);
|
|
|
atomic.set(availableCount);
|
|
|
- log.warn("{}考点时段剩余可约数量:{} {}", existCache ? "更新" : "初始", availableCount, cacheKey);
|
|
|
+ log.warn("{}考点时段剩余可约数量:{} curCapacity:{} finishCount:{} {}",
|
|
|
+ existCache ? "更新" : "初始", availableCount, curCapacity, finishCount, cacheKey);
|
|
|
}
|
|
|
} finally {
|
|
|
try {
|
|
@@ -379,12 +362,13 @@ public class ApplyTaskCacheService implements CacheConstants {
|
|
|
|
|
|
// 获取某考点某时段的“已预约数量”
|
|
|
int finishCount = studentApplyService.countApplyFinishForExamSiteAndTimePeriod(examSite.getExamSiteId(), timePeriodId);
|
|
|
- int capacity = examSiteService.getExamSiteTimePeriodCapacity(examSite.getExamSiteId(), timePeriodId);
|
|
|
+ int curCapacity = examSiteService.getExamSiteTimePeriodCapacity(examSite.getExamSiteId(), timePeriodId);
|
|
|
// 剩余可约数量
|
|
|
- int availableCount = Math.max(capacity - finishCount, 0);
|
|
|
+ int availableCount = Math.max(curCapacity - finishCount, 0);
|
|
|
RAtomicLong atomic = redisClient.getRedissonClient().getAtomicLong(cacheKey);
|
|
|
atomic.set(availableCount);
|
|
|
- log.warn("初始考点时段剩余可约数量:{} {}", availableCount, cacheKey);
|
|
|
+ log.warn("初始考点时段剩余可约数量:{} curCapacity:{} finishCount:{} {}",
|
|
|
+ availableCount, curCapacity, finishCount, cacheKey);
|
|
|
}
|
|
|
} finally {
|
|
|
try {
|