|
@@ -8,23 +8,25 @@ 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.bean.apply.TimePeriodInfo;
|
|
|
+import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
|
|
|
import com.qmth.exam.reserve.dao.StudentApplyDao;
|
|
|
import com.qmth.exam.reserve.entity.ApplyTaskEntity;
|
|
|
import com.qmth.exam.reserve.entity.ExamSiteEntity;
|
|
|
import com.qmth.exam.reserve.entity.StudentApplyEntity;
|
|
|
-import com.qmth.exam.reserve.service.ApplyTaskService;
|
|
|
-import com.qmth.exam.reserve.service.ExamReserveService;
|
|
|
-import com.qmth.exam.reserve.service.ExamSiteService;
|
|
|
-import com.qmth.exam.reserve.service.StudentApplyService;
|
|
|
+import com.qmth.exam.reserve.entity.TimePeriodEntity;
|
|
|
+import com.qmth.exam.reserve.service.*;
|
|
|
+import com.qmth.exam.reserve.util.DateUtil;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.commons.lang3.time.DateUtils;
|
|
|
+import org.apache.commons.lang3.time.FastDateFormat;
|
|
|
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.ArrayList;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class ExamReserveServiceImpl implements ExamReserveService {
|
|
@@ -37,6 +39,9 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
|
@Autowired
|
|
|
private ApplyTaskService applyTaskService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TimePeriodService timePeriodService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ExamSiteService examSiteService;
|
|
|
|
|
@@ -134,12 +139,44 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<String> getApplyDateList(Long studentId) {
|
|
|
+ public List<String> getApplyDateList() {
|
|
|
+ // 日期格式:yyyyMMdd
|
|
|
List<String> dateList = new ArrayList<>();
|
|
|
- dateList.add("20240410");
|
|
|
- dateList.add("20240411");
|
|
|
- dateList.add("20240412");
|
|
|
- // todo
|
|
|
+
|
|
|
+ // 获取当前启用的预约任务
|
|
|
+ CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask();
|
|
|
+ if (curApplyTask == null) {
|
|
|
+ return dateList;
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<TimePeriodEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.select(TimePeriodEntity::getStartTime);
|
|
|
+ wrapper.eq(TimePeriodEntity::getApplyTaskId, curApplyTask.getTaskId());
|
|
|
+ List<TimePeriodEntity> timePeriods = timePeriodService.list(wrapper);
|
|
|
+ if (CollectionUtils.isEmpty(timePeriods)) {
|
|
|
+ return dateList;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 考前N天,禁止考生自主预约
|
|
|
+ Date allowDate = DateUtil.changeDateAndBeginZeroTime(curApplyTask.getAllowApplyDays());
|
|
|
+ Set<String> dates = new HashSet<>();
|
|
|
+ FastDateFormat fdf = FastDateFormat.getInstance("yyyyMMdd");
|
|
|
+ for (TimePeriodEntity timePeriod : timePeriods) {
|
|
|
+ Date curDate = new Date(timePeriod.getStartTime());
|
|
|
+ if (allowDate.after(curDate)) {
|
|
|
+ // 跳过,不在允许的时间内的
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (DateUtils.isSameDay(allowDate, curDate)) {
|
|
|
+ // 跳过,同一天内的
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ dates.add(fdf.format(curDate));
|
|
|
+ }
|
|
|
+
|
|
|
+ dateList.addAll(dates);
|
|
|
+ Collections.sort(dateList);
|
|
|
return dateList;
|
|
|
}
|
|
|
|