weiwenhai 6 سال پیش
والد
کامیت
3b242ad3a1

+ 16 - 2
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/GenPaperService.java

@@ -42,10 +42,14 @@ import cn.com.qmth.examcloud.core.questions.base.CombinationUtils;
 import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
 import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
 import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
+import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLog;
+import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLogFactory;
 import cn.com.qmth.examcloud.commons.web.security.bean.User;
 
 @Service
 public class GenPaperService {
+	
+	protected ExamCloudLog log = ExamCloudLogFactory.getLog(this.getClass());
 
     @Autowired
     PaperRepo paperRepo;
@@ -72,10 +76,12 @@ public class GenPaperService {
      */
     @SuppressWarnings("unchecked")
     public Map<String, Object> genPaper(GenPaperDto genPaperDto) {
+    	log.debug("开始组卷.....");
         String msg = "";
         Map<String, Object> paperMsgMap = new HashMap<String, Object>();
         LinkedList<Question> questions = new LinkedList<Question>();
         //查询试卷结构
+        long start = System.currentTimeMillis();
         PaperStruct paperStruct = paperStructRepo.findOne(genPaperDto.getPaperStructId());
         PaperContext paperContext = new PaperContext(paperStruct, genPaperDto.getConditions());
         List<UnitContext> unitContexts = new LinkedList<UnitContext>();
@@ -93,6 +99,8 @@ public class GenPaperService {
         }
         Set<PaperDetailUnit> spareUnits = new HashSet<PaperDetailUnit>();
     	spareUnits.addAll(unitList);
+    	long total = (System.currentTimeMillis() - start) / 1000;
+    	log.debug("total:"+total);
     	
     	/*for (PaperDetailUnit unit : spareUnits) {
             Question question = unit.getQuestion();
@@ -107,7 +115,8 @@ public class GenPaperService {
             }
             questions.add(question);
         }*/
-   
+    	
+    	long start2 = System.currentTimeMillis();
     	List<Question> oList = new ArrayList<Question>();
     	for (PaperDetailUnit unit : spareUnits) {
     		oList.add(unit.getQuestion());
@@ -120,7 +129,8 @@ public class GenPaperService {
         	}
         	questions.add(oldUnit.getQuestion());
         }
-        
+    	long total2 = (System.currentTimeMillis() - start2) / 1000;
+    	log.debug("total2....."+total2);
         Collections.shuffle(questions);
         int maxLoopCount = questions.size() * 2;
         int selectCount = 0;
@@ -171,7 +181,10 @@ public class GenPaperService {
             paper.setUnitCount(this.getTotalQuesNum(paperDetailunits));
             paper.setPaperType(PaperType.GENERATE);
             // 数据入库
+            long start3 = System.currentTimeMillis();
             paper = this.persistentPaper(PaperStructType.EXACT,paperDetailunits, paperDetails, paper);
+            long total3 = (System.currentTimeMillis() - start3) / 1000;
+        	log.debug("total3....."+total3);
             msg = "success";
             paperMsgMap.put("paper", paper);
             paperMsgMap.put("msg", msg);
@@ -693,6 +706,7 @@ public class GenPaperService {
                                  List<PaperDetailUnit> selectedUnits,
                                  List<PaperDetail> details,
                                  Paper paper) {
+    	log.debug("3.....");
         paper = paperRepo.save(paper);
         for (PaperDetail pd : details) {
             pd.setPaper(paper);