|
@@ -482,34 +482,35 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
entity.setCancel(Boolean.FALSE);
|
|
entity.setCancel(Boolean.FALSE);
|
|
entity.setOperateId(user.getId());
|
|
entity.setOperateId(user.getId());
|
|
//保存考生预约
|
|
//保存考生预约
|
|
- saveOrUpdateStudentApply(entity);
|
|
|
|
-
|
|
|
|
- // 队列bean
|
|
|
|
- ApplyRecordCacheBean bean = new ApplyRecordCacheBean();
|
|
|
|
- bean.setStudentId(vo.getStudentId());
|
|
|
|
- bean.setExamSiteId(agentTimeVO.getAgentId());
|
|
|
|
- bean.setTimePeriodId(agentTimeVO.getTimePeriodId());
|
|
|
|
- bean.setCancel(Boolean.FALSE);
|
|
|
|
- bean.setOperateId(user.getId());
|
|
|
|
- bean.setOperateTime(System.currentTimeMillis());
|
|
|
|
- bean.setBizId(cacheService.increaseBizId());
|
|
|
|
-
|
|
|
|
- // 某考点某时段的“剩余可约数量”(抢占1个数量)
|
|
|
|
- boolean takeSuccess = cacheService.decreaseApplyAvailableCount(bean.getExamSiteId(), bean.getTimePeriodId());
|
|
|
|
- if (!takeSuccess) {
|
|
|
|
- log.warn("[importPreExam] 预约失败,当前预约时段已约满!examSiteId:{} timePeriodId:{} studentId:{}",
|
|
|
|
- bean.getExamSiteId(), bean.getTimePeriodId(), bean.getStudentId());
|
|
|
|
- //考点
|
|
|
|
- ExamSiteCacheBean examSiteBean = examSiteCacheService.getExamSiteById(bean.getExamSiteId());
|
|
|
|
- //时段
|
|
|
|
- TimePeriodEntity timePeriod = timePeriodService.getById(bean.getTimePeriodId());
|
|
|
|
- String message = MessageFormat.format("第{0}行,预约考点:{1},预约时段:{2}", i + 1, examSiteBean.getExamSiteName(),
|
|
|
|
- DateUtil.getStartAndEndTime(timePeriod.getStartTime(), timePeriod.getEndTime()));
|
|
|
|
- throw new StatusException(message);
|
|
|
|
|
|
+ boolean successFlag = saveOrUpdateStudentApply(entity);
|
|
|
|
+ if (successFlag) {
|
|
|
|
+ // 队列bean
|
|
|
|
+ ApplyRecordCacheBean bean = new ApplyRecordCacheBean();
|
|
|
|
+ bean.setStudentId(vo.getStudentId());
|
|
|
|
+ bean.setExamSiteId(agentTimeVO.getAgentId());
|
|
|
|
+ bean.setTimePeriodId(agentTimeVO.getTimePeriodId());
|
|
|
|
+ bean.setCancel(Boolean.FALSE);
|
|
|
|
+ bean.setOperateId(user.getId());
|
|
|
|
+ bean.setOperateTime(System.currentTimeMillis());
|
|
|
|
+ bean.setBizId(cacheService.increaseBizId());
|
|
|
|
+
|
|
|
|
+ // 某考点某时段的“剩余可约数量”(抢占1个数量)
|
|
|
|
+ boolean takeSuccess = cacheService.decreaseApplyAvailableCount(bean.getExamSiteId(), bean.getTimePeriodId());
|
|
|
|
+ if (!takeSuccess) {
|
|
|
|
+ log.warn("[importPreExam] 预约失败,当前预约时段已约满!examSiteId:{} timePeriodId:{} studentId:{}",
|
|
|
|
+ bean.getExamSiteId(), bean.getTimePeriodId(), bean.getStudentId());
|
|
|
|
+ //考点
|
|
|
|
+ ExamSiteCacheBean examSiteBean = examSiteCacheService.getExamSiteById(bean.getExamSiteId());
|
|
|
|
+ //时段
|
|
|
|
+ TimePeriodEntity timePeriod = timePeriodService.getById(bean.getTimePeriodId());
|
|
|
|
+ String message = MessageFormat.format("第{0}行,预约考点:{1},预约时段:{2}", i + 1, examSiteBean.getExamSiteName(),
|
|
|
|
+ DateUtil.getStartAndEndTime(timePeriod.getStartTime(), timePeriod.getEndTime()));
|
|
|
|
+ throw new StatusException(message);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 保存至预约缓存
|
|
|
|
+ cacheService.saveStudentApplyRecord(bean);
|
|
}
|
|
}
|
|
-
|
|
|
|
- // 保存至预约缓存
|
|
|
|
- cacheService.saveStudentApplyRecord(bean);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -1187,15 +1188,37 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
- public void saveOrUpdateStudentApply(StudentApplyEntity studentApply) {
|
|
|
|
- // 预约是否已经存在
|
|
|
|
|
|
+ public boolean saveOrUpdateStudentApply(StudentApplyEntity studentApply) {
|
|
|
|
+ // 缓存中查看考生是否已经预约
|
|
|
|
+ ApplyRecordCacheBean studentApplyRecord = cacheService.getStudentApplyRecord(studentApply.getStudentId(), studentApply.getExamSiteId(),
|
|
|
|
+ studentApply.getTimePeriodId());
|
|
|
|
+ // 考生未预约
|
|
|
|
+ if (studentApplyRecord == null) {
|
|
|
|
+ baseMapper.insert(studentApply);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ // 考生先预约,然后做了取消操作
|
|
|
|
+ if (studentApplyRecord.getCancel()) {
|
|
|
|
+ StudentApplyEntity existStudentApply = findStudentApply(studentApply);
|
|
|
|
+ if (existStudentApply != null) {
|
|
|
|
+ existStudentApply.setCancel(Boolean.FALSE);
|
|
|
|
+ baseMapper.updateById(existStudentApply);
|
|
|
|
+ } else {
|
|
|
|
+ baseMapper.insert(studentApply);
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ } else { //考生已经预约
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* // 预约是否已经存在
|
|
StudentApplyEntity existStudentApply = findStudentApply(studentApply);
|
|
StudentApplyEntity existStudentApply = findStudentApply(studentApply);
|
|
- if (existStudentApply != null) {
|
|
|
|
|
|
+ if (studentApplyRecord != null) {
|
|
existStudentApply.setCancel(Boolean.FALSE);
|
|
existStudentApply.setCancel(Boolean.FALSE);
|
|
baseMapper.updateById(existStudentApply);
|
|
baseMapper.updateById(existStudentApply);
|
|
} else {
|
|
} else {
|
|
baseMapper.insert(studentApply);
|
|
baseMapper.insert(studentApply);
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|