|
@@ -30,7 +30,6 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
import java.util.*;
|
|
@@ -136,8 +135,8 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
|
applyTaskCacheService.increaseApplyFinishCount(examSiteId, timePeriodId);
|
|
|
|
|
|
try {
|
|
|
- // StudentApplyEntity existApply = this.getStudentApply(student.getId(), examSiteId, timePeriodId);
|
|
|
- ApplyRecordCacheBean existApply = applyTaskCacheService.getStudentApplyRecord(student.getId(), examSiteId, timePeriodId);
|
|
|
+ StudentApplyEntity existApply = this.getStudentApply(student.getId(), examSiteId, timePeriodId);
|
|
|
+ // ApplyRecordCacheBean existApply = applyTaskCacheService.getStudentApplyRecord(student.getId(), examSiteId, timePeriodId);
|
|
|
if (existApply != null) {
|
|
|
if (!existApply.getCancel()) {
|
|
|
// 某考点某时段的“已预约数量” 累减1(释放1个被占数量)
|
|
@@ -148,30 +147,36 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
|
}
|
|
|
|
|
|
// 存在“已取消”预约记录,则恢复预约
|
|
|
- existApply.setCancel(false);
|
|
|
- existApply.setOperateId(student.getId());
|
|
|
- existApply.setOperateTime(System.currentTimeMillis());
|
|
|
-
|
|
|
- // 推送至预约队列
|
|
|
- applyTaskCacheService.pushStudentApplyRecordQueue(existApply);
|
|
|
-
|
|
|
- // 保存至预约缓存
|
|
|
- applyTaskCacheService.saveStudentApplyRecord(existApply);
|
|
|
+ // existApply.setCancel(false);
|
|
|
+ // existApply.setOperateId(student.getId());
|
|
|
+ // existApply.setOperateTime(System.currentTimeMillis());
|
|
|
+ // // 推送至预约队列
|
|
|
+ // applyTaskCacheService.pushStudentApplyRecordQueue(existApply);
|
|
|
+ // // 保存至预约缓存
|
|
|
+ // applyTaskCacheService.saveStudentApplyRecord(existApply);
|
|
|
+
|
|
|
+ this.updateStudentApplyForCancel(existApply.getId(), false, student.getId());
|
|
|
} else {
|
|
|
// 不存在则新增预约记录
|
|
|
- ApplyRecordCacheBean newApply = new ApplyRecordCacheBean();
|
|
|
+ // ApplyRecordCacheBean newApply = new ApplyRecordCacheBean();
|
|
|
+ // newApply.setStudentId(student.getId());
|
|
|
+ // newApply.setExamSiteId(examSiteId);
|
|
|
+ // newApply.setTimePeriodId(timePeriodId);
|
|
|
+ // newApply.setCancel(false);
|
|
|
+ // newApply.setOperateId(student.getId());
|
|
|
+ // newApply.setOperateTime(System.currentTimeMillis());
|
|
|
+ // // 推送至预约队列
|
|
|
+ // applyTaskCacheService.pushStudentApplyRecordQueue(newApply);
|
|
|
+ // // 保存至预约缓存
|
|
|
+ // applyTaskCacheService.saveStudentApplyRecord(newApply);
|
|
|
+
|
|
|
+ StudentApplyEntity newApply = new StudentApplyEntity();
|
|
|
newApply.setStudentId(student.getId());
|
|
|
newApply.setExamSiteId(examSiteId);
|
|
|
newApply.setTimePeriodId(timePeriodId);
|
|
|
- newApply.setCancel(false);
|
|
|
newApply.setOperateId(student.getId());
|
|
|
- newApply.setOperateTime(System.currentTimeMillis());
|
|
|
-
|
|
|
- // 推送至预约队列
|
|
|
- applyTaskCacheService.pushStudentApplyRecordQueue(newApply);
|
|
|
-
|
|
|
- // 保存至预约缓存
|
|
|
- applyTaskCacheService.saveStudentApplyRecord(newApply);
|
|
|
+ newApply.setCancel(false);
|
|
|
+ studentApplyService.save(newApply);
|
|
|
}
|
|
|
|
|
|
log.warn("预约成功!studentId:{} examSiteId:{} timePeriodId:{}", student.getId(), examSiteId, timePeriodId);
|
|
@@ -217,8 +222,8 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // StudentApplyEntity existApply = this.getStudentApply(student.getId(), examSiteId, timePeriodId);
|
|
|
- ApplyRecordCacheBean existApply = applyTaskCacheService.getStudentApplyRecord(student.getId(), examSiteId, timePeriodId);
|
|
|
+ StudentApplyEntity existApply = this.getStudentApply(student.getId(), examSiteId, timePeriodId);
|
|
|
+ // ApplyRecordCacheBean existApply = applyTaskCacheService.getStudentApplyRecord(student.getId(), examSiteId, timePeriodId);
|
|
|
if (existApply == null) {
|
|
|
log.warn("取消预约失败,预约记录不存在!examSiteId:{} timePeriodId:{}", examSiteId, timePeriodId);
|
|
|
return;
|
|
@@ -262,15 +267,15 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
|
throw new StatusException(Constants.SYSTEM_BUSY);
|
|
|
}
|
|
|
|
|
|
- existApply.setCancel(true);
|
|
|
- existApply.setOperateId(student.getId());
|
|
|
- existApply.setOperateTime(System.currentTimeMillis());
|
|
|
+ // existApply.setCancel(true);
|
|
|
+ // existApply.setOperateId(student.getId());
|
|
|
+ // existApply.setOperateTime(System.currentTimeMillis());
|
|
|
+ // // 推送至预约队列
|
|
|
+ // applyTaskCacheService.pushStudentApplyRecordQueue(existApply);
|
|
|
+ // // 保存至预约缓存
|
|
|
+ // applyTaskCacheService.saveStudentApplyRecord(existApply);
|
|
|
|
|
|
- // 推送至预约队列
|
|
|
- applyTaskCacheService.pushStudentApplyRecordQueue(existApply);
|
|
|
-
|
|
|
- // 保存至预约缓存
|
|
|
- applyTaskCacheService.saveStudentApplyRecord(existApply);
|
|
|
+ this.updateStudentApplyForCancel(existApply.getId(), true, student.getId());
|
|
|
|
|
|
// 某考点某时段的“已预约数量” 累减1
|
|
|
applyTaskCacheService.decreaseApplyFinishCount(examSiteId, timePeriodId);
|
|
@@ -305,7 +310,7 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
|
return studentApplyService.getOne(wrapper);
|
|
|
}
|
|
|
|
|
|
- @Transactional
|
|
|
+ // @Transactional
|
|
|
public void updateStudentApplyForCancel(Long applyId, boolean cancel, Long operateId) {
|
|
|
LambdaUpdateWrapper<StudentApplyEntity> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(StudentApplyEntity::getCancel, cancel);
|
|
@@ -313,7 +318,6 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
|
updateWrapper.set(StudentApplyEntity::getUpdateTime, System.currentTimeMillis());
|
|
|
updateWrapper.eq(StudentApplyEntity::getId, applyId);
|
|
|
studentApplyService.update(updateWrapper);
|
|
|
- log.warn("更新考生预约记录!applyId:{} cancel:{}", applyId, cancel);
|
|
|
}
|
|
|
|
|
|
private boolean hasTicketNumber(Long studentId, Long examSiteId, Long timePeriodId) {
|
|
@@ -443,7 +447,7 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
|
@Override
|
|
|
public List<ApplyVO> getStudentApplyListForCurrent(LoginUser student) {
|
|
|
// 默认过滤掉“已取消预约”的记录
|
|
|
- List<ApplyVO> list = this.getStudentApplyListFromCache(student, false);
|
|
|
+ List<ApplyVO> list = this.getStudentApplyList(student, false);
|
|
|
|
|
|
Date now = new Date();
|
|
|
List<ApplyVO> newList = new ArrayList<>();
|
|
@@ -547,7 +551,7 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
|
List<TimePeriodEntity> timePeriods = timePeriodService.list(wrapper);
|
|
|
|
|
|
// 获取某考生的 所有的“预约记录”
|
|
|
- Map<String, ApplyRecordCacheBean> maps = applyTaskCacheService.getStudentApplyRecords(student.getId());
|
|
|
+ Map<String, ApplyRecordCacheBean> maps = applyTaskCacheService.getStudentApplyRecordsFormDB(student.getId());
|
|
|
int studentApplyFinishCount = 0;
|
|
|
for (ApplyRecordCacheBean bean : maps.values()) {
|
|
|
if (!bean.getCancel()) {
|