|
@@ -6,8 +6,9 @@ import cn.com.qmth.examcloud.api.commons.enums.SubmitType;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.UserType;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.UserType;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
-import cn.com.qmth.examcloud.commons.util.UUID;
|
|
|
|
import cn.com.qmth.examcloud.commons.util.*;
|
|
import cn.com.qmth.examcloud.commons.util.*;
|
|
|
|
+import cn.com.qmth.examcloud.commons.util.UUID;
|
|
|
|
+import cn.com.qmth.examcloud.commons.util.DateUtil.DatePatterns;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.ExamRecordCloudService;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.ExamRecordCloudService;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.SyncExamDataCloudService;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.SyncExamDataCloudService;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.bean.ExamQuestionBean;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.bean.ExamQuestionBean;
|
|
@@ -65,6 +66,8 @@ import cn.com.qmth.examcloud.ws.api.enums.WebSocketEventType;
|
|
import cn.com.qmth.examcloud.ws.api.request.SendFileAnswerMessageReq;
|
|
import cn.com.qmth.examcloud.ws.api.request.SendFileAnswerMessageReq;
|
|
import cn.com.qmth.examcloud.ws.api.request.SendScanQrCodeMessageReq;
|
|
import cn.com.qmth.examcloud.ws.api.request.SendScanQrCodeMessageReq;
|
|
import cn.com.qmth.examcloud.ws.api.request.SendTextReq;
|
|
import cn.com.qmth.examcloud.ws.api.request.SendTextReq;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.google.common.base.Splitter;
|
|
import com.google.common.base.Splitter;
|
|
import main.java.com.upyun.Base64Coder;
|
|
import main.java.com.upyun.Base64Coder;
|
|
import main.java.com.upyun.UpException;
|
|
import main.java.com.upyun.UpException;
|
|
@@ -138,6 +141,7 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private ExamRecordDataRepo examRecordDataRepo;
|
|
private ExamRecordDataRepo examRecordDataRepo;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private ExamContinuedRecordRepo examContinuedRecordRepo;
|
|
private ExamContinuedRecordRepo examContinuedRecordRepo;
|
|
|
|
|
|
@@ -585,11 +589,16 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|| (examSettingsCacheBean.getExamLimit() != null && examSettingsCacheBean.getExamLimit())) {
|
|
|| (examSettingsCacheBean.getExamLimit() != null && examSettingsCacheBean.getExamLimit())) {
|
|
throw new StatusException("100016", "暂无考试资格,请与学校老师联系");
|
|
throw new StatusException("100016", "暂无考试资格,请与学校老师联系");
|
|
}
|
|
}
|
|
- if (new Date().before(examSettingsCacheBean.getBeginTime())) {
|
|
|
|
- throw new StatusException("100017", "考试未开始");
|
|
|
|
- }
|
|
|
|
- if (examSettingsCacheBean.getEndTime().before(new Date())) {
|
|
|
|
- throw new StatusException("100018", "本次考试已结束");
|
|
|
|
|
|
+ ExamPropertyCacheBean examCycleEnabledCache = CacheHelper.getExamProperty(examId, ExamProperties.EXAM_CYCLE_ENABLED.name());
|
|
|
|
+ if (examCycleEnabledCache != null && StringUtil.isTrue(examCycleEnabledCache.getValue())) {//设置周期的只校验周期
|
|
|
|
+ checkExamCycle(examId);
|
|
|
|
+ } else {
|
|
|
|
+ if (new Date().before(examSettingsCacheBean.getBeginTime())) {
|
|
|
|
+ throw new StatusException("100017", "考试未开始");
|
|
|
|
+ }
|
|
|
|
+ if (examSettingsCacheBean.getEndTime().before(new Date())) {
|
|
|
|
+ throw new StatusException("100018", "本次考试已结束");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if ((!ExamType.ONLINE.name().equals(examSettingsCacheBean.getExamType()))
|
|
if ((!ExamType.ONLINE.name().equals(examSettingsCacheBean.getExamType()))
|
|
@@ -691,6 +700,9 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
examRecordData.setHandInExamType(handInExamType);
|
|
examRecordData.setHandInExamType(handInExamType);
|
|
|
|
|
|
Long studentId = examRecordData.getStudentId();
|
|
Long studentId = examRecordData.getStudentId();
|
|
|
|
+ Long examId = examRecordData.getExamId();
|
|
|
|
+ Long rootOrgId = examRecordData.getRootOrgId();
|
|
|
|
+
|
|
if (handInExamType == HandInExamType.MANUAL) {
|
|
if (handInExamType == HandInExamType.MANUAL) {
|
|
|
|
|
|
// 得到考试时长,校验是否达到冻结时间
|
|
// 得到考试时长,校验是否达到冻结时间
|
|
@@ -700,9 +712,6 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
examRecordData.setEndTime(new Date());
|
|
examRecordData.setEndTime(new Date());
|
|
|
|
|
|
// 手工手卷时,如果开启人脸检测,则更新抓拍队列优先级
|
|
// 手工手卷时,如果开启人脸检测,则更新抓拍队列优先级
|
|
- Long rootOrgId = examRecordData.getRootOrgId();
|
|
|
|
- Long examId = examRecordData.getExamId();
|
|
|
|
-
|
|
|
|
if (FaceBiopsyHelper.isFaceEnable(rootOrgId, examId, studentId)) {
|
|
if (FaceBiopsyHelper.isFaceEnable(rootOrgId, examId, studentId)) {
|
|
//更新照片处理的优先级不影响交卷业务
|
|
//更新照片处理的优先级不影响交卷业务
|
|
try {
|
|
try {
|
|
@@ -1762,12 +1771,12 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
examSessionInfo.getExamId(), examSessionInfo.getExamStudentId()));
|
|
examSessionInfo.getExamId(), examSessionInfo.getExamStudentId()));
|
|
|
|
|
|
// 返回考试剩余时间
|
|
// 返回考试剩余时间
|
|
- long leftTime =0;
|
|
|
|
- if(examSessionInfo.getTimingEnd()) {//定点收卷
|
|
|
|
- Date now=new Date();
|
|
|
|
- leftTime=examSessionInfo.getFixedSubmitTime().getTime()-now.getTime();
|
|
|
|
- }else {
|
|
|
|
- leftTime=examSessionInfo.getExamDuration() - (examingHeartbeat.getCost() * 1000);
|
|
|
|
|
|
+ long leftTime = 0;
|
|
|
|
+ if (examSessionInfo.getTimingEnd()) {//定点收卷
|
|
|
|
+ Date now = new Date();
|
|
|
|
+ leftTime = examSessionInfo.getFixedSubmitTime().getTime() - now.getTime();
|
|
|
|
+ } else {
|
|
|
|
+ leftTime = examSessionInfo.getExamDuration() - (examingHeartbeat.getCost() * 1000);
|
|
}
|
|
}
|
|
return leftTime < 0 ? 0 : leftTime;
|
|
return leftTime < 0 ? 0 : leftTime;
|
|
}
|
|
}
|
|
@@ -1840,7 +1849,7 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
//考试总时长
|
|
//考试总时长
|
|
// long examTotalMilliSeconds = calcExamTotalMilliSeconds(examingSession.getExamRecordDataId());
|
|
// long examTotalMilliSeconds = calcExamTotalMilliSeconds(examingSession.getExamRecordDataId());
|
|
//如果开启场次,并且设置了定点交卷,且已到定点收卷时间,则不需要校验冻结时间,直接返回考试时长
|
|
//如果开启场次,并且设置了定点交卷,且已到定点收卷时间,则不需要校验冻结时间,直接返回考试时长
|
|
- if (examingSession.getTimingEnd() && examingSession.getFixedSubmitTime().getTime()<=new Date().getTime()) {
|
|
|
|
|
|
+ if (examingSession.getTimingEnd() && examingSession.getFixedSubmitTime().getTime() <= new Date().getTime()) {
|
|
return examUsedMilliSeconds;
|
|
return examUsedMilliSeconds;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2050,4 +2059,44 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
|
|
|
return bean;
|
|
return bean;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 校验考试周期
|
|
|
|
+ *
|
|
|
|
+ * @param examId
|
|
|
|
+ */
|
|
|
|
+ private void checkExamCycle(Long examId) {
|
|
|
|
+
|
|
|
|
+ Date now = new Date();
|
|
|
|
+
|
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
|
+ cal.setTime(now);
|
|
|
|
+ int weekIndex = (cal.get(Calendar.DAY_OF_WEEK) + 6) % 7;
|
|
|
|
+ if (weekIndex == 0) {
|
|
|
|
+ weekIndex = 7;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ExamPropertyCacheBean examCycleWeekCache = CacheHelper.getExamProperty(examId, ExamProperties.EXAM_CYCLE_WEEK.name());
|
|
|
|
+ if (!examCycleWeekCache.getValue().contains(String.valueOf(weekIndex))) {
|
|
|
|
+ throw new StatusException("500", "不处于指定开放时间,请稍后进入考试");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ExamPropertyCacheBean examCycleTimeRangeCache = CacheHelper.getExamProperty(examId, ExamProperties.EXAM_CYCLE_TIME_RANGE.name());
|
|
|
|
+
|
|
|
|
+ String day = DateUtil.format(now, DatePatterns.YYYY_MM_DD);
|
|
|
|
+
|
|
|
|
+ JSONArray ja = JSONObject.parseArray(examCycleTimeRangeCache.getValue());
|
|
|
|
+ for (int i = 0; i < ja.size(); i++) {
|
|
|
|
+ JSONObject jo = ja.getJSONObject(i);
|
|
|
|
+ JSONArray timeRange = jo.getJSONArray("timeRange");
|
|
|
|
+ String joStart = timeRange.getString(0);
|
|
|
|
+ String joEnd = timeRange.getString(1);
|
|
|
|
+ long start = DateUtil.parse(day + " " + joStart + ":00", DatePatterns.CHINA_DEFAULT).getTime();
|
|
|
|
+ long end = DateUtil.parse(day + " " + joEnd + ":59", DatePatterns.CHINA_DEFAULT).getTime();
|
|
|
|
+ if (start <= now.getTime() && end >= now.getTime()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ throw new StatusException("500", "不处于指定开放时间,请稍后进入考试");
|
|
|
|
+ }
|
|
}
|
|
}
|