Эх сурвалжийг харах

examRecord和examRecordData表合并为一个表

lideyin 5 жил өмнө
parent
commit
14be8887d4
16 өөрчлөгдсөн 544 нэмэгдсэн , 675 устгасан
  1. 3 13
      examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/controller/ExamControlController.java
  2. 13 33
      examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/controller/OfflineExamController.java
  3. 0 13
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/bean/ExamSessionInfo.java
  4. 22 13
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/ExamRecordDataService.java
  5. 0 28
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/ExamRecordService.java
  6. 3 4
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/ExamScoreService.java
  7. 19 35
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamControlServiceImpl.java
  8. 10 16
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamFaceLivenessVerifyServiceImpl.java
  9. 67 26
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamRecordDataServiceImpl.java
  10. 16 27
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamRecordForMarkingServiceImpl.java
  11. 3 9
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamRecordPaperStructServiceImpl.java
  12. 0 56
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamRecordServiceImpl.java
  13. 8 8
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamScoreServiceImpl.java
  14. 1 1
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamSessionInfoServiceImpl.java
  15. 175 186
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/OfflineExamServiceImpl.java
  16. 204 207
      examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/PracticeServiceImpl.java

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

@@ -10,12 +10,9 @@ import cn.com.qmth.examcloud.core.oe.common.base.Constants;
 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;
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordEntity;
 import cn.com.qmth.examcloud.core.oe.common.enums.ExamProperties;
 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.ExamRecordDataRepo;
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordRepo;
 import cn.com.qmth.examcloud.core.oe.common.service.ExamScoreNoticeQueueService;
 import cn.com.qmth.examcloud.core.oe.common.service.GainBaseDataService;
 import cn.com.qmth.examcloud.core.oe.student.api.request.GetStudentOnlineExamInfoReq;
