|
@@ -157,8 +157,8 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
applyTaskCacheService.increaseApplyFinishCount(examSiteId, timePeriodId);
|
|
applyTaskCacheService.increaseApplyFinishCount(examSiteId, timePeriodId);
|
|
|
|
|
|
try {
|
|
try {
|
|
- StudentApplyEntity existApply = this.getStudentApply(student.getId(), examSiteId, timePeriodId);
|
|
|
|
- // ApplyRecordCacheBean existApply = applyTaskCacheService.getStudentApplyRecord(student.getId(), examSiteId, timePeriodId);
|
|
|
|
|
|
+ // StudentApplyEntity existApply = applyTaskCacheService.getStudentApplyRecordFormDB(student.getId(), examSiteId, timePeriodId);
|
|
|
|
+ ApplyRecordCacheBean existApply = applyTaskCacheService.getStudentApplyRecord(student.getId(), examSiteId, timePeriodId);
|
|
if (existApply != null) {
|
|
if (existApply != null) {
|
|
if (!existApply.getCancel()) {
|
|
if (!existApply.getCancel()) {
|
|
// 某考点某时段的“已预约数量” 累减1(释放1个被占数量)
|
|
// 某考点某时段的“已预约数量” 累减1(释放1个被占数量)
|
|
@@ -169,36 +169,30 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
}
|
|
}
|
|
|
|
|
|
// 存在“已取消”预约记录,则恢复预约
|
|
// 存在“已取消”预约记录,则恢复预约
|
|
- // existApply.setCancel(false);
|
|
|
|
- // existApply.setOperateId(student.getId());
|
|
|
|
- // existApply.setOperateTime(System.currentTimeMillis());
|
|
|
|
- // // 推送至预约队列
|
|
|
|
- // applyTaskCacheService.pushStudentApplyRecordQueue(existApply);
|
|
|
|
- // // 保存至预约缓存
|
|
|
|
- // applyTaskCacheService.saveStudentApplyRecord(existApply);
|
|
|
|
-
|
|
|
|
- this.updateStudentApplyForCancel(existApply.getId(), false, student.getId());
|
|
|
|
|
|
+ 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 {
|
|
} else {
|
|
// 不存在则新增预约记录
|
|
// 不存在则新增预约记录
|
|
- // 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();
|
|
|
|
|
|
+ ApplyRecordCacheBean newApply = new ApplyRecordCacheBean();
|
|
newApply.setStudentId(student.getId());
|
|
newApply.setStudentId(student.getId());
|
|
newApply.setExamSiteId(examSiteId);
|
|
newApply.setExamSiteId(examSiteId);
|
|
newApply.setTimePeriodId(timePeriodId);
|
|
newApply.setTimePeriodId(timePeriodId);
|
|
- newApply.setOperateId(student.getId());
|
|
|
|
newApply.setCancel(false);
|
|
newApply.setCancel(false);
|
|
- studentApplyService.save(newApply);
|
|
|
|
|
|
+ newApply.setOperateId(student.getId());
|
|
|
|
+ newApply.setOperateTime(System.currentTimeMillis());
|
|
|
|
+ // 推送至预约队列
|
|
|
|
+ applyTaskCacheService.pushStudentApplyRecordQueue(newApply);
|
|
|
|
+ // 保存至预约缓存
|
|
|
|
+ applyTaskCacheService.saveStudentApplyRecord(newApply);
|
|
|
|
+
|
|
|
|
+ // this.addStudentApply(newApply);
|
|
}
|
|
}
|
|
|
|
|
|
log.warn("预约成功!studentId:{} examSiteId:{} timePeriodId:{}", student.getId(), examSiteId, timePeriodId);
|
|
log.warn("预约成功!studentId:{} examSiteId:{} timePeriodId:{}", student.getId(), examSiteId, timePeriodId);
|
|
@@ -244,18 +238,6 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- 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;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (existApply.getCancel()) {
|
|
|
|
- log.warn("当前时段已取消,忽略重复取消!examSiteId:{} timePeriodId:{}", examSiteId, timePeriodId);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
TimePeriodEntity timePeriod = timePeriodService.getById(timePeriodId);
|
|
TimePeriodEntity timePeriod = timePeriodService.getById(timePeriodId);
|
|
if (timePeriod == null) {
|
|
if (timePeriod == null) {
|
|
log.warn("取消预约失败,预约时段不存在!examSiteId:{} timePeriodId:{}", examSiteId, timePeriodId);
|
|
log.warn("取消预约失败,预约时段不存在!examSiteId:{} timePeriodId:{}", examSiteId, timePeriodId);
|
|
@@ -288,19 +270,30 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
throw new StatusException(Constants.SYSTEM_BUSY);
|
|
throw new StatusException(Constants.SYSTEM_BUSY);
|
|
}
|
|
}
|
|
|
|
|
|
- // existApply.setCancel(true);
|
|
|
|
- // existApply.setOperateId(student.getId());
|
|
|
|
- // existApply.setOperateTime(System.currentTimeMillis());
|
|
|
|
- // // 推送至预约队列
|
|
|
|
- // applyTaskCacheService.pushStudentApplyRecordQueue(existApply);
|
|
|
|
- // // 保存至预约缓存
|
|
|
|
- // applyTaskCacheService.saveStudentApplyRecord(existApply);
|
|
|
|
|
|
+ // StudentApplyEntity existApply = applyTaskCacheService.getStudentApplyRecordFormDB(student.getId(), examSiteId, timePeriodId);
|
|
|
|
+ ApplyRecordCacheBean existApply = applyTaskCacheService.getStudentApplyRecord(student.getId(), examSiteId, timePeriodId);
|
|
|
|
+ if (existApply == null) {
|
|
|
|
+ log.warn("取消预约失败,预约记录不存在!examSiteId:{} timePeriodId:{}", examSiteId, timePeriodId);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (existApply.getCancel()) {
|
|
|
|
+ log.warn("当前时段已取消,忽略重复取消!examSiteId:{} timePeriodId:{}", examSiteId, timePeriodId);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
- this.updateStudentApplyForCancel(existApply.getId(), true, student.getId());
|
|
|
|
|
|
+ existApply.setCancel(true);
|
|
|
|
+ existApply.setOperateId(student.getId());
|
|
|
|
+ existApply.setOperateTime(System.currentTimeMillis());
|
|
|
|
+ // 推送至预约队列
|
|
|
|
+ applyTaskCacheService.pushStudentApplyRecordQueue(existApply);
|
|
|
|
+ // 保存至预约缓存
|
|
|
|
+ applyTaskCacheService.saveStudentApplyRecord(existApply);
|
|
|
|
+
|
|
|
|
+ // this.updateStudentApplyForCancel(existApply.getId(), true, student.getId());
|
|
|
|
|
|
// 某考点某时段的“已预约数量” 累减1
|
|
// 某考点某时段的“已预约数量” 累减1
|
|
applyTaskCacheService.decreaseApplyFinishCount(examSiteId, timePeriodId);
|
|
applyTaskCacheService.decreaseApplyFinishCount(examSiteId, timePeriodId);
|
|
-
|
|
|
|
log.warn("取消预约成功!studentId:{} examSiteId:{} timePeriodId:{}", student.getId(), examSiteId, timePeriodId);
|
|
log.warn("取消预约成功!studentId:{} examSiteId:{} timePeriodId:{}", student.getId(), examSiteId, timePeriodId);
|
|
} finally {
|
|
} finally {
|
|
try {
|
|
try {
|
|
@@ -315,15 +308,6 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private StudentApplyEntity getStudentApply(Long studentId, Long examSiteId, Long timePeriodId) {
|
|
|
|
- LambdaQueryWrapper<StudentApplyEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
- wrapper.eq(StudentApplyEntity::getExamSiteId, examSiteId);
|
|
|
|
- wrapper.eq(StudentApplyEntity::getTimePeriodId, timePeriodId);
|
|
|
|
- wrapper.eq(StudentApplyEntity::getStudentId, studentId);
|
|
|
|
- return studentApplyService.getOne(wrapper);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // @Transactional
|
|
|
|
public void updateStudentApplyForCancel(Long applyId, boolean cancel, Long operateId) {
|
|
public void updateStudentApplyForCancel(Long applyId, boolean cancel, Long operateId) {
|
|
LambdaUpdateWrapper<StudentApplyEntity> updateWrapper = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<StudentApplyEntity> updateWrapper = new LambdaUpdateWrapper<>();
|
|
updateWrapper.set(StudentApplyEntity::getCancel, cancel);
|
|
updateWrapper.set(StudentApplyEntity::getCancel, cancel);
|
|
@@ -333,6 +317,16 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
studentApplyService.update(updateWrapper);
|
|
studentApplyService.update(updateWrapper);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void addStudentApply(ApplyRecordCacheBean bean) {
|
|
|
|
+ StudentApplyEntity newApply = new StudentApplyEntity();
|
|
|
|
+ newApply.setStudentId(bean.getStudentId());
|
|
|
|
+ newApply.setExamSiteId(bean.getExamSiteId());
|
|
|
|
+ newApply.setTimePeriodId(bean.getTimePeriodId());
|
|
|
|
+ newApply.setOperateId(bean.getStudentId());
|
|
|
|
+ newApply.setCancel(bean.getCancel());
|
|
|
|
+ studentApplyService.save(newApply);
|
|
|
|
+ }
|
|
|
|
+
|
|
private boolean hasTicketNumber(Long studentId, Long examSiteId, Long timePeriodId) {
|
|
private boolean hasTicketNumber(Long studentId, Long examSiteId, Long timePeriodId) {
|
|
LambdaQueryWrapper<StudentApplyEntity> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<StudentApplyEntity> wrapper = new LambdaQueryWrapper<>();
|
|
wrapper.select(StudentApplyEntity::getTicketNumber);//只查询ticketNumber等字段
|
|
wrapper.select(StudentApplyEntity::getTicketNumber);//只查询ticketNumber等字段
|
|
@@ -460,7 +454,8 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
@Override
|
|
@Override
|
|
public List<ApplyVO> getStudentApplyListForCurrent(LoginUser student) {
|
|
public List<ApplyVO> getStudentApplyListForCurrent(LoginUser student) {
|
|
// 默认过滤掉“已取消预约”的记录
|
|
// 默认过滤掉“已取消预约”的记录
|
|
- List<ApplyVO> list = this.getStudentApplyList(student, false);
|
|
|
|
|
|
+ // List<ApplyVO> list = this.getStudentApplyList(student, false);
|
|
|
|
+ List<ApplyVO> list = this.getStudentApplyListFromCache(student, false);
|
|
|
|
|
|
Date now = new Date();
|
|
Date now = new Date();
|
|
List<ApplyVO> newList = new ArrayList<>();
|
|
List<ApplyVO> newList = new ArrayList<>();
|
|
@@ -582,7 +577,8 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
List<ExamSiteTimePeriodInfo> timePeriods = timePeriodExamSiteService.findExamSiteTimePeriods(periodQuery);
|
|
List<ExamSiteTimePeriodInfo> timePeriods = timePeriodExamSiteService.findExamSiteTimePeriods(periodQuery);
|
|
|
|
|
|
// 获取某考生的 所有的“预约记录”
|
|
// 获取某考生的 所有的“预约记录”
|
|
- Map<String, ApplyRecordCacheBean> maps = applyTaskCacheService.getStudentApplyRecordsFromDB(student.getId());
|
|
|
|
|
|
+ // Map<String, ApplyRecordCacheBean> maps = applyTaskCacheService.getStudentApplyRecordsFromDB(student.getId());
|
|
|
|
+ Map<String, ApplyRecordCacheBean> maps = applyTaskCacheService.getStudentApplyRecords(student.getId());
|
|
int studentApplyFinishCount = 0;
|
|
int studentApplyFinishCount = 0;
|
|
for (ApplyRecordCacheBean bean : maps.values()) {
|
|
for (ApplyRecordCacheBean bean : maps.values()) {
|
|
if (!bean.getCancel()) {
|
|
if (!bean.getCancel()) {
|