Sfoglia il codice sorgente

添加交卷类型枚举,交卷代码优化

lideyin 5 anni fa
parent
commit
27edb4afd4

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

@@ -1,7 +1,10 @@
 package cn.com.qmth.examcloud.core.oe.student.api.controller;
 
+import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.core.oe.student.base.utils.Check;
+import cn.com.qmth.examcloud.core.oe.student.dao.enums.HandInExamType;
 import cn.com.qmth.examcloud.support.Constants;
+import cn.com.qmth.examcloud.support.examing.ExamingSession;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -41,4 +44,36 @@ public class ExamControlController extends ControllerSupport {
         return startExamInfo;
     }
 
+    /**
+     * 结束考试:交卷..
+     */
+    @ApiOperation(value = "结束考试:交卷")
+    @GetMapping("/endExam")
+    public void endExam() {
+        User user = getAccessUser();
+        Long studentId = user.getUserId();
+        String sequenceLockKey = Constants.END_EXAM_LOCK_PREFIX + studentId;
+        //系统在请求结束后会,自动释放锁,无需手动解锁
+        SequenceLockHelper.getLock(sequenceLockKey);
+
+        long st = System.currentTimeMillis();
+        long startTime = System.currentTimeMillis();
+
+        ExamingSession examingSession = null;
+//        // 获取考试会话,判断考生是否已结束考试
+//        ExamSessionInfo examSessionInfo = examSessionInfoService.getExamSessionInfo(studentId);
+//        if (examSessionInfo == null) {
+//            throw new StatusException("oestudent-100100", "考试会话已过期");
+//        }
+
+
+        if (log.isDebugEnabled()) {
+            log.debug("0 [END_EXAM] 交卷前处理耗时:" + (System.currentTimeMillis() - startTime) + " ms");
+        }
+        examControlService.handInExam(examingSession.getExamRecordDataId(), HandInExamType.MANUAL);
+        if (log.isDebugEnabled()) {
+            log.debug("1 [END_EXAM]合计 耗时:" + (System.currentTimeMillis() - st) + " ms");
+        }
+    }
+
 }

+ 17 - 1
examcloud-core-oe-student-dao/src/main/java/cn/com/qmth/examcloud/core/oe/student/dao/entity/ExamRecordDataEntity.java

@@ -13,6 +13,7 @@ import javax.persistence.Index;
 import javax.persistence.Table;
 
 import cn.com.qmth.examcloud.core.oe.student.dao.enums.ExamRecordStatus;
+import cn.com.qmth.examcloud.core.oe.student.dao.enums.HandInExamType;
 import org.hibernate.annotations.DynamicInsert;
 
 import cn.com.qmth.examcloud.core.oe.student.dao.enums.ExamType;
@@ -126,9 +127,16 @@ public class ExamRecordDataEntity extends JpaEntity {
      */
     private Integer faceTotalCount;
 
-    //考试记录状态
+    /**
+     * 考试记录状态
+     */
     private ExamRecordStatus examRecordStatus;
 
+    /**
+     * 交卷类型
+     */
+    private HandInExamType handInExamType;
+
     public Long getId() {
         return id;
     }
@@ -296,4 +304,12 @@ public class ExamRecordDataEntity extends JpaEntity {
     public void setExamRecordStatus(ExamRecordStatus examRecordStatus) {
         this.examRecordStatus = examRecordStatus;
     }
+
+    public HandInExamType getHandInExamType() {
+        return handInExamType;
+    }
+
+    public void setHandInExamType(HandInExamType handInExamType) {
+        this.handInExamType = handInExamType;
+    }
 }

+ 20 - 0
examcloud-core-oe-student-dao/src/main/java/cn/com/qmth/examcloud/core/oe/student/dao/enums/HandInExamType.java

@@ -0,0 +1,20 @@
+package cn.com.qmth.examcloud.core.oe.student.dao.enums;
+
+
+/**
+ * @Description 交卷类型
+ * @Author lideyin
+ * @Date 2019/8/1 18:07
+ * @Version 1.0
+ */
+public enum HandInExamType {
+    /**
+     * 手工交卷
+     */
+    MANUAL,
+    /**
+     * 自动交卷
+     */
+    AUTO
+
+}

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

@@ -3,6 +3,7 @@ package cn.com.qmth.examcloud.core.oe.student.service;
 
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.core.oe.student.bean.StartExamInfo;
+import cn.com.qmth.examcloud.core.oe.student.dao.enums.HandInExamType;
 
 /**
  * @author chenken
@@ -18,7 +19,14 @@ public interface ExamControlService {
      * @param examStudentId
      * @param user
      */
-    public StartExamInfo startExam(Long examStudentId, User user);
+    StartExamInfo startExam(Long examStudentId, User user);
 
+    /**
+     * 交卷
+     *
+     * @param examRecordDataId 考试记录id
+     * @param handInExamType   交卷类型
+     */
+    void handInExam(Long examRecordDataId, HandInExamType handInExamType);
 
 }

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

