|
@@ -25,6 +25,7 @@ import com.qmth.cqb.paper.model.PaperDetail;
|
|
|
import com.qmth.cqb.paper.model.PaperDetailUnit;
|
|
|
import com.qmth.cqb.paper.model.PaperStruct;
|
|
|
import com.qmth.cqb.question.model.Question;
|
|
|
+import com.qmth.cqb.utils.BeanCopierUtil;
|
|
|
import com.qmth.cqb.utils.CombinationUtils;
|
|
|
import com.qmth.cqb.utils.CommonUtils;
|
|
|
import com.qmth.cqb.utils.enums.PaperType;
|
|
@@ -46,8 +47,6 @@ public class GenPaperService {
|
|
|
@Autowired
|
|
|
PaperStructRepo paperStructRepo;
|
|
|
|
|
|
- // private List<<>> = new HashMap<String, AtomicInteger>();
|
|
|
-
|
|
|
/**
|
|
|
* 精确组卷,根据设定试卷结构组卷
|
|
|
*
|
|
@@ -197,8 +196,9 @@ public class GenPaperService {
|
|
|
}
|
|
|
}
|
|
|
List<Integer> canChooseNestNum = this.getNestNum(nestQums, otherQuesNum.size(), needQuesNum);
|
|
|
- Collections.shuffle(canChooseNestNum);// 随机乱序
|
|
|
- int ranmdomNum = canChooseNestNum.get(0);// 取第一个
|
|
|
+ int size = canChooseNestNum.size();
|
|
|
+ int index = (int) (Math.random() * size);
|
|
|
+ int ranmdomNum = canChooseNestNum.get(index);// 取第一个
|
|
|
if (ranmdomNum == 0) {// 假如随机到0个套题
|
|
|
selectedUnits = this.getNeedUnits(null, unitList, needQuesNum);
|
|
|
} else {
|
|
@@ -290,10 +290,12 @@ public class GenPaperService {
|
|
|
*/
|
|
|
public Paper constuctPaper(List<PaperDetailUnit> selectedUnits, GenPaperDto genPaperDto) {
|
|
|
Collections.sort(selectedUnits);// 根据大题题型ID排序
|
|
|
+ List<PaperDetailUnit> saveUnits = BeanCopierUtil.copyPropertiesOfList(selectedUnits, PaperDetailUnit.class);
|
|
|
List<QuesStructType> qsts = new ArrayList<QuesStructType>();
|
|
|
- for (int i = 0; i < selectedUnits.size(); i++) {
|
|
|
- if (!qsts.contains(selectedUnits.get(i).getQuestionType())) {
|
|
|
- qsts.add(selectedUnits.get(i).getQuestionType());
|
|
|
+ for (int i = 0; i < saveUnits.size(); i++) {
|
|
|
+ saveUnits.get(i).setId(UUID.randomUUID().toString());
|
|
|
+ if (!qsts.contains(saveUnits.get(i).getQuestionType())) {
|
|
|
+ qsts.add(saveUnits.get(i).getQuestionType());
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -301,9 +303,9 @@ public class GenPaperService {
|
|
|
Map<QuesStructType, Integer> qTypeIndexMap = new HashMap<QuesStructType, Integer>();
|
|
|
for (int i = 1; i <= qsts.size(); i++) {
|
|
|
List<PaperDetailUnit> tempUnits = new ArrayList<PaperDetailUnit>();
|
|
|
- for (int j = 0; j < selectedUnits.size(); j++) {
|
|
|
- if (qsts.get(i - 1) == selectedUnits.get(j).getQuestionType()) {
|
|
|
- tempUnits.add(selectedUnits.get(j));
|
|
|
+ for (int j = 0; j < saveUnits.size(); j++) {
|
|
|
+ if (qsts.get(i - 1) == saveUnits.get(j).getQuestionType()) {
|
|
|
+ tempUnits.add(saveUnits.get(j));
|
|
|
}
|
|
|
}
|
|
|
unitMap.put(qsts.get(i - 1), tempUnits);
|
|
@@ -315,8 +317,8 @@ public class GenPaperService {
|
|
|
details.add(this.constuctPaperDeatil(unitMap.get(qType), qTypeIndexMap.get(qType), qType.getName()));
|
|
|
}
|
|
|
Paper paper = this.constuctPaperByPaperDetails(details, genPaperDto);
|
|
|
- paper.setUnitCount(this.getTotalQuesNum(selectedUnits));// 设置小题数量,需统计subQuestion
|
|
|
- paper = this.persistentPaper(selectedUnits, details, paper);
|
|
|
+ paper.setUnitCount(this.getTotalQuesNum(saveUnits));// 设置小题数量,需统计subQuestion
|
|
|
+ paper = this.persistentPaper(saveUnits, details, paper);
|
|
|
return paper;
|
|
|
|
|
|
}
|