Преглед на файлове

提交exampaper保存代码

chenken преди 8 години
родител
ревизия
f803ba7e6b

+ 2 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/service/ExamPaperService.java

@@ -13,5 +13,7 @@ import com.qmth.cqb.paper.model.ExamPaper;
 public interface ExamPaperService {
 	
 	public List<ExamPaper> findExamPaperList(ExamPaper condition);
+	
+	public ExamPaper saveExamPaper(ExamPaper examPaper);
 }
 

+ 5 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/service/ExamPaperServiceImpl.java

@@ -26,5 +26,10 @@ public class ExamPaperServiceImpl implements ExamPaperService {
 		return examPaperRepo.findAll(Example.of(condition));
 	}
 
+	@Override
+	public ExamPaper saveExamPaper(ExamPaper examPaper) {
+		return examPaperRepo.save(examPaper);
+	}
+
 }
 

+ 21 - 12
cqb-paper/src/main/java/com/qmth/cqb/paper/service/ExtractConfigServiceImpl.java

@@ -52,13 +52,16 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
     private PaperDetailUnitService paperDetailUnitService;
     
     @Autowired
-    PaperService paperService;
+    private PaperService paperService;
     
     @Autowired
-    PaperRepo paperRepo;
+    private PaperRepo paperRepo;
     
     @Autowired
-    QuesRepo quesRepo;
+    private QuesRepo quesRepo;
+    
+    @Autowired
+    private ExamPaperService examPaperService;
     
 	@Override
 	public ExtractConfig findConfig(ExtractConfig condition) {
@@ -86,6 +89,7 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
 			Paper paper = examPaper.getPaper();
 			paper = paperRepo.findOne(paper.getId());
 			examPaper.setPaper(paper);
+			examPaperService.saveExamPaper(examPaper);//保存
 		}
 		extractConfigRepo.save(extractConfig);
 	}
@@ -108,6 +112,9 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
 		}
 		//获得抽取好的试卷
 		Map<String,Paper> paperMap = this.getExamPaperByProbability(extractConfig.getExamPaperList());
+		if(paperMap.isEmpty()){
+			throw new RuntimeException("抽取试卷失败");
+		}
         for (Map.Entry<String, Paper> entry : paperMap.entrySet()) {
         	String key = entry.getKey();
         	//根据原有试卷重新组卷得到新试卷
@@ -120,7 +127,7 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
          * 设置map,并保存调卷规则
          * 如果已经设置过了,就不再设置
          */
-        if(extractConfig.getIfFinish()==null){
+        if(extractConfig.getIfFinish()==null||extractConfig.getIfFinish()==0){
         	extractConfig.setFinishedPaperIdMap(finishedPaperIdMap);
         	extractConfig.setIfFinish((short)1);
         	extractConfigRepo.save(extractConfig);
@@ -192,14 +199,16 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
 				}
 			}
 		}
-		Set<String> keys = examPaperMap.keySet();
-		Iterator<String> it = keys.iterator();
-		while (it.hasNext()) {
-			String key = it.next();
-			Paper paper = this.getPaperByProbability(examPaperMap.get(key));
-			//不能用原来的paper对象,否则examPaperList中的paper对象会被覆盖
-			Paper newPaper =paperRepo.findOne(paper.getId());
-			paperByTypeMap.put(key,newPaper);
+		if(examPaperMap!=null){
+			Set<String> keys = examPaperMap.keySet();
+			Iterator<String> it = keys.iterator();
+			while (it.hasNext()) {
+				String key = it.next();
+				Paper paper = this.getPaperByProbability(examPaperMap.get(key));
+				//不能用原来的paper对象,否则examPaperList中的paper对象会被覆盖
+				Paper newPaper =paperRepo.findOne(paper.getId());
+				paperByTypeMap.put(key,newPaper);
+			}
 		}
         return paperByTypeMap;
 	}