|
@@ -13,6 +13,7 @@ import com.qmth.exam.reserve.bean.apply.TimePeriodInfo;
|
|
import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
|
|
import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
|
|
import com.qmth.exam.reserve.bean.login.LoginUser;
|
|
import com.qmth.exam.reserve.bean.login.LoginUser;
|
|
import com.qmth.exam.reserve.cache.CacheConstants;
|
|
import com.qmth.exam.reserve.cache.CacheConstants;
|
|
|
|
+import com.qmth.exam.reserve.cache.impl.ApplyTaskCacheService;
|
|
import com.qmth.exam.reserve.dao.StudentApplyDao;
|
|
import com.qmth.exam.reserve.dao.StudentApplyDao;
|
|
import com.qmth.exam.reserve.entity.*;
|
|
import com.qmth.exam.reserve.entity.*;
|
|
import com.qmth.exam.reserve.enums.ApplyStatus;
|
|
import com.qmth.exam.reserve.enums.ApplyStatus;
|
|
@@ -51,6 +52,9 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
@Autowired
|
|
@Autowired
|
|
private ExamSiteService examSiteService;
|
|
private ExamSiteService examSiteService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ApplyTaskCacheService applyTaskCacheService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private ConcurrentService concurrentService;
|
|
private ConcurrentService concurrentService;
|
|
|
|
|
|
@@ -112,19 +116,21 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
throw new StatusException("学生信息不存在");
|
|
throw new StatusException("学生信息不存在");
|
|
}
|
|
}
|
|
|
|
|
|
- if (stu.getApplyFinished()) {
|
|
|
|
- String msg = "当前学生无剩余可约时段,已完成预约" + stu.getApplyNumber() + "次";
|
|
|
|
|
|
+ int studentApplyFinishCount = this.getStudentApplyFinishCount(student.getId());
|
|
|
|
+ if (stu.getApplyNumber() - studentApplyFinishCount < 1) {
|
|
|
|
+ String msg = "当前学生无剩余可约时段次数,已完成预约" + stu.getApplyNumber() + "次";
|
|
log.warn(msg);
|
|
log.warn(msg);
|
|
- // throw new StatusException(msg);
|
|
|
|
|
|
+ // throw new StatusException(msg);todo
|
|
}
|
|
}
|
|
|
|
|
|
// 当前预约时段剩余可约数量
|
|
// 当前预约时段剩余可约数量
|
|
- int availableCount = 0;//todo
|
|
|
|
- // if (availableCount == 0) {
|
|
|
|
- // throw new StatusException("当前预约时段已约满");
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // 更新预约时段、机房容量等操作
|
|
|
|
|
|
+ int totalCount = applyTaskCacheService.getApplyTotalCount(examSiteId, timePeriodId);
|
|
|
|
+ int finishCount = applyTaskCacheService.getApplyFinishCount(examSiteId, timePeriodId);
|
|
|
|
+ int availableCount = totalCount - finishCount;
|
|
|
|
+ if (availableCount < 1) {
|
|
|
|
+ log.warn("预约失败,当前预约时段已约满!totalCount:{} finishCount:{}", totalCount, finishCount);
|
|
|
|
+ throw new StatusException("当前预约时段已约满");
|
|
|
|
+ }
|
|
|
|
|
|
LambdaQueryWrapper<StudentApplyEntity> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<StudentApplyEntity> wrapper = new LambdaQueryWrapper<>();
|
|
wrapper.eq(StudentApplyEntity::getStudentId, student.getId());
|
|
wrapper.eq(StudentApplyEntity::getStudentId, student.getId());
|
|
@@ -150,6 +156,9 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
studentApplyService.save(entity);
|
|
studentApplyService.save(entity);
|
|
log.warn("新增考生预约记录!applyId:{} examSiteId:{} timePeriodId:{}", entity.getId(), examSiteId, timePeriodId);
|
|
log.warn("新增考生预约记录!applyId:{} examSiteId:{} timePeriodId:{}", entity.getId(), examSiteId, timePeriodId);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // 某考点某时段的“已预约数量” 累加1
|
|
|
|
+ applyTaskCacheService.increaseApplyFinishCount(examSiteId, timePeriodId);
|
|
} finally {
|
|
} finally {
|
|
studentApplyLock.unlock();
|
|
studentApplyLock.unlock();
|
|
}
|
|
}
|
|
@@ -220,8 +229,10 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
|
|
|
|
this.updateStudentApplyForCancel(applyId, true, student.getId());
|
|
this.updateStudentApplyForCancel(applyId, true, student.getId());
|
|
|
|
|
|
- // todo
|
|
|
|
- // 更新预约时段、机房容量等操作
|
|
|
|
|
|
+ // 某考点某时段的“已预约数量” 累减1
|
|
|
|
+ applyTaskCacheService.decreaseApplyFinishCount(studentApply.getExamSiteId(), studentApply.getTimePeriodId());
|
|
|
|
+
|
|
|
|
+ // todo 取消预约事件
|
|
} finally {
|
|
} finally {
|
|
studentApplyLock.unlock();
|
|
studentApplyLock.unlock();
|
|
}
|
|
}
|
|
@@ -237,6 +248,13 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
log.warn("更新考生预约记录!applyId:{} cancel:{}", applyId, cancel);
|
|
log.warn("更新考生预约记录!applyId:{} cancel:{}", applyId, cancel);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private int getStudentApplyFinishCount(Long studentId) {
|
|
|
|
+ LambdaQueryWrapper<StudentApplyEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(StudentApplyEntity::getStudentId, studentId);
|
|
|
|
+ wrapper.eq(StudentApplyEntity::getCancel, Boolean.FALSE);
|
|
|
|
+ return studentApplyService.count(wrapper);
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<ApplyVO> getStudentApplyList(LoginUser student, Boolean cancel) {
|
|
public List<ApplyVO> getStudentApplyList(LoginUser student, Boolean cancel) {
|
|
CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask(student.getOrgId());
|
|
CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask(student.getOrgId());
|