xiatian 5 жил өмнө
parent
commit
db412ac4a1

+ 1 - 1
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/ExamingSessionService.java

@@ -12,7 +12,7 @@ public interface ExamingSessionService {
      * 保存
      * @param timeout   秒
      */
-    public void saveExamingSession(Long studentId,ExamingSession examingSession,int timeout);
+    public void saveExamingSession(Long studentId,ExamingSession examingSession);
 
     /**
      * 获取

+ 91 - 68
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamControlServiceImpl.java

@@ -51,6 +51,7 @@ import cn.com.qmth.examcloud.support.cache.bean.ExtractConfigPaperCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.SysPropertyCacheBean;
 import cn.com.qmth.examcloud.support.examing.ExamingSession;
 import cn.com.qmth.examcloud.support.examing.ExamingStatus;
+import cn.com.qmth.examcloud.support.helper.FaceBiopsyHelper;
 
 /**
  * @author chenken
@@ -141,31 +142,30 @@ public class ExamControlServiceImpl implements ExamControlService {
         // 如果开启人脸比对,将同步人脸比对结果存储到抓后结果表中
         Long rootOrgId = examRecordData.getRootOrgId();
         Long examId = examRecordData.getExamId();
-        // TODO
-        // if (FaceBiopsyHelper.isFaceEnable(rootOrgId, examId, studentId)) {
-        // SaveExamCaptureSyncCompareResultReq req = new
-        // SaveExamCaptureSyncCompareResultReq();
-        // req.setExamRecordDataId(examRecordData.getId());
-        // req.setStudentId(user.getUserId());
-        // examCaptureCloudService.saveExamCaptureSyncCompareResult(req);
-        // }
+        //TODO
+//        if (FaceBiopsyHelper.isFaceEnable(rootOrgId, examId, studentId)) {
+//            SaveExamCaptureSyncCompareResultReq req = new SaveExamCaptureSyncCompareResultReq();
+//            req.setExamRecordDataId(examRecordData.getId());
+//            req.setStudentId(user.getUserId());
+//            examCaptureCloudService.saveExamCaptureSyncCompareResult(req);
+//        }
 
         if (log.isDebugEnabled()) {
-            log.debug("8 生成考试记录耗时:" + (System.currentTimeMillis() - startTime) + " ms");
+            log.debug("4 生成考试记录耗时:" + (System.currentTimeMillis() - startTime) + " ms");
         }
 
         // 生成试卷结构
         ExtractConfigPaperCacheBean extractConfigPaper = CacheHelper.getExtractConfigPaper(examingSession.getExamId(),
                 courseBean.getCode(), examingSession.getPaperType(), paperId);
         if (log.isDebugEnabled()) {
-            log.debug("4 获取题库试卷结构耗时:" + (System.currentTimeMillis() - startTime) + " ms");
+            log.debug("5 获取题库试卷结构耗时:" + (System.currentTimeMillis() - startTime) + " ms");
         }
 
         // 小题乱序,选项乱序
         startTime = System.currentTimeMillis();
         reorderPaperStruct(extractConfig, extractConfigPaper);
         if (log.isDebugEnabled()) {
-            log.debug("5 小题乱序耗时:" + (System.currentTimeMillis() - startTime) + " ms");
+            log.debug("6 小题乱序耗时:" + (System.currentTimeMillis() - startTime) + " ms");
         }
 
         // 保存考试试卷结构
@@ -173,7 +173,7 @@ public class ExamControlServiceImpl implements ExamControlService {
         examRecordPaperStructService.saveExamRecordPaperStruct(examRecordData.getId(),
                 extractConfigPaper.getDefaultPaper());
         if (log.isDebugEnabled()) {
-            log.debug("6 保存考试试卷结构耗时:" + (System.currentTimeMillis() - startTime) + " ms");
+            log.debug("7 保存考试试卷结构耗时:" + (System.currentTimeMillis() - startTime) + " ms");
         }
 
         // 创建考试作答记录
@@ -181,28 +181,24 @@ public class ExamControlServiceImpl implements ExamControlService {
         examRecordQuestionsService.createExamRecordQuestions(examRecordData.getId(),
                 extractConfigPaper.getDefaultPaper());
         if (log.isDebugEnabled()) {
-            log.debug("9 创建考试作答记录耗时:" + (System.currentTimeMillis() - startTime) + " ms");
+            log.debug("8 创建考试作答记录耗时:" + (System.currentTimeMillis() - startTime) + " ms");
         }
 
-        // 创建考试会话
+        // 初始化考试会话
         startTime = System.currentTimeMillis();
-        // TODO
-        // initializeExamRecordSession(originalExamStudent, examRecordData,
-        // examBean);
+        initializeExamRecordSession(examingSession, examRecordData, examBean);
         if (log.isDebugEnabled()) {
-            log.debug("11 创建考试会话耗时:" + (System.currentTimeMillis() - startTime) + " ms");
+            log.debug("9 初始化考试会话耗时:" + (System.currentTimeMillis() - startTime) + " ms");
         }
 
         if (log.isDebugEnabled()) {
-            log.debug("12 合计 耗时:" + (System.currentTimeMillis() - st) + " ms");
+            log.debug("10 合计 耗时:" + (System.currentTimeMillis() - st) + " ms");
         }
         // 在线考生开考打点
         ReportsUtil.report(
                 new OnlineExamStudentReport(user.getRootOrgId(), user.getUserId(), examBean.getId(), examStudentId));
-        // TODO
-        // return buildStartExamInfo(examRecordData.getId(),
-        // originalExamStudent, examBean, courseBean);
-        return null;
+        StartExamInfo startExamInfo = buildStartExamInfo(examRecordData.getId(), examingSession, examBean, courseBean);
+        return startExamInfo;
 
     }
 
@@ -407,20 +403,17 @@ public class ExamControlServiceImpl implements ExamControlService {
         }
         return false;
     }
-    // TODO
-
-    // private StartExamInfo buildStartExamInfo(Long examRecordDataId,
-    // ExamingSession examingSession, ExamBean examBean,
-    // CourseBean courseBean) {
-    // StartExamInfo startExamInfo = new StartExamInfo();
-    // startExamInfo.setExamRecordDataId(examRecordDataId);
-    // startExamInfo.setCourseName(courseBean.getName());
-    // startExamInfo.setDuration(examBean.getDuration());
-    // startExamInfo.setFaceVerifyMinute(getFaceVerifyMinute(examingSession.getRootOrgId(),
-    // examBean.getId(),
-    // examingSession.getOrgId(), examingSession.getStudentId()));
-    // return startExamInfo;
-    // }
+
+    private StartExamInfo buildStartExamInfo(Long examRecordDataId, ExamingSession examingSession, ExamBean examBean,
+            CourseBean courseBean) {
+        StartExamInfo startExamInfo = new StartExamInfo();
+        startExamInfo.setExamRecordDataId(examRecordDataId);
+        startExamInfo.setCourseName(courseBean.getName());
+        startExamInfo.setDuration(examBean.getDuration());
+        startExamInfo.setFaceVerifyMinute(getFaceVerifyMinute(examingSession.getRootOrgId(), examBean.getId(),
+                examingSession.getOrgId(), examingSession.getStudentId()));
+        return startExamInfo;
+    }
 
     /**
      * 确定活体检测开始分钟数
@@ -428,35 +421,65 @@ public class ExamControlServiceImpl implements ExamControlService {
      * @param examId
      * @return
      */
-    // TODO
-    // private Integer getFaceVerifyMinute(Long rootOrgId, Long examId, Long
-    // orgId, Long studentId) {
-    // // 如果开启了活体检测
-    // if (FaceBiopsyHelper.isFaceVerify(rootOrgId, examId, studentId)) {
-    // // 开始分钟数
-    // String startMinuteStr = ExamCacheTransferHelper
-    // .getCachedExamProperty(examId, studentId,
-    // ExamProperties.FACE_VERIFY_START_MINUTE.name()).getValue();
-    // if (CommonUtil.isBlank(startMinuteStr)) {
-    // throw new
-    // StatusException("ExamControlServiceImpl-getFaceVerifyMinute-001",
-    // ExamProperties.FACE_VERIFY_START_MINUTE.getDesc() + "未设置");
-    // }
-    // Integer faceVerifyStartMinute = Integer.valueOf(startMinuteStr);
-    //
-    // // 结束分钟数
-    // String endMinuteStr = ExamCacheTransferHelper
-    // .getCachedExamProperty(examId, studentId,
-    // ExamProperties.FACE_VERIFY_END_MINUTE.name()).getValue();
-    // if (CommonUtil.isBlank(endMinuteStr)) {
-    // throw new
-    // StatusException("ExamControlServiceImpl-getFaceVerifyMinute-002",
-    // ExamProperties.FACE_VERIFY_END_MINUTE.getDesc() + "未设置");
-    // }
-    // Integer faceVerifyEndMinute = Integer.valueOf(endMinuteStr);
-    // return CommonUtil.calculationRandomNumber(faceVerifyStartMinute,
-    // faceVerifyEndMinute);
-    // }
-    // return null;
-    // }
+    private Integer getFaceVerifyMinute(Long rootOrgId, Long examId, Long orgId, Long studentId) {
+        // 如果开启了活体检测
+        if (FaceBiopsyHelper.isFaceVerify(rootOrgId, examId, studentId)) {
+            // 开始分钟数
+            String startMinuteStr = ExamCacheTransferHelper
+                    .getCachedExamProperty(examId, studentId, ExamProperties.FACE_VERIFY_START_MINUTE.name())
+                    .getValue();
+            if (CommonUtil.isBlank(startMinuteStr)) {
+                throw new StatusException("5001",
+                        ExamProperties.FACE_VERIFY_START_MINUTE.getDesc() + "未设置");
+            }
+            Integer faceVerifyStartMinute = Integer.valueOf(startMinuteStr);
+
+            // 结束分钟数
+            String endMinuteStr = ExamCacheTransferHelper
+                    .getCachedExamProperty(examId, studentId, ExamProperties.FACE_VERIFY_END_MINUTE.name()).getValue();
+            if (CommonUtil.isBlank(endMinuteStr)) {
+                throw new StatusException("5002",
+                        ExamProperties.FACE_VERIFY_END_MINUTE.getDesc() + "未设置");
+            }
+            Integer faceVerifyEndMinute = Integer.valueOf(endMinuteStr);
+            return CommonUtil.calculationRandomNumber(faceVerifyStartMinute, faceVerifyEndMinute);
+        }
+        return null;
+    }
+
+    /**
+     * 初始化考试会话
+     *
+     * @param examRecordData
+     * @param examBean
+     */
+    public void initializeExamRecordSession(ExamingSession examSessionInfo, ExamRecordDataEntity examRecordData,
+            final ExamBean examBean) {
+        examSessionInfo.setExamRecordDataId(examRecordData.getId());
+        examSessionInfo.setStartTime(examRecordData.getStartTime().getTime());
+        examSessionInfo.setExamType(examBean.getExamType());
+        examSessionInfo.setExamId(examBean.getId());
+        // EXAM_RECONNECT_TIME:断点续考时间
+        String examReconnectTimeStr = ExamCacheTransferHelper.getCachedExamProperty(examBean.getId(),
+                examSessionInfo.getStudentId(), ExamProperties.EXAM_RECONNECT_TIME.name()).getValue();
+        log.debug("11.2 断点时间:" + examReconnectTimeStr);
+        if (CommonUtil.isBlank(examReconnectTimeStr)) {
+            throw new StatusException("6001",
+                    ExamProperties.EXAM_RECONNECT_TIME.getDesc() + "未设置");
+        }
+        examSessionInfo.setExamReconnectTime(Integer.valueOf(examReconnectTimeStr));
+        // FREEZE_TIME:冻结时间
+        String freezeTimeStr = ExamCacheTransferHelper.getCachedExamProperty(examBean.getId(),
+                examSessionInfo.getStudentId(), ExamProperties.FREEZE_TIME.name()).getValue();
+        log.debug("11.3 冻结时间:" + freezeTimeStr);
+        if (CommonUtil.isBlank(freezeTimeStr)) {
+            throw new StatusException("6002",
+                    ExamProperties.FREEZE_TIME.getDesc() + "未设置");
+        }
+        examSessionInfo.setFreezeTime(Integer.valueOf(freezeTimeStr));
+        examSessionInfo.setExamingStatus(ExamingStatus.FORMAL);
+        log.debug("11.4 开始保存考试会话...studentId=" + examSessionInfo.getStudentId());
+        examingSessionService.saveExamingSession(examSessionInfo.getStudentId(), examSessionInfo);
+        log.debug("11.5 保存考试会话结束 ");
+    }
 }

