|
@@ -62,8 +62,8 @@ public class GenPaperService {
|
|
|
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>();
|
|
|
+ Map<String, Object> paperMsgMap = new HashMap<>();
|
|
|
+ LinkedList<Question> questions = new LinkedList<>();
|
|
|
//查询试卷结构
|
|
|
long start = System.currentTimeMillis();
|
|
|
PaperStruct paperStruct = Model.of(paperStructRepo.findById(genPaperDto.getPaperStructId()));
|
|
@@ -72,20 +72,20 @@ public class GenPaperService {
|
|
|
return paperMsgMap;
|
|
|
}
|
|
|
PaperContext paperContext = new PaperContext(paperStruct, genPaperDto.getConditions());
|
|
|
- List<UnitContext> unitContexts = new LinkedList<UnitContext>();
|
|
|
+ List<UnitContext> unitContexts = new LinkedList<>();
|
|
|
List<DetailContext> detailContexts = paperContext.getDetails();
|
|
|
for (DetailContext dc : detailContexts) {
|
|
|
unitContexts.addAll(dc.getUnits());
|
|
|
}
|
|
|
- List<Paper> papers = (List<Paper>) paperRepo.findByIdIn(genPaperDto.getPaperIds());
|
|
|
- List<PaperDetailUnit> unitList = new ArrayList<PaperDetailUnit>();
|
|
|
+ List<Paper> papers = paperRepo.findByIdIn(genPaperDto.getPaperIds());
|
|
|
+ List<PaperDetailUnit> unitList = new ArrayList<>();
|
|
|
for (Paper oldPaper : papers) {
|
|
|
//unitList.addAll(unitRepo.findByPaperOrderByNumber(oldPaper));
|
|
|
for (PaperDetailUnit paperDetailUnit : unitRepo.findByPaperOrderByNumber(oldPaper)) {
|
|
|
unitList.add(paperDetailUnit);
|
|
|
}
|
|
|
}
|
|
|
- Set<PaperDetailUnit> spareUnits = new HashSet<PaperDetailUnit>();
|
|
|
+ Set<PaperDetailUnit> spareUnits = new HashSet<>();
|
|
|
spareUnits.addAll(unitList);
|
|
|
long total = (System.currentTimeMillis() - start) / 1000;
|
|
|
log.debug("total:" + total);
|
|
@@ -105,7 +105,7 @@ public class GenPaperService {
|
|
|
questions.add(question);
|
|
|
}*/
|
|
|
|
|
|
- List<String> oIds = new ArrayList<String>();
|
|
|
+ List<String> oIds = new ArrayList<>();
|
|
|
for (PaperDetailUnit unit : spareUnits) {
|
|
|
oIds.add(unit.getQuestion().getId());
|
|
|
}
|
|
@@ -239,13 +239,13 @@ public class GenPaperService {
|
|
|
|
|
|
//通过题目分数组卷
|
|
|
private Map<String, Object> extractByQuestioScore(GenPaperDto genPaperDto, User user) {
|
|
|
- Map<String, Object> paperMsgMap = new HashMap<String, Object>();
|
|
|
+ Map<String, Object> paperMsgMap = new HashMap<>();
|
|
|
//获取所有试卷与分数
|
|
|
//Map<String, Double> paperMap = genPaperDto.getSimpleParams();
|
|
|
Map<String, NumberDto> paperMap = genPaperDto.getSimpleParams();
|
|
|
if (paperMap != null && paperMap.size() > 0) {
|
|
|
//定义随机选中的小题集合
|
|
|
- List<PaperDetailUnit> selectedUnits = new ArrayList<PaperDetailUnit>();
|
|
|
+ List<PaperDetailUnit> selectedUnits = new ArrayList<>();
|
|
|
//将所有小题按questionId去重,并按试卷分类
|
|
|
Map<String, List<PaperDetailUnit>> unitMap = sortUnitsByPaper(paperMap);
|
|
|
//随机抽题
|
|
@@ -268,7 +268,7 @@ public class GenPaperService {
|
|
|
}
|
|
|
//将所有试题按照 公开度 和 难度 进行分类
|
|
|
Map<String, List<PaperDetailUnit>> paperUnitMap = sortUnitsByProperty(unitList);
|
|
|
- List<PaperDetailUnit> newDetailUnits = new ArrayList<PaperDetailUnit>();
|
|
|
+ List<PaperDetailUnit> newDetailUnits = new ArrayList<>();
|
|
|
//获取公开简单数量
|
|
|
if (numberDto.getPublicSimple() > 0) {
|
|
|
Double needUnitScore = numberDto.getPublicSimple();
|
|
@@ -342,7 +342,7 @@ public class GenPaperService {
|
|
|
newDetailUnits = commonScoreList(needUnitScore, units, newDetailUnits, genPaperDto.getCreator());
|
|
|
}
|
|
|
//生成随机抽取的题号
|
|
|
- /*List<Integer> questionsIndex = new ArrayList<Integer>();
|
|
|
+ /*List<Integer> questionsIndex = new ArrayList<>();
|
|
|
questionsIndex = CommonUtils.getRandom(questionsIndex, unitList.size(), unitList.size());
|
|
|
//定义随机抽题的数量
|
|
|
double lastScore = 0;
|
|
@@ -392,12 +392,12 @@ public class GenPaperService {
|
|
|
|
|
|
//通过题目数量组卷
|
|
|
private Map<String, Object> extractByQuestionNum(GenPaperDto genPaperDto, User user) {
|
|
|
- Map<String, Object> paperMsgMap = new HashMap<String, Object>();
|
|
|
+ Map<String, Object> paperMsgMap = new HashMap<>();
|
|
|
//获取所有试卷与抽题数
|
|
|
Map<String, NumberDto> paperMap = genPaperDto.getSimpleParams();
|
|
|
if (paperMap != null && paperMap.size() > 0) {
|
|
|
//定义随机选中的小题集合
|
|
|
- List<PaperDetailUnit> selectedUnits = new ArrayList<PaperDetailUnit>();
|
|
|
+ List<PaperDetailUnit> selectedUnits = new ArrayList<>();
|
|
|
//将所有小题按questionId去重,并按试卷分类
|
|
|
Map<String, List<PaperDetailUnit>> unitMap = sortUnitsByPaper(paperMap);
|
|
|
//随机抽题
|
|
@@ -420,7 +420,7 @@ public class GenPaperService {
|
|
|
}
|
|
|
//将所有试题按照 公开度 和 难度 进行分类
|
|
|
Map<String, List<PaperDetailUnit>> paperUnitMap = sortUnitsByProperty(unitList);
|
|
|
- List<PaperDetailUnit> newDetailUnits = new ArrayList<PaperDetailUnit>();
|
|
|
+ List<PaperDetailUnit> newDetailUnits = new ArrayList<>();
|
|
|
//获取公开简单数量
|
|
|
if (numberDto.getPublicSimple() > 0) {
|
|
|
Integer needUnits = Integer.valueOf(numberDto.getPublicSimple().intValue());
|
|
@@ -482,7 +482,7 @@ public class GenPaperService {
|
|
|
newDetailUnits = commonNumList(needUnits, units, newDetailUnits, genPaperDto.getCreator());
|
|
|
}
|
|
|
//生成随机抽取的题号
|
|
|
- /*List<Integer> questionsIndex = new ArrayList<Integer>();
|
|
|
+ /*List<Integer> questionsIndex = new ArrayList<>();
|
|
|
questionsIndex = CommonUtils.getRandom(questionsIndex, unitList.size(), unitList.size());*/
|
|
|
//定义随机抽题的数量
|
|
|
/*int lastNumber = 0;
|
|
@@ -587,7 +587,7 @@ public class GenPaperService {
|
|
|
private Map<String, List<PaperDetailUnit>> sortUnitsByPaper(Map<String, NumberDto> paperMap) {
|
|
|
if (paperMap != null && paperMap.size() > 0) {
|
|
|
//所有小题集合
|
|
|
- List<PaperDetailUnit> oldUnits = new ArrayList<PaperDetailUnit>();
|
|
|
+ List<PaperDetailUnit> oldUnits = new ArrayList<>();
|
|
|
//取到试卷id
|
|
|
for (String paperId : paperMap.keySet()) {
|
|
|
//取到所有小题
|
|
@@ -596,13 +596,13 @@ public class GenPaperService {
|
|
|
oldUnits.addAll(unitList);
|
|
|
}
|
|
|
//如果是卷库来源,进行questionId去重
|
|
|
- Set<PaperDetailUnit> spareUnits = new HashSet<PaperDetailUnit>();
|
|
|
+ Set<PaperDetailUnit> spareUnits = new HashSet<>();
|
|
|
spareUnits.addAll(oldUnits);
|
|
|
- Map<String, List<PaperDetailUnit>> map = new HashMap<String, List<PaperDetailUnit>>();
|
|
|
+ Map<String, List<PaperDetailUnit>> map = new HashMap<>();
|
|
|
List<PaperDetailUnit> units = null;
|
|
|
for (PaperDetailUnit unit : spareUnits) {
|
|
|
if (map.get(unit.getPaper().getId()) == null) {
|
|
|
- units = new ArrayList<PaperDetailUnit>();
|
|
|
+ units = new ArrayList<>();
|
|
|
} else {
|
|
|
units = map.get(unit.getPaper().getId());
|
|
|
}
|
|
@@ -616,7 +616,7 @@ public class GenPaperService {
|
|
|
|
|
|
//将试卷下面的所有小题按照 公开度 和 难度 进行分类
|
|
|
private Map<String, List<PaperDetailUnit>> sortUnitsByProperty(List<PaperDetailUnit> units) {
|
|
|
- Map<String, List<PaperDetailUnit>> map = new HashMap<String, List<PaperDetailUnit>>();
|
|
|
+ Map<String, List<PaperDetailUnit>> map = new HashMap<>();
|
|
|
if (units != null && units.size() > 0) {
|
|
|
for (PaperDetailUnit unit : units) {
|
|
|
Question question = unit.getQuestion();
|
|
@@ -631,7 +631,7 @@ public class GenPaperService {
|
|
|
if (map.get(key) != null && map.get(key).size() > 0) {
|
|
|
units2 = map.get(key);
|
|
|
} else {
|
|
|
- units2 = new ArrayList<PaperDetailUnit>();
|
|
|
+ units2 = new ArrayList<>();
|
|
|
}
|
|
|
units2.add(unit);
|
|
|
map.put(key, units2);
|
|
@@ -727,7 +727,7 @@ public class GenPaperService {
|
|
|
|
|
|
//把集合里面相同大题的小题分类
|
|
|
private Map<String, List<PaperDetailUnit>> sortPaperDeatilUnit(List<PaperDetailUnit> selectedUnits) {
|
|
|
- Map<String, List<PaperDetailUnit>> map = new HashMap<String, List<PaperDetailUnit>>();
|
|
|
+ Map<String, List<PaperDetailUnit>> map = new HashMap<>();
|
|
|
List<PaperDetailUnit> units = null;
|
|
|
if (selectedUnits != null && selectedUnits.size() > 0) {
|
|
|
for (PaperDetailUnit unit : selectedUnits) {
|
|
@@ -735,7 +735,7 @@ public class GenPaperService {
|
|
|
if (map.get(name) != null) {
|
|
|
units = map.get(name);
|
|
|
} else {
|
|
|
- units = new ArrayList<PaperDetailUnit>();
|
|
|
+ units = new ArrayList<>();
|
|
|
}
|
|
|
units.add(unit);
|
|
|
map.put(name, units);
|
|
@@ -886,8 +886,8 @@ public class GenPaperService {
|
|
|
public Map<String, Object> genBluePaper(GenPaperDto genPaperDto) {
|
|
|
log.debug("开始蓝图组卷.....");
|
|
|
String msg = "";
|
|
|
- Map<String, Object> paperMsgMap = new HashMap<String, Object>();
|
|
|
- LinkedList<Question> questions = new LinkedList<Question>();
|
|
|
+ Map<String, Object> paperMsgMap = new HashMap<>();
|
|
|
+ LinkedList<Question> questions = new LinkedList<>();
|
|
|
//查询试卷结构
|
|
|
long start = System.currentTimeMillis();
|
|
|
PaperStruct paperStruct = Model.of(paperStructRepo.findById(genPaperDto.getPaperStructId()));
|
|
@@ -896,20 +896,20 @@ public class GenPaperService {
|
|
|
return paperMsgMap;
|
|
|
}
|
|
|
PaperContext paperContext = new PaperContext(paperStruct, genPaperDto.getConditions());
|
|
|
- List<UnitContext> unitContexts = new LinkedList<UnitContext>();
|
|
|
+ List<UnitContext> unitContexts = new LinkedList<>();
|
|
|
List<DetailContext> detailContexts = paperContext.getDetails();
|
|
|
for (DetailContext dc : detailContexts) {
|
|
|
unitContexts.addAll(dc.getUnits());
|
|
|
}
|
|
|
List<Paper> papers = (List<Paper>) paperRepo.findByIdIn(genPaperDto.getPaperIds());
|
|
|
- List<PaperDetailUnit> unitList = new ArrayList<PaperDetailUnit>();
|
|
|
+ List<PaperDetailUnit> unitList = new ArrayList<>();
|
|
|
for (Paper oldPaper : papers) {
|
|
|
//unitList.addAll(unitRepo.findByPaperOrderByNumber(oldPaper));
|
|
|
for (PaperDetailUnit paperDetailUnit : unitRepo.findByPaperOrderByNumber(oldPaper)) {
|
|
|
unitList.add(paperDetailUnit);
|
|
|
}
|
|
|
}
|
|
|
- Set<PaperDetailUnit> spareUnits = new HashSet<PaperDetailUnit>();
|
|
|
+ Set<PaperDetailUnit> spareUnits = new HashSet<>();
|
|
|
spareUnits.addAll(unitList);
|
|
|
long total = (System.currentTimeMillis() - start) / 1000;
|
|
|
log.debug("total:" + total);
|
|
@@ -929,7 +929,7 @@ public class GenPaperService {
|
|
|
questions.add(question);
|
|
|
}*/
|
|
|
|
|
|
- List<String> oIds = new ArrayList<String>();
|
|
|
+ List<String> oIds = new ArrayList<>();
|
|
|
for (PaperDetailUnit unit : spareUnits) {
|
|
|
oIds.add(unit.getQuestion().getId());
|
|
|
}
|
|
@@ -1023,7 +1023,7 @@ public class GenPaperService {
|
|
|
* @return
|
|
|
*/
|
|
|
private List<String> bulidGroup(Question question) {
|
|
|
- List<String> propertyGroups = new ArrayList<String>();
|
|
|
+ List<String> propertyGroups = new ArrayList<>();
|
|
|
propertyGroups.add(String.valueOf(question.getPublicity()) + "-" + question.getDifficulty());
|
|
|
return propertyGroups;
|
|
|
}
|
|
@@ -1035,7 +1035,7 @@ public class GenPaperService {
|
|
|
*/
|
|
|
private List<String> bulidPropertyGroup(Question question) {
|
|
|
String propertyGroup = null;
|
|
|
- List<String> propertyGroups = new ArrayList<String>();
|
|
|
+ List<String> propertyGroups = new ArrayList<>();
|
|
|
//获取试题关联的多组属性
|
|
|
List<QuesProperty> quesProperties = question.getQuesProperties();
|
|
|
if (quesProperties != null && quesProperties.size() > 0) {
|