|
@@ -12,6 +12,7 @@ import cn.com.qmth.examcloud.core.oe.student.base.bean.ExamRecordQuestions;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.base.utils.CommonUtil;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.base.utils.QuestionTypeUtil;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.bean.*;
|
|
|
+import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamRecordDataEntity;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.service.*;
|
|
|
import cn.com.qmth.examcloud.core.oe.task.api.ExamCaptureCloudService;
|
|
|
import cn.com.qmth.examcloud.core.oe.task.api.request.SaveExamCaptureSyncCompareResultReq;
|
|
@@ -41,6 +42,7 @@ import cn.com.qmth.examcloud.support.helper.ExamCacheTransferHelper;
|
|
|
import cn.com.qmth.examcloud.support.helper.FaceBiopsyHelper;
|
|
|
import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
|
|
|
import cn.com.qmth.examcloud.web.exception.SequenceLockException;
|
|
|
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
import cn.com.qmth.examcloud.web.helpers.SequenceLockHelper;
|
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
import cn.com.qmth.examcloud.ws.api.WsCloudService;
|
|
@@ -60,9 +62,12 @@ import org.apache.commons.lang3.time.DateUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -351,13 +356,12 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
throw new StatusException("100005", "无效的二维码");
|
|
|
}
|
|
|
|
|
|
- ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(Long.valueOf(examRecordDataId));
|
|
|
- // 判断考生是否存在
|
|
|
- if (!examRecordData.getExamStudentId().equals(Long.valueOf(examStudentId))) {
|
|
|
+ ExamStudentCacheBean examStudent = CacheHelper.getExamStudent(Long.valueOf(examStudentId));
|
|
|
+ if (examStudent == null) {
|
|
|
throw new StatusException("100012", "考生不存在");
|
|
|
}
|
|
|
|
|
|
- ExamingSession examSessionInfo = examingSessionService.getExamingSession(examRecordData.getStudentId());
|
|
|
+ ExamingSession examSessionInfo = examingSessionService.getExamingSession(examStudent.getStudentId());
|
|
|
String clientId;
|
|
|
String userId = key.substring(key.lastIndexOf("_") + 1);
|
|
|
|
|
@@ -389,7 +393,7 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
throw new StatusException("100007", "登录信息已失效");
|
|
|
}
|
|
|
res.setToken(user.getToken());
|
|
|
- CourseCacheBean courseBean = ExamCacheTransferHelper.getCachedCourse(examRecordData.getCourseId());
|
|
|
+ CourseCacheBean courseBean = ExamCacheTransferHelper.getCachedCourse(examStudent.getCourseId());
|
|
|
|
|
|
res.setCourseId(courseBean.getId());
|
|
|
res.setCourseName(courseBean.getName());
|
|
@@ -413,6 +417,7 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
res.setQuestionMainNumber(eqe.getMainNumber());
|
|
|
res.setSubNumber(getSubNumber(examRecordQuestions, Integer.valueOf(order)));
|
|
|
try {
|
|
|
+ ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(Long.valueOf(examRecordDataId));
|
|
|
this.sendScanQrCodeToWebSocket(clientId, Long.valueOf(examRecordDataId), Integer.valueOf(order),
|
|
|
Long.valueOf(userId), examRecordData.getRootOrgId());
|
|
|
} catch (Exception e) {
|
|
@@ -542,6 +547,66 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
return u;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取二维码
|
|
|
+ *
|
|
|
+ * @param req
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String getQrCode(GetQrCodeReq req, User user) {
|
|
|
+ if (user == null) {
|
|
|
+ throw new StatusException("100002", "登录信息错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果是调用环境监测的接口,不用做如下校验
|
|
|
+ if (!req.isTestEnv()) {
|
|
|
+ ExamingSession examSessionInfo = examingSessionService.getExamingSession(user.getUserId());
|
|
|
+
|
|
|
+ ExamStudentCacheBean examStudent = CacheHelper.getExamStudent(req.getExamStudentId());
|
|
|
+ if (examStudent == null) {
|
|
|
+ throw new StatusException("100012", "考生不存在");
|
|
|
+ }
|
|
|
+ if (!user.getUserId().equals(examStudent.getStudentId())) {
|
|
|
+ throw new StatusException("100013", "无效的请求");
|
|
|
+ }
|
|
|
+ if (examSessionInfo == null) {
|
|
|
+ throw new StatusException("100006", "考试已结束");
|
|
|
+ }
|
|
|
+ if (examSessionInfo.getExamRecordDataId().longValue() != req.getExamRecordDataId().longValue()
|
|
|
+ || examSessionInfo.getExamStudentId().longValue() != req.getExamStudentId().longValue()) {
|
|
|
+ throw new StatusException("100008", "无效的请求");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 环境检测时,需要重新给考生id赋值
|
|
|
+ ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(req.getExamRecordDataId());
|
|
|
+ req.setExamStudentId(examRecordData.getExamStudentId());
|
|
|
+ }
|
|
|
+ String key = user.getKey();
|
|
|
+ StringBuffer param = new StringBuffer();
|
|
|
+ String transferFileType = StringUtils.isBlank(req.getTransferFileType()) ? "" : req.getTransferFileType();
|
|
|
+ param.append("examStudentId=").append(req.getExamStudentId()).append("&examRecordDataId=")
|
|
|
+ .append(req.getExamRecordDataId()).append("&order=").append(req.getOrder()).append("&transferFileType=")
|
|
|
+ .append(transferFileType).append("&key=").append(key);
|
|
|
+ // 需要签名的参数
|
|
|
+ StringBuffer sourStr = new StringBuffer();
|
|
|
+ sourStr.append(req.getOrder()).append(UNDERLINE).append(req.getExamRecordDataId()).append(UNDERLINE).append(key)
|
|
|
+ .append(UNDERLINE).append(req.getExamStudentId());
|
|
|
+ // 签名
|
|
|
+ byte[] bytes = SHA256.encode(sourStr.toString());
|
|
|
+ String hexAscii = ByteUtil.toHexAscii(bytes);
|
|
|
+ param.append("&token=").append(hexAscii);
|
|
|
+ String qrStr;
|
|
|
+ try {
|
|
|
+ String audioAppUrl = PropertyHolder.getString("audio.app.url");
|
|
|
+ qrStr = audioAppUrl + SEPARATOR + URLEncoder.encode(param.toString(), "UTF-8");
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ throw new StatusException("100001", "参数编码异常");
|
|
|
+ }
|
|
|
+ return qrStr;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param bucketName //不能为空
|
|
|
* @param expiration //不能为空
|