|
@@ -171,7 +171,7 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
|
|
|
// 又拍云签名有效时间(秒)
|
|
|
private static final Integer SIGN_TIMEOUT = 60;
|
|
|
-
|
|
|
+
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public StartExamInfo startExam(Long examStudentId, User user) {
|
|
@@ -753,6 +753,12 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
throw new StatusException("100002", "登录信息错误");
|
|
|
}
|
|
|
|
|
|
+ //考生id为空时,需要给考生id重新赋值
|
|
|
+ if (req.getExamRecordDataId() == null) {
|
|
|
+ ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(req.getExamRecordDataId());
|
|
|
+ req.setExamStudentId(examRecordData.getExamStudentId());
|
|
|
+ }
|
|
|
+
|
|
|
// 如果是调用环境监测的接口,不用做如下校验
|
|
|
if (!req.isTestEnv()) {
|
|
|
ExamingSession examSessionInfo = examingSessionService.getExamingSession(user.getUserId());
|
|
@@ -771,11 +777,8 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
|| examSessionInfo.getExamStudentId().longValue() != req.getExamStudentId().longValue()) {
|
|
|
throw new StatusException("100008", "无效的请求");
|
|
|
}
|
|
|
- } else {
|
|
|
- // 环境检测时,需要重新给考生id赋值
|
|
|
- ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(req.getExamRecordDataId());
|
|
|
- req.setExamStudentId(examRecordData.getExamStudentId());
|
|
|
}
|
|
|
+
|
|
|
String key = user.getKey();
|
|
|
StringBuffer param = new StringBuffer();
|
|
|
String transferFileType = StringUtils.isBlank(req.getTransferFileType()) ? "" : req.getTransferFileType();
|
|
@@ -1192,7 +1195,7 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
}
|
|
|
// 更新考试中的断点续考属性
|
|
|
examRecordDataService.saveExamRecordDataCache(examingRecord.getId(), examingRecord);
|
|
|
-
|
|
|
+
|
|
|
String examingHeartbeatKey = RedisKeyHelper.getBuilder()
|
|
|
.examingHeartbeatKey(examSessionInfo.getExamRecordDataId());
|
|
|
ExamingHeartbeat examingHeartbeat = redisClient.get(examingHeartbeatKey,
|
|
@@ -1230,7 +1233,7 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
if (examingRecord == null) {
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
String examingHeartbeatKey = RedisKeyHelper.getBuilder()
|
|
|
.examingHeartbeatKey(examSessionInfo.getExamRecordDataId());
|
|
|
ExamingHeartbeat examingHeartbeat = redisClient.get(examingHeartbeatKey,
|
|
@@ -1243,7 +1246,7 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
delayHandInExamIfLocked(examingRecord.getId());
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
String examingActiveTimeKey = RedisKeyHelper.getBuilder()
|
|
|
.examingActiveTimeKey(examSessionInfo.getExamRecordDataId());
|
|
|
ExamingActivityTime examingActiveTime = redisClient.get(examingActiveTimeKey,
|
|
@@ -1326,24 +1329,24 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
|
|
|
String examingHeartbeatKey = RedisKeyHelper.getBuilder().examingHeartbeatKey(examSessionInfo.getExamRecordDataId());
|
|
|
ExamingHeartbeat examingHeartbeat = redisClient.get(examingHeartbeatKey,ExamingHeartbeat.class);
|
|
|
-
|
|
|
+
|
|
|
if (null != examingHeartbeat
|
|
|
&& examingHeartbeat.getCost() >= examSessionInfo.getExamDuration()) {
|
|
|
throw new StatusException("8002", "考试会话已过期,请重新开考");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (null==examingHeartbeat) {
|
|
|
examingHeartbeat=new ExamingHeartbeat();
|
|
|
examingHeartbeat.setCost(0L);
|
|
|
examingHeartbeat.setTimes(0L);
|
|
|
examingHeartbeat.setExamRecordDataId(examSessionInfo.getExamRecordDataId());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
examingHeartbeat.setTimes(examingHeartbeat.getTimes()+1);
|
|
|
examingHeartbeat.setCost(examingHeartbeat.getCost() + 60);
|
|
|
-
|
|
|
+
|
|
|
redisClient.set(examingHeartbeatKey, examingHeartbeat);
|
|
|
-
|
|
|
+
|
|
|
String examingActiveTimeKey = RedisKeyHelper.getBuilder()
|
|
|
.examingActiveTimeKey(examSessionInfo.getExamRecordDataId());
|
|
|
ExamingActivityTime examingActiveTime = redisClient.get(examingActiveTimeKey,
|
|
@@ -1353,17 +1356,17 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
examingActiveTime.setActiveTime(System.currentTimeMillis());
|
|
|
examingActiveTime.setExamRecordDataId(examSessionInfo.getExamRecordDataId());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
redisClient.set(examingActiveTimeKey, examingActiveTime);
|
|
|
|
|
|
long activeTime = examingActiveTime.getActiveTime();
|
|
|
-
|
|
|
+
|
|
|
long now = System.currentTimeMillis();
|
|
|
if (now - activeTime>= examSessionInfo.getExamReconnectTime().intValue() * 60 * 1000) {
|
|
|
delayHandInExamIfLocked(examSessionInfo.getExamRecordDataId());
|
|
|
return 0L;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 在线考生心跳打点
|
|
|
ReportsUtil.report(new OnlineExamStudentReport(user.getRootOrgId(), user.getUserId(),
|
|
|
examSessionInfo.getExamId(), examSessionInfo.getExamStudentId()));
|
|
@@ -1385,14 +1388,14 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
if (examingSession == null) {
|
|
|
throw new StatusException("oestudent-100100", "考试会话已过期");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
String examingHeartbeatKey = RedisKeyHelper.getBuilder()
|
|
|
.examingHeartbeatKey(examingSession.getExamRecordDataId());
|
|
|
ExamingHeartbeat examingHeartbeat = redisClient.get(examingHeartbeatKey,
|
|
|
ExamingHeartbeat.class);
|
|
|
|
|
|
long cost = null == examingHeartbeat ? 0L : examingHeartbeat.getCost();
|
|
|
-
|
|
|
+
|
|
|
Long examUsedMilliSeconds = cost * 1000;
|
|
|
// 如果没有超过冻结时间,抛出异常
|
|
|
if (examingSession.getExamType().equals(ExamType.ONLINE.name())) {
|