|
@@ -1,19 +1,28 @@
|
|
package com.qmth.themis.business.service.impl;
|
|
package com.qmth.themis.business.service.impl;
|
|
|
|
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.Objects;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.qmth.themis.business.bean.exam.ExamPrepareBean;
|
|
import com.qmth.themis.business.bean.exam.ExamPrepareBean;
|
|
|
|
+import com.qmth.themis.business.cache.RedisKeyHelper;
|
|
|
|
+import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
|
|
|
|
+import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
|
|
import com.qmth.themis.business.dao.TEExamMapper;
|
|
import com.qmth.themis.business.dao.TEExamMapper;
|
|
import com.qmth.themis.business.entity.TEExam;
|
|
import com.qmth.themis.business.entity.TEExam;
|
|
import com.qmth.themis.business.service.TEExamActivityService;
|
|
import com.qmth.themis.business.service.TEExamActivityService;
|
|
import com.qmth.themis.business.service.TEExamService;
|
|
import com.qmth.themis.business.service.TEExamService;
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
-
|
|
|
|
-import javax.annotation.Resource;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
+import com.qmth.themis.business.service.TEExamStudentService;
|
|
|
|
+import com.qmth.themis.business.util.RedisUtil;
|
|
|
|
+import com.qmth.themis.common.exception.BusinessException;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description: 考试批次 服务实现类
|
|
* @Description: 考试批次 服务实现类
|
|
@@ -29,8 +38,13 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
TEExamMapper teExamMapper;
|
|
TEExamMapper teExamMapper;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- TEExamActivityService examActivityService;
|
|
|
|
|
|
+ TEExamActivityService teExamActivityService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ TEExamStudentService teExamStudentService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ RedisUtil redisUtil;
|
|
/**
|
|
/**
|
|
* 查询考试批次
|
|
* 查询考试批次
|
|
*
|
|
*
|
|
@@ -59,7 +73,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
if (Objects.nonNull(list) && list.size() > 0) {
|
|
if (Objects.nonNull(list) && list.size() > 0) {
|
|
for (int i = 0; i < list.size(); i++) {
|
|
for (int i = 0; i < list.size(); i++) {
|
|
Map m = list.get(i);
|
|
Map m = list.get(i);
|
|
- List<Map> teExamActivityList = examActivityService.getWaitingExam(studentId, Long.parseLong(String.valueOf(m.get("id"))), Long.parseLong(String.valueOf(m.get("examActivityId"))));
|
|
|
|
|
|
+ List<Map> teExamActivityList = teExamActivityService.getWaitingExam(studentId, Long.parseLong(String.valueOf(m.get("id"))), Long.parseLong(String.valueOf(m.get("examActivityId"))));
|
|
m.put("activities", teExamActivityList);
|
|
m.put("activities", teExamActivityList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -68,8 +82,36 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
- public ExamPrepareBean prepare(Long studentId, Long activityId) {
|
|
|
|
- // TODO Auto-generated method stub
|
|
|
|
- return null;
|
|
|
|
|
|
+ public ExamPrepareBean prepare(Long studentId, Long examStudentId) {
|
|
|
|
+ ExamPrepareBean ret=null;
|
|
|
|
+ ExamStudentCacheBean es=null;
|
|
|
|
+ es=(ExamStudentCacheBean)redisUtil.get(RedisKeyHelper.examStudentCacheKey(examStudentId));
|
|
|
|
+ if(es==null) {
|
|
|
|
+ es=teExamStudentService.getExamStudnetCacheBean(examStudentId);
|
|
|
|
+ }
|
|
|
|
+ if(es==null) {
|
|
|
|
+ throw new BusinessException("未找到考试");
|
|
|
|
+ }
|
|
|
|
+ if(studentId.equals(es.getStudentId())) {
|
|
|
|
+ throw new BusinessException("考生Id和当前登录用户不一致");
|
|
|
|
+ }
|
|
|
|
+ if(es.getLeftExamCount()==0) {
|
|
|
|
+ throw new BusinessException("没有剩余考试次数");
|
|
|
|
+ }
|
|
|
|
+ Long activityId=es.getExamActivityId();
|
|
|
|
+ ExamActivityCacheBean ac=teExamActivityService.getExamActivityCacheBean(activityId);
|
|
|
|
+ if(ac==null) {
|
|
|
|
+ throw new BusinessException("未找到场次");
|
|
|
|
+ }
|
|
|
|
+ Date now=new Date();
|
|
|
|
+ Long start=ac.getStartTime().getTime()-(ac.getPrepareSeconds()*1000);
|
|
|
|
+ Long end=ac.getStartTime().getTime()+(ac.getOpeningSeconds()*1000);
|
|
|
|
+ if(now.getTime()<start) {
|
|
|
|
+ throw new BusinessException("没有到允许开考的时间");
|
|
|
|
+ }
|
|
|
|
+ if(now.getTime()>end) {
|
|
|
|
+ throw new BusinessException("允许开考的时间已结束");
|
|
|
|
+ }
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
}
|
|
}
|