|
@@ -300,12 +300,29 @@ public class TimePeriodExamRoomServiceImpl extends ServiceImpl<TimePeriodExamRoo
|
|
|
oldCapacityMap.put(timePeriodId, capacity);
|
|
|
}
|
|
|
|
|
|
+ List<TimePeriodExamRoomEntity> verifyList = new ArrayList<>();
|
|
|
+ //只处理禁用的时段
|
|
|
+ List<TimePeriodExamRoomEntity> newTimePeriodList = toBeSaved.stream().filter(item -> !item.getEnable()).collect(Collectors.toList());
|
|
|
+ if (!newTimePeriodList.isEmpty()) {
|
|
|
+ verifyList.addAll(newTimePeriodList);
|
|
|
+ }
|
|
|
+ if (!toBeUpdated.isEmpty()) {
|
|
|
+ verifyList.addAll(toBeUpdated);
|
|
|
+ }
|
|
|
+
|
|
|
//容量验证
|
|
|
int availableCount, haveApplyCount, oldCount;
|
|
|
- for (TimePeriodExamRoomEntity toUpdate : toBeUpdated) {
|
|
|
- TimePeriodExamSiteBean bean = existingMap.get(toUpdate.getId());
|
|
|
+ for (TimePeriodExamRoomEntity toUpdate : verifyList) {
|
|
|
+ TimePeriodExamSiteBean bean;
|
|
|
+ if (toUpdate.getId() == null) {
|
|
|
+ bean = new TimePeriodExamSiteBean();
|
|
|
+ bean.setEnable(toUpdate.getEnable());
|
|
|
+ bean.setTimePeriodId(toUpdate.getTimePeriodId());
|
|
|
+ } else {
|
|
|
+ bean = existingMap.get(toUpdate.getId());
|
|
|
+ }
|
|
|
//只处理从开启到关闭的时段
|
|
|
- if (bean != null && bean.getEnable() && !toUpdate.getEnable()) {
|
|
|
+ if (bean != null && (bean.getId() == null || (bean.getEnable() && !toUpdate.getEnable()))) {
|
|
|
// 剩余的容量,从缓存中获取
|
|
|
availableCount = applyTaskCacheService.getApplyAvailableCount(examSiteCacheBean.getExamSiteId(), toUpdate.getTimePeriodId());
|
|
|
// 修改之前的容量
|
|
@@ -314,6 +331,9 @@ public class TimePeriodExamRoomServiceImpl extends ServiceImpl<TimePeriodExamRoo
|
|
|
haveApplyCount = oldCount - availableCount;
|
|
|
// 关闭之后的剩余容量
|
|
|
int remainCount = oldCount - examRoom.getCapacity();
|
|
|
+
|
|
|
+ log.warn("haveApplyCount:{}, remainCount:{}", haveApplyCount, remainCount);
|
|
|
+
|
|
|
if (haveApplyCount > remainCount) {
|
|
|
TimePeriodEntity timePeriod = timePeriodService.getById(toUpdate.getTimePeriodId());
|
|
|
String dateStr = DateUtil.getShortDateByLongTime(timePeriod.getStartTime());
|