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