@@ -71,18 +68,12 @@ public class ExamControlController extends ControllerSupport {
     @Autowired
     private ExamScoreNoticeQueueService examScoreNoticeQueueService;
     @Autowired
-    private GainBaseDataService gainBaseDataService;
-    @Autowired
     UpyunService upyunService;
     @Value("${$upyun.site.1.domain}")
     private String upyunFileUrl;
     @Autowired
     RedisClient redisClient;
     @Autowired
-    private ExamCaptureQueueRepo examCaptureQueueRepo;
-    @Autowired
-    private ExamRecordRepo examRecordRepo;
-    @Autowired
     ExamRecordDataService examRecordDataService;
     @Autowired
     private ExamSessionInfoService examSessionInfoService;
@@ -168,9 +159,8 @@ public class ExamControlController extends ControllerSupport {
         ExamProcessResultDomain res = new ExamProcessResultDomain();
         ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId,
                 ExamRecordDataEntity.class);
-        ExamRecordEntity examRecord = GlobalHelper.getEntity(examRecordRepo, examRecordData.getExamRecordId(), ExamRecordEntity.class);
         try {
-            examControlService.processAfterHandInExam(examRecordDataId, examRecord.getStudentId(), HandInExamType.MANUAL);
+            examControlService.processAfterHandInExam(examRecordDataId, examRecordData.getStudentId(), HandInExamType.MANUAL);
         } catch (StatusException e) {
             if (e.getCode().equals(Constants.CAPTURE_PROCESSING_STATUS_CODE)) {
                 res.setCode(Constants.PROCESSING_EXAM_RECORD_CODE);
@@ -183,8 +173,8 @@ public class ExamControlController extends ControllerSupport {
 
 
         //根据相关条件添加推分队列
-        Long examId = examRecord.getExamId();
-        String isPushScore = CacheHelper.getExamOrgProperty(examId, examRecord.getOrgId(),
+        Long examId = examRecordData.getExamId();
+        String isPushScore = CacheHelper.getExamOrgProperty(examId, examRecordData.getOrgId(),
                 ExamProperties.PUSH_SCORE.name()).getValue();
         if (isPushScore != null && Constants.isTrue.equals(isPushScore)) {
             //保存分数通知队列(只有考试设置中,配置为允许推分的才发送通知)

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

@@ -1,39 +1,27 @@
 package cn.com.qmth.examcloud.core.oe.student.controller;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.List;
-
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordRepo;
-import cn.com.qmth.examcloud.support.cache.CacheHelper;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
-
 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.utils.Check;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordDataEntity;
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordEntity;
 import cn.com.qmth.examcloud.core.oe.common.enums.ExamProperties;
 import cn.com.qmth.examcloud.core.oe.common.enums.ExamType;
 import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordDataRepo;
-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.OfflineExamService;
+import cn.com.qmth.examcloud.support.cache.CacheHelper;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.*;
+import java.util.List;
 
 
 /**
@@ -50,14 +38,9 @@ public class OfflineExamController extends ControllerSupport{
 
 	@Autowired
 	private OfflineExamService offlineExamService;
-	
-	@Autowired
-	private GainBaseDataService gainBaseDataService;
-	
+
 	@Autowired
 	private ExamRecordDataRepo examRecordDataRepo;
-	@Autowired
-	private ExamRecordRepo examRecordRepo;
 	/**
 	 * 答案文件最大限制
 	 * 单位:M
@@ -108,14 +91,11 @@ public class OfflineExamController extends ControllerSupport{
 		}
 		
 		ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo,examRecordDataId,ExamRecordDataEntity.class);
-
-		ExamRecordEntity examRecord =GlobalHelper.getEntity(
-				examRecordRepo,examRecordData.getExamRecordId(),ExamRecordEntity.class);
-		if(examRecord.getExamType() != ExamType.OFFLINE){
+		if(examRecordData.getExamType() != ExamType.OFFLINE){
 			throw new StatusException("OfflineExamController-submitPaper-002","非离线考试"); 
 		}
-		String offlineUploadFileType = CacheHelper.getExamOrgProperty(examRecord.getExamId(),
-				examRecord.getOrgId(),ExamProperties.OFFLINE_UPLOAD_FILE_TYPE.name()).getValue();
+		String offlineUploadFileType = CacheHelper.getExamOrgProperty(examRecordData.getExamId(),
+				examRecordData.getOrgId(),ExamProperties.OFFLINE_UPLOAD_FILE_TYPE.name()).getValue();
 		if(StringUtils.isBlank(offlineUploadFileType) || "[]".equals(offlineUploadFileType)){
 			throw new StatusException("OfflineExamController-submitPaper-003","当前考试设置不允许上传附件"); 
 		}

+ 0 - 13
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/bean/ExamSessionInfo.java

@@ -16,10 +16,6 @@ public class ExamSessionInfo implements JsonSerializable {
 	 */
 	private static final long serialVersionUID = 7271713913526550662L;
 	private Long examId;
-	/**
-     * 考试记录ID
-     */
-    private Long examRecordId;
     /**
      * 考试记录DataID
      */
@@ -64,15 +60,6 @@ public class ExamSessionInfo implements JsonSerializable {
      * 试卷类型
      */
     private String paperType;
-
-    public Long getExamRecordId() {
-        return examRecordId;
-    }
-
-    public void setExamRecordId(Long examRecordId) {
-        this.examRecordId = examRecordId;
-    }
-
     public Long getStartTime() {
         return startTime;
     }

+ 22 - 13
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/ExamRecordDataService.java

@@ -1,13 +1,17 @@
 package cn.com.qmth.examcloud.core.oe.student.service;
 
-import java.util.List;
-
-import cn.com.qmth.examcloud.core.oe.common.entity.*;
+import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
+import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordDataEntity;
+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.ExamRecordStatus;
 import cn.com.qmth.examcloud.core.oe.common.enums.ExamType;
 import cn.com.qmth.examcloud.core.oe.student.bean.CalculateFaceCheckResultInfo;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
 
+import java.util.List;
+
 /**
  * @author chenken
  * @date 2018/8/15 11:16
@@ -18,14 +22,17 @@ public interface ExamRecordDataService {
 
     /**
      * 创建ExamRecordDataEntity
-     * @param examRecord 考试记录实体
      * @param examedTimes 已考次数
      * @param canExamTimes 可考次数
      * @param isReExamine 本次考试是否为重考
      * @param isFullyObjetive 是否全客观题
      * @return
      */
-    ExamRecordDataEntity createExamRecordData(ExamRecordEntity examRecord, Integer examedTimes, Long canExamTimes,
+    ExamRecordDataEntity createExamRecordData(ExamStudentEntity examStudent,
+                                              ExamBean examBean,
+                                              CourseBean courseBean,
+                                              String basePaperId,
+                                              String paperStructId, Integer examedTimes, Long canExamTimes,
                                               Boolean isReExamine, Boolean isFullyObjetive);
 
     List<ExamRecordDataEntity> findByStatusAndExamTypeIn(ExamRecordStatus examRecordStatus, List<String> examTypeList);
@@ -49,29 +56,27 @@ public interface ExamRecordDataService {
     /**
      * 创建进行中的考试记录
      *
-     * @param examRecordId
      * @param examRecordDataId
      * @param studentId
      */
-    void createExamingRecord(Long examRecordId, Long examRecordDataId, Long studentId, ExamType examType);
+    void createExamingRecord(Long examRecordDataId, Long studentId, ExamType examType);
 
     /**
      * 创建已交卷的考试记录
      *
-     * @param examRecordId
      * @param examRecordDataId
      * @param studentId
      */
-    void createHandInExamRecord(Long examRecordId, Long examRecordDataId, Long studentId);
+    void createHandInExamRecord(Long examRecordDataId, Long studentId);
 
     /**
      * 删除进行中考试记录id
      *
-     * @param examRecordId
+     * @param examRecordDataId
      */
-    void deleteExamingRecord(Long examRecordId);
+    void deleteExamingRecord(Long examRecordDataId);
 
-    void deleteHandInExamRecord(Long examRecordId);
+    void deleteHandInExamRecord(Long examRecordDataId);
 
     /**
      * 获取指定数量的考试中的数据
@@ -105,7 +110,11 @@ public interface ExamRecordDataService {
      * @param fullyObjective
      * @return
      */
-    ExamRecordDataEntity createOfflineExamRecordData(ExamRecordEntity examRecord, Boolean fullyObjective);
+    ExamRecordDataEntity createOfflineExamRecordData(ExamStudentEntity examStudent,
+                                                     ExamBean examBean,
+                                                     CourseBean courseBean,
+                                                     String basePaperId,
+                                                     String paperStructId, Boolean fullyObjective);
 
     /**
      * 违纪自动审核

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

@@ -1,28 +0,0 @@
-package cn.com.qmth.examcloud.core.oe.student.service;
-
-import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordEntity;
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamStudentEntity;
-import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
-
-/**
- * 
- * @author  	chenken
- * @date    	2018年9月1日 上午10:28:52
- * @company 	QMTH
- * @description 考试记录服务接口
- */
-public interface ExamRecordService {
-
-	/**
-	 * 开始考试,创建考试记录
-	 * @param examStudentEntity	考生
-	 * @param examBean			考试
-	 * @param courseBean		课程
-	 * @param basePaperId		基础试卷ID-题库
-	 * @param paperStructId		新试卷结构ID-网考
-	 * @return
-	 */
-	public ExamRecordEntity createExamRecord(ExamStudentEntity examStudent,ExamBean examBean,CourseBean courseBean,String basePaperId,String paperStructId);
-	
-}

+ 3 - 4
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/ExamScoreService.java

@@ -1,12 +1,11 @@
 package cn.com.qmth.examcloud.core.oe.student.service;
 
-import java.util.List;
-
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordDataEntity;
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordEntity;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamScoreEntity;
 import cn.com.qmth.examcloud.core.oe.student.bean.ObjectiveScoreInfo;
 
+import java.util.List;
+
 
 /**
  * 
@@ -18,7 +17,7 @@ import cn.com.qmth.examcloud.core.oe.student.bean.ObjectiveScoreInfo;
 public interface ExamScoreService {
 
 	
-	public ExamScoreEntity saveExamScore(ExamRecordEntity examRecord, ExamRecordDataEntity examRecordData);
+	public ExamScoreEntity saveExamScore(ExamRecordDataEntity examRecordData);
 	
 	/**
 	 * 离线考试初始化得分

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

@@ -98,9 +98,6 @@ public class ExamControlServiceImpl implements ExamControlService {
     @Autowired
     private ExamRecordQuestionsService examRecordQuestionsService;
 
-    @Autowired
-    private ExamRecordService examRecordService;
-
     @Autowired
     private ExamScoreService examScoreService;
 
@@ -139,8 +136,6 @@ public class ExamControlServiceImpl implements ExamControlService {
     private FileAnswerWebsocketCloudService fileAnswerWebsocketCloudService;
     @Autowired
     private ExamCaptureQueueRepo examCaptureQueueRepo;
-    @Autowired
-    private ExamRecordRepo examRecordRepo;
 
     @Value("${audio.app.url}")
     private String audioAppUrl;
@@ -254,15 +249,14 @@ public class ExamControlServiceImpl implements ExamControlService {
 
         // 生成考试记录
         startTime = System.currentTimeMillis();
-        ExamRecordEntity examRecord = examRecordService.createExamRecord(originalExamStudent, examBean, courseBean,
-                paperId, examRecordPaperStruct.getId());
-        ExamRecordDataEntity examRecordData = examRecordDataService.createExamRecordData(examRecord,
+        ExamRecordDataEntity examRecordData = examRecordDataService.createExamRecordData(originalExamStudent, examBean, courseBean,
+                paperId, examRecordPaperStruct.getId(),
                 examedTimes, examBean.getExamTimes(), originalExamStudent.getIsReExamine(),
                 extractConfigPaper.getDefaultPaper().getFullyObjective());
 
         //生成进行中的考试记录
-        examRecordDataService.createExamingRecord(examRecord.getId(), examRecordData.getId(),
-                examRecord.getStudentId(), examRecord.getExamType());
+        examRecordDataService.createExamingRecord(examRecordData.getId(),
+                examRecordData.getStudentId(), examRecordData.getExamType());
 
         if (log.isDebugEnabled()) {
             log.debug("8 生成考试记录耗时:" + (System.currentTimeMillis() - startTime) + " ms");
@@ -458,7 +452,6 @@ public class ExamControlServiceImpl implements ExamControlService {
     public void initializeExamRecordSession(final ExamStudentEntity examStudent,
                                             final ExamRecordDataEntity examRecordData, final ExamBean examBean) {
         ExamSessionInfo examSessionInfo = new ExamSessionInfo();
-        examSessionInfo.setExamRecordId(examRecordData.getExamRecordId());
         examSessionInfo.setExamRecordDataId(examRecordData.getId());
         examSessionInfo.setExamStudentId(examStudent.getExamStudentId());
         examSessionInfo.setStartTime(examRecordData.getStartTime().getTime());
@@ -606,7 +599,7 @@ public class ExamControlServiceImpl implements ExamControlService {
         }
         // 如果没有超过冻结时间,抛出异常
         if (examSessionInfo.getExamType().equals(ExamType.ONLINE.name())) {
-            ExamingRecordEntity rec = GlobalHelper.getEntity(examingRecordRepo, examSessionInfo.getExamRecordId(), ExamingRecordEntity.class);
+            ExamingRecordEntity rec = GlobalHelper.getEntity(examingRecordRepo, examSessionInfo.getExamRecordDataId(), ExamingRecordEntity.class);
 
             if (rec != null && rec.getIsExceed() != null && rec.getIsExceed()) {// 超过断点最大次数的不校验冻结时间
                 return usedTime;
@@ -641,7 +634,6 @@ public class ExamControlServiceImpl implements ExamControlService {
         long startTime = System.currentTimeMillis();
 
         ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
-        ExamRecordEntity examRecord = GlobalHelper.getEntity(examRecordRepo, examRecordData.getExamRecordId(), ExamRecordEntity.class);
         if (log.isDebugEnabled()) {
             log.debug("1  [HAND_IN_EXAM]获取考试记录耗时:" + (System.currentTimeMillis() - startTime) + " ms");
         }
@@ -649,7 +641,7 @@ public class ExamControlServiceImpl implements ExamControlService {
         if (handInExamType == HandInExamType.MANUAL) {
             startTime = System.currentTimeMillis();
             // 获取考试会话,判断考生是否已结束考试(二次校验)
-            ExamSessionInfo examSessionInfo = examSessionInfoService.getExamSessionInfo(examRecord.getStudentId());
+            ExamSessionInfo examSessionInfo = examSessionInfoService.getExamSessionInfo(examRecordData.getStudentId());
             if (examSessionInfo == null) {
                 throw new StatusException("oestudent-100100", "考试会话已过期");
             }
@@ -660,7 +652,7 @@ public class ExamControlServiceImpl implements ExamControlService {
             examRecordData.setEndTime(new Date());
 
             //手工手卷时,如果开启人脸检测,则更新抓拍队列优先级
-            String isFaceEnable = CacheHelper.getExamOrgProperty(examRecord.getExamId(), examRecord.getOrgId(),
+            String isFaceEnable = CacheHelper.getExamOrgProperty(examRecordData.getExamId(), examRecordData.getOrgId(),
                     ExamProperties.IS_FACE_ENABLE.name()).getValue();
             if (isFaceEnable != null && Constants.isTrue.equals(isFaceEnable)) {
                 //更新照片抓拍队列优先级为高优先级
@@ -678,7 +670,7 @@ public class ExamControlServiceImpl implements ExamControlService {
 
         startTime = System.currentTimeMillis();
         //将考试中的断点相关信息更新到考试记录表中
-        ExamingRecordEntity examingRecord = GlobalHelper.getEntity(examingRecordRepo, examRecordData.getExamRecordId(), ExamingRecordEntity.class);
+        ExamingRecordEntity examingRecord = GlobalHelper.getEntity(examingRecordRepo, examRecordData.getId(), ExamingRecordEntity.class);
         examRecordData.setIsContinued(examingRecord.getIsContinued());
         examRecordData.setContinuedCount(examingRecord.getContinuedCount());
         examRecordData.setIsExceed(examingRecord.getIsExceed());
@@ -691,7 +683,7 @@ public class ExamControlServiceImpl implements ExamControlService {
 
         startTime = System.currentTimeMillis();
         // 计算保存考试分数
-        examScoreService.saveExamScore(examRecord, examRecordData);
+        examScoreService.saveExamScore(examRecordData);
         if (log.isDebugEnabled()) {
             log.debug("3 [HAND_IN_EXAM]计算保存考试分数耗时:" + (System.currentTimeMillis() - startTime) + " ms");
         }
@@ -699,21 +691,21 @@ public class ExamControlServiceImpl implements ExamControlService {
 
         startTime = System.currentTimeMillis();
         //把进行中的考试记录放入交卷队列中
-        examRecordDataService.createHandInExamRecord(examRecord.getId(), examRecordData.getId(), examRecord.getStudentId());
+        examRecordDataService.createHandInExamRecord(examRecordData.getId(), examRecordData.getStudentId());
         if (log.isDebugEnabled()) {
             log.debug("4 [HAND_IN_EXAM]把进行中的考试记录放入交卷队列中耗时:" + (System.currentTimeMillis() - startTime) + " ms");
         }
 
         startTime = System.currentTimeMillis();
         //删除进行中的考试记录数据
-        examRecordDataService.deleteExamingRecord(examRecordData.getExamRecordId());
+        examRecordDataService.deleteExamingRecord(examRecordData.getId());
         if (log.isDebugEnabled()) {
             log.debug("5 [HAND_IN_EXAM]删除进行中的考试记录数据耗时:" + (System.currentTimeMillis() - startTime) + " ms");
         }
 
         startTime = System.currentTimeMillis();
         // 删除redis会话
-        examSessionInfoService.deleteExamSessionInfo(examRecord.getStudentId());
+        examSessionInfoService.deleteExamSessionInfo(examRecordData.getStudentId());
         if (log.isDebugEnabled()) {
             log.debug("6 [HAND_IN_EXAM]删除redis会话:" + (System.currentTimeMillis() - startTime) + " ms");
         }
@@ -774,7 +766,7 @@ public class ExamControlServiceImpl implements ExamControlService {
         examScoreObtainQueueService.saveExamScoreObtainQueue(examRecordData);
 
         //删除已交卷的考试记录数据
-        examRecordDataService.deleteHandInExamRecord(examRecordData.getExamRecordId());
+        examRecordDataService.deleteHandInExamRecord(examRecordData.getId());
 
         return true;
     }
@@ -941,7 +933,6 @@ public class ExamControlServiceImpl implements ExamControlService {
 
     @Override
     public void cleanHandInExamRecord(HandInExamRecordEntity handInExamRecord) {
-        ExamRecordEntity examRecord = GlobalHelper.getEntity(examRecordRepo, handInExamRecord.getId(), ExamRecordEntity.class);
         ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, handInExamRecord.getExamRecordDataId(), ExamRecordDataEntity.class);
 
         //只清理状态为已交卷的数据,才能执行交卷后续动作
@@ -956,7 +947,7 @@ public class ExamControlServiceImpl implements ExamControlService {
             }
             cleanExamRecordTaskLog.debug("[CLEAN_HAND_IN_EXAM_RECORD_" + examRecordData.getId() + "]开始执行交卷后续动作,.");
             try {
-                processAfterHandInExam(handInExamRecord.getExamRecordDataId(), examRecord.getStudentId(), handInExamType);
+                processAfterHandInExam(handInExamRecord.getExamRecordDataId(), examRecordData.getStudentId(), handInExamType);
             } catch (StatusException e) {
                 if (e.getCode().equals(Constants.CAPTURE_PROCESSING_STATUS_CODE)) {
                     cleanExamRecordTaskLog.debug("[CLEAN_HAND_IN_EXAM_RECORD_" + examRecordData.getId() + "]有未处理完成的图片,稍侯重试...");
@@ -1011,17 +1002,14 @@ public class ExamControlServiceImpl implements ExamControlService {
         // 保存考试分数数据到分数获取队列
         examScoreObtainQueueService.saveExamScoreObtainQueue(examRecordData);
         // 发送获取分数通知
-
-        ExamRecordEntity examRecord = GlobalHelper.getEntity(
-                examRecordRepo, examRecordData.getExamRecordId(), ExamRecordEntity.class);
-        examScoreObtainQueueService.sendObtainScoreNotify(examRecord.getRootOrgId());
+        examScoreObtainQueueService.sendObtainScoreNotify(examRecordData.getRootOrgId());
     }
 
     @Override
     public UpyunSignatureInfo getUpyunSignature(GetUpyunSignatureReq req) {
         UpyunSignatureInfo u = new UpyunSignatureInfo();
         try {
-            ExamRecordDataEntity reco = GlobalHelper.getEntity(examRecordDataRepo, Long.valueOf(req.getExamRecordDataId()), ExamRecordDataEntity.class);
+            ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, Long.valueOf(req.getExamRecordDataId()), ExamRecordDataEntity.class);
             String md5 = req.getFileMd5();
             Date signDate = null;
             Date now = new Date();
@@ -1029,11 +1017,9 @@ public class ExamControlServiceImpl implements ExamControlService {
 
             StringBuffer filePath = new StringBuffer();
 
-            ExamRecordEntity examRecord = GlobalHelper.getEntity(
-                    examRecordRepo, reco.getExamRecordId(), ExamRecordEntity.class);
-            filePath.append(SEPARATOR).append(OE_ANSWER_FILE_PATH).append(SEPARATOR).append(examRecord.getExamStudentId())
+            filePath.append(SEPARATOR).append(OE_ANSWER_FILE_PATH).append(SEPARATOR).append(examRecordData.getExamStudentId())
                     .append(SEPARATOR).append(req.getExamRecordDataId()).append(SEPARATOR).append(req.getOrder())
-                    .append(SEPARATOR).append(examRecord.getExamStudentId()).append(UNDERLINE)
+                    .append(SEPARATOR).append(examRecordData.getExamStudentId()).append(UNDERLINE)
                     .append(req.getExamRecordDataId()).append(UNDERLINE).append(req.getOrder()).append(UNDERLINE)
                     .append(System.currentTimeMillis())
                     .append(RandomUtils.nextInt(8999) + 1000);
@@ -1176,9 +1162,7 @@ public class ExamControlServiceImpl implements ExamControlService {
             //环境检测时,需要重新给考生id赋值
             ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, req.getExamRecordDataId(),
                     ExamRecordDataEntity.class);
-            ExamRecordEntity examingRecord = GlobalHelper.getEntity(examRecordRepo, examRecordData.getExamRecordId(),
-                    ExamRecordEntity.class);
-            req.setExamStudentId(examingRecord.getExamStudentId());
+            req.setExamStudentId(examRecordData.getExamStudentId());
         }
         String key = user.getKey();
         StringBuffer param = new StringBuffer();

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

@@ -1,10 +1,6 @@
 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.entity.ExamRecordEntity;
-import cn.com.qmth.examcloud.core.oe.common.enums.HandInExamType;
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordRepo;
-import cn.com.qmth.examcloud.core.oe.common.service.GainBaseDataService;
 import cn.com.qmth.examcloud.core.oe.common.base.Constants;
 import cn.com.qmth.examcloud.core.oe.common.base.utils.CommonUtil;
 import cn.com.qmth.examcloud.core.oe.common.base.utils.FileDisposeUtil;
@@ -13,9 +9,11 @@ import cn.com.qmth.examcloud.core.oe.common.entity.ExamFaceLivenessVerifyEntity;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordDataEntity;
 import cn.com.qmth.examcloud.core.oe.common.enums.ExamProperties;
 import cn.com.qmth.examcloud.core.oe.common.enums.FaceVerifyResult;
+import cn.com.qmth.examcloud.core.oe.common.enums.HandInExamType;
 import cn.com.qmth.examcloud.core.oe.common.enums.IsSuccess;
 import cn.com.qmth.examcloud.core.oe.common.repository.ExamFaceLivenessVerifyRepo;
 import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordDataRepo;
+import cn.com.qmth.examcloud.core.oe.common.service.GainBaseDataService;
 import cn.com.qmth.examcloud.core.oe.student.bean.GetFaceVerifyTokenInfo;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamControlService;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamFaceLivenessVerifyService;
@@ -25,15 +23,6 @@ import cn.com.qmth.examcloud.support.cache.CacheHelper;
 import cn.com.qmth.examcloud.support.cache.bean.StudentCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.SysPropertyCacheBean;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpEntity;
 import org.apache.http.client.methods.CloseableHttpResponse;
@@ -47,6 +36,14 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
 
 /**
  * @author chenken
@@ -77,9 +74,6 @@ public class ExamFaceLivenessVerifyServiceImpl implements ExamFaceLivenessVerify
     @Autowired
     private ExamControlService examControlService;
 
-    @Autowired
-    private ExamRecordRepo examRecordRepo;
-
     @Value("${$facepp.faceid.api_key}")
     private String faceIdApiKey;
 

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

@@ -1,6 +1,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.jpa.Searcher;
 import cn.com.qmth.examcloud.core.oe.common.base.jpa.SpecUtils;
@@ -77,9 +78,6 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
     @Autowired
     private ExamCaptureRepo examCaptureRepo;
 
-    @Autowired
-    private ExamRecordRepo examRecordRepo;
-
     @Autowired
     private ExamingRecordRepo examingRecordRepo;
     @Autowired
@@ -88,14 +86,38 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
     private static final Logger log = LoggerFactory.getLogger(ExamRecordDataServiceImpl.class);
 
     @Override
-    public ExamRecordDataEntity createExamRecordData(ExamRecordEntity examRecord, Integer examedTimes, Long canExamTimes,
+    public ExamRecordDataEntity createExamRecordData(ExamStudentEntity examStudent,
+                                                     ExamBean examBean,
+                                                     CourseBean courseBean,
+                                                     String basePaperId,
+                                                     String paperStructId, Integer examedTimes, Long canExamTimes,
                                                      Boolean isReExamine, Boolean isFullyObjetive) {
         ExamRecordDataEntity examRecordData = new ExamRecordDataEntity();
-        examRecordData.setExamRecordId(examRecord.getId());
+        examRecordData.setExamId(examBean.getId());
+        examRecordData.setExamType(ExamType.strToEnum(examBean.getExamType()));
+
+        examRecordData.setExamStudentId(examStudent.getExamStudentId());
+        examRecordData.setStudentId(examStudent.getStudentId());
+        examRecordData.setStudentCode(examStudent.getStudentCode());
+        examRecordData.setStudentName(examStudent.getStudentName());
+        examRecordData.setIdentityNumber(examStudent.getIdentityNumber());
+        examRecordData.setOrgId(examStudent.getOrgId());
+        examRecordData.setRootOrgId(examStudent.getRootOrgId());
+
+        examRecordData.setCourseId(courseBean.getId());
+        examRecordData.setCourseLevel(examStudent.getCourseLevel());
+        examRecordData.setBasePaperId(basePaperId);
+
+        examRecordData.setPaperType(examStudent.getPaperType());
+        examRecordData.setPaperStructId(paperStructId);
+
+        examRecordData.setInfoCollector(examStudent.getInfoCollector());
+
+//        examRecordData.setExamRecordDataId(examRecord.getId());
         examRecordData.setStartTime(new Date());
         examRecordData.setExamRecordStatus(ExamRecordStatus.EXAM_ING);
         //已考的考试次数
-        int finalExamedTimes=examedTimes==null?0:examedTimes.intValue();
+        int finalExamedTimes = examedTimes == null ? 0 : examedTimes.intValue();
         //考试机会
         int finalCanExamTimes = canExamTimes == null ? 0 : canExamTimes.intValue();
         boolean finalIsReExamine = isReExamine == null ? false : isReExamine;
@@ -122,10 +144,10 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
     }
 
     @Override
-    public void createExamingRecord(Long examRecordId, Long examRecordDataId, Long studentId, ExamType examType) {
+    public void createExamingRecord(Long examRecordDataId, Long studentId, ExamType examType) {
         ExamingRecordEntity examingRecord = new ExamingRecordEntity();
         examingRecord.setStudentId(studentId);
-        examingRecord.setId(examRecordId);
+        examingRecord.setId(examRecordDataId);
         examingRecord.setExamRecordDataId(examRecordDataId);
         examingRecord.setExamType(examType);
         examingRecord.setIsContinued(false);
@@ -134,22 +156,22 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
     }
 
     @Override
-    public void createHandInExamRecord(Long examRecordId, Long examRecordDataId, Long studentId) {
+    public void createHandInExamRecord(Long examRecordDataId, Long studentId) {
         HandInExamRecordEntity handInExamRecord = new HandInExamRecordEntity();
         handInExamRecord.setStudentId(studentId);
-        handInExamRecord.setId(examRecordId);
+        handInExamRecord.setId(examRecordDataId);
         handInExamRecord.setExamRecordDataId(examRecordDataId);
         handInExamRecordRepo.save(handInExamRecord);
     }
 
     @Override
-    public void deleteExamingRecord(Long examRecordId) {
-        examingRecordRepo.deleteById(examRecordId);
+    public void deleteExamingRecord(Long examRecordDataId) {
+        examingRecordRepo.deleteById(examRecordDataId);
     }
 
     @Override
-    public void deleteHandInExamRecord(Long examRecordId) {
-        handInExamRecordRepo.deleteById(examRecordId);
+    public void deleteHandInExamRecord(Long examRecordDataId) {
+        handInExamRecordRepo.deleteById(examRecordDataId);
     }
 
     @Override
@@ -175,10 +197,8 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
                 setExamRecordWithFaceLivenessVerifyFailed(examRecordDataEntity, faceVerifies);
             }
         } else {
-            ExamRecordEntity examRecord = GlobalHelper.getEntity(
-                    examRecordRepo, examRecordDataEntity.getExamRecordId(), ExamRecordEntity.class);
-            Long examId = examRecord.getExamId();
-            String isFaceVerify = CacheHelper.getExamOrgProperty(examId, examRecord.getOrgId(),
+            Long examId = examRecordDataEntity.getExamId();
+            String isFaceVerify = CacheHelper.getExamOrgProperty(examId, examRecordDataEntity.getOrgId(),
                     ExamProperties.IS_FACE_VERIFY.name()).getValue();
 
             //是否进行活体检测
@@ -230,10 +250,8 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
     @Override
     public CalculateFaceCheckResultInfo calculateFaceCheckResult(ExamRecordDataEntity examRecordData) {
         CalculateFaceCheckResultInfo calculateFaceCheckResultInfo = new CalculateFaceCheckResultInfo();
-        ExamRecordEntity examRecord = GlobalHelper.getEntity(
-                examRecordRepo, examRecordData.getExamRecordId(), ExamRecordEntity.class);
-        Long examId = examRecord.getExamId();
-        String isFaceEnable = CacheHelper.getExamOrgProperty(examId, examRecord.getOrgId(),
+        Long examId = examRecordData.getExamId();
+        String isFaceEnable = CacheHelper.getExamOrgProperty(examId, examRecordData.getOrgId(),
                 ExamProperties.IS_FACE_ENABLE.name()).getValue();
         //未开启人脸检测
         if (!Constants.isTrue.equals(isFaceEnable)) {
@@ -258,14 +276,14 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
             return calculateFaceCheckResultInfo;
         }
         //人脸识别阀值
-        String warnThresholdStr = CacheHelper.getExamOrgProperty(examId, examRecord.getOrgId(),
+        String warnThresholdStr = CacheHelper.getExamOrgProperty(examId, examRecordData.getOrgId(),
                 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, examRecord.getOrgId(),
+        String liveWarnThresholdStr = CacheHelper.getExamOrgProperty(examId, examRecordData.getOrgId(),
                 ExamProperties.LIVING_WARN_THRESHOLD.name()).getValue();
         if (CommonUtil.isBlank(liveWarnThresholdStr)) {
             throw new StatusException("ExamRecordDataServiceImpl-calculateFaceCheckResult-002", ExamProperties.LIVING_WARN_THRESHOLD.getDesc() + "未设置");
@@ -386,9 +404,32 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
     }
 
     @Override
-    public ExamRecordDataEntity createOfflineExamRecordData(ExamRecordEntity examRecord, Boolean fullyObjective) {
+    public ExamRecordDataEntity createOfflineExamRecordData(ExamStudentEntity examStudent,
+                                                            ExamBean examBean,
+                                                            CourseBean courseBean,
+                                                            String basePaperId,
+                                                            String paperStructId, Boolean fullyObjective) {
         ExamRecordDataEntity examRecordDataEntity = new ExamRecordDataEntity();
-        examRecordDataEntity.setExamRecordId(examRecord.getId());
+        examRecordDataEntity.setExamId(examBean.getId());
+        examRecordDataEntity.setExamType(ExamType.strToEnum(examBean.getExamType()));
+
+        examRecordDataEntity.setExamStudentId(examStudent.getExamStudentId());
+        examRecordDataEntity.setStudentId(examStudent.getStudentId());
+        examRecordDataEntity.setStudentCode(examStudent.getStudentCode());
+        examRecordDataEntity.setStudentName(examStudent.getStudentName());
+        examRecordDataEntity.setIdentityNumber(examStudent.getIdentityNumber());
+        examRecordDataEntity.setOrgId(examStudent.getOrgId());
+        examRecordDataEntity.setRootOrgId(examStudent.getRootOrgId());
+
+        examRecordDataEntity.setCourseId(courseBean.getId());
+        examRecordDataEntity.setCourseLevel(examStudent.getCourseLevel());
+        examRecordDataEntity.setBasePaperId(basePaperId);
+
+        examRecordDataEntity.setPaperType(examStudent.getPaperType());
+        examRecordDataEntity.setPaperStructId(paperStructId);
+
+        examRecordDataEntity.setInfoCollector(examStudent.getInfoCollector());
+//        examRecordDataEntity.setExamRecordDataId(examRecord.getId());
         examRecordDataEntity.setStartTime(new Date());
         examRecordDataEntity.setExamRecordStatus(ExamRecordStatus.EXAM_ING);
         examRecordDataEntity.setExamOrder(1);

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

@@ -1,15 +1,5 @@
 package cn.com.qmth.examcloud.core.oe.student.service.impl;
 
-import java.util.Date;
-
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordEntity;
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordRepo;
-import main.java.com.UpYun;
-
-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.common.entity.ExamRecordDataEntity;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordForMarkingEntity;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamScoreEntity;
@@ -19,6 +9,12 @@ import cn.com.qmth.examcloud.core.oe.common.repository.ExamScoreRepo;
 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.web.helpers.GlobalHelper;
+import main.java.com.UpYun;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
 
 @Service("examRecordForMarkingService")
 public class ExamRecordForMarkingServiceImpl implements ExamRecordForMarkingService {
@@ -35,9 +31,6 @@ public class ExamRecordForMarkingServiceImpl implements ExamRecordForMarkingServ
 	@Autowired
 	private ExamScoreRepo examScoreRepo;
 
-	@Autowired
-	private ExamRecordRepo examRecordRepo;
-	
 	@Value("${$upyun.site.1.bucketName}")
     private String bucketName;
 	
@@ -78,15 +71,13 @@ public class ExamRecordForMarkingServiceImpl implements ExamRecordForMarkingServ
     	}
 
 
-		ExamRecordEntity examRecord =GlobalHelper.getEntity(
-				examRecordRepo,examRecordData.getExamRecordId(),ExamRecordEntity.class);
 		ExamRecordForMarkingEntity examRecordForMarking = new ExamRecordForMarkingEntity();
-        examRecordForMarking.setExamId(examRecord.getExamId());
+        examRecordForMarking.setExamId(examRecordData.getExamId());
         examRecordForMarking.setExamRecordDataId(examRecordData.getId());
-        examRecordForMarking.setExamStudentId(examRecord.getExamStudentId());
-        examRecordForMarking.setBasePaperId(examRecord.getBasePaperId());
-        examRecordForMarking.setPaperType(examRecord.getPaperType());
-        examRecordForMarking.setCourseId(examRecord.getCourseId());
+        examRecordForMarking.setExamStudentId(examRecordData.getExamStudentId());
+        examRecordForMarking.setBasePaperId(examRecordData.getBasePaperId());
+        examRecordForMarking.setPaperType(examRecordData.getPaperType());
+        examRecordForMarking.setCourseId(examRecordData.getCourseId());
         examRecordForMarking.setObjectiveScore(objectiveQuestionTotalScore);
 
         int subjectiveAnswerLength = examRecordQuestionsService.calculationSubjectiveAnswerLength(examRecordData.getId());
@@ -109,18 +100,16 @@ public class ExamRecordForMarkingServiceImpl implements ExamRecordForMarkingServ
 			upyun.deleteFile(offlineFileUrl);
 		}
 
-		ExamRecordEntity examRecord =GlobalHelper.getEntity(
-				examRecordRepo,examRecordData.getExamRecordId(),ExamRecordEntity.class);
-        examRecordForMarking.setExamId(examRecord.getExamId());
+        examRecordForMarking.setExamId(examRecordData.getExamId());
         examRecordForMarking.setExamRecordDataId(examRecordData.getId());
-        examRecordForMarking.setExamStudentId(examRecord.getExamStudentId());
-        examRecordForMarking.setCourseId(examRecord.getCourseId());
+        examRecordForMarking.setExamStudentId(examRecordData.getExamStudentId());
+        examRecordForMarking.setCourseId(examRecordData.getCourseId());
         examRecordForMarking.setOfflineFileUrl(fileUrl);
         examRecordForMarking.setOfflineFileName(offlineFileName);
         examRecordForMarking.setObjectiveScore(0D);
         examRecordForMarking.setSubjectiveAnswerLength(0);
-        examRecordForMarking.setBasePaperId(examRecord.getBasePaperId());
-        examRecordForMarking.setPaperType(examRecord.getPaperType());
+        examRecordForMarking.setBasePaperId(examRecordData.getBasePaperId());
+        examRecordForMarking.setPaperType(examRecordData.getPaperType());
         examRecordForMarking.setUpdateTime(new Date());
         examRecordForMarkingRepo.save(examRecordForMarking);
 	}

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

@@ -1,16 +1,13 @@
 package cn.com.qmth.examcloud.core.oe.student.service.impl;
 
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordEntity;
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordRepo;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
 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.repository.ExamRecordDataRepo;
 import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordPaperStructRepo;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordPaperStructService;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 
 /**
  * 
@@ -27,13 +24,10 @@ public class ExamRecordPaperStructServiceImpl implements ExamRecordPaperStructSe
 	
 	@Autowired
 	private ExamRecordPaperStructRepo examRecordPaperStructRepo;
-	@Autowired
-	private ExamRecordRepo examRecordRepo;
 	@Override
 	public ExamRecordPaperStructEntity getExamRecordPaperStruct(Long examRecordDataId) {
 		ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo,examRecordDataId,ExamRecordDataEntity.class);
-		ExamRecordEntity examRecord =GlobalHelper.getEntity(examRecordRepo,examRecordData.getExamRecordId(),ExamRecordEntity.class);
-		return GlobalHelper.getEntity(examRecordPaperStructRepo,examRecord.getPaperStructId(),ExamRecordPaperStructEntity.class);
+		return GlobalHelper.getEntity(examRecordPaperStructRepo,examRecordData.getPaperStructId(),ExamRecordPaperStructEntity.class);
 	}
 
 }

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

@@ -1,56 +0,0 @@
-package cn.com.qmth.examcloud.core.oe.student.service.impl;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordEntity;
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamStudentEntity;
-import cn.com.qmth.examcloud.core.oe.common.enums.ExamType;
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordRepo;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordService;
-import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
-
-/**
- * 
- * @author  	chenken
- * @date    	2018年9月1日 上午10:25:41
- * @company 	QMTH
- * @description 考试记录服务实现
- */
-@Service("examRecordService")
-public class ExamRecordServiceImpl implements ExamRecordService{
-	
-	@Autowired
-	private ExamRecordRepo examRecordRepo;
-
-	@Override
-	public ExamRecordEntity createExamRecord(ExamStudentEntity examStudent, 
-											 ExamBean examBean,
-											 CourseBean courseBean, 
-											 String basePaperId,
-											 String paperStructId) {
-		ExamRecordEntity examRecordEntity = new ExamRecordEntity();
-        examRecordEntity.setExamId(examBean.getId());
-        examRecordEntity.setExamType(ExamType.strToEnum(examBean.getExamType()));
-        
-        examRecordEntity.setExamStudentId(examStudent.getExamStudentId());
-        examRecordEntity.setStudentId(examStudent.getStudentId());
-        examRecordEntity.setStudentCode(examStudent.getStudentCode());
-        examRecordEntity.setStudentName(examStudent.getStudentName());
-        examRecordEntity.setIdentityNumber(examStudent.getIdentityNumber());
-        examRecordEntity.setOrgId(examStudent.getOrgId());
-        examRecordEntity.setRootOrgId(examStudent.getRootOrgId());
-        
-        examRecordEntity.setCourseId(courseBean.getId());
-        examRecordEntity.setCourseLevel(examStudent.getCourseLevel());
-        examRecordEntity.setBasePaperId(basePaperId);
-        
-        examRecordEntity.setPaperType(examStudent.getPaperType());
-        examRecordEntity.setPaperStructId(paperStructId);
-        
-        examRecordEntity.setInfoCollector(examStudent.getInfoCollector());
-        return examRecordRepo.save(examRecordEntity);
-	}
-
-}

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

@@ -1,7 +1,10 @@
 package cn.com.qmth.examcloud.core.oe.student.service.impl;
 
 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.entity.ExamQuestionEntity;
+import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordDataEntity;
+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.enums.ExamRecordStatus;
 import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordDataRepo;
 import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordQuestionsRepo;
@@ -12,12 +15,9 @@ import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordDataService;
 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.question.commons.core.question.DefaultQuestionStructure;
-import cn.com.qmth.examcloud.question.commons.core.question.DefaultQuestionUnit;
 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.QuestionAnswerCacheBean;
-import cn.com.qmth.examcloud.support.cache.bean.QuestionCacheBean;
 import cn.com.qmth.examcloud.web.redis.RedisClient;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -72,7 +72,7 @@ public class ExamScoreServiceImpl implements ExamScoreService {
      * @return
      */
     @Override
-    public ExamScoreEntity saveExamScore(final ExamRecordEntity examRecord, ExamRecordDataEntity examRecordData) {
+    public ExamScoreEntity saveExamScore(ExamRecordDataEntity examRecordData) {
         long st = System.currentTimeMillis();
         long startTime = System.currentTimeMillis();
         //获取考试作答记录并修复考试记录数据(如有必要)
@@ -91,13 +91,13 @@ public class ExamScoreServiceImpl implements ExamScoreService {
         //是否需要更新客观题答案
         Boolean needUpdateObjectiveAnswer=false;
         //获取考试会话
-        ExamSessionInfo examSessionInfo = examSessionInfoService.getExamSessionInfo(examRecord.getStudentId());
+        ExamSessionInfo examSessionInfo = examSessionInfoService.getExamSessionInfo(examRecordData.getStudentId());
         for (int i = 0; i < examQuestionList.size(); i++) {
             ExamQuestionEntity examQuestionEntity = examQuestionList.get(i);
             String courseCode;
             //自动服务交卷时,会话可能已经过期,需要重新查询课程
             if (examSessionInfo == null) {
-                CourseCacheBean courseCache = CacheHelper.getCourse(examRecord.getCourseId());
+                CourseCacheBean courseCache = CacheHelper.getCourse(examRecordData.getCourseId());
                 courseCode = courseCache.getCode();
             }
             //会话未过期,可以直接从会话中获取
@@ -112,7 +112,7 @@ public class ExamScoreServiceImpl implements ExamScoreService {
                 //如果标准答案为空,则更新标准答案
                 if (StringUtils.isEmpty(examQuestionEntity.getCorrectAnswer())) {
                     needUpdateObjectiveAnswer=true;
-                    updateCorrectAnswer(examRecord.getExamId(),courseCode,examRecord.getPaperType(),
+                    updateCorrectAnswer(examRecordData.getExamId(),courseCode,examRecordData.getPaperType(),
                             examQuestionEntity.getQuestionId(),examRecordQuestionsEntity);
                 }
 

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

@@ -31,7 +31,7 @@ public class ExamSessionInfoServiceImpl implements ExamSessionInfoService {
         log.debug("11.4.1 进入开始保存考试会话方法,redisKey="+examRedisKeyPrefix+studentId);
         redisClient.set(examRedisKeyPrefix+studentId,examSessionInfo,timeout);
         ExamSessionInfo sessionInfo =redisClient.get(examRedisKeyPrefix+studentId,ExamSessionInfo.class);
-        log.debug("11.4.2 保存考试会话方法完成,尝试取一下值 ="+sessionInfo.getExamRecordId());
+        log.debug("11.4.2 保存考试会话方法完成,尝试取一下值 ="+sessionInfo.getExamRecordDataId());
     }
 
     @Override

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

@@ -2,16 +2,13 @@ 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.basic.api.bean.OrgBean;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordDataEntity;
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordEntity;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordForMarkingEntity;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamStudentEntity;
 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.repository.ExamRecordDataRepo;
 import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordForMarkingRepo;
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordRepo;
 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.OfflineExamCourseInfo;
@@ -36,139 +33,132 @@ import java.util.Date;
 import java.util.List;
 
 /**
- * 
- * @author  	chenken
- * @date    	2018年9月5日 下午3:24:44
- * @company 	QMTH
+ * @author chenken
+ * @date 2018年9月5日 下午3:24:44
+ * @company QMTH
  * @description 离线考试服务实现
  */
 @Service("offlineExamService")
 public class OfflineExamServiceImpl implements OfflineExamService {
-	
-	@Autowired
-	private ExamStudentRepo examStudentRepo;
-	
-	@Autowired
-	private ExamRecordDataRepo examRecordDataRepo;
-	
-	@Autowired
-	public ExamRecordRepo examRecordRepo;
-	
+
+    @Autowired
+    private ExamStudentRepo examStudentRepo;
+
+    @Autowired
+    private ExamRecordDataRepo examRecordDataRepo;
+
     @Autowired
     private GainBaseDataService gainBaseDataService;
-	
-	@Autowired
+
+    @Autowired
     private ExtractConfigCloudService extractConfigCloudService;
-	
-	@Autowired
-    private ExamRecordService examRecordService;
-	
-	@Autowired
+
+    @Autowired
     private ExamRecordDataService examRecordDataService;
-	
-	@Autowired
-	private ExamScoreService examScoreService;
-	
-	@Autowired
-	private ExamRecordForMarkingService examRecordForMarkingService;
-	
-	@Autowired
-	private ExamRecordForMarkingRepo examRecordForMarkingRepo;
 
-	@Value("${$upyun.site.1.bucketName}")
+    @Autowired
+    private ExamScoreService examScoreService;
+
+    @Autowired
+    private ExamRecordForMarkingService examRecordForMarkingService;
+
+    @Autowired
+    private ExamRecordForMarkingRepo examRecordForMarkingRepo;
+
+    @Value("${$upyun.site.1.bucketName}")
     private String bucketName;
-	
-	@Value("${$upyun.site.1.userName}")
-	private String userName;
-	
-	@Value("${$upyun.site.1.password}")
-	private String password;
-	
-	@Value("${app.upyun.uploadUrl}")
-	private String upyunUploadUrl;
-	
-	@Value("${$upyun.site.1.domain}")
-	private String upyunFileUrl;
-	
-	@Override
-	public List<OfflineExamCourseInfo> getOfflineCourse(Long studentId) {
-		List<ExamStudentEntity> examStudents = examStudentRepo.findByStudentId(studentId);
-		List<OfflineExamCourseInfo> offlineExamCourseInfoList = new ArrayList<OfflineExamCourseInfo>();
-		for(ExamStudentEntity examStudent:examStudents){
-			ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudent.getExamId(),
-					examStudent.getOrgId());
-			if(!ExamType.OFFLINE.name().equals(examBean.getExamType())){
-				continue;
-			}
-			if(!examBean.getEnable() || (examBean.getExamLimit() !=null && examBean.getExamLimit())){
-				continue;
-	        }
-	        if(new Date().before(examBean.getBeginTime()) || examBean.getEndTime().before(new Date())){
-	        	continue;
-	        }
-	        offlineExamCourseInfoList.add(toOfflineExamCourse(examStudent,examBean));
-		}
-		return offlineExamCourseInfoList;
-	}
-	private OfflineExamCourseInfo toOfflineExamCourse(ExamStudentEntity examStudent,ExamBean examBean) {
-		OfflineExamCourseInfo offlineExamCourseInfo = new OfflineExamCourseInfo();
-		
-		CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examStudent.getCourseId());
-		offlineExamCourseInfo.setCourseCode(courseBean.getCode());
-		offlineExamCourseInfo.setCourseLevel(courseBean.getLevel());
-		offlineExamCourseInfo.setCourseName(courseBean.getName());
-		offlineExamCourseInfo.setExamId(examBean.getId());
-		offlineExamCourseInfo.setExamName(examBean.getName());
-		offlineExamCourseInfo.setSpecialtyName(examStudent.getSpecialtyName());
-		offlineExamCourseInfo.setExamStudentId(examStudent.getExamStudentId());
-		offlineExamCourseInfo.setStudentCode(examStudent.getStudentCode());
-		offlineExamCourseInfo.setStudentName(examStudent.getStudentName());
-		offlineExamCourseInfo.setStartTime(examBean.getBeginTime());
-		offlineExamCourseInfo.setEndTime(examBean.getEndTime());
-		Date nowDate = new Date();
-        if(nowDate.getTime()>offlineExamCourseInfo.getStartTime().getTime()
-        				&&nowDate.getTime()<offlineExamCourseInfo.getEndTime().getTime()){
-        	offlineExamCourseInfo.setIsvalid(true);
-        }else{
-        	offlineExamCourseInfo.setIsvalid(false);
+
+    @Value("${$upyun.site.1.userName}")
+    private String userName;
+
+    @Value("${$upyun.site.1.password}")
+    private String password;
+
+    @Value("${app.upyun.uploadUrl}")
+    private String upyunUploadUrl;
+
+    @Value("${$upyun.site.1.domain}")
+    private String upyunFileUrl;
+
+    @Override
+    public List<OfflineExamCourseInfo> getOfflineCourse(Long studentId) {
+        List<ExamStudentEntity> examStudents = examStudentRepo.findByStudentId(studentId);
+        List<OfflineExamCourseInfo> offlineExamCourseInfoList = new ArrayList<OfflineExamCourseInfo>();
+        for (ExamStudentEntity examStudent : examStudents) {
+            ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudent.getExamId(),
+                    examStudent.getOrgId());
+            if (!ExamType.OFFLINE.name().equals(examBean.getExamType())) {
+                continue;
+            }
+            if (!examBean.getEnable() || (examBean.getExamLimit() != null && examBean.getExamLimit())) {
+                continue;
+            }
+            if (new Date().before(examBean.getBeginTime()) || examBean.getEndTime().before(new Date())) {
+                continue;
+            }
+            offlineExamCourseInfoList.add(toOfflineExamCourse(examStudent, examBean));
         }
+        return offlineExamCourseInfoList;
+    }
+
+    private OfflineExamCourseInfo toOfflineExamCourse(ExamStudentEntity examStudent, ExamBean examBean) {
+        OfflineExamCourseInfo offlineExamCourseInfo = new OfflineExamCourseInfo();
+
+        CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examStudent.getCourseId());
+        offlineExamCourseInfo.setCourseCode(courseBean.getCode());
+        offlineExamCourseInfo.setCourseLevel(courseBean.getLevel());
+        offlineExamCourseInfo.setCourseName(courseBean.getName());
+        offlineExamCourseInfo.setExamId(examBean.getId());
+        offlineExamCourseInfo.setExamName(examBean.getName());
+        offlineExamCourseInfo.setSpecialtyName(examStudent.getSpecialtyName());
+        offlineExamCourseInfo.setExamStudentId(examStudent.getExamStudentId());
+        offlineExamCourseInfo.setStudentCode(examStudent.getStudentCode());
+        offlineExamCourseInfo.setStudentName(examStudent.getStudentName());
+        offlineExamCourseInfo.setStartTime(examBean.getBeginTime());
+        offlineExamCourseInfo.setEndTime(examBean.getEndTime());
+        Date nowDate = new Date();
+        if (nowDate.getTime() > offlineExamCourseInfo.getStartTime().getTime()
+                && nowDate.getTime() < offlineExamCourseInfo.getEndTime().getTime()) {
+            offlineExamCourseInfo.setIsvalid(true);
+        } else {
+            offlineExamCourseInfo.setIsvalid(false);
+        }
+
+        OrgCacheBean orgBean = gainBaseDataService.getOrgBean(examStudent.getOrgId());
+        offlineExamCourseInfo.setOrgName(orgBean.getName());
 
-		OrgCacheBean orgBean = gainBaseDataService.getOrgBean(examStudent.getOrgId());
-		offlineExamCourseInfo.setOrgName(orgBean.getName());
-        
-		List<ExamRecordEntity> examRecords = examRecordRepo.findByExamStudentId(examStudent.getExamStudentId());
-		if(examRecords.size()>0){
-			ExamRecordEntity examRecord = examRecords.get(0);
-			ExamRecordDataEntity examRecordDataEntity = examRecordDataRepo.findByExamRecordId(examRecord.getId());
-			offlineExamCourseInfo.setExamRecordDataId(examRecordDataEntity.getId());
-			offlineExamCourseInfo.setStatus(examRecordDataEntity.getExamRecordStatus());
-			offlineExamCourseInfo.setPaperId(examRecord.getBasePaperId());
-			if(examRecordDataEntity.getExamRecordStatus() == ExamRecordStatus.EXAM_END){
-				ExamRecordForMarkingEntity examRecordForMarkingEntity = examRecordForMarkingRepo.findByExamRecordDataId(examRecordDataEntity.getId());
-				offlineExamCourseInfo.setOfflineFileUrl(examRecordForMarkingEntity.getOfflineFileUrl());
-				offlineExamCourseInfo.setFileName(examRecordForMarkingEntity.getOfflineFileName());
-			}
-		}
-		return offlineExamCourseInfo;
-	}
+        List<ExamRecordDataEntity> examRecords = examRecordDataRepo.findByExamStudentId(examStudent.getExamStudentId());
+        if (examRecords.size() > 0) {
+            ExamRecordDataEntity examRecordDataEntity = examRecords.get(0);
+            offlineExamCourseInfo.setExamRecordDataId(examRecordDataEntity.getId());
+            offlineExamCourseInfo.setStatus(examRecordDataEntity.getExamRecordStatus());
+            offlineExamCourseInfo.setPaperId(examRecordDataEntity.getBasePaperId());
+            if (examRecordDataEntity.getExamRecordStatus() == ExamRecordStatus.EXAM_END) {
+                ExamRecordForMarkingEntity examRecordForMarkingEntity = examRecordForMarkingRepo.findByExamRecordDataId(examRecordDataEntity.getId());
+                offlineExamCourseInfo.setOfflineFileUrl(examRecordForMarkingEntity.getOfflineFileUrl());
+                offlineExamCourseInfo.setFileName(examRecordForMarkingEntity.getOfflineFileName());
+            }
+        }
+        return offlineExamCourseInfo;
+    }
 
-	@Override
-	public void startOfflineExam(Long examStudentId) {
-		SysPropertyCacheBean stuClientLoginLimit = CacheHelper.getSysProperty("STU_CLIENT_LOGIN_LIMIT");
-		Boolean stuClientLoginLimitBoolean=false;
-		if (stuClientLoginLimit.getHasValue()){
-			stuClientLoginLimitBoolean= Boolean.valueOf(stuClientLoginLimit.getValue().toString());
-		}
-    	if (stuClientLoginLimitBoolean) {
-			throw new StatusException("OE-001505", "系统维护中... ...");
-		}
-		List<ExamRecordEntity> examRecordList = examRecordRepo.findByExamStudentId(examStudentId);
-        if(examRecordList!=null && examRecordList.size()>0){
-        	throw new StatusException("OfflineExamServiceImpl-startOfflineExam-exception","已经存在examStudentId="+examStudentId+"的离线考试记录");
+    @Override
+    public void startOfflineExam(Long examStudentId) {
+        SysPropertyCacheBean stuClientLoginLimit = CacheHelper.getSysProperty("STU_CLIENT_LOGIN_LIMIT");
+        Boolean stuClientLoginLimitBoolean = false;
+        if (stuClientLoginLimit.getHasValue()) {
+            stuClientLoginLimitBoolean = Boolean.valueOf(stuClientLoginLimit.getValue().toString());
+        }
+        if (stuClientLoginLimitBoolean) {
+            throw new StatusException("OE-001505", "系统维护中... ...");
         }
-		//获取考生信息
-		ExamStudentEntity examStudentEntity = examStudentRepo.findByExamStudentId(examStudentId);
-		//检查并获取课程信息
+        List<ExamRecordDataEntity> examRecordList = examRecordDataRepo.findByExamStudentId(examStudentId);
+        if (examRecordList != null && examRecordList.size() > 0) {
+            throw new StatusException("OfflineExamServiceImpl-startOfflineExam-exception", "已经存在examStudentId=" + examStudentId + "的离线考试记录");
+        }
+        //获取考生信息
+        ExamStudentEntity examStudentEntity = examStudentRepo.findByExamStudentId(examStudentId);
+        //检查并获取课程信息
         CourseBean courseBean = checkCourse(examStudentEntity);
         //检查并获取考试信息
         ExamBean examBean = checkExam(examStudentEntity);
@@ -180,84 +170,83 @@ public class OfflineExamServiceImpl implements OfflineExamService {
         GetPaperResp getPaperResp = extractConfigCloudService.getPaper(getPaperReq);
 
         //生成考试记录
-        ExamRecordEntity examRecord = examRecordService.createExamRecord(examStudentEntity,examBean,courseBean,getPaperResp.getPaperId(),null);
-        ExamRecordDataEntity examRecordData = examRecordDataService.createOfflineExamRecordData(examRecord,getPaperResp.getDefaultPaper().getFullyObjective());
+        ExamRecordDataEntity examRecordData = examRecordDataService.createOfflineExamRecordData(examStudentEntity,
+                examBean, courseBean, getPaperResp.getPaperId(),
+                null, getPaperResp.getDefaultPaper().getFullyObjective());
         //生成分数
         examScoreService.createExamScoreWithOffline(examRecordData.getId());
         //更新考生
         examStudentRepo.updateExamStudentFinished(examStudentId);
-	}
-	
-	private CourseBean checkCourse(ExamStudentEntity examStudentEntity) {
+    }
+
+    private CourseBean checkCourse(ExamStudentEntity examStudentEntity) {
         CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examStudentEntity.getCourseId());
-        if(!courseBean.getEnable()){
-            throw new StatusException("OfflineExamServiceImpl-checkCourse-exception","该课程已被禁用");
+        if (!courseBean.getEnable()) {
+            throw new StatusException("OfflineExamServiceImpl-checkCourse-exception", "该课程已被禁用");
         }
         return courseBean;
-	}
-	
-	private ExamBean checkExam(ExamStudentEntity examStudentEntity) {
-		ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudentEntity.getExamId(),
-				examStudentEntity.getOrgId());
+    }
 
-		if(!examBean.getEnable() || (examBean.getExamLimit() !=null && examBean.getExamLimit())){
-        	throw new StatusException("ExamControlServiceImpl-checkExam-exception-01","暂无考试资格,请与学校老师联系");
+    private ExamBean checkExam(ExamStudentEntity examStudentEntity) {
+        ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudentEntity.getExamId(),
+                examStudentEntity.getOrgId());
+
+        if (!examBean.getEnable() || (examBean.getExamLimit() != null && examBean.getExamLimit())) {
+            throw new StatusException("ExamControlServiceImpl-checkExam-exception-01", "暂无考试资格,请与学校老师联系");
         }
-        if(new Date().before(examBean.getBeginTime())){
-        	throw new StatusException("ExamControlServiceImpl-checkExam-exception-02","考试未开始");
+        if (new Date().before(examBean.getBeginTime())) {
+            throw new StatusException("ExamControlServiceImpl-checkExam-exception-02", "考试未开始");
         }
-        if(examBean.getEndTime().before(new Date())){
-        	throw new StatusException("ExamControlServiceImpl-checkExam-exception-03","本次考试已结束");
+        if (examBean.getEndTime().before(new Date())) {
+            throw new StatusException("ExamControlServiceImpl-checkExam-exception-03", "本次考试已结束");
         }
         return examBean;
-	}
+    }
 
-	@Override
-	@Transactional
-	public void submitPaper(Long examRecordDataId, File tempFile) throws Exception {
-		SysPropertyCacheBean stuClientLoginLimit = CacheHelper.getSysProperty("STU_CLIENT_LOGIN_LIMIT");
-		Boolean stuClientLoginLimitBoolean=false;
-		if (stuClientLoginLimit.getHasValue()){
-			stuClientLoginLimitBoolean= Boolean.valueOf(stuClientLoginLimit.getValue().toString());
-		}
-    	if (stuClientLoginLimitBoolean) {
-			throw new StatusException("OE-001505", "系统维护中... ...");
-		}
-		ExamRecordDataEntity examRecordDataEntity = GlobalHelper.getEntity(examRecordDataRepo,examRecordDataId,ExamRecordDataEntity.class);
-		if(examRecordDataEntity == null){
-			return;
-		}
-		String fileName = tempFile.getName();
-		String fileSuffix = fileName.substring(fileName.lastIndexOf(".")+1, fileName.length()).toLowerCase();
-		//上传文件至又拍云
-		String fileNewName = createOfflineFileName(examRecordDataEntity)+"."+fileSuffix;
+    @Override
+    @Transactional
+    public void submitPaper(Long examRecordDataId, File tempFile) throws Exception {
+        SysPropertyCacheBean stuClientLoginLimit = CacheHelper.getSysProperty("STU_CLIENT_LOGIN_LIMIT");
+        Boolean stuClientLoginLimitBoolean = false;
+        if (stuClientLoginLimit.getHasValue()) {
+            stuClientLoginLimitBoolean = Boolean.valueOf(stuClientLoginLimit.getValue().toString());
+        }
+        if (stuClientLoginLimitBoolean) {
+            throw new StatusException("OE-001505", "系统维护中... ...");
+        }
+        ExamRecordDataEntity examRecordDataEntity = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
+        if (examRecordDataEntity == null) {
+            return;
+        }
+        String fileName = tempFile.getName();
+        String fileSuffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()).toLowerCase();
+        //上传文件至又拍云
+        String fileNewName = createOfflineFileName(examRecordDataEntity) + "." + fileSuffix;
 
-		ExamRecordEntity examRecord =GlobalHelper.getEntity(examRecordRepo,examRecordDataEntity.getExamRecordId(),ExamRecordEntity.class);
-		String upyunFilePath = upyunUploadUrl+examRecord.getExamId()+"/"+fileNewName;
-		UpYun upyun = new UpYun(bucketName,userName,password);
-		upyun.writeFile(upyunFilePath,tempFile,true);
-		tempFile.delete();
-		//保存 文件信息
-		String fileUrl = upyunFileUrl+upyunFilePath;
-		examRecordForMarkingService.saveOffLineExamRecordForMarking(examRecordDataEntity, fileNewName, fileUrl);
-		//更新考试记录状态
-		examRecordDataEntity.setExamRecordStatus(ExamRecordStatus.EXAM_END);
-		examRecordDataEntity.setEndTime(new Date());//交卷(上传)时间
-		examRecordDataRepo.save(examRecordDataEntity);
-	}
+        ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
+        String upyunFilePath = upyunUploadUrl + examRecordData.getExamId() + "/" + fileNewName;
+        UpYun upyun = new UpYun(bucketName, userName, password);
+        upyun.writeFile(upyunFilePath, tempFile, true);
+        tempFile.delete();
+        //保存 文件信息
+        String fileUrl = upyunFileUrl + upyunFilePath;
+        examRecordForMarkingService.saveOffLineExamRecordForMarking(examRecordDataEntity, fileNewName, fileUrl);
+        //更新考试记录状态
+        examRecordDataEntity.setExamRecordStatus(ExamRecordStatus.EXAM_END);
+        examRecordDataEntity.setEndTime(new Date());//交卷(上传)时间
+        examRecordDataRepo.save(examRecordDataEntity);
+    }
 
-	private String createOfflineFileName(ExamRecordDataEntity examRecordDataEntity){
-		long currentTime = System.currentTimeMillis();
+    private String createOfflineFileName(ExamRecordDataEntity examRecordDataEntity) {
+        long currentTime = System.currentTimeMillis();
 
-		ExamRecordEntity examRecord =GlobalHelper.getEntity(
-				examRecordRepo,examRecordDataEntity.getExamRecordId(),ExamRecordEntity.class);
-		long orgId = examRecord.getOrgId();
-		OrgCacheBean orgBean = gainBaseDataService.getOrgBean(orgId);
-		long courseId = examRecord.getCourseId();
-		CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(courseId);
-		return orgBean.getCode()+"_"+
-				examRecord.getStudentCode()+"_"+
-				examRecord.getStudentName()+"_"+
-				courseBean.getCode()+"_"+currentTime;
-	}
+        long orgId = examRecordDataEntity.getOrgId();
+        OrgCacheBean orgBean = gainBaseDataService.getOrgBean(orgId);
+        long courseId = examRecordDataEntity.getCourseId();
+        CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(courseId);
+        return orgBean.getCode() + "_" +
+                examRecordDataEntity.getStudentCode() + "_" +
+                examRecordDataEntity.getStudentName() + "_" +
+                courseBean.getCode() + "_" + currentTime;
+    }
 }

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

@@ -4,7 +4,10 @@ import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
 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;
-import cn.com.qmth.examcloud.core.oe.common.repository.*;
+import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordDataRepo;
+import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordQuestionsRepo;
+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.service.GainBaseDataService;
 import cn.com.qmth.examcloud.core.oe.student.bean.PaperStructInfo;
 import cn.com.qmth.examcloud.core.oe.student.bean.PracticeCourseInfo;
@@ -27,241 +30,235 @@ import java.util.stream.Collectors;
 
 
 /**
- * 
- * @author  	chenken
- * @date    	2018年9月7日 上午11:05:18
- * @company 	QMTH
+ * @author chenken
+ * @date 2018年9月7日 上午11:05:18
+ * @company QMTH
  * @description PracticeServiceImpl.java
  */
 @Service("practiceService")
 public class PracticeServiceImpl implements PracticeService {
 
-	@Autowired
-	private ExamStudentRepo examStudentRepo;
-	
-	@Autowired
-	private ExamRecordRepo examRecordRepo;
-	
-	@Autowired
-	private ExamRecordDataRepo examRecordDataRepo;
-	
-	@Autowired
-	private ExamScoreRepo examScoreRepo;
-	
-	@Autowired
-	private ExamRecordQuestionsRepo examRecordQuestionsRepo;
-	
-	@Autowired
-	private ExamRecordPaperStructService examRecordPaperStructService;
-	
+    @Autowired
+    private ExamStudentRepo examStudentRepo;
+
+    @Autowired
+    private ExamRecordDataRepo examRecordDataRepo;
+
+    @Autowired
+    private ExamScoreRepo examScoreRepo;
+
+    @Autowired
+    private ExamRecordQuestionsRepo examRecordQuestionsRepo;
+
+    @Autowired
+    private ExamRecordPaperStructService examRecordPaperStructService;
+
     @Autowired
     private GainBaseDataService gainBaseDataService;
-	
-	@Override
-	public List<PracticeCourseInfo> queryPracticeCourseList(Long examId,Long studentId) {
-		if(examId == null || studentId == null){
-			return null;
-		}
-		List<ExamStudentEntity> examStudentList = examStudentRepo.findByExamIdAndStudentId(examId, studentId);
-		if(examStudentList == null || examStudentList.size() == 0){
-			return null;
-		}
-		List<PracticeCourseInfo> practiceCourseInfos = new ArrayList<PracticeCourseInfo>();
-		ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examId,examStudentList.get(0).getOrgId());
-		for(ExamStudentEntity examStudent:examStudentList){
-			practiceCourseInfos.add(buildPracticeCourseInfo(examStudent,examBean));
-		}
-		return practiceCourseInfos;
-	}
 
+    @Override
+    public List<PracticeCourseInfo> queryPracticeCourseList(Long examId, Long studentId) {
+        if (examId == null || studentId == null) {
+            return null;
+        }
+        List<ExamStudentEntity> examStudentList = examStudentRepo.findByExamIdAndStudentId(examId, studentId);
+        if (examStudentList == null || examStudentList.size() == 0) {
+            return null;
+        }
+        List<PracticeCourseInfo> practiceCourseInfos = new ArrayList<PracticeCourseInfo>();
+        ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examId, examStudentList.get(0).getOrgId());
+        for (ExamStudentEntity examStudent : examStudentList) {
+            practiceCourseInfos.add(buildPracticeCourseInfo(examStudent, examBean));
+        }
+        return practiceCourseInfos;
+    }
+
+
+    private PracticeCourseInfo buildPracticeCourseInfo(ExamStudentEntity examStudent, ExamBean examBean) {
+        PracticeCourseInfo practiceCourseInfo = new PracticeCourseInfo();
+        practiceCourseInfo.setExamStudentId(examStudent.getExamStudentId());
+        practiceCourseInfo.setCourseCode(examStudent.getCourseCode());
+
+        CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examStudent.getCourseId());
+        practiceCourseInfo.setCourseName(courseBean.getName());
+        practiceCourseInfo.setStudentCode(examStudent.getStudentCode());
+        practiceCourseInfo.setStudentName(examStudent.getStudentName());
+
+        practiceCourseInfo.setExamId(examBean.getId());
+        practiceCourseInfo.setExamName(examBean.getName());
+        practiceCourseInfo.setExamType(examBean.getExamType());
+        practiceCourseInfo.setStartTime(examBean.getBeginTime());
+        practiceCourseInfo.setEndTime(examBean.getEndTime());
+
+        List<ExamRecordDataEntity> examRecordEntities = examRecordDataRepo.findByExamStudentId(examStudent.getExamStudentId());
 
-	private PracticeCourseInfo buildPracticeCourseInfo(ExamStudentEntity examStudent,ExamBean examBean) {
-		PracticeCourseInfo practiceCourseInfo = new PracticeCourseInfo();
-		practiceCourseInfo.setExamStudentId(examStudent.getExamStudentId());
-		practiceCourseInfo.setCourseCode(examStudent.getCourseCode());
-		
-		CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examStudent.getCourseId());
-		practiceCourseInfo.setCourseName(courseBean.getName());
-		practiceCourseInfo.setStudentCode(examStudent.getStudentCode());
-		practiceCourseInfo.setStudentName(examStudent.getStudentName());
-		
-		practiceCourseInfo.setExamId(examBean.getId());
-		practiceCourseInfo.setExamName(examBean.getName());
-		practiceCourseInfo.setExamType(examBean.getExamType());
-		practiceCourseInfo.setStartTime(examBean.getBeginTime());
-		practiceCourseInfo.setEndTime(examBean.getEndTime());
-		
-		List<ExamRecordEntity> examRecordEntities = examRecordRepo.findByExamStudentId(examStudent.getExamStudentId());
-		
-		int allExamRecordNums = 0;
-		List<ExamScoreEntity> examScoreEntities = new ArrayList<ExamScoreEntity>();
-		for(ExamRecordEntity examRecord:examRecordEntities){
-			ExamRecordDataEntity examRecordData = examRecordDataRepo.findByExamRecordId(examRecord.getId());
-			if(examRecordData.getExamRecordStatus() != ExamRecordStatus.EXAM_ING){
-				allExamRecordNums++;
-				ExamScoreEntity examScore = examScoreRepo.findByExamRecordDataId(examRecordData.getId());
-				examScoreEntities.add(examScore);
-			}
-		}
-		double allObjectiveAccuracy = 0;//总正确率
+        int allExamRecordNums = 0;
+        List<ExamScoreEntity> examScoreEntities = new ArrayList<ExamScoreEntity>();
+        for (ExamRecordDataEntity examRecordData : examRecordEntities) {
+            if (examRecordData.getExamRecordStatus() != ExamRecordStatus.EXAM_ING) {
+                allExamRecordNums++;
+                ExamScoreEntity examScore = examScoreRepo.findByExamRecordDataId(examRecordData.getId());
+                examScoreEntities.add(examScore);
+            }
+        }
+        double allObjectiveAccuracy = 0;//总正确率
         double maxObjectiveAccuracy = 0;//最高客观题正确率
         long recentObjectiveAccuracyId = 0;//最近ID
         double recentObjectiveAccuracy = 0;//最近客观题正确率
-        
-        for(ExamScoreEntity examScore:examScoreEntities){
-        	if(examScore != null){
-        		if (examScore.getObjectiveAccuracy() > maxObjectiveAccuracy) {
+
+        for (ExamScoreEntity examScore : examScoreEntities) {
+            if (examScore != null) {
+                if (examScore.getObjectiveAccuracy() > maxObjectiveAccuracy) {
                     maxObjectiveAccuracy = examScore.getObjectiveAccuracy();
                 }
-            	if (examScore.getId() > recentObjectiveAccuracyId) {//判断是否为最近的
+                if (examScore.getId() > recentObjectiveAccuracyId) {//判断是否为最近的
                     recentObjectiveAccuracyId = examScore.getId();
                     recentObjectiveAccuracy = examScore.getObjectiveAccuracy();
                 }
-            	allObjectiveAccuracy = allObjectiveAccuracy + examScore.getObjectiveAccuracy();
-        	}
+                allObjectiveAccuracy = allObjectiveAccuracy + examScore.getObjectiveAccuracy();
+            }
         }
         //平均正确率
         double aveObjectiveAccuracy = 0D;
-        if(allExamRecordNums>0){
-        	 aveObjectiveAccuracy = Double.valueOf(new DecimalFormat("#.00").format(allObjectiveAccuracy / allExamRecordNums));
+        if (allExamRecordNums > 0) {
+            aveObjectiveAccuracy = Double.valueOf(new DecimalFormat("#.00").format(allObjectiveAccuracy / allExamRecordNums));
         }
         practiceCourseInfo.setAveObjectiveAccuracy(aveObjectiveAccuracy);
         practiceCourseInfo.setMaxObjectiveAccuracy(maxObjectiveAccuracy);
         practiceCourseInfo.setRecentObjectiveAccuracy(recentObjectiveAccuracy);
         practiceCourseInfo.setPracticeCount(allExamRecordNums);//练习总次数
-		return practiceCourseInfo;
-	}
+        return practiceCourseInfo;
+    }
+
+    @Override
+    public List<PracticeRecordInfo> queryPracticeRecordList(Long examStudentId) {
+        if (examStudentId == null) {
+            return null;
+        }
+        List<ExamRecordDataEntity> examRecordDataList = examRecordDataRepo.findByExamStudentId(examStudentId);
+        List<PracticeRecordInfo> practiceRecords = new ArrayList<PracticeRecordInfo>();
+        ExamStudentEntity examStudent = examStudentRepo.findByExamStudentId(examStudentId);
+        CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examStudent.getCourseId());
+        for (ExamRecordDataEntity examRecordData : examRecordDataList) {
+            if (examRecordData.getExamRecordStatus() != ExamRecordStatus.EXAM_ING) {
+                practiceRecords.add(buildPracticeRecord(examRecordData, courseBean));
+            }
+        }
+        return practiceRecords;
+    }
 
-	@Override
-	public List<PracticeRecordInfo> queryPracticeRecordList(Long examStudentId) {
-		if(examStudentId == null){
-			return null;
-		}
-		List<ExamRecordEntity> examRecordList = examRecordRepo.findByExamStudentId(examStudentId);
-		List<PracticeRecordInfo> practiceRecords = new ArrayList<PracticeRecordInfo>();
-		ExamStudentEntity examStudent = examStudentRepo.findByExamStudentId(examStudentId);
-		CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examStudent.getCourseId());
-		for(ExamRecordEntity examRecord:examRecordList){
-			ExamRecordDataEntity examRecordData = examRecordDataRepo.findByExamRecordId(examRecord.getId());
-			if(examRecordData.getExamRecordStatus() != ExamRecordStatus.EXAM_ING){
-				practiceRecords.add(buildPracticeRecord(examRecordData,courseBean));
-			}
-		}
-		return practiceRecords;
-	}
+    private PracticeRecordInfo buildPracticeRecord(ExamRecordDataEntity examRecordData, CourseBean courseBean) {
+        PracticeRecordInfo practiceRecordInfo = new PracticeRecordInfo();
 
-	private PracticeRecordInfo buildPracticeRecord(ExamRecordDataEntity examRecordData,CourseBean courseBean) {
-		PracticeRecordInfo practiceRecordInfo = new PracticeRecordInfo();
-		
-		practiceRecordInfo.setId(examRecordData.getId());
-		practiceRecordInfo.setCourseCode(courseBean.getCode());
-		practiceRecordInfo.setCourseName(courseBean.getName());
-		practiceRecordInfo.setStartTime(examRecordData.getStartTime());
-		practiceRecordInfo.setEndTime(examRecordData.getEndTime());
-		practiceRecordInfo.setUsedExamTime(examRecordData.getUsedExamTime());
-		
-		ExamScoreEntity examScoreEntity = examScoreRepo.findByExamRecordDataId(examRecordData.getId());
-		practiceRecordInfo.setObjectiveAccuracy(examScoreEntity.getObjectiveAccuracy());//客观题答对的比率
-		ExamRecordQuestionsEntity examRecordQuestions = examRecordQuestionsRepo.findByExamRecordDataId(examRecordData.getId());
-		List<ExamQuestionEntity> examQuestionEntities = examRecordQuestions.getExamQuestionEntities();
-		practiceRecordInfo = calculationExamQuestionSituationInfo(practiceRecordInfo,examQuestionEntities);
-		
-		return practiceRecordInfo;
-	}
+        practiceRecordInfo.setId(examRecordData.getId());
+        practiceRecordInfo.setCourseCode(courseBean.getCode());
+        practiceRecordInfo.setCourseName(courseBean.getName());
+        practiceRecordInfo.setStartTime(examRecordData.getStartTime());
+        practiceRecordInfo.setEndTime(examRecordData.getEndTime());
+        practiceRecordInfo.setUsedExamTime(examRecordData.getUsedExamTime());
 
-	/**
-	 * 计算答题情况
-	 * @param practiceRecordInfo
-	 * @param examQuestionEntities
-	 * @return
-	 */
-	private PracticeRecordInfo calculationExamQuestionSituationInfo(PracticeRecordInfo practiceRecordInfo,List<ExamQuestionEntity> examQuestionEntities){
-		if(practiceRecordInfo == null){
-			practiceRecordInfo = new PracticeRecordInfo();
-		}
-		int succQuestionNum = 0;//正确答题数
-		int failQuestionNum = 0;//错误答题数
-		int notAnsweredCount = 0;//未作答题数
-		for(ExamQuestionEntity examQuestionEntity:examQuestionEntities){
-			if(examQuestionEntity.getIsAnswer() == null || !examQuestionEntity.getIsAnswer()){
-				notAnsweredCount++;
-			}else{
-				//客观题判断正确错误
-				if(QuestionTypeUtil.isObjectiveQuestion(examQuestionEntity.getQuestionType())){
-					if(examQuestionEntity.getCorrectAnswer() !=null 
-							&& examQuestionEntity.getStudentAnswer() != null 
-								&& examQuestionEntity.getCorrectAnswer().equals(examQuestionEntity.getStudentAnswer())){
-						succQuestionNum++;
-					}else{
-						failQuestionNum++;
-					}
-				}
-			}
-		}
-		int objectiveQuestionsNum = 0;//客观题总数
-		for(ExamQuestionEntity examQuestionEntity:examQuestionEntities){
-			if(QuestionTypeUtil.isObjectiveQuestion(examQuestionEntity.getQuestionType())){
-				objectiveQuestionsNum++;
-			}
-		}
-		practiceRecordInfo.setObjectiveNum(objectiveQuestionsNum);
-		practiceRecordInfo.setSuccQuestionNum(succQuestionNum);
-		practiceRecordInfo.setFailQuestionNum(failQuestionNum);
-		practiceRecordInfo.setNotAnsweredCount(notAnsweredCount);
-		practiceRecordInfo.setTotalQuestionCount(examQuestionEntities.size());
-		return practiceRecordInfo;
-	}
+        ExamScoreEntity examScoreEntity = examScoreRepo.findByExamRecordDataId(examRecordData.getId());
+        practiceRecordInfo.setObjectiveAccuracy(examScoreEntity.getObjectiveAccuracy());//客观题答对的比率
+        ExamRecordQuestionsEntity examRecordQuestions = examRecordQuestionsRepo.findByExamRecordDataId(examRecordData.getId());
+        List<ExamQuestionEntity> examQuestionEntities = examRecordQuestions.getExamQuestionEntities();
+        practiceRecordInfo = calculationExamQuestionSituationInfo(practiceRecordInfo, examQuestionEntities);
 
-	@Override
-	public PracticeDetailInfo getPracticeDetailInfo(Long examRecordDataId) {
-		if(examRecordDataId == null){
-			return null;
-		}
-		PracticeDetailInfo practiceDetailInfo = new PracticeDetailInfo();
-		//取出试卷结构
-		ExamRecordPaperStructEntity examRecordPaperStruct = examRecordPaperStructService.getExamRecordPaperStruct(examRecordDataId);
-		DefaultPaper defaultPaper = examRecordPaperStruct.getDefaultPaper();
-		List<PaperStructInfo> paperStructInfos = new  ArrayList<PaperStructInfo>();
-		List<DefaultQuestionGroup> questionGroupList = defaultPaper.getQuestionGroupList();
-		//取出作答记录
-		ExamRecordQuestionsEntity examRecordQuestions = examRecordQuestionsRepo.findByExamRecordDataId(examRecordDataId);
-		List<ExamQuestionEntity> examQuestionEntities = examRecordQuestions.getExamQuestionEntities();
-		//遍历大题
-		int objectiveNum = 0;//各个大题中的客观题总数
-		int objectSuccessNum = 0;//各个大题中的客观题答对的总数量
-		for(int i = 0;i<questionGroupList.size();i++){
-			DefaultQuestionGroup defaultQuestionGroup = questionGroupList.get(i);
-			PaperStructInfo paperStructInfo = new PaperStructInfo();
-			paperStructInfo.setTitle(defaultQuestionGroup.getGroupName());//大题名称
-			paperStructInfo.setIndex(i+1);//大题号
-			//使用大题号过滤
-			List<ExamQuestionEntity> examQuestionEntitiesOfMainQuestion = examQuestionEntities.stream().filter(o1->o1.getMainNumber().intValue() == paperStructInfo.getIndex()).collect(Collectors.toList());
-			//计算出作答情况
-			PracticeRecordInfo practiceRecordInfo = calculationExamQuestionSituationInfo(null,examQuestionEntitiesOfMainQuestion);
-			
-			objectiveNum += practiceRecordInfo.getObjectiveNum();
-			objectSuccessNum += practiceRecordInfo.getSuccQuestionNum();
-			
-			paperStructInfo.setQuestionCount(practiceRecordInfo.getTotalQuestionCount());
-			paperStructInfo.setSuccQuestionNum(practiceRecordInfo.getSuccQuestionNum());
-			paperStructInfo.setFailQuestionNum(practiceRecordInfo.getFailQuestionNum());
-			paperStructInfo.setNotAnsweredCount(practiceRecordInfo.getNotAnsweredCount());
-			paperStructInfos.add(paperStructInfo);
-		}
-		practiceDetailInfo.setPaperStructInfos(paperStructInfos);
-		ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo,examRecordDataId,ExamRecordDataEntity.class);
-		ExamRecordEntity examRecord =GlobalHelper.getEntity(examRecordRepo,examRecordData.getExamRecordId(),ExamRecordEntity.class);
-		CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examRecord.getCourseId());
-		practiceDetailInfo.setCourseCode(courseBean.getCode());
-		practiceDetailInfo.setCourseName(courseBean.getName());
-		practiceDetailInfo.setId(examRecordDataId);
-		
-		double objectiveAccuracy = 0;//客观题答题正确率
-		if (objectiveNum > 0) {
+        return practiceRecordInfo;
+    }
+
+    /**
+     * 计算答题情况
+     *
+     * @param practiceRecordInfo
+     * @param examQuestionEntities
+     * @return
+     */
+    private PracticeRecordInfo calculationExamQuestionSituationInfo(PracticeRecordInfo practiceRecordInfo, List<ExamQuestionEntity> examQuestionEntities) {
+        if (practiceRecordInfo == null) {
+            practiceRecordInfo = new PracticeRecordInfo();
+        }
+        int succQuestionNum = 0;//正确答题数
+        int failQuestionNum = 0;//错误答题数
+        int notAnsweredCount = 0;//未作答题数
+        for (ExamQuestionEntity examQuestionEntity : examQuestionEntities) {
+            if (examQuestionEntity.getIsAnswer() == null || !examQuestionEntity.getIsAnswer()) {
+                notAnsweredCount++;
+            } else {
+                //客观题判断正确错误
+                if (QuestionTypeUtil.isObjectiveQuestion(examQuestionEntity.getQuestionType())) {
+                    if (examQuestionEntity.getCorrectAnswer() != null
+                            && examQuestionEntity.getStudentAnswer() != null
+                            && examQuestionEntity.getCorrectAnswer().equals(examQuestionEntity.getStudentAnswer())) {
+                        succQuestionNum++;
+                    } else {
+                        failQuestionNum++;
+                    }
+                }
+            }
+        }
+        int objectiveQuestionsNum = 0;//客观题总数
+        for (ExamQuestionEntity examQuestionEntity : examQuestionEntities) {
+            if (QuestionTypeUtil.isObjectiveQuestion(examQuestionEntity.getQuestionType())) {
+                objectiveQuestionsNum++;
+            }
+        }
+        practiceRecordInfo.setObjectiveNum(objectiveQuestionsNum);
+        practiceRecordInfo.setSuccQuestionNum(succQuestionNum);
+        practiceRecordInfo.setFailQuestionNum(failQuestionNum);
+        practiceRecordInfo.setNotAnsweredCount(notAnsweredCount);
+        practiceRecordInfo.setTotalQuestionCount(examQuestionEntities.size());
+        return practiceRecordInfo;
+    }
+
+    @Override
+    public PracticeDetailInfo getPracticeDetailInfo(Long examRecordDataId) {
+        if (examRecordDataId == null) {
+            return null;
+        }
+        PracticeDetailInfo practiceDetailInfo = new PracticeDetailInfo();
+        //取出试卷结构
+        ExamRecordPaperStructEntity examRecordPaperStruct = examRecordPaperStructService.getExamRecordPaperStruct(examRecordDataId);
+        DefaultPaper defaultPaper = examRecordPaperStruct.getDefaultPaper();
+        List<PaperStructInfo> paperStructInfos = new ArrayList<PaperStructInfo>();
+        List<DefaultQuestionGroup> questionGroupList = defaultPaper.getQuestionGroupList();
+        //取出作答记录
+        ExamRecordQuestionsEntity examRecordQuestions = examRecordQuestionsRepo.findByExamRecordDataId(examRecordDataId);
+        List<ExamQuestionEntity> examQuestionEntities = examRecordQuestions.getExamQuestionEntities();
+        //遍历大题
+        int objectiveNum = 0;//各个大题中的客观题总数
+        int objectSuccessNum = 0;//各个大题中的客观题答对的总数量
+        for (int i = 0; i < questionGroupList.size(); i++) {
+            DefaultQuestionGroup defaultQuestionGroup = questionGroupList.get(i);
+            PaperStructInfo paperStructInfo = new PaperStructInfo();
+            paperStructInfo.setTitle(defaultQuestionGroup.getGroupName());//大题名称
+            paperStructInfo.setIndex(i + 1);//大题号
+            //使用大题号过滤
+            List<ExamQuestionEntity> examQuestionEntitiesOfMainQuestion = examQuestionEntities.stream().filter(o1 -> o1.getMainNumber().intValue() == paperStructInfo.getIndex()).collect(Collectors.toList());
+            //计算出作答情况
+            PracticeRecordInfo practiceRecordInfo = calculationExamQuestionSituationInfo(null, examQuestionEntitiesOfMainQuestion);
+
+            objectiveNum += practiceRecordInfo.getObjectiveNum();
+            objectSuccessNum += practiceRecordInfo.getSuccQuestionNum();
+
+            paperStructInfo.setQuestionCount(practiceRecordInfo.getTotalQuestionCount());
+            paperStructInfo.setSuccQuestionNum(practiceRecordInfo.getSuccQuestionNum());
+            paperStructInfo.setFailQuestionNum(practiceRecordInfo.getFailQuestionNum());
+            paperStructInfo.setNotAnsweredCount(practiceRecordInfo.getNotAnsweredCount());
+            paperStructInfos.add(paperStructInfo);
+        }
+        practiceDetailInfo.setPaperStructInfos(paperStructInfos);
+        ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
+        CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examRecordData.getCourseId());
+        practiceDetailInfo.setCourseCode(courseBean.getCode());
+        practiceDetailInfo.setCourseName(courseBean.getName());
+        practiceDetailInfo.setId(examRecordDataId);
+
+        double objectiveAccuracy = 0;//客观题答题正确率
+        if (objectiveNum > 0) {
             objectiveAccuracy = Double.valueOf(new DecimalFormat("#.00").format(objectSuccessNum * 100D / objectiveNum));
         }
-		practiceDetailInfo.setObjectiveAccuracy(objectiveAccuracy);
-		return practiceDetailInfo;
-	}
-	
+        practiceDetailInfo.setObjectiveAccuracy(objectiveAccuracy);
+        return practiceDetailInfo;
+    }
+
 }