|
@@ -84,21 +84,24 @@ public class GenPaperService {
|
|
|
unitContexts.addAll(dc.getUnits());
|
|
|
}
|
|
|
List<Paper> papers = (List<Paper>) paperRepo.findAll(genPaperDto.getPaperIds());
|
|
|
+ List<PaperDetailUnit> unitList = new ArrayList<PaperDetailUnit>();
|
|
|
for (Paper oldPaper : papers) {
|
|
|
- List<PaperDetailUnit> unitList = unitRepo.findByPaperOrderByNumber(oldPaper);
|
|
|
- for (PaperDetailUnit unit : unitList) {
|
|
|
- Question question = unit.getQuestion();
|
|
|
- //根据questionId查询题库中大题来源
|
|
|
- List<PaperDetailUnit> units = unitRepo.findByQuestion(question);
|
|
|
- for(PaperDetailUnit oldUnit:units){
|
|
|
- Paper paper = oldUnit.getPaper();
|
|
|
- if(paper.getPaperType() == PaperType.IMPORT){
|
|
|
- question.setQuesName(oldUnit.getPaperDetail().getName());
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- questions.add(question);
|
|
|
+ unitList.addAll(unitRepo.findByPaperOrderByNumber(oldPaper));
|
|
|
+ }
|
|
|
+ Set<PaperDetailUnit> spareUnits = new HashSet<PaperDetailUnit>();
|
|
|
+ spareUnits.addAll(unitList);
|
|
|
+ for (PaperDetailUnit unit : unitList) {
|
|
|
+ Question question = unit.getQuestion();
|
|
|
+ //根据questionId查询题库中大题来源
|
|
|
+ List<PaperDetailUnit> units = unitRepo.findByQuestion(question);
|
|
|
+ for(PaperDetailUnit oldUnit:units){
|
|
|
+ Paper paper = oldUnit.getPaper();
|
|
|
+ if(paper.getPaperType() == PaperType.IMPORT){
|
|
|
+ question.setQuesName(oldUnit.getPaperDetail().getName());
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+ questions.add(question);
|
|
|
}
|
|
|
Collections.shuffle(questions);
|
|
|
int maxLoopCount = questions.size() * 2;
|