|
@@ -50,6 +50,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
|
|
+import java.text.MessageFormat;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -423,7 +424,7 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
for (int i = 0; i < applyList.size(); i++) {
|
|
for (int i = 0; i < applyList.size(); i++) {
|
|
StudentImportVO vo = applyList.get(i);
|
|
StudentImportVO vo = applyList.get(i);
|
|
try {
|
|
try {
|
|
- saveStudentApply(vo, user.getId());
|
|
|
|
|
|
+ saveStudentApply(i, vo, user.getId());
|
|
} catch (StatusException e) {
|
|
} catch (StatusException e) {
|
|
failRecords.add(newError(i + 1, "系统异常"));
|
|
failRecords.add(newError(i + 1, "系统异常"));
|
|
log.error("[importPreExam] 导入异常", e);
|
|
log.error("[importPreExam] 导入异常", e);
|
|
@@ -483,7 +484,7 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
- private void saveStudentApply(StudentImportVO vo, Long userId) {
|
|
|
|
|
|
+ private void saveStudentApply(int row, StudentImportVO vo, Long userId) {
|
|
List<AgentAndTimeVO> agentTimeList = vo.getAgentTimeList();
|
|
List<AgentAndTimeVO> agentTimeList = vo.getAgentTimeList();
|
|
String studentApplyLockKey = String.format(CacheConstants.LOCK_STUDENT_APPLY, vo.getStudentId());
|
|
String studentApplyLockKey = String.format(CacheConstants.LOCK_STUDENT_APPLY, vo.getStudentId());
|
|
RLock studentApplyLock = (RLock) concurrentService.getLock(studentApplyLockKey);
|
|
RLock studentApplyLock = (RLock) concurrentService.getLock(studentApplyLockKey);
|
|
@@ -493,22 +494,6 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
} else {
|
|
} else {
|
|
log.warn("[importPreExam] 获取锁成功,lockKey:{}", studentApplyLockKey);
|
|
log.warn("[importPreExam] 获取锁成功,lockKey:{}", studentApplyLockKey);
|
|
for (AgentAndTimeVO agentTimeVO : agentTimeList) {
|
|
for (AgentAndTimeVO agentTimeVO : agentTimeList) {
|
|
- /*
|
|
|
|
- //数据库操作
|
|
|
|
- StudentApplyEntity studentApply = new StudentApplyEntity();
|
|
|
|
- studentApply.setStudentId(vo.getStudentId());
|
|
|
|
- studentApply.setExamSiteId(agentTimeVO.getAgentId());
|
|
|
|
- studentApply.setTimePeriodId(agentTimeVO.getTimePeriodId());
|
|
|
|
- studentApply.setCancel(Boolean.FALSE);
|
|
|
|
- studentApply.setOperateId(userId);
|
|
|
|
- StudentApplyEntity existStudentApply = findStudentApply(studentApply);
|
|
|
|
- if (existStudentApply != null) {
|
|
|
|
- existStudentApply.setCancel(Boolean.FALSE);
|
|
|
|
- baseMapper.updateById(existStudentApply);
|
|
|
|
- } else {
|
|
|
|
- baseMapper.insert(studentApply);
|
|
|
|
- }*/
|
|
|
|
-
|
|
|
|
// 队列bean
|
|
// 队列bean
|
|
ApplyRecordCacheBean bean = new ApplyRecordCacheBean();
|
|
ApplyRecordCacheBean bean = new ApplyRecordCacheBean();
|
|
bean.setStudentId(vo.getStudentId());
|
|
bean.setStudentId(vo.getStudentId());
|
|
@@ -521,9 +506,15 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
// 某考点某时段的“剩余可约数量”(抢占1个数量)
|
|
// 某考点某时段的“剩余可约数量”(抢占1个数量)
|
|
boolean takeSuccess = cacheService.decreaseApplyAvailableCount(bean.getExamSiteId(), bean.getTimePeriodId());
|
|
boolean takeSuccess = cacheService.decreaseApplyAvailableCount(bean.getExamSiteId(), bean.getTimePeriodId());
|
|
if (!takeSuccess) {
|
|
if (!takeSuccess) {
|
|
- log.warn("预约失败,当前预约时段已约满!examSiteId:{} timePeriodId:{} studentId:{}",
|
|
|
|
|
|
+ log.warn("[importPreExam] 预约失败,当前预约时段已约满!examSiteId:{} timePeriodId:{} studentId:{}",
|
|
bean.getExamSiteId(), bean.getTimePeriodId(), bean.getStudentId());
|
|
bean.getExamSiteId(), bean.getTimePeriodId(), bean.getStudentId());
|
|
- throw new StatusException("当前预约时段已约满");
|
|
|
|
|
|
+ //考点
|
|
|
|
+ ExamSiteCacheBean examSiteBean = examSiteCacheService.getExamSiteById(bean.getExamSiteId());
|
|
|
|
+ //时段
|
|
|
|
+ TimePeriodEntity timePeriod = timePeriodService.getById(bean.getTimePeriodId());
|
|
|
|
+ String message = MessageFormat.format("第{0}行,预约考点:{1},预约时段:{2}", row + 1, examSiteBean.getExamSiteName(),
|
|
|
|
+ DateUtil.getStartAndEndTime(timePeriod.getStartTime(), timePeriod.getEndTime()));
|
|
|
|
+ throw new StatusException(message);
|
|
}
|
|
}
|
|
// 推送至预约队列
|
|
// 推送至预约队列
|
|
cacheService.pushStudentApplyRecordQueue(bean);
|
|
cacheService.pushStudentApplyRecordQueue(bean);
|