deason il y a 1 an
Parent
commit
5e8ce59b48

+ 17 - 3
src/main/java/com/qmth/exam/reserve/bean/apply/ApplyVO.java

@@ -1,5 +1,6 @@
 package com.qmth.exam.reserve.bean.apply;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.qmth.exam.reserve.bean.IModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
@@ -14,14 +15,23 @@ public class ApplyVO implements IModel {
     @ApiModelProperty(value = "预约ID")
     private Long applyId;
 
+    @ApiModelProperty(value = "预约时段ID")
+    private Long timePeriodId;
+
     @ApiModelProperty(value = "预约的开始时间")
     private Long timePeriodStart;
 
     @ApiModelProperty(value = "预约的结束时间")
     private Long timePeriodEnd;
 
+    @ApiModelProperty(value = "教学点ID")
+    private Long categoryId;
+
     @ApiModelProperty(value = "教学点名称")
-    private String teachingName;
+    private String categoryName;
+
+    @ApiModelProperty(value = "考点ID")
+    private Long examSiteId;
 
     @ApiModelProperty(value = "考点名称")
     private String examSiteName;
@@ -29,8 +39,8 @@ public class ApplyVO implements IModel {
     @ApiModelProperty(value = "考点地址")
     private String examSiteAddress;
 
-    @ApiModelProperty(value = "状态")
-    private String status;
+    @ApiModelProperty(value = "是否已取消预约")
+    private Boolean cancel;
 
     @ApiModelProperty(value = "是否允许取消预约")
     private Boolean allowCancel;
@@ -38,4 +48,8 @@ public class ApplyVO implements IModel {
     @ApiModelProperty(value = "是否显示电子准考证标志")
     private Boolean showTicket;
 
+    @JsonIgnore
+    @ApiModelProperty(value = "准考证号", hidden = true)
+    private String ticketNumber;
+
 }

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

@@ -47,8 +47,8 @@ public class StudentApplyController extends BaseController {
 
     @ApiOperation(value = "获取考生预约结果列表(个人中心)")
     @PostMapping(value = "/apply/list")
-    public List<ApplyVO> list(@ApiParam("包含状态:多个值逗号分隔;不填时代表全部状态") @RequestParam(required = false) String includeStatus) {
-        return examReserveService.getStudentApplyList(curLoginStudent().getId(), includeStatus);
+    public List<ApplyVO> list(@ApiParam("是否已取消预约") @RequestParam(required = false) Boolean cancel) {
+        return examReserveService.getStudentApplyList(curLoginStudent().getId(), cancel);
     }
 
     @ApiOperation(value = "获取考生当前进行中的预约列表(首页)")

+ 7 - 4
src/main/java/com/qmth/exam/reserve/dao/StudentApplyDao.java

@@ -1,19 +1,22 @@
 package com.qmth.exam.reserve.dao;
 
-import java.util.List;
-
-import org.apache.ibatis.annotations.Param;
-
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.exam.reserve.bean.apply.ApplyVO;
 import com.qmth.exam.reserve.bean.stdapply.StudentApplyReq;
 import com.qmth.exam.reserve.bean.stdapply.StudentApplyVO;
 import com.qmth.exam.reserve.entity.StudentApplyEntity;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface StudentApplyDao extends BaseMapper<StudentApplyEntity> {
 
     IPage<StudentApplyVO> page(Page<StudentApplyVO> page, @Param(value = "req") StudentApplyReq req);
 
     Integer getHaveApplyCount(@Param(value = "examSiteIds") List<Long> examSiteIds);
+
+    List<ApplyVO> getStudentApplyList(@Param("studentId") Long studentId, @Param("cancel") Boolean cancel);
+
 }

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

@@ -13,7 +13,7 @@ public interface ExamReserveService {
 
     void cancelStudentApply(Long studentId, Long applyId);
 
-    List<ApplyVO> getStudentApplyList(Long studentId, String includeStatus);
+    List<ApplyVO> getStudentApplyList(Long studentId, Boolean cancel);
 
     List<ApplyVO> getStudentApplyListForCurrent(Long studentId);
 

+ 60 - 4
src/main/java/com/qmth/exam/reserve/service/impl/ExamReserveServiceImpl.java

@@ -1,15 +1,21 @@
 package com.qmth.exam.reserve.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.qmth.exam.reserve.bean.RichTextBean;
 import com.qmth.exam.reserve.bean.apply.ApplyTimePeriodResult;
 import com.qmth.exam.reserve.bean.apply.ApplyVO;
 import com.qmth.exam.reserve.bean.apply.TicketInfo;
+import com.qmth.exam.reserve.dao.StudentApplyDao;
+import com.qmth.exam.reserve.entity.StudentApplyEntity;
 import com.qmth.exam.reserve.service.ExamReserveService;
 import com.qmth.exam.reserve.service.StudentApplyService;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -22,23 +28,73 @@ public class ExamReserveServiceImpl implements ExamReserveService {
     private StudentApplyService studentApplyService;
 
     @Override
+    @Transactional
     public void saveStudentApply(Long studentId, Long examSiteId, Long timePeriodId) {
-
+        LambdaQueryWrapper<StudentApplyEntity> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(StudentApplyEntity::getStudentId, studentId);
+        wrapper.eq(StudentApplyEntity::getExamSiteId, examSiteId);
+        wrapper.eq(StudentApplyEntity::getTimePeriodId, timePeriodId);
+        StudentApplyEntity existEntity = studentApplyService.getOne(wrapper);
+        if (existEntity != null) {
+            if (existEntity.getCancel()) {
+                existEntity.setCancel(false);
+                existEntity.setOperateId(studentId);
+                existEntity.setUpdateTime(System.currentTimeMillis());
+                studentApplyService.updateById(existEntity);
+            }
+            return;
+        }
+
+        // todo
+        // 考前多少天,禁止考生自主预约(考前是指待预约时段的开始时间)
+        // 系统自动预约“任务执行期间”不允许预约
+
+        StudentApplyEntity entity = new StudentApplyEntity();
+        entity.setStudentId(studentId);
+        entity.setExamSiteId(examSiteId);
+        entity.setTimePeriodId(timePeriodId);
+        entity.setOperateId(studentId);
+        entity.setCancel(false);
+        studentApplyService.save(entity);
     }
 
     @Override
+    @Transactional
     public void cancelStudentApply(Long studentId, Long applyId) {
+        LambdaUpdateWrapper<StudentApplyEntity> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.set(StudentApplyEntity::getCancel, true);
+        updateWrapper.set(StudentApplyEntity::getOperateId, studentId);
+        updateWrapper.set(StudentApplyEntity::getUpdateTime, System.currentTimeMillis());
+        updateWrapper.eq(StudentApplyEntity::getId, applyId);
+        studentApplyService.update(updateWrapper);
+        // todo
+        // 考前多少天,禁止考生自主取消预约(考前是指已预约时段的开始时间)
+        // 系统自动预约“任务执行期间”不允许取消预约
 
     }
 
     @Override
-    public List<ApplyVO> getStudentApplyList(Long studentId, String includeStatus) {
-        return null;
+    public List<ApplyVO> getStudentApplyList(Long studentId, Boolean cancel) {
+        StudentApplyDao baseMapper = (StudentApplyDao) studentApplyService.getBaseMapper();
+        List<ApplyVO> list = baseMapper.getStudentApplyList(studentId, cancel);
+
+        for (ApplyVO vo : list) {
+            vo.setShowTicket(false);
+            vo.setAllowCancel(false);
+            if (StringUtils.isNotEmpty(vo.getTicketNumber())) {
+                vo.setShowTicket(true);
+            }
+            // todo
+        }
+
+        return list;
     }
 
     @Override
     public List<ApplyVO> getStudentApplyListForCurrent(Long studentId) {
-        return null;
+        List<ApplyVO> list = this.getStudentApplyList(studentId, null);
+        // todo
+        return list;
     }
 
     @Override

+ 60 - 43
src/main/resources/mapper/StudentApplyMapper.xml

@@ -1,47 +1,64 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.exam.reserve.dao.StudentApplyDao">
-	<select id="page"
-		resultType="com.qmth.exam.reserve.bean.stdapply.StudentApplyVO">
-		select a.id,s.name,s.identity_number
-		identityNumber,s.student_code
-		studentCode,o.name teachingName,es.name
-		agentName, p.start_time
-		startTime,p.end_time endTime,
-		r.name roomName, a.cancel,a.update_time
-		updateTime,u.name userName
-		from t_student s,t_category o,t_student_apply a
-		left join t_exam_site es on
-		es.id=a.exam_site_id
-		left join t_time_period
-		p on p.id=a.time_period_id
-		left join t_exam_room r on
-		r.id=a.exam_room_id
-		left join t_user u on u.id=a.user_id
-		where
-		a.student_id=s.id and s.category_id=o.id
-		<if test="req.teachingId != null">
-			and s.category_id=#{req.teachingId}
-		</if>
-		<if test="req.agentId != null">
-			and a.exam_site_id=#{req.agentId}
-		</if>
-		<if test="req.name != null and req.name !=''">
-			and s.name like concat('%',#{req.name},'%')
-		</if>
-		<if test="req.identityNumber != null and req.identityNumber !=''">
-			and s.identity_number=#{req.identityNumber}
-		</if>
-		<if test="req.studentCode != null and req.studentCode !=''">
-			and s.student_code=#{req.studentCode}
-		</if>
-		order by a.id
-	</select>
-	
-	<select id="getHaveApplyCount" resultType="int">
-		select count(sa.id) from t_student_apply sa, t_exam_site s where sa.exam_site_id=s.id and sa.cancel=1 and sa.exam_site_id in
-		<foreach collection="examSiteIds" item="item" index="index" separator="," open="(" close=")">
-			#{item}
-		</foreach>
-	</select>
+    <select id="page"
+            resultType="com.qmth.exam.reserve.bean.stdapply.StudentApplyVO">
+        select a.id,s.name,s.identity_number
+        identityNumber,s.student_code
+        studentCode,o.name teachingName,es.name
+        agentName, p.start_time
+        startTime,p.end_time endTime,
+        r.name roomName, a.cancel,a.update_time
+        updateTime,u.name userName
+        from t_student s,t_category o,t_student_apply a
+        left join t_exam_site es on
+        es.id=a.exam_site_id
+        left join t_time_period
+        p on p.id=a.time_period_id
+        left join t_exam_room r on
+        r.id=a.exam_room_id
+        left join t_user u on u.id=a.user_id
+        where
+        a.student_id=s.id and s.category_id=o.id
+        <if test="req.teachingId != null">
+            and s.category_id=#{req.teachingId}
+        </if>
+        <if test="req.agentId != null">
+            and a.exam_site_id=#{req.agentId}
+        </if>
+        <if test="req.name != null and req.name !=''">
+            and s.name like concat('%',#{req.name},'%')
+        </if>
+        <if test="req.identityNumber != null and req.identityNumber !=''">
+            and s.identity_number=#{req.identityNumber}
+        </if>
+        <if test="req.studentCode != null and req.studentCode !=''">
+            and s.student_code=#{req.studentCode}
+        </if>
+        order by a.id
+    </select>
+
+    <select id="getHaveApplyCount" resultType="int">
+        select count(sa.id) from t_student_apply sa, t_exam_site s where sa.exam_site_id=s.id and sa.cancel=1 and
+        sa.exam_site_id in
+        <foreach collection="examSiteIds" item="item" index="index" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="getStudentApplyList" resultType="com.qmth.exam.reserve.bean.apply.ApplyVO">
+        select sa.id applyId,sa.time_period_id,sa.exam_site_id,sa.cancel,sa.ticket_number,
+        tp.start_time timePeriodStart,tp.end_time timePeriodEnd,
+        es.name examSiteName,es.address examSiteAddress,
+        c.id categoryId,c.name categoryName
+        from t_student_apply sa
+        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
+        inner join t_category c on c.id=es.category_id
+        where sa.student_id = #{studentId}
+        <if test="cancel != null">
+            and sa.cancel = #{cancel}
+        </if>
+    </select>
+
 </mapper>