|
@@ -124,11 +124,9 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
|
}
|
|
|
|
|
|
// 当前预约时段剩余可约数量
|
|
|
- int totalCount = applyTaskCacheService.getApplyTotalCount(examSiteId, timePeriodId);
|
|
|
- int finishCount = applyTaskCacheService.getApplyFinishCount(examSiteId, timePeriodId);
|
|
|
- int availableCount = totalCount - finishCount;
|
|
|
+ int availableCount = this.getApplyAvailableCount(examSiteId, timePeriod.getId());
|
|
|
if (availableCount < 1) {
|
|
|
- log.warn("预约失败,当前预约时段已约满!totalCount:{} finishCount:{}", totalCount, finishCount);
|
|
|
+ log.warn("预约失败,当前预约时段已约满!examSiteId:{} timePeriodId:{}", examSiteId, timePeriod.getId());
|
|
|
throw new StatusException("当前预约时段已约满");
|
|
|
}
|
|
|
|
|
@@ -258,6 +256,14 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
|
return studentApplyService.count(wrapper);
|
|
|
}
|
|
|
|
|
|
+ private int getApplyAvailableCount(Long examSiteId, Long timePeriodId) {
|
|
|
+ // 当前预约时段剩余可约数量
|
|
|
+ int totalCount = applyTaskCacheService.getApplyTotalCount(examSiteId, timePeriodId);
|
|
|
+ int finishCount = applyTaskCacheService.getApplyFinishCount(examSiteId, timePeriodId);
|
|
|
+ int availableCount = totalCount - finishCount;
|
|
|
+ return Math.max(availableCount, 0);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<ApplyVO> getStudentApplyList(LoginUser student, Boolean cancel) {
|
|
|
CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask(student.getOrgId());
|
|
@@ -402,13 +408,20 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
|
info.setTimePeriodId(timePeriod.getId());
|
|
|
info.setTimePeriodStart(timePeriod.getStartTime());
|
|
|
info.setTimePeriodEnd(timePeriod.getEndTime());
|
|
|
- info.setStatus(ApplyStatus.AVAILABLE);
|
|
|
- info.setAvailableCount(1);
|
|
|
+
|
|
|
+ int availableCount = this.getApplyAvailableCount(examSiteId, timePeriod.getId());
|
|
|
+ info.setAvailableCount(availableCount);
|
|
|
+ if (availableCount < 1) {
|
|
|
+ info.setStatus(ApplyStatus.FULL);
|
|
|
+ } else {
|
|
|
+ info.setStatus(ApplyStatus.AVAILABLE);
|
|
|
+ }
|
|
|
+
|
|
|
periodList.add(info);
|
|
|
}
|
|
|
}
|
|
|
- // todo
|
|
|
|
|
|
+ // todo
|
|
|
ApplyTimePeriodResult result = new ApplyTimePeriodResult();
|
|
|
result.setUnApplyNumber(1);
|
|
|
result.setPeriodList(periodList);
|