|
|
@@ -42,6 +42,7 @@ import com.zhongzheng.modules.exam.service.IExamApplySiteTimeService;
|
|
|
import com.zhongzheng.modules.exam.vo.ExamApplySiteTimeTwoVo;
|
|
|
import com.zhongzheng.modules.exam.vo.ExamApplySiteVo;
|
|
|
import com.zhongzheng.modules.exam.vo.ExamApplyVo;
|
|
|
+import com.zhongzheng.modules.exam.vo.ExamSessionVo;
|
|
|
import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
|
@@ -75,12 +76,20 @@ import java.io.*;
|
|
|
import java.net.URL;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.time.ZonedDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.List;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.zip.ZipOutputStream;
|
|
|
|
|
|
+import static java.util.stream.Collectors.toCollection;
|
|
|
+import static java.util.stream.IntStream.rangeClosed;
|
|
|
+
|
|
|
/**
|
|
|
* 用户预约考试Service业务层处理
|
|
|
*
|
|
|
@@ -2093,6 +2102,45 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
|
return add.getSubscribeId();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<ExamSessionVo> getExamSession(Integer month) {
|
|
|
+ //根据月份筛选
|
|
|
+ String dateStr = String.format("20230%s",month); // 指定年月
|
|
|
+ LocalDate date = LocalDate.parse(dateStr + "01", DateTimeFormatter.BASIC_ISO_DATE);
|
|
|
+ LocalDate dateFirst = date.with(TemporalAdjusters.firstDayOfMonth()); // 指定年月的第一天
|
|
|
+ LocalDate dateEnd = date.with(TemporalAdjusters.lastDayOfMonth()); // 指定年月的最后一天
|
|
|
+ ZonedDateTime zonedDateTime1 = dateFirst.atStartOfDay(ZoneId.systemDefault());
|
|
|
+ Date date1 = Date.from(zonedDateTime1.toInstant());
|
|
|
+ ZonedDateTime zonedDateTime = dateEnd.atStartOfDay(ZoneId.systemDefault());
|
|
|
+ Date date2 = Date.from(zonedDateTime.toInstant());
|
|
|
+ Long startTime = date1.getTime()/1000;
|
|
|
+ Long endTime = (date2.getTime()/1000) + 86400;
|
|
|
+
|
|
|
+ List<ExamApplySiteTime> siteTimes = iExamApplySiteTimeService
|
|
|
+ .list(new LambdaQueryWrapper<ExamApplySiteTime>()
|
|
|
+ .ge(ExamApplySiteTime::getExamTime, startTime)
|
|
|
+ .le(ExamApplySiteTime::getExamTime, endTime));
|
|
|
+ if (CollectionUtils.isEmpty(siteTimes)){
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ return siteTimes.stream().map(item -> {
|
|
|
+ ExamSessionVo vo = new ExamSessionVo();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("MM月dd号");
|
|
|
+ String format = sdf.format(new Date(item.getExamTime() * 1000));
|
|
|
+ List<ExamApplySiteTimeTwoAddBo> siteTimeTwoAddBos = JSONArray.parseArray(item.getSiteTime(), ExamApplySiteTimeTwoAddBo.class);
|
|
|
+ ExamApplySiteTimeTwoAddBo twoAddBo = siteTimeTwoAddBos.get(0);
|
|
|
+ vo.setExamSession(String.format("%s(%s-%s)",format,twoAddBo.getStartTime(),twoAddBo.getEndTime()));
|
|
|
+ vo.setExamTime(item.getExamTime());
|
|
|
+ vo.setExamStartTime(twoAddBo.getStartTime());
|
|
|
+ vo.setExamEndTime(twoAddBo.getEndTime());
|
|
|
+
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private Integer getSeatNumber(UserSubscribeAddBo bo,Long userNum) {
|
|
|
List<UserSubscribe> list = list(new LambdaQueryWrapper<UserSubscribe>().eq(UserSubscribe::getApplyId, bo.getApplyId())
|
|
|
.eq(UserSubscribe::getApplySiteStartTime, bo.getApplySiteStartTime())
|
|
|
@@ -2108,20 +2156,22 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
|
if (list.stream().allMatch(x -> ObjectUtils.isNull(x.getSeatNumber()))){
|
|
|
return 1;
|
|
|
}
|
|
|
- Integer num = 0;
|
|
|
- randomNum(list,num);
|
|
|
- return num;
|
|
|
- }
|
|
|
|
|
|
- private void randomNum(List<UserSubscribe> list, Integer num) {
|
|
|
- Random random = new Random();
|
|
|
- Integer tNum = 1 + random.nextInt(50);
|
|
|
- if (list.stream().anyMatch(x -> Integer.parseInt(x.getSeatNumber()) == tNum)){
|
|
|
- randomNum(list,num);
|
|
|
+ List<Integer> nums = list.stream().map(x -> Integer.valueOf(x.getSeatNumber())).collect(Collectors.toList());
|
|
|
+ SortedSet<Integer> set = new TreeSet<Integer>(nums);
|
|
|
+ TreeSet<Integer> collect = rangeClosed(1, set.last()).boxed()
|
|
|
+ .filter(i -> !set.contains(i))
|
|
|
+ .collect(toCollection(TreeSet::new));
|
|
|
+ if (CollectionUtils.isNotEmpty(collect)){
|
|
|
+ Integer num = collect.stream().sorted(Comparator.comparing(o -> o)).findFirst().get();
|
|
|
+ return num;
|
|
|
}
|
|
|
- num = tNum;
|
|
|
+ Integer integer = nums.stream().max(Comparator.comparing(o -> o)).get();
|
|
|
+ return integer + 1;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
private String drawReport(String imageStr, UserSubscribeSignReportBo bo){
|
|
|
Font font = new Font("宋体", Font.BOLD, 48);// 添加字体的属性设置 微软雅黑
|
|
|
String imgName = null;
|