소스 검색

update getApplyDateList

deason 8 달 전
부모
커밋
a85bb5c6a3

+ 26 - 0
src/main/java/com/qmth/exam/reserve/bean/apply/ExamSiteTimePeriodInfo.java

@@ -0,0 +1,26 @@
+package com.qmth.exam.reserve.bean.apply;
+
+import com.qmth.exam.reserve.bean.IModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class ExamSiteTimePeriodInfo implements IModel {
+
+    private static final long serialVersionUID = 8158455040867688700L;
+
+    @ApiModelProperty(value = "预约时段ID")
+    private Long timePeriodId;
+
+    @ApiModelProperty(value = "预约时段开始")
+    private Long startTime;
+
+    @ApiModelProperty(value = "预约时段结束")
+    private Long endTime;
+
+    @ApiModelProperty(value = "是否启用")
+    private Boolean enable;
+
+}

+ 6 - 0
src/main/java/com/qmth/exam/reserve/dao/TimePeriodExamSiteDao.java

@@ -1,8 +1,14 @@
 package com.qmth.exam.reserve.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qmth.exam.reserve.bean.apply.ExamSiteTimePeriodInfo;
 import com.qmth.exam.reserve.entity.TimePeriodExamSiteEntity;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface TimePeriodExamSiteDao extends BaseMapper<TimePeriodExamSiteEntity> {
 
+    List<ExamSiteTimePeriodInfo> allTimePeriods(@Param("applyTaskId") Long applyTaskId, @Param("examSiteId") Long examSiteId);
+
 }

+ 12 - 5
src/main/java/com/qmth/exam/reserve/service/impl/ExamReserveServiceImpl.java

@@ -15,6 +15,7 @@ import com.qmth.exam.reserve.cache.CacheConstants;
 import com.qmth.exam.reserve.cache.impl.ApplyTaskCacheService;
 import com.qmth.exam.reserve.cache.impl.ExamSiteCacheService;
 import com.qmth.exam.reserve.dao.StudentApplyDao;
+import com.qmth.exam.reserve.dao.TimePeriodExamSiteDao;
 import com.qmth.exam.reserve.entity.ApplyTaskEntity;
 import com.qmth.exam.reserve.entity.ExamSiteEntity;
 import com.qmth.exam.reserve.entity.StudentApplyEntity;
@@ -56,6 +57,9 @@ public class ExamReserveServiceImpl implements ExamReserveService {
     @Autowired
     private TimePeriodService timePeriodService;
 
+    @Autowired
+    private TimePeriodExamSiteService timePeriodExamSiteService;
+
     @Autowired
     private StudentApplyService studentApplyService;
 
@@ -499,10 +503,8 @@ public class ExamReserveServiceImpl implements ExamReserveService {
             return dateList;
         }
 
-        LambdaQueryWrapper<TimePeriodEntity> wrapper = new LambdaQueryWrapper<>();
-        wrapper.select(TimePeriodEntity::getStartTime);// 只查询startTime等字段
-        wrapper.eq(TimePeriodEntity::getApplyTaskId, curApplyTask.getTaskId());
-        List<TimePeriodEntity> timePeriods = timePeriodService.list(wrapper);
+        TimePeriodExamSiteDao baseMapper = (TimePeriodExamSiteDao) timePeriodExamSiteService.getBaseMapper();
+        List<ExamSiteTimePeriodInfo> timePeriods = baseMapper.allTimePeriods(curApplyTask.getTaskId(), examSiteId);
         if (CollectionUtils.isEmpty(timePeriods)) {
             return dateList;
         }
@@ -511,7 +513,12 @@ public class ExamReserveServiceImpl implements ExamReserveService {
         Date allowDate = DateUtil.changeDateAndTimeEnd(new Date(), curApplyTask.getAllowApplyDays());
         Set<String> dates = new HashSet<>();
         FastDateFormat fdf = FastDateFormat.getInstance("yyyyMMdd");
-        for (TimePeriodEntity timePeriod : timePeriods) {
+        for (ExamSiteTimePeriodInfo timePeriod : timePeriods) {
+            if (!timePeriod.getEnable()) {
+                // 跳过未启用的时段
+                continue;
+            }
+
             Date curDate = new Date(timePeriod.getStartTime());
             if (curDate.before(allowDate)) {
                 // 跳过过期时段,“当前时段开始时间”在“允许预约时间”之前,则禁止预约

+ 9 - 1
src/main/resources/mapper/TimePeriodExamSiteMapper.xml

@@ -2,6 +2,14 @@
 <!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.TimePeriodExamSiteDao">
 
-
+    <select id="allTimePeriods" resultType="com.qmth.exam.reserve.bean.apply.ExamSiteTimePeriodInfo">
+        select p.id                                        as time_period_id,
+               p.start_time,
+               p.end_time,
+               (case when pe.enable = 0 then 0 else 1 end) as enable
+        from t_time_period p
+                 left join t_time_period_exam_site pe on pe.time_period_id = p.id and pe.exam_site_id = #{examSiteId}
+        where p.apply_task_id = #{applyTaskId}
+    </select>
 
 </mapper>