@@ -1,23 +1,5 @@
 package cn.com.qmth.examcloud.core.oe.student.service.impl;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
 import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
@@ -28,11 +10,8 @@ import cn.com.qmth.examcloud.core.oe.student.base.utils.CommonUtil;
 import cn.com.qmth.examcloud.core.oe.student.base.utils.QuestionTypeUtil;
 import cn.com.qmth.examcloud.core.oe.student.bean.ExamRecordDataBean;
 import cn.com.qmth.examcloud.core.oe.student.bean.StartExamInfo;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamControlService;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordDataService;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordPaperStructService;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordQuestionsService;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamingSessionService;
+import cn.com.qmth.examcloud.core.oe.student.dao.enums.HandInExamType;
+import cn.com.qmth.examcloud.core.oe.student.service.*;
 import cn.com.qmth.examcloud.core.oe.task.api.ExamCaptureCloudService;
 import cn.com.qmth.examcloud.core.oe.task.api.request.SaveExamCaptureSyncCompareResultReq;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
@@ -44,16 +23,19 @@ import cn.com.qmth.examcloud.question.commons.core.question.QuestionType;
 import cn.com.qmth.examcloud.reports.commons.bean.OnlineExamStudentReport;
 import cn.com.qmth.examcloud.reports.commons.util.ReportsUtil;
 import cn.com.qmth.examcloud.support.cache.CacheHelper;
-import cn.com.qmth.examcloud.support.cache.bean.ExamOrgSettingsCacheBean;
-import cn.com.qmth.examcloud.support.cache.bean.ExamPropertyCacheBean;
-import cn.com.qmth.examcloud.support.cache.bean.ExamStudentSettingsCacheBean;
-import cn.com.qmth.examcloud.support.cache.bean.ExtractConfigCacheBean;
-import cn.com.qmth.examcloud.support.cache.bean.ExtractConfigDetailCacheBean;
-import cn.com.qmth.examcloud.support.cache.bean.ExtractConfigPaperCacheBean;
-import cn.com.qmth.examcloud.support.cache.bean.SysPropertyCacheBean;
+import cn.com.qmth.examcloud.support.cache.bean.*;
 import cn.com.qmth.examcloud.support.examing.ExamingSession;
 import cn.com.qmth.examcloud.support.examing.ExamingStatus;
 import cn.com.qmth.examcloud.support.helper.FaceBiopsyHelper;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
 
 /**
  * @author chenken
@@ -207,11 +189,23 @@ public class ExamControlServiceImpl implements ExamControlService {
 
     }
 
+    /**
+     * 交卷
+     *
+     * @param examRecordDataId 考试记录id
+     * @param handInExamType   交卷类型
+     */
+    @Override
+    public void handInExam(Long examRecordDataId, HandInExamType handInExamType) {
+
+    }
+
     /**
      * 检查并返回考试 开考条件 1.enable为true 2.开始时间和结束时间判断 3.examLimit为null或false
      * 4.剩余考试次数>0
      *
-     * @param examStudentEntity
+     * @param examId
+     * @param studentId
      * @return
      */
     private ExamBean checkExam(Long examId, Long studentId) {