瀏覽代碼

重构考试记录和考试记录属性的相关引用代码

lideyin 5 年之前
父節點
當前提交
a2650b102f
共有 12 個文件被更改,包括 158 次插入325 次删除
  1. 4 3
      examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/controller/ExamControlController.java
  2. 5 3
      examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/controller/FaceBiopsyController.java
  3. 4 2
      examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/controller/OfflineExamController.java
  4. 0 100
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/ExamCacheTransferHelper.java
  5. 1 1
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/ExamFaceLivenessVerifyService.java
  6. 69 144
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamControlServiceImpl.java
  7. 10 8
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamFaceLivenessVerifyServiceImpl.java
  8. 11 7
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamRecordDataServiceImpl.java
  9. 14 12
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamStudentServiceImpl.java
  10. 27 24
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/FaceBiopsyServiceImpl.java
  11. 10 19
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/OfflineExamServiceImpl.java
  12. 3 2
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/PracticeServiceImpl.java

+ 4 - 3
examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/controller/ExamControlController.java

@@ -8,6 +8,7 @@ import cn.com.qmth.examcloud.core.basic.api.bean.StudentBean;
 import cn.com.qmth.examcloud.core.basic.api.request.GetStudentReq;
 import cn.com.qmth.examcloud.core.basic.api.response.GetStudentResp;
 import cn.com.qmth.examcloud.core.oe.common.base.Constants;
