haogh 8 月之前
父節點
當前提交
9a4279ab70
共有 1 個文件被更改,包括 11 次插入20 次删除
  1. 11 20
      src/main/java/com/qmth/exam/reserve/service/impl/StudentApplyServiceImpl.java

+ 11 - 20
src/main/java/com/qmth/exam/reserve/service/impl/StudentApplyServiceImpl.java

@@ -50,6 +50,7 @@ import org.springframework.transaction.annotation.Transactional;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.text.MessageFormat;
 import java.time.LocalDate;
 import java.time.ZoneId;
 import java.util.*;
@@ -423,7 +424,7 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
             for (int i = 0; i < applyList.size(); i++) {
                 StudentImportVO vo = applyList.get(i);
                 try {
-                    saveStudentApply(vo, user.getId());
+                    saveStudentApply(i, vo, user.getId());
                 } catch (StatusException e) {
                     failRecords.add(newError(i + 1, "系统异常"));
                     log.error("[importPreExam] 导入异常", e);
@@ -483,7 +484,7 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
         return map;
     }
 
-    private void saveStudentApply(StudentImportVO vo, Long userId) {
+    private void saveStudentApply(int row, StudentImportVO vo, Long userId) {
         List<AgentAndTimeVO> agentTimeList = vo.getAgentTimeList();
         String studentApplyLockKey = String.format(CacheConstants.LOCK_STUDENT_APPLY, vo.getStudentId());
         RLock studentApplyLock = (RLock) concurrentService.getLock(studentApplyLockKey);
@@ -493,22 +494,6 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
             } else {
                 log.warn("[importPreExam] 获取锁成功,lockKey:{}", studentApplyLockKey);
                 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
                     ApplyRecordCacheBean bean = new ApplyRecordCacheBean();
                     bean.setStudentId(vo.getStudentId());
@@ -521,9 +506,15 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
                     // 某考点某时段的“剩余可约数量”(抢占1个数量)
                     boolean takeSuccess = cacheService.decreaseApplyAvailableCount(bean.getExamSiteId(), bean.getTimePeriodId());
                     if (!takeSuccess) {
-                        log.warn("预约失败,当前预约时段已约满!examSiteId:{} timePeriodId:{} studentId:{}",
+                        log.warn("[importPreExam] 预约失败,当前预约时段已约满!examSiteId:{} timePeriodId:{} studentId:{}",
                                 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);