Explorar o código

merge manualEndExam api

deason %!s(int64=3) %!d(string=hai) anos
pai
achega
800683c269

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

@@ -11,10 +11,8 @@ import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordDataService;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamingSessionService;
 import cn.com.qmth.examcloud.support.Constants;
 import cn.com.qmth.examcloud.support.enums.FileAnswerAcknowledgeStatus;
-import cn.com.qmth.examcloud.support.enums.HandInExamType;
 import cn.com.qmth.examcloud.support.examing.ExamFileAnswer;
 import cn.com.qmth.examcloud.support.examing.ExamRecordData;
-import cn.com.qmth.examcloud.support.examing.ExamingSession;
 import cn.com.qmth.examcloud.support.filestorage.FileStorageUtil;
 import cn.com.qmth.examcloud.support.redis.RedisKeyHelper;
 import cn.com.qmth.examcloud.web.filestorage.FileStorageHelper;
@@ -122,27 +120,7 @@ public class ExamControlController extends ControllerSupport {
     @GetMapping("/endExam")
     public void endExam(HttpServletRequest request) {
         User user = getAccessUser();
-        Long studentId = user.getUserId();
-        String sequenceLockKey = Constants.EXAM_CONTROL_LOCK_PREFIX + user.getUserId();
-        //系统在请求结束后会,自动释放锁,无需手动解锁
-        SequenceLockHelper.getLock(sequenceLockKey);
-
-        long st = System.currentTimeMillis();
-        long startTime = System.currentTimeMillis();
-
-        ExamingSession examingSession = examingSessionService.getExamingSession(studentId);
-
-        if (examingSession == null) {
-            throw new StatusException("8010", "无效的会话,请离开考试");
-        }
-
-        if (LOGGER.isDebugEnabled()) {
-            LOGGER.debug("0 [END_EXAM] 交卷前处理耗时:" + (System.currentTimeMillis() - startTime) + " ms");
-        }
-        examControlService.handInExam(examingSession.getExamRecordDataId(), HandInExamType.MANUAL, getIp(request));
-        if (LOGGER.isDebugEnabled()) {
-            LOGGER.debug("1 [END_EXAM]合计 耗时:" + (System.currentTimeMillis() - st) + " ms");
-        }
+        examControlService.manualEndExam(user.getUserId(), getIp(request));
     }
 
     /**

+ 1 - 23
examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/api/controller/client/ExamProcessController.java

@@ -6,10 +6,8 @@ import cn.com.qmth.examcloud.commons.util.JsonUtil;
 import cn.com.qmth.examcloud.core.oe.student.bean.*;
 import cn.com.qmth.examcloud.core.oe.student.service.*;
 import cn.com.qmth.examcloud.support.Constants;
-import cn.com.qmth.examcloud.support.enums.HandInExamType;
 import cn.com.qmth.examcloud.support.examing.*;
 import cn.com.qmth.examcloud.support.redis.RedisKeyHelper;
-import cn.com.qmth.examcloud.web.helpers.SequenceLockHelper;
 import cn.com.qmth.examcloud.web.redis.RedisClient;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.Api;
@@ -81,27 +79,7 @@ public class ExamProcessController extends ControllerSupport {
     @PostMapping("/endExam")
     public void endExam(HttpServletRequest request) {
         User user = getAccessUser();
-        Long studentId = user.getUserId();
-        String sequenceLockKey = Constants.EXAM_CONTROL_LOCK_PREFIX + user.getUserId();
-        //系统在请求结束后会,自动释放锁,无需手动解锁
-        SequenceLockHelper.getLock(sequenceLockKey);
-
-        long st = System.currentTimeMillis();
-        long startTime = System.currentTimeMillis();
-
-        ExamingSession examingSession = examingSessionService.getExamingSession(studentId);
-
-        if (examingSession == null) {
-            throw new StatusException("8010", "无效的会话,请离开考试");
-        }
-
-        if (LOGGER.isDebugEnabled()) {
-            LOGGER.debug("0 [END_EXAM] 交卷前处理耗时:" + (System.currentTimeMillis() - startTime) + " ms");
-        }
-        examControlService.handInExam(examingSession.getExamRecordDataId(), HandInExamType.MANUAL, getIp(request));
-        if (LOGGER.isDebugEnabled()) {
-            LOGGER.debug("1 [END_EXAM]合计 耗时:" + (System.currentTimeMillis() - st) + " ms");
-        }
+        examControlService.manualEndExam(user.getUserId(), getIp(request));
     }
 
     @ApiOperation(value = "获取考试记录信息")

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

@@ -5,8 +5,6 @@ import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.core.oe.student.bean.*;
 import cn.com.qmth.examcloud.support.enums.HandInExamType;
 
-import javax.validation.constraints.Null;
-
 /**
  * @author chenken
  * @date 2018年8月13日 下午2:09:38
@@ -30,6 +28,11 @@ public interface ExamControlService {
      */
     StartAnswerInfo startAnswer(Long examRecordDataId, Long userId);
 
+    /**
+     * 手动交卷
+     */
+    void manualEndExam(Long studentId, String ip);
+
     /**
      * 交卷
      *
@@ -37,7 +40,7 @@ public interface ExamControlService {
      * @param handInExamType   交卷类型
      * @param ip               请求ip,可以为空
      */
-    void handInExam(Long examRecordDataId, HandInExamType handInExamType, @Null String ip);
+    void handInExam(Long examRecordDataId, HandInExamType handInExamType, String ip);
 
     /**
      * 断点续考:检查正在进行中的考试

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

@@ -696,6 +696,24 @@ public class ExamControlServiceImpl implements ExamControlService {
         redisClient.set(examBossKey, examBoss, 60);
     }
 
+    @Override
+    public void manualEndExam(Long studentId, String ip) {
+        String sequenceLockKey = Constants.EXAM_CONTROL_LOCK_PREFIX + studentId;
+        //系统在请求结束后会,自动释放锁,无需手动解锁
+        SequenceLockHelper.getLock(sequenceLockKey);
+
+        long startTime = System.currentTimeMillis();
+        ExamingSession examingSession = examingSessionService.getExamingSession(studentId);
+        if (examingSession == null) {
+            throw new StatusException("8010", "无效的会话,请离开考试");
+        }
+
+        this.handInExam(examingSession.getExamRecordDataId(), HandInExamType.MANUAL, ip);
+        if (log.isDebugEnabled()) {
+            log.debug("[manualEndExam] cost " + (System.currentTimeMillis() - startTime) + " ms");
+        }
+    }
+
     /**
      * 交卷
      *