+import cn.com.qmth.examcloud.core.oe.common.base.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.core.oe.common.base.utils.Check;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamFileAnswerTempEntity;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordDataEntity;
@@ -178,8 +179,8 @@ public class ExamControlController extends ControllerSupport {
 
         //根据相关条件添加推分队列
         Long examId = examRecordData.getExamId();
-        String isPushScore = CacheHelper.getExamOrgProperty(examId, examRecordData.getOrgId(),
-                ExamProperties.PUSH_SCORE.name()).getValue();
+        String isPushScore = ExamCacheTransferHelper.getCachedExamProperty(examId, examRecordData.getOrgId(),
+                examRecordData.getStudentId(), ExamProperties.PUSH_SCORE.name()).getValue();
         if (isPushScore != null && Constants.isTrue.equals(isPushScore)) {
             //保存分数通知队列(只有考试设置中,配置为允许推分的才发送通知)
             boolean isExistNoticeQueue = examScoreNoticeQueueService.isExistExamScoreNoticeQueue(user.getRootOrgId());
@@ -398,7 +399,7 @@ public class ExamControlController extends ControllerSupport {
             upyunSignDomain.setSignIdentifier(signIdentifier);
 
             signDomainList.add(upyunSignDomain);
-            Util.sleep(TimeUnit.MILLISECONDS,1);
+            Util.sleep(TimeUnit.MILLISECONDS, 1);
         }
         BatchGetUpyunSignDomain result = new BatchGetUpyunSignDomain();
         result.setList(signDomainList);

+ 5 - 3
examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/controller/FaceBiopsyController.java

@@ -3,6 +3,7 @@ package cn.com.qmth.examcloud.core.oe.student.controller;
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.core.oe.common.base.Constants;
+import cn.com.qmth.examcloud.core.oe.common.base.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordDataEntity;
 import cn.com.qmth.examcloud.core.oe.common.entity.FaceBiopsyItemEntity;
 import cn.com.qmth.examcloud.core.oe.common.entity.FaceBiopsyItemStepEntity;
@@ -69,7 +70,8 @@ public class FaceBiopsyController extends ControllerSupport {
         }
 
         //考试未开启人脸活体检测,不允许获取活检信息
-        String isFaceVerifyStr = CacheHelper.getExamOrgProperty(examRecordData.getExamId(), examRecordData.getOrgId(),
+        String isFaceVerifyStr = ExamCacheTransferHelper.getCachedExamProperty(examRecordData.getExamId(),
+                examRecordData.getOrgId(), examRecordData.getStudentId(),
                 ExamProperties.IS_FACE_VERIFY.name()).getValue();
         if (!Constants.isTrue.equals(isFaceVerifyStr)) {
             throw new StatusException("200103", "本场考试未开启人脸活体检测");
@@ -102,11 +104,11 @@ public class FaceBiopsyController extends ControllerSupport {
         }
         FaceBiopsyItemEntity faceBiopsyItemEntity = GlobalHelper.getEntity(faceBiopsyItemRepo, req.getFaceBiopsyItemId(),
                 FaceBiopsyItemEntity.class);
-        if (faceBiopsyItemEntity==null){
+        if (faceBiopsyItemEntity == null) {
             throw new StatusException("200111", "人脸活体检测明细id不存在");
         }
 
-        if (faceBiopsyItemEntity.getCompleted()==true){
+        if (faceBiopsyItemEntity.getCompleted() == true) {
             throw new StatusException("200112", "不允许操作已结束的人脸活体检测数据");
         }
 

+ 4 - 2
examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/controller/OfflineExamController.java

@@ -2,6 +2,7 @@ package cn.com.qmth.examcloud.core.oe.student.controller;
 
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.core.oe.common.base.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.core.oe.common.base.utils.Check;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordDataEntity;
 import cn.com.qmth.examcloud.core.oe.common.enums.ExamProperties;
@@ -94,8 +95,9 @@ public class OfflineExamController extends ControllerSupport{
 		if(examRecordData.getExamType() != ExamType.OFFLINE){
 			throw new StatusException("OfflineExamController-submitPaper-002","非离线考试"); 
 		}
-		String offlineUploadFileType = CacheHelper.getExamOrgProperty(examRecordData.getExamId(),
-				examRecordData.getOrgId(),ExamProperties.OFFLINE_UPLOAD_FILE_TYPE.name()).getValue();
+		String offlineUploadFileType = ExamCacheTransferHelper.getCachedExamProperty(examRecordData.getExamId(),
+				examRecordData.getOrgId(),examRecordData.getStudentId(),
+				ExamProperties.OFFLINE_UPLOAD_FILE_TYPE.name()).getValue();
 		if(StringUtils.isBlank(offlineUploadFileType) || "[]".equals(offlineUploadFileType)){
 			throw new StatusException("OfflineExamController-submitPaper-003","当前考试设置不允许上传附件"); 
 		}

+ 0 - 100
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/ExamCacheTransferHelper.java

@@ -1,100 +0,0 @@
-/*
- * *************************************************
- * Copyright (c) 2018 QMTH. All Rights Reserved.
- * Created by Deason on 2018-08-29 10:44:05.
- * *************************************************
- */
-
-package cn.com.qmth.examcloud.core.oe.student.service;
-
-import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
-import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
-import cn.com.qmth.examcloud.support.cache.CacheHelper;
-import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
-import cn.com.qmth.examcloud.support.cache.bean.ExamOrgSettingsCacheBean;
-import cn.com.qmth.examcloud.support.cache.bean.ExamSettingsCacheBean;
-
-/**
- * @Description 网考缓存实体转换服务
- * @Author lideyin
- * @Date 2019/8/13 16:00
- * @Version 1.0
- */
-public class ExamCacheTransferHelper {
-
-    /**
-     * 获取缓存的考试信息
-     * @param examId 考试id
-     * @param orgId 组织机构id
-     * @return ExamBean
-     */
-    public static ExamBean getCachedExam(Long examId,Long orgId){
-        ExamOrgSettingsCacheBean examCacheBean = CacheHelper.getExamOrgSettings(examId,orgId);
-        return copyExamBeanFrom(examCacheBean);
-    }
-    /**
-     * 获取缓存的考试信息
-     * @param examId 考试id
-     * @return ExamBean
-     */
-    public static ExamBean getCachedExam(Long examId){
-        ExamSettingsCacheBean examCacheBean = CacheHelper.getExamSettings(examId);
-        return copyExamBeanFrom(examCacheBean);
-    }
-
-    /**
-     * 获取能在的课程
-     * @param courseId 课程id
-     * @return CourseBean
-     */
-    public static CourseBean getCachedCourse(Long courseId){
-        CourseCacheBean courseCacheBean = CacheHelper.getCourse(courseId);
-        return copyCourseBeanFrom(courseCacheBean);
-    }
-
-    private static ExamBean copyExamBeanFrom(ExamOrgSettingsCacheBean examCacheBean) {
-        ExamBean resultBean = new ExamBean();
-        resultBean.setId(examCacheBean.getId());
-        resultBean.setBeginTime(examCacheBean.getBeginTime());
-        resultBean.setCode(examCacheBean.getCode());
-        resultBean.setDuration(examCacheBean.getDuration());
-        resultBean.setEnable(examCacheBean.getEnable());
-        resultBean.setEndTime(examCacheBean.getEndTime());
-        resultBean.setExamLimit(examCacheBean.getExamLimit());
-        resultBean.setExamTimes(examCacheBean.getExamTimes());
-        resultBean.setExamType(examCacheBean.getExamType());
-        resultBean.setName(examCacheBean.getName());
-        resultBean.setRemark(examCacheBean.getRemark());
-        resultBean.setRootOrgId(examCacheBean.getRootOrgId());
-        return resultBean;
-    }
-
-    private static ExamBean copyExamBeanFrom(ExamSettingsCacheBean examCacheBean) {
-        ExamBean resultBean = new ExamBean();
-        resultBean.setId(examCacheBean.getId());
-        resultBean.setBeginTime(examCacheBean.getBeginTime());
-        resultBean.setCode(examCacheBean.getCode());
-        resultBean.setDuration(examCacheBean.getDuration());
-        resultBean.setEnable(examCacheBean.getEnable());
-        resultBean.setEndTime(examCacheBean.getEndTime());
-        resultBean.setExamLimit(examCacheBean.getExamLimit());
-        resultBean.setExamTimes(examCacheBean.getExamTimes());
-        resultBean.setExamType(examCacheBean.getExamType());
-        resultBean.setName(examCacheBean.getName());
-        resultBean.setRemark(examCacheBean.getRemark());
-        resultBean.setRootOrgId(examCacheBean.getRootOrgId());
-        return resultBean;
-    }
-
-    private static CourseBean copyCourseBeanFrom(CourseCacheBean courseCacheBean) {
-        CourseBean resultBean = new CourseBean();
-        resultBean.setCode(courseCacheBean.getCode());
-        resultBean.setEnable(courseCacheBean.getEnable());
-        resultBean.setId(courseCacheBean.getId());
-        resultBean.setLevel(courseCacheBean.getLevel());
-        resultBean.setName(courseCacheBean.getName());
-        resultBean.setRootOrgId(courseCacheBean.getRootOrgId());
-
-        return resultBean;
-    }
-}

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

@@ -67,7 +67,7 @@ public interface ExamFaceLivenessVerifyService {
 	 * @param heartbeat
 	 * @return
 	 */
-	public Integer getFaceLivenessVerifyMinute(Long orgId,Long examId,Long examRecordDataId, Integer heartbeat);
+	public Integer getFaceLivenessVerifyMinute(Long orgId,Long examId,Long studentId,Long examRecordDataId, Integer heartbeat);
 	
 }
 

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

@@ -1,40 +1,5 @@
 package cn.com.qmth.examcloud.core.oe.student.service.impl;
 
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-import java.util.TimeZone;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
-
-import javax.validation.Valid;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.math.RandomUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-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 com.google.common.base.Splitter;
-
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.commons.util.ByteUtil;
@@ -43,57 +8,18 @@ import cn.com.qmth.examcloud.commons.util.UrlUtil;
 import cn.com.qmth.examcloud.commons.util.Util;
 import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
 import cn.com.qmth.examcloud.core.oe.common.base.Constants;
+import cn.com.qmth.examcloud.core.oe.common.base.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.core.oe.common.base.utils.CommonUtil;
 import cn.com.qmth.examcloud.core.oe.common.base.utils.QuestionTypeUtil;
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamFileAnswerTempEntity;
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamQuestionEntity;
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordDataEntity;
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordPaperStructEntity;
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordQuestionsEntity;
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamScoreEntity;
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamStudentEntity;
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamingRecordEntity;
-import cn.com.qmth.examcloud.core.oe.common.entity.HandInExamRecordEntity;
-import cn.com.qmth.examcloud.core.oe.common.enums.ExamProperties;
-import cn.com.qmth.examcloud.core.oe.common.enums.ExamRecordStatus;
-import cn.com.qmth.examcloud.core.oe.common.enums.ExamType;
-import cn.com.qmth.examcloud.core.oe.common.enums.FileAnswerAcknowledgeStatus;
-import cn.com.qmth.examcloud.core.oe.common.enums.HandInExamType;
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamCaptureQueueRepo;
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamFileAnswerTempRepo;
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordDataRepo;
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordPaperStructRepo;
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamScoreRepo;
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamStudentRepo;
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamingRecordRepo;
+import cn.com.qmth.examcloud.core.oe.common.entity.*;
+import cn.com.qmth.examcloud.core.oe.common.enums.*;
+import cn.com.qmth.examcloud.core.oe.common.repository.*;
 import cn.com.qmth.examcloud.core.oe.common.service.ExamScoreObtainQueueService;
 import cn.com.qmth.examcloud.core.oe.common.service.ExamScorePushQueueService;
-import cn.com.qmth.examcloud.core.oe.student.bean.CalculateFaceCheckResultInfo;
-import cn.com.qmth.examcloud.core.oe.student.bean.CheckExamInProgressInfo;
-import cn.com.qmth.examcloud.core.oe.student.bean.CheckQrCodeInfo;
-import cn.com.qmth.examcloud.core.oe.student.bean.EndExamInfo;
-import cn.com.qmth.examcloud.core.oe.student.bean.ExamSessionInfo;
-import cn.com.qmth.examcloud.core.oe.student.bean.GetQrCodeReq;
-import cn.com.qmth.examcloud.core.oe.student.bean.GetUploadedFileAcknowledgeStatusReq;
-import cn.com.qmth.examcloud.core.oe.student.bean.GetUploadedFileAnswerListReq;
-import cn.com.qmth.examcloud.core.oe.student.bean.GetUpyunSignatureReq;
-import cn.com.qmth.examcloud.core.oe.student.bean.SaveUploadedFileAcknowledgeStatusReq;
-import cn.com.qmth.examcloud.core.oe.student.bean.SaveUploadedFileReq;
-import cn.com.qmth.examcloud.core.oe.student.bean.StartExamInfo;
-import cn.com.qmth.examcloud.core.oe.student.bean.UploadedFileAnswerInfo;
-import cn.com.qmth.examcloud.core.oe.student.bean.UpyunSignatureInfo;
+import cn.com.qmth.examcloud.core.oe.student.bean.*;
 import cn.com.qmth.examcloud.core.oe.student.face.api.ExamCaptureCloudService;
 import cn.com.qmth.examcloud.core.oe.student.face.api.request.SaveExamCaptureSyncCompareResultReq;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamCacheTransferHelper;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamControlService;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamFaceLivenessVerifyService;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordDataService;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordForMarkingService;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordQuestionsService;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamScoreService;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamSessionInfoService;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamStudentService;
-import cn.com.qmth.examcloud.core.oe.student.service.FaceBiopsyService;
+import cn.com.qmth.examcloud.core.oe.student.service.*;
 import cn.com.qmth.examcloud.core.oe.websocket.api.FileAnswerWebsocketCloudService;
 import cn.com.qmth.examcloud.core.oe.websocket.api.enums.WebSocketEventType;
 import cn.com.qmth.examcloud.core.oe.websocket.api.request.SendFileAnswerMessageReq;
@@ -110,19 +36,36 @@ import cn.com.qmth.examcloud.question.commons.core.question.QuestionType;
 import cn.com.qmth.examcloud.reports.commons.bean.OnlineExamStudentReport;
 import cn.com.qmth.examcloud.reports.commons.util.ReportsUtil;
 import cn.com.qmth.examcloud.support.cache.CacheHelper;
-import cn.com.qmth.examcloud.support.cache.bean.ExtractConfigCacheBean;
-import cn.com.qmth.examcloud.support.cache.bean.ExtractConfigDetailCacheBean;
-import cn.com.qmth.examcloud.support.cache.bean.ExtractConfigPaperCacheBean;
-import cn.com.qmth.examcloud.support.cache.bean.OrgPropertyCacheBean;
-import cn.com.qmth.examcloud.support.cache.bean.SysPropertyCacheBean;
+import cn.com.qmth.examcloud.support.cache.bean.*;
 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 com.google.common.base.Splitter;
 import main.java.com.upyun.Base64Coder;
 import main.java.com.upyun.UpException;
 import main.java.com.upyun.UpYunUtils;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.math.RandomUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+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 javax.validation.Valid;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 /**
  * @author chenken
@@ -337,9 +280,8 @@ public class ExamControlServiceImpl implements ExamControlService {
                 examRecordData.getExamType());
 
         // 如果开启人脸比对,将同步人脸比对结果存储到抓后结果表中
-        Long examId = examRecordData.getExamId();
-        String isFaceEnable = CacheHelper.getExamOrgProperty(examRecordData.getExamId(), examRecordData.getOrgId(),
-                ExamProperties.IS_FACE_ENABLE.name()).getValue();
+        String isFaceEnable = ExamCacheTransferHelper.getCachedExamProperty(examRecordData.getExamId(), examRecordData.getOrgId(),
+                examRecordData.getStudentId(), ExamProperties.IS_FACE_ENABLE.name()).getValue();
         if (isFaceEnable != null && Constants.isTrue.equals(isFaceEnable)) {
             SaveExamCaptureSyncCompareResultReq req = new SaveExamCaptureSyncCompareResultReq();
             req.setExamRecordDataId(examRecordData.getId());
@@ -444,7 +386,7 @@ public class ExamControlServiceImpl implements ExamControlService {
     }
 
     private StartExamInfo buildStartExamInfo(Long examRecordDataId, ExamStudentEntity examStudentEntity,
-            ExamBean examBean, CourseBean courseBean) {
+                                             ExamBean examBean, CourseBean courseBean) {
         StartExamInfo startExamInfo = new StartExamInfo();
         startExamInfo.setExamRecordDataId(examRecordDataId);
         startExamInfo.setStudentCode(examStudentEntity.getStudentCode());
@@ -452,7 +394,8 @@ public class ExamControlServiceImpl implements ExamControlService {
         startExamInfo.setCourseCode(examStudentEntity.getCourseCode());
         startExamInfo.setCourseName(courseBean.getName());
         startExamInfo.setDuration(examBean.getDuration());
-        startExamInfo.setFaceVerifyMinute(getFaceVerifyMinute(examBean.getId(), examStudentEntity.getOrgId()));
+        startExamInfo.setFaceVerifyMinute(getFaceVerifyMinute(examBean.getId(), examStudentEntity.getOrgId(),
+                examStudentEntity.getStudentId()));
         return startExamInfo;
     }
 
@@ -462,9 +405,9 @@ public class ExamControlServiceImpl implements ExamControlService {
      * @param examId
      * @return
      */
-    private Integer getFaceVerifyMinute(Long examId, Long orgId) {
-        String isFaceVerifyStr = CacheHelper.getExamOrgProperty(examId, orgId, ExamProperties.IS_FACE_VERIFY.name())
-                .getValue();
+    private Integer getFaceVerifyMinute(Long examId, Long orgId, Long studentId) {
+        String isFaceVerifyStr = ExamCacheTransferHelper.getCachedExamProperty(examId, orgId,
+                studentId, ExamProperties.IS_FACE_VERIFY.name()).getValue();
         // 如果开启了活体检测
         if (Constants.isTrue.equals(isFaceVerifyStr)) {
             // 开始分钟数
@@ -508,18 +451,16 @@ public class ExamControlServiceImpl implements ExamControlService {
 
         // examStudentEntity.getOrgId());
 
-        // 通用考试配置
-        ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudentEntity.getExamId());
         // 学习中心特殊考试配置(是否禁考,开考时间可以特殊设置)
-        ExamBean specialExamBean = ExamCacheTransferHelper.getCachedExam(examStudentEntity.getExamId(),
-                examStudentEntity.getOrgId());
-        if (!examBean.getEnable() || (specialExamBean.getExamLimit() != null && specialExamBean.getExamLimit())) {
+        ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudentEntity.getExamId(),
+                examStudentEntity.getOrgId(), examStudentEntity.getStudentId());
+        if (!examBean.getEnable() || (examBean.getExamLimit() != null && examBean.getExamLimit())) {
             throw new StatusException("ExamControlServiceImpl-checkExam-exception-01", "暂无考试资格,请与学校老师联系");
         }
-        if (new Date().before(specialExamBean.getBeginTime())) {
+        if (new Date().before(examBean.getBeginTime())) {
             throw new StatusException("ExamControlServiceImpl-checkExam-exception-02", "考试未开始");
         }
-        if (specialExamBean.getEndTime().before(new Date())) {
+        if (examBean.getEndTime().before(new Date())) {
             throw new StatusException("ExamControlServiceImpl-checkExam-exception-03", "本次考试已结束");
         }
         if (ExamType.ONLINE.name().equals(examBean.getExamType())
@@ -539,7 +480,7 @@ public class ExamControlServiceImpl implements ExamControlService {
      * @param examBean
      */
     public void initializeExamRecordSession(final ExamStudentEntity examStudent,
-            final ExamRecordDataEntity examRecordData, final ExamBean examBean) {
+                                            final ExamRecordDataEntity examRecordData, final ExamBean examBean) {
         ExamSessionInfo examSessionInfo = new ExamSessionInfo();
         examSessionInfo.setExamRecordDataId(examRecordData.getId());
         examSessionInfo.setExamStudentId(examStudent.getExamStudentId());
@@ -583,10 +524,8 @@ public class ExamControlServiceImpl implements ExamControlService {
     /**
      * 获取试卷结构 小题乱序、选项乱序
      *
-     * @param extractConfig
-     *            调卷规则对象
-     * @param paperStruct
-     *            试卷结构对象
+     * @param extractConfig 调卷规则对象
+     * @param paperStruct   试卷结构对象
      */
     private void reorderPaperStruct(ExtractConfigCacheBean extractConfig, ExtractConfigPaperCacheBean paperStruct) {
         // 小题乱序
@@ -673,8 +612,7 @@ public class ExamControlServiceImpl implements ExamControlService {
     /**
      * 计算考试时长 校验是否达到冻结时间
      *
-     * @param studentId
-     *            学生id
+     * @param studentId 学生id
      * @return
      */
     private Long checkAndComputeExamDuration(Long studentId) {
@@ -706,8 +644,7 @@ public class ExamControlServiceImpl implements ExamControlService {
     /**
      * 计算考试已用时间(毫秒)
      *
-     * @param examSessionInfo
-     *            考试会话对象
+     * @param examSessionInfo 考试会话对象
      * @return
      */
     @Override
@@ -731,10 +668,8 @@ public class ExamControlServiceImpl implements ExamControlService {
     }
 
     /**
-     * @param examRecordDataId
-     *            考试记录id
-     * @param handInExamType
-     *            交卷类型
+     * @param examRecordDataId 考试记录id
+     * @param handInExamType   交卷类型
      */
     @Override
     @Transactional
@@ -768,8 +703,9 @@ public class ExamControlServiceImpl implements ExamControlService {
             examRecordData.setEndTime(new Date());
 
             // 手工手卷时,如果开启人脸检测,则更新抓拍队列优先级
-            String isFaceEnable = CacheHelper.getExamOrgProperty(examRecordData.getExamId(), examRecordData.getOrgId(),
-                    ExamProperties.IS_FACE_ENABLE.name()).getValue();
+            String isFaceEnable = ExamCacheTransferHelper.getCachedExamProperty(examRecordData.getExamId(),
+                    examRecordData.getOrgId(),
+                    examRecordData.getStudentId(), ExamProperties.IS_FACE_ENABLE.name()).getValue();
             if (isFaceEnable != null && Constants.isTrue.equals(isFaceEnable)) {
                 // 更新照片抓拍队列优先级为高优先级
                 examCaptureQueueRepo.updateExamCaptureQueuePriority(Constants.PROCESS_CAPTURE_HIGH_PRIORITY,
@@ -901,8 +837,7 @@ public class ExamControlServiceImpl implements ExamControlService {
     /**
      * 考试心跳每分钟调用一次
      *
-     * @param user
-     *            学生
+     * @param user 学生
      */
     @Override
     public long examHeartbeat(User user) {
@@ -977,13 +912,13 @@ public class ExamControlServiceImpl implements ExamControlService {
 
             // 如果是新活体检测方案,则使用新的计算方案计算活检开始时间
             if (NEW_FACE_BIOPSY_SCHEME.equals(orgProperty.getValue())) {
-                faceVerifyMinute = examFaceLivenessVerifyService.getFaceLivenessVerifyMinute(
-                        examStudentEntity.getOrgId(), examStudentEntity.getExamId(),
-                        examingRecord.getExamRecordDataId(), examSessionInfo.getHeartbeat());
+                faceVerifyMinute = faceBiopsyService.getFaceBiopsyStartMinute(examingRecord.getExamRecordDataId());
             }
             // 非新活检,默认使用旧的活检计算方式
             else {
-                faceVerifyMinute = faceBiopsyService.getFaceBiopsyStartMinute(examingRecord.getExamRecordDataId());
+                faceVerifyMinute = examFaceLivenessVerifyService.getFaceLivenessVerifyMinute(
+                        examStudentEntity.getOrgId(), examStudentEntity.getExamId(), studentId,
+                        examingRecord.getExamRecordDataId(), examSessionInfo.getHeartbeat());
             }
 
             checkExamInProgressInfo.setFaceVerifyMinute(faceVerifyMinute);
@@ -1022,8 +957,7 @@ public class ExamControlServiceImpl implements ExamControlService {
     /**
      * 如果有序列化锁,则延迟交卷
      *
-     * @param examRecordDataId
-     *            考试记录id
+     * @param examRecordDataId 考试记录id
      * @return
      */
     private void delayHandInExamIfLocked(Long examRecordDataId) {
@@ -1195,16 +1129,11 @@ public class ExamControlServiceImpl implements ExamControlService {
     }
 
     /**
-     * @param bucketName
-     *            //不能为空
-     * @param expiration
-     *            //不能为空
-     * @param filePath
-     *            //不能为空
-     * @param date
-     *            为空时,以又怕云时间和expiration比较,不为空时以此date和expiration比较
-     * @param md5
-     *            //可以为空
+     * @param bucketName //不能为空
+     * @param expiration //不能为空
+     * @param filePath   //不能为空
+     * @param date       为空时,以又怕云时间和expiration比较,不为空时以此date和expiration比较
+     * @param md5        //可以为空
      * @return
      */
     private String policy(String bucketName, Long expiration, String filePath, Date date, String md5) {
@@ -1237,7 +1166,7 @@ public class ExamControlServiceImpl implements ExamControlService {
      * @throws UpException
      */
     private String sign(String method, String date, String bucketName, String policy, String userName, String password,
-            String md5) throws UpException {
+                        String md5) throws UpException {
 
         StringBuilder sb = new StringBuilder();
         String sp = "&";
@@ -1335,20 +1264,16 @@ public class ExamControlServiceImpl implements ExamControlService {
     /**
      * 通过websocket发送消息
      *
-     * @param examRecordDataId
-     *            考试记录id
-     * @param order
-     *            题序号
-     * @param fileUrl
-     *            文件路径
-     * @param transferFileType
-     *            传输文件类型
+     * @param examRecordDataId 考试记录id
+     * @param order            题序号
+     * @param fileUrl          文件路径
+     * @param transferFileType 传输文件类型
      * @param userId
      * @throws Exception
      */
     @Override
     public void sendFileAnswerToWebSocket(Long examRecordDataId, Integer order, String fileUrl, String transferFileType,
-            Long userId) throws Exception {
+                                          Long userId) throws Exception {
         Map<String, Object> data = new HashMap<String, Object>();
         data.put("examRecordDataId", examRecordDataId);
         data.put("order", order);
@@ -1620,7 +1545,7 @@ public class ExamControlServiceImpl implements ExamControlService {
          * Collectors.toList()).get(0); //集合中取id最大的值 if (currentTemp.getId() <
          * temp.getId()) { newestUploadedFileAnswerList.remove(currentTemp);
          * newestUploadedFileAnswerList.add(temp); } } }
-         * 
+         *
          * //按大题号给所有的小题定义序号 List<UploadedFileAnswerInfo> allQuestionAnswerList =
          * getReSortedQuestionList(req.getExamRecordDataId()); //当前考生已作答的题目集合
          * List<ExamQuestionEntity> examQuestionsInMongo =

+ 10 - 8
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamFaceLivenessVerifyServiceImpl.java

@@ -2,6 +2,7 @@ package cn.com.qmth.examcloud.core.oe.student.service.impl;
 
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.core.oe.common.base.Constants;
+import cn.com.qmth.examcloud.core.oe.common.base.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.core.oe.common.base.utils.CommonUtil;
 import cn.com.qmth.examcloud.core.oe.common.base.utils.FileDisposeUtil;
 import cn.com.qmth.examcloud.core.oe.common.base.utils.HttpPoolUtil;
@@ -215,7 +216,7 @@ public class ExamFaceLivenessVerifyServiceImpl implements ExamFaceLivenessVerify
     }
 
     @Override
-    public void faceTestEndHandle(Long examRecordDataId,Long studentId, String result) {
+    public void faceTestEndHandle(Long examRecordDataId, Long studentId, String result) {
         //保存活体检测的结果
         ExamRecordDataEntity examRecordDataEntity = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
         examRecordDataEntity.setFaceVerifyResult(IsSuccess.strToEnum(result) == IsSuccess.FAILED ? IsSuccess.FAILED : IsSuccess.SUCCESS);
@@ -278,9 +279,10 @@ public class ExamFaceLivenessVerifyServiceImpl implements ExamFaceLivenessVerify
     }
 
     @Override
-    public Integer getFaceLivenessVerifyMinute(Long orgId, Long examId, Long examRecordDataId, Integer heartbeat) {
-        String isFaceVerifyStr = CacheHelper.getExamOrgProperty(examId, orgId,
-                ExamProperties.IS_FACE_VERIFY.name()).getValue();
+    public Integer getFaceLivenessVerifyMinute(Long orgId, Long examId, Long studentId,
+                                               Long examRecordDataId, Integer heartbeat) {
+        String isFaceVerifyStr = ExamCacheTransferHelper.getCachedExamProperty(examId, orgId,
+                studentId, ExamProperties.IS_FACE_VERIFY.name()).getValue();
         //开启了人脸检测
         if (Constants.isTrue.equals(isFaceVerifyStr)) {
 
@@ -288,12 +290,12 @@ public class ExamFaceLivenessVerifyServiceImpl implements ExamFaceLivenessVerify
             //如果没有进行过人脸检测
             if (faceLivenessVerifys.size() == 0) {
 
-                String faceVerifyStartMinuteStr = CacheHelper.getExamOrgProperty(examId, orgId,
-                        ExamProperties.FACE_VERIFY_START_MINUTE.name()).getValue();
+                String faceVerifyStartMinuteStr = ExamCacheTransferHelper.getCachedExamProperty(examId, orgId,
+                        studentId, ExamProperties.FACE_VERIFY_START_MINUTE.name()).getValue();
                 Integer faceVerifyStartMinute = Integer.valueOf(faceVerifyStartMinuteStr);
 
-                String faceVerifyEndMinuteStr = CacheHelper.getExamOrgProperty(examId, orgId,
-                        ExamProperties.FACE_VERIFY_END_MINUTE.name()).getValue();
+                String faceVerifyEndMinuteStr = ExamCacheTransferHelper.getCachedExamProperty(examId, orgId,
+                        studentId, ExamProperties.FACE_VERIFY_END_MINUTE.name()).getValue();
                 Integer faceVerifyEndMinute = Integer.valueOf(faceVerifyEndMinuteStr);
                 //	case1.如果考生已使用的考试时间(即心跳时间)还未达到系统设置的活体检测开始时间,则实际活体检测时间=random(配置结束时间-配置结束时间)-考试已用时间
                 if (heartbeat < faceVerifyStartMinute) {

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

@@ -3,6 +3,7 @@ package cn.com.qmth.examcloud.core.oe.student.service.impl;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
 import cn.com.qmth.examcloud.core.oe.common.base.Constants;
+import cn.com.qmth.examcloud.core.oe.common.base.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.core.oe.common.base.jpa.Searcher;
 import cn.com.qmth.examcloud.core.oe.common.base.jpa.SpecUtils;
 import cn.com.qmth.examcloud.core.oe.common.base.utils.CommonUtil;
@@ -198,7 +199,8 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
             }
         } else {
             Long examId = examRecordDataEntity.getExamId();
-            String isFaceVerify = CacheHelper.getExamOrgProperty(examId, examRecordDataEntity.getOrgId(),
+            String isFaceVerify = ExamCacheTransferHelper.getCachedExamProperty(examId,
+                    examRecordDataEntity.getOrgId(), examRecordDataEntity.getStudentId(),
                     ExamProperties.IS_FACE_VERIFY.name()).getValue();
 
             //是否进行活体检测
@@ -251,8 +253,10 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
     public CalculateFaceCheckResultInfo calculateFaceCheckResult(ExamRecordDataEntity examRecordData) {
         CalculateFaceCheckResultInfo calculateFaceCheckResultInfo = new CalculateFaceCheckResultInfo();
         Long examId = examRecordData.getExamId();
-        String isFaceEnable = CacheHelper.getExamOrgProperty(examId, examRecordData.getOrgId(),
-                ExamProperties.IS_FACE_ENABLE.name()).getValue();
+        Long orgId = examRecordData.getOrgId();
+        Long studentId = examRecordData.getStudentId();
+        String isFaceEnable = ExamCacheTransferHelper.getCachedExamProperty(examId, orgId,
+                studentId, ExamProperties.IS_FACE_ENABLE.name()).getValue();
         //未开启人脸检测
         if (!Constants.isTrue.equals(isFaceEnable)) {
             examRecordData.setIsWarn(false);
@@ -276,15 +280,15 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
             return calculateFaceCheckResultInfo;
         }
         //人脸识别阀值
-        String warnThresholdStr = CacheHelper.getExamOrgProperty(examId, examRecordData.getOrgId(),
-                ExamProperties.WARN_THRESHOLD.name()).getValue();
+        String warnThresholdStr = ExamCacheTransferHelper.getCachedExamProperty(examId, orgId,
+                studentId, ExamProperties.WARN_THRESHOLD.name()).getValue();
         if (CommonUtil.isBlank(warnThresholdStr)) {
             throw new StatusException("ExamRecordDataServiceImpl-calculateFaceCheckResult-001", ExamProperties.WARN_THRESHOLD.getDesc() + "未设置");
         }
         double warnThreshold = Double.parseDouble(warnThresholdStr);
         //人脸真实性(百度活体检测)通过阀值
-        String liveWarnThresholdStr = CacheHelper.getExamOrgProperty(examId, examRecordData.getOrgId(),
-                ExamProperties.LIVING_WARN_THRESHOLD.name()).getValue();
+        String liveWarnThresholdStr = ExamCacheTransferHelper.getCachedExamProperty(examId, orgId,
+                studentId, ExamProperties.LIVING_WARN_THRESHOLD.name()).getValue();
         if (CommonUtil.isBlank(liveWarnThresholdStr)) {
             throw new StatusException("ExamRecordDataServiceImpl-calculateFaceCheckResult-002", ExamProperties.LIVING_WARN_THRESHOLD.getDesc() + "未设置");
         }

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

@@ -1,6 +1,7 @@
 package cn.com.qmth.examcloud.core.oe.student.service.impl;
 
 import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
+import cn.com.qmth.examcloud.core.oe.common.base.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.core.oe.common.base.utils.CommonUtil;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamStudentEntity;
 import cn.com.qmth.examcloud.core.oe.common.enums.CourseLevel;
@@ -9,7 +10,6 @@ import cn.com.qmth.examcloud.core.oe.common.enums.ExamType;
 import cn.com.qmth.examcloud.core.oe.common.repository.ExamStudentRepo;
 import cn.com.qmth.examcloud.core.oe.common.service.GainBaseDataService;
 import cn.com.qmth.examcloud.core.oe.student.bean.ExamStudentInfo;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamStudentService;
 import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
@@ -105,7 +105,8 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         examStudentInfo.setOrgId(examStudent.getOrgId());
 
         OrgCacheBean orgBean = gainBaseDataService.getOrgBean(examStudent.getOrgId());
-        ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudent.getExamId());
+        ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudent.getExamId(),
+                examStudent.getOrgId(), examStudent.getStudentId());
 
         examStudentInfo.setOrgName(orgBean.getName());
         examStudentInfo.setExamId(examBean.getId());
@@ -116,17 +117,18 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         examStudentInfo.setPaperMins(examBean.getDuration());
 
         //是否启用人脸识别
-        String isFaceEnable = CacheHelper.getExamOrgProperty(examBean.getId(), examStudent.getOrgId(),
-                ExamProperties.IS_FACE_ENABLE.name()).getValue();
+        String isFaceEnable = ExamCacheTransferHelper.getCachedExamProperty(examBean.getId(), examStudent.getOrgId(),
+                examStudent.getStudentId(), ExamProperties.IS_FACE_ENABLE.name()).getValue();
         if (StringUtils.isBlank(isFaceEnable)) {
             examStudentInfo.setFaceEnable(false);
         } else {
             examStudentInfo.setFaceEnable(Boolean.valueOf(isFaceEnable));
+            Class booleanClass = Boolean.class;
         }
 
         //进入考试是否验证人脸识别(强制、非强制)
-        String isFaceCheck = CacheHelper.getExamOrgProperty(examBean.getId(), examStudent.getOrgId(),
-                ExamProperties.IS_FACE_CHECK.name()).getValue();
+        String isFaceCheck = ExamCacheTransferHelper.getCachedExamProperty(examBean.getId(), examStudent.getOrgId(),
+                examStudent.getStudentId(), ExamProperties.IS_FACE_CHECK.name()).getValue();
         if (StringUtils.isBlank(isFaceCheck)) {
             examStudentInfo.setFaceCheck(false);
         } else {
@@ -179,13 +181,13 @@ public class ExamStudentServiceImpl implements ExamStudentService {
     }
 
     @Override
-    public int updateExamStudentByStartExam(Long id,Boolean isReExamine,Boolean reExamineCompleted,
-                                                          Integer normalExamTimes,final ExamBean examBean) {
+    public int updateExamStudentByStartExam(Long id, Boolean isReExamine, Boolean reExamineCompleted,
+                                            Integer normalExamTimes, final ExamBean examBean) {
         //考试完的最终状态
-        Boolean finalIsReExamine=isReExamine;
-        Boolean finalReExamineCompleted=reExamineCompleted;
+        Boolean finalIsReExamine = isReExamine;
+        Boolean finalReExamineCompleted = reExamineCompleted;
         //考生的已考次数(不包括重考)
-        int finalNormalExamTimes=normalExamTimes == null ? 0 : normalExamTimes;
+        int finalNormalExamTimes = normalExamTimes == null ? 0 : normalExamTimes;
         //考试机会,即可考次数
         long canExamTimes = examBean.getExamTimes();
         //有可能中途改变考试次数
@@ -199,7 +201,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         if (CommonUtil.isTrue(finalIsReExamine)) {
             finalIsReExamine = false;
             finalReExamineCompleted = true;
-            finalNormalExamTimes=finalNormalExamTimes+1;
+            finalNormalExamTimes = finalNormalExamTimes + 1;
         }
         Date now = new Date();
         //更新相关属性

+ 27 - 24
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/FaceBiopsyServiceImpl.java

@@ -2,6 +2,7 @@ package cn.com.qmth.examcloud.core.oe.student.service.impl;
 
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.core.oe.common.base.Constants;
+import cn.com.qmth.examcloud.core.oe.common.base.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.core.oe.common.base.utils.CommonUtil;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordDataEntity;
 import cn.com.qmth.examcloud.core.oe.common.entity.FaceBiopsyEntity;
@@ -18,7 +19,6 @@ import cn.com.qmth.examcloud.core.oe.student.bean.*;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamControlService;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamSessionInfoService;
 import cn.com.qmth.examcloud.core.oe.student.service.FaceBiopsyService;
-import cn.com.qmth.examcloud.support.cache.CacheHelper;
 import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import com.mysql.cj.util.StringUtils;
@@ -265,7 +265,8 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
             //冻结时间内第一次或第二次活检成功,且开启冻结时间外增加一次活检,则需要下次活检,否则不需要
             ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId,
                     ExamRecordDataEntity.class);
-            return addFaceVerifyOutFreezeTime(examRecordData.getExamId(), examRecordData.getOrgId());
+            return addFaceVerifyOutFreezeTime(examRecordData.getExamId(),
+                    examRecordData.getOrgId(), examRecordData.getStudentId());
         } else {
             //冻结时间外,无论活检成功或失败,均不可进行下次活检
             return false;
@@ -293,10 +294,10 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
         if (!StringUtils.isNullOrEmpty(resourceUrl)) {
             String domain = PropertyHolder.getString("$upyun.site.1.domain");
             String backupDomain = PropertyHolder.getString("$upyun.site.1.domain.backup");
-            if (!StringUtils.isNullOrEmpty(domain)){
+            if (!StringUtils.isNullOrEmpty(domain)) {
                 resourceUrl = resourceUrl.replace(domain, "");
             }
-            if (!StringUtils.isNullOrEmpty(backupDomain)){
+            if (!StringUtils.isNullOrEmpty(backupDomain)) {
                 resourceUrl = resourceUrl.replace(backupDomain, "");
             }
         }
@@ -462,8 +463,8 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
         Long studentId = examRecordData.getStudentId();
 
         //再次校验是否开启人脸活体校验
-        String isFaceVerifyStr = CacheHelper.getExamOrgProperty(examId, orgId,
-                ExamProperties.IS_FACE_VERIFY.name()).getValue();
+        String isFaceVerifyStr = ExamCacheTransferHelper.getCachedExamProperty(examId, orgId,
+                studentId, ExamProperties.IS_FACE_VERIFY.name()).getValue();
 
         //如果未开启人脸活体检测,则返回null
         if (!Constants.isTrue.equals(isFaceVerifyStr)) {
@@ -478,11 +479,11 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
         Integer heartbeat = examSessionInfo.getHeartbeat();
         //如果冻结时间内,使用冻结时间内的计算方式
         if (calculateIsInFreezeTime(examRecordDataId)) {
-            return generateInFreezeTimeFaceBiopsyStartMinute(examId, orgId, heartbeat, verifyTimes);
+            return generateInFreezeTimeFaceBiopsyStartMinute(examId, orgId, studentId, heartbeat, verifyTimes);
         }
         //如果超过冻结时间则使用冻结时间外的计算方式
         else {
-            return generateOutFreezeTimeFaceBiopsyStartMinute(examId, orgId, heartbeat);
+            return generateOutFreezeTimeFaceBiopsyStartMinute(examId, orgId, studentId, heartbeat);
         }
     }
 
@@ -495,16 +496,16 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
      * @param verifyTimes
      * @return
      */
-    private Integer generateInFreezeTimeFaceBiopsyStartMinute(Long examId, Long orgId, Integer heartbeat,
-                                                              Integer verifyTimes) {
+    private Integer generateInFreezeTimeFaceBiopsyStartMinute(Long examId, Long orgId, Long studentId,
+                                                              Integer heartbeat, Integer verifyTimes) {
         //如果没有进行过人脸检测(即第一次活体检测)
         if (verifyTimes == 1) {
-            String faceVerifyStartMinuteStr = CacheHelper.getExamOrgProperty(examId, orgId,
-                    ExamProperties.FACE_VERIFY_START_MINUTE.name()).getValue();
+            String faceVerifyStartMinuteStr = ExamCacheTransferHelper.getCachedExamProperty(examId, orgId,
+                    studentId, ExamProperties.FACE_VERIFY_START_MINUTE.name()).getValue();
             Integer faceVerifyStartMinute = Integer.valueOf(faceVerifyStartMinuteStr);
 
-            String faceVerifyEndMinuteStr = CacheHelper.getExamOrgProperty(examId, orgId,
-                    ExamProperties.FACE_VERIFY_END_MINUTE.name()).getValue();
+            String faceVerifyEndMinuteStr = ExamCacheTransferHelper.getCachedExamProperty(examId, orgId,
+                    studentId, ExamProperties.FACE_VERIFY_END_MINUTE.name()).getValue();
             Integer faceVerifyEndMinute = Integer.valueOf(faceVerifyEndMinuteStr);
             //	case1.如果考生已使用的考试时间(即心跳时间)还未达到系统设置的活体检测开始时间,
             //	则实际活体检测时间=random(配置结束时间-配置结束时间)-考试已用时间
@@ -535,18 +536,19 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
      *
      * @return
      */
-    private Integer generateOutFreezeTimeFaceBiopsyStartMinute(Long examId, Long orgId, Integer heartbeat) {
+    private Integer generateOutFreezeTimeFaceBiopsyStartMinute(Long examId, Long orgId,
+                                                               Long studentId, Integer heartbeat) {
         //如果冻结时间外不添加活体检测,则直接返回null
-        if (!addFaceVerifyOutFreezeTime(examId, orgId)) {
+        if (!addFaceVerifyOutFreezeTime(examId, orgId, studentId)) {
             return null;
         }
 
-        String strOutFreezeTimeFaceVerifyStartMinute = CacheHelper.getExamOrgProperty(examId, orgId,
-                ExamProperties.OUT_FREEZE_TIME_FACE_VERIFY_START_MINUTE.name()).getValue();
+        String strOutFreezeTimeFaceVerifyStartMinute = ExamCacheTransferHelper.getCachedExamProperty(examId, orgId,
+                studentId, ExamProperties.OUT_FREEZE_TIME_FACE_VERIFY_START_MINUTE.name()).getValue();
         Integer faceVerifyStartMinute = Integer.valueOf(strOutFreezeTimeFaceVerifyStartMinute);
 
-        String strOutFreezeTimeFaceVerifyEndMinute = CacheHelper.getExamOrgProperty(examId, orgId,
-                ExamProperties.OUT_FREEZE_TIME_FACE_VERIFY_END_MINUTE.name()).getValue();
+        String strOutFreezeTimeFaceVerifyEndMinute = ExamCacheTransferHelper.getCachedExamProperty(examId, orgId,
+                studentId, ExamProperties.OUT_FREEZE_TIME_FACE_VERIFY_END_MINUTE.name()).getValue();
         Integer faceVerifyEndMinute = Integer.valueOf(strOutFreezeTimeFaceVerifyEndMinute);
         //	case1.如果考生已使用的考试时间(即心跳时间)还未达到系统设置的活体检测开始时间,
         //	则实际活体检测时间=random(配置结束时间-配置结束时间)-考试已用时间
@@ -572,9 +574,9 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
      * @param orgId
      * @return
      */
-    private boolean addFaceVerifyOutFreezeTime(Long examId, Long orgId) {
-        String addFaceVerifyOutFreezeTime = CacheHelper.getExamOrgProperty(examId, orgId,
-                ExamProperties.ADD_FACE_VERIFY_OUT_FREEZE_TIME.name()).getValue();
+    private boolean addFaceVerifyOutFreezeTime(Long examId, Long orgId, Long studentId) {
+        String addFaceVerifyOutFreezeTime = ExamCacheTransferHelper.getCachedExamProperty(examId, orgId,
+                studentId, ExamProperties.ADD_FACE_VERIFY_OUT_FREEZE_TIME.name()).getValue();
         return Constants.isTrue.equals(addFaceVerifyOutFreezeTime);
     }
 
@@ -587,7 +589,8 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
     private boolean addFaceVerifyOutFreezeTime(Long examRecordDataId) {
         ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId,
                 ExamRecordDataEntity.class);
-        return addFaceVerifyOutFreezeTime(examRecordData.getExamId(), examRecordData.getOrgId());
+        return addFaceVerifyOutFreezeTime(examRecordData.getExamId(),
+                examRecordData.getOrgId(), examRecordData.getStudentId());
     }
 
     /**

+ 10 - 19
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/OfflineExamServiceImpl.java

@@ -3,6 +3,7 @@ package cn.com.qmth.examcloud.core.oe.student.service.impl;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.commons.util.HttpClientUtil;
 import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
+import cn.com.qmth.examcloud.core.oe.common.base.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordDataEntity;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordForMarkingEntity;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamStudentEntity;
@@ -15,7 +16,10 @@ import cn.com.qmth.examcloud.core.oe.common.repository.ExamStudentRepo;
 import cn.com.qmth.examcloud.core.oe.common.repository.OfflineFileRepo;
 import cn.com.qmth.examcloud.core.oe.common.service.GainBaseDataService;
 import cn.com.qmth.examcloud.core.oe.student.bean.OfflineExamCourseInfo;
-import cn.com.qmth.examcloud.core.oe.student.service.*;
+import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordDataService;
+import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordForMarkingService;
+import cn.com.qmth.examcloud.core.oe.student.service.ExamScoreService;
+import cn.com.qmth.examcloud.core.oe.student.service.OfflineExamService;
 import cn.com.qmth.examcloud.core.questions.api.ExtractConfigCloudService;
 import cn.com.qmth.examcloud.core.questions.api.request.GetPaperReq;
 import cn.com.qmth.examcloud.core.questions.api.response.GetPaperResp;
@@ -23,33 +27,20 @@ import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
 import cn.com.qmth.examcloud.support.cache.CacheHelper;
 import cn.com.qmth.examcloud.support.cache.bean.OrgCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.SysPropertyCacheBean;
-import cn.com.qmth.examcloud.web.facepp.FaceppClient;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import main.java.com.UpYun;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.compress.utils.IOUtils;
 import org.apache.commons.io.FileUtils;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.config.CookieSpecs;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.util.EntityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.transaction.Transactional;
-import java.io.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
-import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -110,7 +101,7 @@ public class OfflineExamServiceImpl implements OfflineExamService {
         List<OfflineExamCourseInfo> offlineExamCourseInfoList = new ArrayList<OfflineExamCourseInfo>();
         for (ExamStudentEntity examStudent : examStudents) {
             ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudent.getExamId(),
-                    examStudent.getOrgId());
+                    examStudent.getOrgId(),studentId);
             if (!ExamType.OFFLINE.name().equals(examBean.getExamType())) {
                 continue;
             }
@@ -213,7 +204,7 @@ public class OfflineExamServiceImpl implements OfflineExamService {
 
     private ExamBean checkExam(ExamStudentEntity examStudentEntity) {
         ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudentEntity.getExamId(),
-                examStudentEntity.getOrgId());
+                examStudentEntity.getOrgId(),examStudentEntity.getStudentId());
 
         if (!examBean.getEnable() || (examBean.getExamLimit() != null && examBean.getExamLimit())) {
             throw new StatusException("ExamControlServiceImpl-checkExam-exception-01", "暂无考试资格,请与学校老师联系");

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

@@ -1,6 +1,7 @@
 package cn.com.qmth.examcloud.core.oe.student.service.impl;
 
 import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
+import cn.com.qmth.examcloud.core.oe.common.base.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.core.oe.common.base.utils.QuestionTypeUtil;
 import cn.com.qmth.examcloud.core.oe.common.entity.*;
 import cn.com.qmth.examcloud.core.oe.common.enums.ExamRecordStatus;
@@ -13,7 +14,6 @@ import cn.com.qmth.examcloud.core.oe.student.bean.PaperStructInfo;
 import cn.com.qmth.examcloud.core.oe.student.bean.PracticeCourseInfo;
 import cn.com.qmth.examcloud.core.oe.student.bean.PracticeDetailInfo;
 import cn.com.qmth.examcloud.core.oe.student.bean.PracticeRecordInfo;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordPaperStructService;
 import cn.com.qmth.examcloud.core.oe.student.service.PracticeService;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
@@ -66,7 +66,8 @@ public class PracticeServiceImpl implements PracticeService {
             return null;
         }
         List<PracticeCourseInfo> practiceCourseInfos = new ArrayList<PracticeCourseInfo>();
-        ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examId, examStudentList.get(0).getOrgId());
+        ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examId,
+                examStudentList.get(0).getOrgId(),studentId);
         for (ExamStudentEntity examStudent : examStudentList) {
             practiceCourseInfos.add(buildPracticeCourseInfo(examStudent, examBean));
         }