|
@@ -1,29 +1,26 @@
|
|
|
package cn.com.qmth.examcloud.core.oe.task.service.pipeline;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
import cn.com.qmth.examcloud.commons.helpers.KeyValuePair;
|
|
|
import cn.com.qmth.examcloud.commons.helpers.pipeline.NodeExecuter;
|
|
|
-import cn.com.qmth.examcloud.commons.helpers.pipeline.Storer;
|
|
|
import cn.com.qmth.examcloud.commons.helpers.pipeline.TaskContext;
|
|
|
import cn.com.qmth.examcloud.core.oe.task.service.ExamRecordDataService;
|
|
|
import cn.com.qmth.examcloud.core.oe.task.service.ExamingSessionService;
|
|
|
-import cn.com.qmth.examcloud.examwork.api.ExamStudentCloudService;
|
|
|
import cn.com.qmth.examcloud.support.Constants;
|
|
|
import cn.com.qmth.examcloud.support.enums.ExamRecordStatus;
|
|
|
import cn.com.qmth.examcloud.support.examing.ExamRecordData;
|
|
|
+import cn.com.qmth.examcloud.support.examing.ExamingActivityTime;
|
|
|
+import cn.com.qmth.examcloud.support.examing.ExamingHeartbeat;
|
|
|
import cn.com.qmth.examcloud.support.examing.ExamingSession;
|
|
|
+import cn.com.qmth.examcloud.support.redis.RedisKeyHelper;
|
|
|
import cn.com.qmth.examcloud.web.helpers.SequenceLockHelper;
|
|
|
-import com.google.common.collect.Lists;
|
|
|
-import com.sun.org.apache.xpath.internal.operations.Bool;
|
|
|
-import org.apache.commons.io.FileUtils;
|
|
|
-import org.apache.commons.lang3.RandomUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
-import java.io.File;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
|
|
|
/**
|
|
|
* @Description 自动交卷执行器
|
|
@@ -38,6 +35,8 @@ public class HandInExamExecutor implements NodeExecuter<Long, ExamRecordData, Lo
|
|
|
private ExamingSessionService examingSessionService;
|
|
|
@Autowired
|
|
|
private ExamRecordDataService examRecordDataService;
|
|
|
+ @Autowired
|
|
|
+ private RedisClient redisClient;
|
|
|
|
|
|
@Override
|
|
|
public List<KeyValuePair<Long, ExamRecordData>> execute(Long key, ExamRecordData examRecordData, TaskContext context) throws Exception {
|
|
@@ -88,7 +87,14 @@ public class HandInExamExecutor implements NodeExecuter<Long, ExamRecordData, Lo
|
|
|
* @return
|
|
|
*/
|
|
|
private boolean isOverExamTime(ExamingSession examingSession) {
|
|
|
- return examingSession.getExamDuration() <= examingSession.getCost() * 1000;
|
|
|
+ String examingHeartbeatKey = RedisKeyHelper.getBuilder()
|
|
|
+ .examingHeartbeatKey(examingSession.getExamRecordDataId());
|
|
|
+ ExamingHeartbeat examingHeartbeat = redisClient.get(examingHeartbeatKey,
|
|
|
+ ExamingHeartbeat.class);
|
|
|
+
|
|
|
+ //秒
|
|
|
+ long cost = null == examingHeartbeat ? 0 : examingHeartbeat.getCost();
|
|
|
+ return examingSession.getExamDuration() <= cost * 1000;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -99,6 +105,16 @@ public class HandInExamExecutor implements NodeExecuter<Long, ExamRecordData, Lo
|
|
|
*/
|
|
|
private boolean isOverBreakpointTime(ExamingSession examingSession) {
|
|
|
long now = System.currentTimeMillis();
|
|
|
- return now - examingSession.getActiveTime() >= examingSession.getExamReconnectTime().intValue() * 60 * 1000;
|
|
|
+
|
|
|
+ String examingActiveTimeKey = RedisKeyHelper.getBuilder()
|
|
|
+ .examingActiveTimeKey(examingSession.getExamRecordDataId());
|
|
|
+ ExamingActivityTime examingActiveTime = redisClient.get(examingActiveTimeKey,
|
|
|
+ ExamingActivityTime.class);
|
|
|
+
|
|
|
+ long activeTime = null == examingActiveTime
|
|
|
+ ? System.currentTimeMillis()
|
|
|
+ : examingActiveTime.getActiveTime();
|
|
|
+ return now - activeTime>= examingSession.getExamReconnectTime().intValue() * 60 * 1000;
|
|
|
}
|
|
|
+
|
|
|
}
|