deason 1 жил өмнө
parent
commit
e7c3922268

+ 7 - 4
src/main/java/com/qmth/exam/reserve/controller/student/StudentApplyController.java

@@ -41,8 +41,9 @@ public class StudentApplyController extends BaseController {
 
     @ApiOperation(value = "取消考生预约结果")
     @PostMapping(value = "/apply/cancel")
-    public void cancel(@ApiParam("预约记录ID") @RequestParam Long applyId) {
-        examReserveService.cancelStudentApply(curLoginStudent(), applyId);
+    public void cancel(@ApiParam("考点ID") @RequestParam Long examSiteId,
+                       @ApiParam("预约时段ID") @RequestParam Long timePeriodId) {
+        examReserveService.cancelStudentApply(curLoginStudent(), examSiteId, timePeriodId);
     }
 
     @ApiOperation(value = "获取考生预约结果列表(个人中心)")
@@ -59,8 +60,9 @@ public class StudentApplyController extends BaseController {
 
     @ApiOperation(value = "获取考生预约-电子准考证")
     @PostMapping(value = "/apply/ticket")
-    public TicketInfo ticket(@ApiParam("预约记录ID") @RequestParam Long applyId) {
-        return examReserveService.getApplyTicket(curLoginStudent().getId(), applyId);
+    public TicketInfo ticket(@ApiParam("考点ID") @RequestParam Long examSiteId,
+                             @ApiParam("预约时段ID") @RequestParam Long timePeriodId) {
+        return examReserveService.getApplyTicket(curLoginStudent().getId(), examSiteId, timePeriodId);
     }
 
     @ApiOperation(value = "获取考试须知")
@@ -89,3 +91,4 @@ public class StudentApplyController extends BaseController {
     }
 
 }
+

+ 5 - 1
src/main/java/com/qmth/exam/reserve/dao/StudentApplyDao.java

@@ -23,7 +23,11 @@ public interface StudentApplyDao extends BaseMapper<StudentApplyEntity> {
 
     Integer countApplyFinishForExamSiteAndTimePeriod(@Param("examSiteId") Long examSiteId, @Param("timePeriodId") Long timePeriodId);
 
-    TicketInfo getStudentApplyTicket(@Param("applyId") Long applyId);
+    TicketInfo getStudentApplyTicket(
+            @Param("studentId") Long studentId,
+            @Param("examSiteId") Long examSiteId,
+            @Param("timePeriodId") Long timePeriodId
+    );
 
     List<StudentApplyEntity> listTimePeriod(@Param(value = "timePeriodIds") List<Long> timePeriodIds,
                                             @Param(value = "cancel") Boolean cancel);

+ 2 - 2
src/main/java/com/qmth/exam/reserve/service/ExamReserveService.java

@@ -12,13 +12,13 @@ public interface ExamReserveService {
 
     void saveStudentApply(LoginUser student, Long examSiteId, Long timePeriodId);
 
-    void cancelStudentApply(LoginUser student, Long applyId);
+    void cancelStudentApply(LoginUser student, Long examSiteId, Long timePeriodId);
 
     List<ApplyVO> getStudentApplyList(LoginUser student, Boolean cancel);
 
     List<ApplyVO> getStudentApplyListForCurrent(LoginUser student);
 
-    TicketInfo getApplyTicket(Long studentId, Long applyId);
+    TicketInfo getApplyTicket(Long studentId, Long examSiteId, Long timePeriodId);
 
     List<String> getApplyDateList(LoginUser student);
 

+ 26 - 19
src/main/java/com/qmth/exam/reserve/service/impl/ExamReserveServiceImpl.java

@@ -179,14 +179,17 @@ public class ExamReserveServiceImpl implements ExamReserveService {
 
     @Override
     @Transactional
-    public void cancelStudentApply(LoginUser student, Long applyId) {
-        if (applyId == null) {
-            throw new StatusException("预约记录ID不能为空");
+    public void cancelStudentApply(LoginUser student, Long examSiteId, Long timePeriodId) {
+        if (examSiteId == null) {
+            throw new StatusException("考点ID不能为空");
+        }
+        if (timePeriodId == null) {
+            throw new StatusException("预约时段ID不能为空");
         }
 
         CurrentApplyTaskVO curApplyTask = applyTaskCacheService.currentApplyTask(student.getOrgId());
         if (curApplyTask == null) {
-            log.warn("取消预约失败,尚未开启预约任务!stuApplyTaskId:{} applyId:{}", student.getApplyTaskId(), applyId);
+            log.warn("取消预约失败,尚未开启预约任务!stuApplyTaskId:{}", student.getApplyTaskId());
             return;
         }
         if (!curApplyTask.getTaskId().equals(student.getApplyTaskId())) {
@@ -194,24 +197,24 @@ public class ExamReserveServiceImpl implements ExamReserveService {
             return;
         }
 
-        StudentApplyEntity studentApply = studentApplyService.getById(applyId);
+        LambdaQueryWrapper<StudentApplyEntity> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(StudentApplyEntity::getExamSiteId, examSiteId);
+        wrapper.eq(StudentApplyEntity::getTimePeriodId, timePeriodId);
+        wrapper.eq(StudentApplyEntity::getStudentId, student.getId());
+        StudentApplyEntity studentApply = studentApplyService.getOne(wrapper);
         if (studentApply == null) {
-            log.warn("取消预约失败,预约记录不存在!applyId:{}", applyId);
-            return;
-        }
-        if (!studentApply.getStudentId().equals(student.getId())) {
-            log.warn("取消预约失败,预约记录与当前学生的不匹配!applyId:{} {}!={}", applyId, studentApply.getStudentId(), student.getId());
+            log.warn("取消预约失败,预约记录不存在!examSiteId:{} timePeriodId:{}", examSiteId, timePeriodId);
             return;
         }
 
         if (studentApply.getCancel()) {
-            log.warn("当前时段已取消预约,忽略重复取消!applyId:{}", applyId);
+            log.warn("当前时段已取消预约,忽略重复取消!examSiteId:{} timePeriodId:{}", examSiteId, timePeriodId);
             return;
         }
 
-        TimePeriodEntity timePeriod = timePeriodService.getById(studentApply.getTimePeriodId());
+        TimePeriodEntity timePeriod = timePeriodService.getById(timePeriodId);
         if (timePeriod == null) {
-            log.warn("取消预约失败,预约时段不存在!applyId:{} timePeriodId:{}", applyId, studentApply.getTimePeriodId());
+            log.warn("取消预约失败,预约时段不存在!examSiteId:{} timePeriodId:{}", examSiteId, timePeriodId);
             return;
         }
 
@@ -240,7 +243,7 @@ public class ExamReserveServiceImpl implements ExamReserveService {
                 throw new StatusException(Constants.SYSTEM_BUSY);
             }
 
-            this.updateStudentApplyForCancel(applyId, true, student.getId());
+            this.updateStudentApplyForCancel(studentApply.getId(), true, student.getId());
 
             // 某考点某时段的“已预约数量” 累减1
             applyTaskCacheService.decreaseApplyFinishCount(studentApply.getExamSiteId(), studentApply.getTimePeriodId());
@@ -328,15 +331,19 @@ public class ExamReserveServiceImpl implements ExamReserveService {
     }
 
     @Override
-    public TicketInfo getApplyTicket(Long studentId, Long applyId) {
+    public TicketInfo getApplyTicket(Long studentId, Long examSiteId, Long timePeriodId) {
+        if (examSiteId == null) {
+            throw new StatusException("考点ID不能为空");
+        }
+        if (timePeriodId == null) {
+            throw new StatusException("预约时段ID不能为空");
+        }
+
         StudentApplyDao baseMapper = (StudentApplyDao) studentApplyService.getBaseMapper();
-        TicketInfo info = baseMapper.getStudentApplyTicket(applyId);
+        TicketInfo info = baseMapper.getStudentApplyTicket(studentId, examSiteId, timePeriodId);
         if (info == null || info.getCancel()) {
             throw new StatusException("准考证信息不存在");
         }
-        if (!info.getStudentId().equals(studentId)) {
-            throw new StatusException("准考证信息不匹配");
-        }
         if (StringUtils.isEmpty(info.getTicketNumber())) {
             throw new StatusException("准考证信息尚未生成");
         }

+ 10 - 7
src/main/resources/mapper/StudentApplyMapper.xml

@@ -98,16 +98,19 @@
                  inner join t_time_period tp on tp.id = sa.time_period_id
                  inner join t_exam_site es on es.id = sa.exam_site_id
                  left join t_exam_room ec on ec.id = sa.exam_room_id
-        where sa.id = #{applyId}
+        where sa.exam_site_id = #{examSiteId}
+          and sa.time_period_id = #{timePeriodId}
+          and sa.student_id = #{studentId}
     </select>
     
     <select id="listTimePeriod" resultType="com.qmth.exam.reserve.entity.StudentApplyEntity">
-		select sa.* from t_student_apply sa,t_student s where sa.student_id=s.id and  sa.cancel=#{cancel} and sa.time_period_id in
-		<foreach collection="timePeriodIds" item="item" index="index" separator="," open="(" close=")">
-			#{item}
-		</foreach>
-		 order by s.student_code
-	</select>
+        select sa.* from t_student_apply sa,t_student s where sa.student_id=s.id and sa.cancel=#{cancel} and
+        sa.time_period_id in
+        <foreach collection="timePeriodIds" item="item" index="index" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        order by s.student_code
+    </select>
 	
 	<select id="listStudentApply" resultType="com.qmth.exam.reserve.bean.stdapply.StudentApplyVO">
 		select s.name,s.student_code studentCode,sa.seat_number seatNumber from t_student_apply sa,t_student s where sa.student_id=s.id and seat_number is not null