Explorar o código

添加节点的最大时长的默认值

lideyin %!s(int64=5) %!d(string=hai) anos
pai
achega
fce5703ef5

+ 16 - 11
examcloud-core-oe-task-service/src/main/java/cn/com/qmth/examcloud/core/oe/task/service/pipeline/AfterHandInExamExecutor.java

@@ -36,6 +36,7 @@ public class AfterHandInExamExecutor implements NodeExecuter<Long, ExamRecordDat
 
     @Autowired
     private ExamRecordDataService examRecordDataService;
+    private static Long DEFAULT_MAX_PROCESS_SECONDS = 30L;
 
     @Override
     public List<KeyValuePair<Long, ExamRecordData>> execute(Long key, ExamRecordData examRecordData, TaskContext context) throws Exception {
@@ -48,21 +49,25 @@ public class AfterHandInExamExecutor implements NodeExecuter<Long, ExamRecordDat
                 examRecordData.getExamRecordStatus() == ExamRecordStatus.EXAM_AUTO_HAND_IN) {
 
             SysPropertyCacheBean maxProcessSecondsProperty = CacheHelper.getSysProperty("oe.task.maxProcessSeconds");
+            //本节点最大处理时长
+            Long maxProcessSeconds;
             if (maxProcessSecondsProperty.getHasValue()) {
-                //本节点最大处理时长
-                Long maxProcessSeconds = Long.valueOf(maxProcessSecondsProperty.getValue().toString());
-                //交卷时间戳
-                Long handInTime = (examRecordData.getEndTime() == null ? examRecordData.getCleanTime() : examRecordData.getEndTime()).getTime();
-                Long times = System.currentTimeMillis() - handInTime;
+                maxProcessSeconds = Long.valueOf(maxProcessSecondsProperty.getValue().toString());
+            } else {
+                maxProcessSeconds = DEFAULT_MAX_PROCESS_SECONDS;
+            }
+
+            //交卷时间戳
+            Long handInTime = (examRecordData.getEndTime() == null ? examRecordData.getCleanTime() : examRecordData.getEndTime()).getTime();
+            Long times = System.currentTimeMillis() - handInTime;
 
-                //如果交卷后超过指定时长内仍未处理完成,则交给下一节点进行处理
-                if (times > maxProcessSeconds * 1000) {
-                    resultList.add(keyValuePair);
-                    return resultList;
-                }
+            //如果交卷后超过指定时长内仍未处理完成,则交给下一节点进行处理
+            if (times > maxProcessSeconds * 1000) {
+                resultList.add(keyValuePair);
+                return resultList;
             }
 
-            examRecordData=examRecordDataService.processAfterHandInExam(examRecordData.getId());
+            examRecordData = examRecordDataService.processAfterHandInExam(examRecordData.getId());
 
             keyValuePair.setValue(examRecordData);
             resultList.add(keyValuePair);