فهرست منبع

同步开发环境代码

lideyin 4 سال پیش
والد
کامیت
8f7a74e223

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

@@ -1,7 +1,6 @@
 package cn.com.qmth.examcloud.core.oe.student.service.impl;
 
 import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
-import cn.com.qmth.examcloud.api.commons.enums.ExamStageStartExamStatus;
 import cn.com.qmth.examcloud.api.commons.enums.ExamType;
 import cn.com.qmth.examcloud.api.commons.enums.SubmitType;
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
@@ -38,9 +37,7 @@ 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.core.oe.task.api.request.UpdateExamCaptureQueuePriorityReq;
 import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
-import cn.com.qmth.examcloud.examwork.api.ExamStageCloudService;
 import cn.com.qmth.examcloud.examwork.api.request.GetExamPropertyReq;
-import cn.com.qmth.examcloud.examwork.api.request.ModifyExamStageStartExamStatusReq;
 import cn.com.qmth.examcloud.examwork.api.response.GetExamPropertyResp;
 import cn.com.qmth.examcloud.question.commons.core.paper.DefaultPaper;
 import cn.com.qmth.examcloud.question.commons.core.paper.DefaultQuestionGroup;
@@ -138,8 +135,7 @@ public class ExamControlServiceImpl implements ExamControlService {
 
     @Autowired
     SyncExamDataCloudService syncExamDataCloudService;
-    @Autowired
-    private ExamStageCloudService examStageCloudService;
+
     @Autowired
     private ExamRecordDataRepo examRecordDataRepo;
     @Autowired
@@ -288,20 +284,6 @@ public class ExamControlServiceImpl implements ExamControlService {
         eb.setStartCount(eb.getStartCount() + 1);
         examBossService.saveExamBoss(examStudentId, eb);
 
-        //更新场次的开考状态
-        if (null != examStudent.getExamStageId()) {
-            ExamSettingsCacheBean cachedExam =
-                    ExamCacheTransferHelper.getCachedExam(examId, studentId, examStudent.getExamStageId());
-            if (cachedExam.getSpecialSettingsEnabled()
-                    && ExamSpecialSettingsType.STAGE_BASED == cachedExam.getSpecialSettingsType()) {
-                //更改考务中的考试状态 TODO 高并发下此处可能会影响开考的性能
-                ModifyExamStageStartExamStatusReq req = new ModifyExamStageStartExamStatusReq();
-                req.setExamStageId(examStudent.getExamStageId());
-                req.setExamStageStartExamStatus(ExamStageStartExamStatus.STARTED.name());
-                examStageCloudService.modifyExamStageStartExamStatus(req);
-            }
-        }
-
         //设置并保存上次活动时间
         setAndSaveActiveTime(examRecordData.getId(), ip);
 
@@ -1502,7 +1484,9 @@ public class ExamControlServiceImpl implements ExamControlService {
             //考试过程记录(断点)打点
             ExamingActivityTime lastExamingActivityTime = getExamingActivityTime(examingRecord.getId());
             ReportsUtil.report(
-                    new ExamProcessRecordReport(examingRecord.getId(), ExamProcess.BREAK_OFF, new Date(lastExamingActivityTime.getActiveTime()))
+                    new ExamProcessRecordReport(examingRecord.getId(),
+                            ExamProcess.BREAK_OFF,
+                            lastExamingActivityTime.getActiveTime() == null ? new Date() : new Date(lastExamingActivityTime.getActiveTime()))
             );
             //考试过程记录(断点续考)打点
             ReportsUtil.report(new ExamProcessRecordReport(examingRecord.getId(), ExamProcess.CONTINUE, new Date()));
@@ -1549,10 +1533,10 @@ public class ExamControlServiceImpl implements ExamControlService {
 
         ExamingActivityTime examingActiveTime = getExamingActivityTime(examSessionInfo.getExamRecordDataId());
 
-        long activeTime = examingActiveTime.getActiveTime();
+        long now = System.currentTimeMillis();
+        long activeTime = examingActiveTime.getActiveTime() == null ? now : examingActiveTime.getActiveTime();
 
         // 如果已经过了断点续考时间,自动交卷
-        long now = System.currentTimeMillis();
         if (now - activeTime >= examSessionInfo.getExamReconnectTime().intValue() * 60 * 1000) {
             delayHandInExamIfLocked(examingRecord.getId());
             return null;
@@ -1700,7 +1684,7 @@ public class ExamControlServiceImpl implements ExamControlService {
 
         //ip如果发生变更,则记录ip变更记录
         String lastIp = examingActiveTime.getRealIp();
-        if (StringUtils.isNotEmpty(ip) && !ip.equals(lastIp)) {
+        if (StringUtils.isNotEmpty(ip) && StringUtils.isNotEmpty(lastIp) && !ip.equals(lastIp)) {
             ReportsUtil.report(
                     new ExamProcessRecordReport(examRecrodDataId, ExamProcess.IP_CHANGE, new Date(now))
             );

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

@@ -7,6 +7,11 @@ import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
+import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
+import cn.com.qmth.examcloud.api.commons.enums.ExamStageStartExamStatus;
+import cn.com.qmth.examcloud.examwork.api.ExamStageCloudService;
+import cn.com.qmth.examcloud.examwork.api.request.ModifyExamStageStartExamStatusReq;
+import cn.com.qmth.examcloud.support.helper.ExamCacheTransferHelper;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -72,6 +77,9 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
     @Autowired
     private ExamRecordQuestionsService examRecordQuestionsService;
 
+    @Autowired
+    private ExamStageCloudService examStageCloudService;
+
     @Transactional
     @Override
     public ExamRecordData createExamRecordData(ExamingSession examingSession, ExamSettingsCacheBean examBean,
@@ -107,6 +115,19 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
         examRecordData.setExamStageId(examStageId);
         examRecordData.setExamStageOrder(examStageOrder);
         examRecordDataRepo.save(examRecordData);
+
+        //更新场次的开考状态
+        if (null != examStageId) {
+            if (examBean.getSpecialSettingsEnabled()
+                    && ExamSpecialSettingsType.STAGE_BASED == examBean.getSpecialSettingsType()) {
+                //更改考务中的考试状态 TODO 高并发下此处可能会影响开考的性能
+                ModifyExamStageStartExamStatusReq req = new ModifyExamStageStartExamStatusReq();
+                req.setExamStageId(examStageId);
+                req.setExamStageStartExamStatus(ExamStageStartExamStatus.STARTED.name());
+                examStageCloudService.modifyExamStageStartExamStatus(req);
+            }
+        }
+
         ExamRecordData bean = of(examRecordData);
         //存入redis
         saveExamRecordDataCache(examRecordData.getId(), bean);