deason 2 年之前
父节点
当前提交
0782d0dd63

+ 28 - 3
examcloud-core-oe-task-service/src/main/java/cn/com/qmth/examcloud/core/oe/task/service/job/AfterHandInExamJobHandler.java

@@ -101,9 +101,11 @@ public class AfterHandInExamJobHandler {
 
         // 交卷时间(手动交卷取endTime,自动交卷取cleanTime)
         Date handInTime = examRecordDataCache.getEndTime() != null ? examRecordDataCache.getEndTime() : examRecordDataCache.getCleanTime();
-        long diff = (System.currentTimeMillis() - handInTime.getTime()) / 1000;
-        log.warn("交卷类型:{} 交卷距离现在已{}秒, examRecordDataId:{}, studentId:{}, curTodoSize:{}, curTodoIndex:{}",
-                examRecordDataCache.getHandInExamType(), diff, examRecordDataId, examRecordDataCache.getStudentId(), curTodoSize, curTodoIndex);
+        long diffSecond = (System.currentTimeMillis() - handInTime.getTime()) / 1000L;
+        String warnMsg = (diffSecond / 3600L) >= 12L ? "【警告】交卷处理超过12小时!!!" : "";
+        log.warn("【{}】交卷距离现在已:{}, examRecordDataId:{}, studentId:{}, curTodoSize:{}, curTodoIndex:{} {}",
+                examRecordDataCache.getHandInExamType(), this.diff(diffSecond), examRecordDataId,
+                examRecordDataCache.getStudentId(), curTodoSize, curTodoIndex, warnMsg);
 
         try {
             // 处理人脸、活体、违纪、算分等
@@ -118,4 +120,27 @@ public class AfterHandInExamJobHandler {
         }
     }
 
+    /**
+     * 将相差多少秒 格式化为:xx小时xx分xx秒
+     */
+    private String diff(long diffSecond) {
+        long hour = diffSecond / 3600;
+        long minute = diffSecond / 60 - hour * 60;
+        long second = diffSecond - hour * 3600 - minute * 60;
+        StringBuilder result = new StringBuilder();
+        if (hour > 0) {
+            result.append(hour).append("小时");
+            result.append(minute).append("分");
+            result.append(second).append("秒");
+            return result.toString();
+        }
+        if (minute > 0) {
+            result.append(minute).append("分");
+            result.append(second).append("秒");
+            return result.toString();
+        }
+        result.append(second).append("秒");
+        return result.toString();
+    }
+
 }