|
@@ -32,8 +32,13 @@ import com.zhongzheng.modules.course.mapper.CourseMapper;
|
|
|
import com.zhongzheng.modules.course.service.IMajorService;
|
|
|
import com.zhongzheng.modules.exam.bo.ExamApplyQueryBo;
|
|
|
import com.zhongzheng.modules.exam.bo.ExamApplySiteTimeJson;
|
|
|
+import com.zhongzheng.modules.exam.bo.ExamApplySiteTimeTwoAddBo;
|
|
|
+import com.zhongzheng.modules.exam.domain.ExamApplySite;
|
|
|
+import com.zhongzheng.modules.exam.domain.ExamApplySiteTime;
|
|
|
import com.zhongzheng.modules.exam.mapper.ExamApplyMapper;
|
|
|
+import com.zhongzheng.modules.exam.service.IExamApplyService;
|
|
|
import com.zhongzheng.modules.exam.service.IExamApplySiteService;
|
|
|
+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;
|
|
@@ -112,6 +117,12 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
|
@Autowired
|
|
|
private IExamApplySiteService iExamApplySiteService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IExamApplyService iExamApplyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IExamApplySiteTimeService iExamApplySiteTimeService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IMajorService majorService;
|
|
|
|
|
@@ -2000,6 +2011,36 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
|
if (System.currentTimeMillis()/1000 > time){
|
|
|
throw new CustomException("当前选择的考试时间已过期,请重新预约,选择未过期考试时间");
|
|
|
}
|
|
|
+ //生成座位号
|
|
|
+ ExamApplySite applySite = iExamApplySiteService.getOne(new LambdaQueryWrapper<ExamApplySite>()
|
|
|
+ .eq(ExamApplySite::getApplyId, bo.getApplyId())
|
|
|
+ .eq(ExamApplySite::getSiteId, bo.getSiteId())
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNull(applySite)){
|
|
|
+ throw new CustomException("考试地点查询有误,请检查");
|
|
|
+ }
|
|
|
+ List<ExamApplySiteTime> siteTimeList = iExamApplySiteTimeService.list(new LambdaQueryWrapper<ExamApplySiteTime>()
|
|
|
+ .eq(ExamApplySiteTime::getApplyId, bo.getApplyId())
|
|
|
+ .eq(ExamApplySiteTime::getApplySiteId, applySite.getId())
|
|
|
+ .eq(ExamApplySiteTime::getExamTime, bo.getApplySiteExamTime()));
|
|
|
+ if (CollectionUtils.isEmpty(siteTimeList)){
|
|
|
+ throw new CustomException("考试时间查询有误,请检查");
|
|
|
+ }
|
|
|
+ ExamApplySiteTime examApplySiteTime = siteTimeList.stream().filter(item -> {
|
|
|
+ List<ExamApplySiteTimeTwoAddBo> siteTimeTwoAddBos = JSONArray.parseArray(item.getSiteTime(), ExamApplySiteTimeTwoAddBo.class);
|
|
|
+ ExamApplySiteTimeTwoAddBo twoAddBo = siteTimeTwoAddBos.get(0);
|
|
|
+ return twoAddBo.getStartTime().equals(bo.getApplySiteStartTime()) && twoAddBo.getEndTime().equals(bo.getApplySiteEndTime());
|
|
|
+ }).findFirst().orElse(null);
|
|
|
+ if (ObjectUtils.isNull(examApplySiteTime)){
|
|
|
+ throw new CustomException("预约考试时间不存在,请重新选择");
|
|
|
+ }
|
|
|
+ //考场人数
|
|
|
+ List<ExamApplySiteTimeTwoAddBo> siteTimeTwoAddBos = JSONArray.parseArray(examApplySiteTime.getSiteTime(), ExamApplySiteTimeTwoAddBo.class);
|
|
|
+ Long userNum = siteTimeTwoAddBos.get(0).getNum();
|
|
|
+
|
|
|
+ //生成座位号
|
|
|
+ Integer tNum = getSeatNumber(bo,userNum);
|
|
|
+ add.setSeatNumber(tNum.toString());
|
|
|
//要求非必填考点
|
|
|
if(Validator.isNotEmpty(bo.getApplySiteAddress())){
|
|
|
ExamApplyQueryBo queryTimeBo = new ExamApplyQueryBo();
|
|
@@ -2052,6 +2093,35 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
|
return add.getSubscribeId();
|
|
|
}
|
|
|
|
|
|
+ private Integer getSeatNumber(UserSubscribeAddBo bo,Long userNum) {
|
|
|
+ List<UserSubscribe> list = list(new LambdaQueryWrapper<UserSubscribe>().eq(UserSubscribe::getApplyId, bo.getApplyId())
|
|
|
+ .eq(UserSubscribe::getApplySiteStartTime, bo.getApplySiteStartTime())
|
|
|
+ .eq(UserSubscribe::getApplySiteEndTime, bo.getApplySiteEndTime())
|
|
|
+ .eq(UserSubscribe::getSubscribeStatus, 1)
|
|
|
+ .eq(UserSubscribe::getSiteId, bo.getSiteId()));
|
|
|
+ if (CollectionUtils.isEmpty(list)){
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ if (list.size() >= userNum){
|
|
|
+ throw new CustomException("本场考试已预约满,请选择其他场次!");
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ num = tNum;
|
|
|
+ }
|
|
|
+
|
|
|
private String drawReport(String imageStr, UserSubscribeSignReportBo bo){
|
|
|
Font font = new Font("宋体", Font.BOLD, 48);// 添加字体的属性设置 微软雅黑
|
|
|
String imgName = null;
|