deason 1 год назад
Родитель
Сommit
bd9c5cde76

+ 4 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PaperStructService.java

@@ -20,6 +20,8 @@ import cn.com.qmth.examcloud.support.CacheConstants;
 import cn.com.qmth.examcloud.web.redis.RedisClient;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageImpl;
@@ -40,6 +42,8 @@ import java.util.stream.Collectors;
 @Service
 public class PaperStructService {
 
+    private static final Logger log = LoggerFactory.getLogger(PaperStructService.class);
+
     private static int cacheTimeOut = 2 * 60 * 60;
 
     @Autowired

+ 12 - 20
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/RandomPaperServiceImpl.java

@@ -60,7 +60,7 @@ import java.util.stream.Collectors;
 @Service
 public class RandomPaperServiceImpl implements RandomPaperService {
 
-    private static final Logger log = LoggerFactory.getLogger(RandomPaperService.class);
+    private static final Logger log = LoggerFactory.getLogger(RandomPaperServiceImpl.class);
 
     private static int cacheTimeOut = 2 * 60 * 60;
 
@@ -895,14 +895,14 @@ public class RandomPaperServiceImpl implements RandomPaperService {
 
     @Override
     public DefaultPaper getRandomPaper(String randomPaperId, Integer playTime) {
-        log.warn("开始抽卷");
-        long d1 = System.currentTimeMillis();
-        RandomPaperCache rp = getByCache(randomPaperId);
-        long d2 = System.currentTimeMillis();
-        log.warn("获取抽卷模板耗时(ms):" + (d2 - d1));
+        long start = System.currentTimeMillis();
+        RandomPaperCache rp = this.getRandomPaperTemplateCacheById(randomPaperId);
+        long start2 = System.currentTimeMillis();
+        log.warn("获取抽卷模板耗时:{}ms ID:{} 题数量:{}", start2 - start, randomPaperId, rp.getQuestionMap().size());
+
         PaperStruct ps = paperStructService.getByCache(rp.getPaperStructId());
-        long d3 = System.currentTimeMillis();
-        log.warn("获取组卷结构耗时(ms):" + (d3 - d2));
+        log.warn("获取组卷结构耗时:{}ms 结构类型:{} ID:{}", System.currentTimeMillis() - start2, ps.getPaperStrucType(), rp.getPaperStructId());
+
         CreateDefaultPaperParam param = new CreateDefaultPaperParam();
         param.setFullyObjective(true);
         param.setRp(rp);
@@ -911,11 +911,11 @@ public class RandomPaperServiceImpl implements RandomPaperService {
         paper.setName(rp.getName());
         List<DefaultQuestionGroup> details = new ArrayList<>();
         paper.setQuestionGroupList(details);
+
         if (PaperStructType.BLUEPRINT.equals(ps.getPaperStrucType())) {
             if (CollectionUtils.isNotEmpty(ps.getPaperDetailStructs())) {
                 int detailNumber = 0;
                 for (PaperDetailStruct ds : ps.getPaperDetailStructs()) {
-                    long f1 = System.currentTimeMillis();
                     DefaultQuestionGroup detail = new DefaultQuestionGroup();
                     details.add(detail);
                     detail.setGroupName(ds.getName());
@@ -931,17 +931,12 @@ public class RandomPaperServiceImpl implements RandomPaperService {
                             createUnitByBlueProp(param);
                         }
                     }
-                    long f2 = System.currentTimeMillis();
-                    log.warn("蓝图抽卷一个大题耗时(ms):" + (f2 - f1));
                 }
             }
-            long d4 = System.currentTimeMillis();
-            log.warn("蓝图抽卷耗时(ms):" + (d4 - d3));
         } else if (PaperStructType.EXACT.equals(ps.getPaperStrucType())) {
             if (CollectionUtils.isNotEmpty(ps.getPaperDetailStructs())) {
                 int detailNumber = 0;
                 for (PaperDetailStruct ds : ps.getPaperDetailStructs()) {
-                    long f1 = System.currentTimeMillis();
                     DefaultQuestionGroup detail = new DefaultQuestionGroup();
                     details.add(detail);
                     detail.setGroupName(ds.getName());
@@ -958,15 +953,12 @@ public class RandomPaperServiceImpl implements RandomPaperService {
                         param.setUs(us);
                         createUnitByExact(param);
                     }
-                    long f2 = System.currentTimeMillis();
-                    log.warn("精确抽卷一个大题耗时(ms):" + (f2 - f1));
                 }
             }
-            long d4 = System.currentTimeMillis();
-            log.warn("精确抽卷耗时(ms):" + (d4 - d3));
         }
         paper.setFullyObjective(param.getFullyObjective());
-        log.warn("结束抽卷");
+
+        log.warn("抽卷完成,总耗时:{}ms ID:{}", System.currentTimeMillis() - start, randomPaperId);
         return paper;
     }
 
@@ -1133,7 +1125,7 @@ public class RandomPaperServiceImpl implements RandomPaperService {
         return ret;
     }
 
-    private RandomPaperCache getByCache(String id) {
+    private RandomPaperCache getRandomPaperTemplateCacheById(String id) {
         String key = CacheConstants.CACHE_Q_RANDOM_PAPER + id;
         RandomPaperCache rp = redisClient.get(key, RandomPaperCache.class, cacheTimeOut);
         if (rp == null) {