瀏覽代碼

阅卷接口添加日志,跟踪慢的原因

lideyin 5 年之前
父節點
當前提交
21f00244a8

+ 45 - 0
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/provider/ExamRecordCloudServiceProvider.java

@@ -268,6 +268,8 @@ public class ExamRecordCloudServiceProvider extends ControllerSupport implements
     @ApiOperation(value = "分页获取待阅卷的考试记录")
     @PostMapping("/getPagedToBeMarkExamRecord")
     public GetPagedToBeMarkExamRecordResp getPagedToBeMarkExamRecord(@RequestBody GetPagedToBeMarkExamRecordReq req) {
+        Long st = System.currentTimeMillis();
+
         Long examId = req.getExamId();
         String courseCode = req.getSubjectCode();
         Long startId = req.getStartId();
@@ -275,26 +277,54 @@ public class ExamRecordCloudServiceProvider extends ControllerSupport implements
 
         validateToBeMarkData(examId, courseCode, startId, size);
 
+        Long startTime = System.currentTimeMillis();
+
         List<ExamStudentEntity> limitedExamStuList =
                 examStudentRepo.getLimitExamStudentList(examId, courseCode, startId, size);
 
+        if (log.isDebugEnabled()) {
+            log.debug("1.[GET_PAGED_TO_BE_MARK_EXAM_RECORD-" + examId + "-" + courseCode + "-" + startId + "]" +
+                    "获取考生耗时:" + (System.currentTimeMillis() - startTime) + " ms");
+        }
+
+        startTime = System.currentTimeMillis();
+
         GetPagedToBeMarkExamRecordResp resp = new GetPagedToBeMarkExamRecordResp();
         Long nextId = startId;
 
         if (null == limitedExamStuList || limitedExamStuList.isEmpty()) {
             resp.setNextId(nextId);
             resp.setToBeMarkExamRecordBeanList(null);
+
+            if (log.isDebugEnabled()) {
+                log.debug("999.[GET_PAGED_TO_BE_MARK_EXAM_RECORD-" + examId + "-" + courseCode + "-" + startId + "]end..." +
+                        "未找到对应的考生数据,合计耗时:" + (System.currentTimeMillis() - st) + " ms");
+            }
+
             return resp;
         }
 
         List<PagedToBeMarkExamRecordBean> pagedToBeMarkList = new ArrayList<>();
 
         CourseCacheBean course = CacheHelper.getCourse(limitedExamStuList.get(0).getCourseId());
+
+        int si = 0;//考生索引
         for (ExamStudentEntity examStu : limitedExamStuList) {
+            si++;
+
+            Long st1 = System.currentTimeMillis();
+
             //当前考生待阅卷的考试记录
             List<ExamRecordForMarkingEntity> examRecordForMarkingList =
                     examRecordForMarkingService.queryValidExamRecordList(examStu.getExamStudentId());
 
+            if (log.isDebugEnabled()) {
+                log.debug("1-2." + si + "[GET_PAGED_TO_BE_MARK_EXAM_RECORD-" + examId + "-" + courseCode + "-" + examStu.getExamStudentId() + "]" +
+                        "获取考生待阅卷的考试记录耗时:" + (System.currentTimeMillis() - st1) + " ms");
+            }
+
+            st1=System.currentTimeMillis();
+
             for (ExamRecordForMarkingEntity record : examRecordForMarkingList) {
                 PagedToBeMarkExamRecordBean pagedBean = new PagedToBeMarkExamRecordBean();
                 pagedBean.setExamId(examId);
@@ -313,11 +343,26 @@ public class ExamRecordCloudServiceProvider extends ControllerSupport implements
 
                 pagedToBeMarkList.add(pagedBean);
             }
+
+            if (log.isDebugEnabled()) {
+                log.debug("1-2." + si + "[GET_PAGED_TO_BE_MARK_EXAM_RECORD-" + examId + "-" + courseCode + "-" + examStu.getExamStudentId() + "]" +
+                        "构建带作答记录的待阅卷的考试记录耗时:" + (System.currentTimeMillis() - st1) + " ms");
+            }
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("2.[GET_PAGED_TO_BE_MARK_EXAM_RECORD-" + examId + "-" + courseCode + "-" + startId + "]" +
+                    "获取" + size + "条考生的待阅卷记录共耗时:" + (System.currentTimeMillis() - startTime) + " ms");
         }
 
         nextId = limitedExamStuList.get(limitedExamStuList.size() - 1).getExamStudentId() + 1;
         resp.setNextId(nextId);
         resp.setToBeMarkExamRecordBeanList(pagedToBeMarkList);
+
+        if (log.isDebugEnabled()) {
+            log.debug("999.[GET_PAGED_TO_BE_MARK_EXAM_RECORD-" + examId + "-" + courseCode + "-" + startId + "]end..." +
+                    "合计耗时:" + (System.currentTimeMillis() - st) + " ms");
+        }
         return resp;
     }