|
@@ -3,13 +3,19 @@ package com.qmth.exam.reserve.service.impl;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
|
|
+import java.time.Instant;
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
+import java.time.ZoneId;
|
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.Calendar;
|
|
import java.util.Calendar;
|
|
|
|
+import java.util.Collections;
|
|
import java.util.Comparator;
|
|
import java.util.Comparator;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
|
|
+import java.util.LinkedHashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Map.Entry;
|
|
import java.util.Map.Entry;
|
|
@@ -40,6 +46,7 @@ import com.qmth.boot.tools.io.ZipWriter;
|
|
import com.qmth.exam.reserve.bean.login.LoginUser;
|
|
import com.qmth.exam.reserve.bean.login.LoginUser;
|
|
import com.qmth.exam.reserve.bean.stdapply.AgentAndTimeVO;
|
|
import com.qmth.exam.reserve.bean.stdapply.AgentAndTimeVO;
|
|
import com.qmth.exam.reserve.bean.stdapply.MaterialTitleInfo;
|
|
import com.qmth.exam.reserve.bean.stdapply.MaterialTitleInfo;
|
|
|
|
+import com.qmth.exam.reserve.bean.stdapply.SignInVO;
|
|
import com.qmth.exam.reserve.bean.stdapply.StudentApplyReq;
|
|
import com.qmth.exam.reserve.bean.stdapply.StudentApplyReq;
|
|
import com.qmth.exam.reserve.bean.stdapply.StudentApplyVO;
|
|
import com.qmth.exam.reserve.bean.stdapply.StudentApplyVO;
|
|
import com.qmth.exam.reserve.bean.stdapply.StudentImportVO;
|
|
import com.qmth.exam.reserve.bean.stdapply.StudentImportVO;
|
|
@@ -554,11 +561,12 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
if (studentApplyLock.tryLock()) {
|
|
if (studentApplyLock.tryLock()) {
|
|
baseMapper.insert(studentApply);
|
|
baseMapper.insert(studentApply);
|
|
insertApplyList.add(studentApply);
|
|
insertApplyList.add(studentApply);
|
|
|
|
+ studentApplyLock.unlock();
|
|
} else {
|
|
} else {
|
|
log.warn("获取锁失败,不允许同一个考生同时操作预约!lockKey:{}", studentApplyLockKey);
|
|
log.warn("获取锁失败,不允许同一个考生同时操作预约!lockKey:{}", studentApplyLockKey);
|
|
}
|
|
}
|
|
num++;
|
|
num++;
|
|
- if (toApplyNum - (studentApplyList.size() + 1) == 0) {
|
|
|
|
|
|
+ if (student.getApplyNumber() - (studentApplyList.size() + 1) == 0) {
|
|
iterator.remove();
|
|
iterator.remove();
|
|
student.setApplyFinished(true);
|
|
student.setApplyFinished(true);
|
|
this.studentService.updateById(student);
|
|
this.studentService.updateById(student);
|
|
@@ -846,4 +854,53 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
return value != null ? value : 0;
|
|
return value != null ? value : 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<SignInVO> listSignInDate(Long taskId) {
|
|
|
|
+ List<SignInVO> signInList = new ArrayList<>();
|
|
|
|
+ ApplyTaskEntity task = null;
|
|
|
|
+ if (taskId == null) {
|
|
|
|
+ task = applyTaskService.getById(taskId);
|
|
|
|
+ } else {
|
|
|
|
+ task = getApplyTask();
|
|
|
|
+ }
|
|
|
|
+ List<TimePeriodEntity> timePeriodList = listTimePeroid(task.getId());
|
|
|
|
+ if (timePeriodList.isEmpty()) {
|
|
|
|
+ throw new StatusException("未配置考试时段");
|
|
|
|
+ }
|
|
|
|
+ TimePeriodEntity time = timePeriodList.get(0);
|
|
|
|
+ List<TimePeriodEntity> noCancelTimePeroidList = listNoCancelApplyTimePeroid(timePeriodList,
|
|
|
|
+ task.getAllowApplyCancelDays());
|
|
|
|
+ if (noCancelTimePeroidList.isEmpty()) {
|
|
|
|
+ throw new StatusException("未到可以取消预约的时间");
|
|
|
|
+ }
|
|
|
|
+ LinkedHashMap<LocalDate, LocalDate> map = groupTimestampsByDay(noCancelTimePeroidList);
|
|
|
|
+ long between = ChronoUnit.DAYS.between(LocalDate.now(), map.entrySet().iterator().next().getKey());
|
|
|
|
+ for (long i = 0; i < between; i++) {
|
|
|
|
+ LocalDate day = LocalDate.now().plusDays(i);
|
|
|
|
+ long epochMilli = day.plusDays(1).atStartOfDay(ZoneId.systemDefault()).minusSeconds(1).toInstant()
|
|
|
|
+ .toEpochMilli();
|
|
|
|
+ // 判断是否在考试时段内
|
|
|
|
+ if (epochMilli >= time.getStartTime()) {
|
|
|
|
+ map.put(day, day);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (Entry<LocalDate, LocalDate> entry : map.entrySet()) {
|
|
|
|
+ SignInVO signIn = new SignInVO();
|
|
|
|
+ signIn.setExamDate(entry.getKey().atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli());
|
|
|
|
+ signInList.add(signIn);
|
|
|
|
+ }
|
|
|
|
+ Collections.sort(signInList, Comparator.comparing(SignInVO::getExamDate));
|
|
|
|
+ return signInList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private LinkedHashMap<LocalDate, LocalDate> groupTimestampsByDay(List<TimePeriodEntity> timeList) {
|
|
|
|
+ LinkedHashMap<LocalDate, LocalDate> map = new LinkedHashMap<>();
|
|
|
|
+ for (TimePeriodEntity time : timeList) {
|
|
|
|
+ Instant instant = Instant.ofEpochMilli(time.getStartTime());
|
|
|
|
+ LocalDate date = instant.atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
|
+ map.putIfAbsent(date, date);
|
|
|
|
+ }
|
|
|
|
+ return map;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|