haogh vor 3 Wochen
Ursprung
Commit
2e27d8dc3c

+ 15 - 0
src/main/java/com/qmth/exam/reserve/service/impl/StudentApplyServiceImpl.java

@@ -210,6 +210,12 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
             throw new StatusException(Constants.SYSTEM_BUSY);
         }
 
+        String capacityLockKey = String.format(CacheConstants.LOCK_EXAM_SITE_CAPACITY, studentApplyEntity.getExamSiteId());
+        if (concurrentService.isLocked(capacityLockKey)) {
+            log.warn("[cancel]考点剩余可约数量更新中,不允许取消预约!lockKey:{}", capacityLockKey);
+            throw new StatusException("考点的容量有老师正在修改,不能取消预约,请稍后再试");
+        }
+
         // 教学点管理员,只能取消本教学点的考生
         if (user.getRole().equals(Role.TEACHING) && !user.getCategoryId().equals(student.getCategoryId())) {
             log.warn("[cancel] 教学点管理员,只能取消本教学点的考生, userId:{}, studentId:{}", user.getId(), studentApplyEntity.getStudentId());
@@ -487,6 +493,8 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
                 return failRecords;
             }
 
+            //考点容量变更锁
+            String capacityLockKey;
             //保存数据
             for (int i = 0; i < applyList.size(); i++) {
                 StudentImportVO vo = applyList.get(i);
@@ -500,6 +508,13 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
                         } else {
                             log.warn("[importPreExam] 获取锁成功,lockKey:{}", studentApplyLockKey);
                             for (AgentAndTimeVO agentTimeVO : agentTimeList) {
+
+                                capacityLockKey = String.format(CacheConstants.LOCK_EXAM_SITE_CAPACITY, agentTimeVO.getAgentId());
+                                if (concurrentService.isLocked(capacityLockKey)) {
+                                    log.warn("[importPreExam] 考点剩余可约数量更新中,不允许导入预约!lockKey:{}", capacityLockKey);
+                                    throw new StatusException("其他老师正在修改考点的容量,不允许导入预约,请稍后再试");
+                                }
+
                                 StudentApplyEntity entity = new StudentApplyEntity();
                                 entity.setStudentId(vo.getStudentId());
                                 entity.setExamSiteId(agentTimeVO.getAgentId());

+ 1 - 0
src/main/resources/mapper/TimePeriodMapper.xml

@@ -71,5 +71,6 @@
             AND tper.exam_room_id = #{examRoomId}
         </if>
         order by tp.start_time
+        for update
     </select>
 </mapper>