+ 2 - 0
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamRecordDataServiceImpl.java

@@ -9,6 +9,7 @@ import org.springframework.transaction.annotation.Transactional;
 import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
 import cn.com.qmth.examcloud.core.oe.student.dao.ExamRecordDataRepo;
 import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamRecordDataEntity;
+import cn.com.qmth.examcloud.core.oe.student.dao.enums.ExamRecordStatus;
 import cn.com.qmth.examcloud.core.oe.student.dao.enums.ExamType;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordDataService;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
@@ -51,6 +52,7 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
         examRecordData.setFaceTotalCount(0);
         examRecordData.setFaceFailedCount(0);
         examRecordData.setFaceStrangerCount(0);
+        examRecordData.setExamRecordStatus(ExamRecordStatus.EXAM_ING);
         return examRecordDataRepo.save(examRecordData);
     }
 

+ 6 - 12
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamingSessionServiceImpl.java

@@ -1,14 +1,13 @@
 package cn.com.qmth.examcloud.core.oe.student.service.impl;
 
-import cn.com.qmth.examcloud.core.oe.student.service.ExamingSessionService;
-import cn.com.qmth.examcloud.support.examing.ExamingSession;
-import cn.com.qmth.examcloud.web.redis.RedisClient;
-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 cn.com.qmth.examcloud.core.oe.student.service.ExamingSessionService;
+import cn.com.qmth.examcloud.support.examing.ExamingSession;
+import cn.com.qmth.examcloud.web.redis.RedisClient;
+
 /**
  * @author chenken
  * @date 2018/8/15 9:24
@@ -24,14 +23,9 @@ public class ExamingSessionServiceImpl implements ExamingSessionService {
     @Value("${exam_redis_key_prefix}")
     private String examRedisKeyPrefix;
 
-    private static final Logger log = LoggerFactory.getLogger(ExamControlServiceImpl.class);
-
     @Override
-    public void saveExamingSession(Long studentId, ExamingSession examingSession, int timeout) {
-        log.debug("11.4.1 进入开始保存考试会话方法,redisKey="+examRedisKeyPrefix+studentId);
-        redisClient.set(examRedisKeyPrefix+studentId,examingSession,timeout);
-        ExamingSession sessionInfo =redisClient.get(examRedisKeyPrefix+studentId,ExamingSession.class);
-        log.debug("11.4.2 保存考试会话方法完成"+sessionInfo.getExamStudentId());
+    public void saveExamingSession(Long studentId, ExamingSession examingSession) {
+        redisClient.set(examRedisKeyPrefix+studentId,examingSession);
     }
 
     @Override