|
@@ -28,6 +28,7 @@ public class QuestionInfoServiceImpl extends ServiceImpl<QuestionInfoMapper, Que
|
|
|
private QuestionInfoMapper questionInfoMapper;
|
|
|
@Autowired
|
|
|
private ITAppExamRuleService appExamRuleService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询题库列表
|
|
|
*
|
|
@@ -35,12 +36,12 @@ public class QuestionInfoServiceImpl extends ServiceImpl<QuestionInfoMapper, Que
|
|
|
* @return 题库
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<QuestionInfo> selectQuestionInfoList(QuestionInfoDTO questionInfoDTO){
|
|
|
+ public List<QuestionInfo> selectQuestionInfoList(QuestionInfoDTO questionInfoDTO) {
|
|
|
|
|
|
//1:分类练习:class_sort;2:精选考题:excell_sort;3:地方专题:place_sort;4:顺序练习:seque_sort;
|
|
|
Integer sort = questionInfoDTO.getSort();
|
|
|
- if(sort!=null) {
|
|
|
- switch (sort){
|
|
|
+ if (sort != null) {
|
|
|
+ switch (sort) {
|
|
|
case 1:
|
|
|
questionInfoDTO.setSortName("class_sort");
|
|
|
break;
|
|
@@ -92,14 +93,12 @@ public class QuestionInfoServiceImpl extends ServiceImpl<QuestionInfoMapper, Que
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
public List<QuestionInfo> selectTestQuestionInfo(QuestionInfoTestDTO questionInfoTestDTO) {
|
|
|
|
|
|
|
|
|
- if("1".equals(questionInfoTestDTO.getLiceMoto())) {
|
|
|
- if(questionInfoTestDTO.getSubject()==1){
|
|
|
+ if ("1".equals(questionInfoTestDTO.getLiceMoto())) {
|
|
|
+ if (questionInfoTestDTO.getSubject() == 1) {
|
|
|
questionInfoTestDTO.setQuestionType(1);
|
|
|
questionInfoTestDTO.setNum(20);
|
|
|
List<QuestionInfo> list1 = questionInfoMapper.selectTestQuestionInfoList(questionInfoTestDTO);
|
|
@@ -108,7 +107,7 @@ public class QuestionInfoServiceImpl extends ServiceImpl<QuestionInfoMapper, Que
|
|
|
List<QuestionInfo> list2 = questionInfoMapper.selectTestQuestionInfoList(questionInfoTestDTO);
|
|
|
list1.addAll(list2);
|
|
|
return list1;
|
|
|
- } else if (questionInfoTestDTO.getSubject()==4) {
|
|
|
+ } else if (questionInfoTestDTO.getSubject() == 4) {
|
|
|
questionInfoTestDTO.setQuestionType(1);
|
|
|
questionInfoTestDTO.setNum(20);
|
|
|
List<QuestionInfo> list1 = questionInfoMapper.selectTestQuestionInfoList(questionInfoTestDTO);
|
|
@@ -123,7 +122,7 @@ public class QuestionInfoServiceImpl extends ServiceImpl<QuestionInfoMapper, Que
|
|
|
return list1;
|
|
|
}
|
|
|
} else {
|
|
|
- if(questionInfoTestDTO.getSubject()==1){
|
|
|
+ if (questionInfoTestDTO.getSubject() == 1) {
|
|
|
//旧判断20题
|
|
|
questionInfoTestDTO.setQuestionType(1);
|
|
|
questionInfoTestDTO.setNum(20);
|
|
@@ -149,7 +148,7 @@ public class QuestionInfoServiceImpl extends ServiceImpl<QuestionInfoMapper, Que
|
|
|
list1.addAll(list3);
|
|
|
list1.addAll(list4);
|
|
|
return list1;
|
|
|
- } else if (questionInfoTestDTO.getSubject()==4) {
|
|
|
+ } else if (questionInfoTestDTO.getSubject() == 4) {
|
|
|
questionInfoTestDTO.setQuestionType(1);
|
|
|
questionInfoTestDTO.setNum(20);
|
|
|
questionInfoTestDTO.setExcellIssueName("必");
|
|
@@ -179,14 +178,13 @@ public class QuestionInfoServiceImpl extends ServiceImpl<QuestionInfoMapper, Que
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
public List<QuestionInfo> selectTestQuestionInfoList(QuestionInfoTestDTO questionInfoTestDTO) {
|
|
|
return questionInfoMapper.selectTestQuestionInfoList(questionInfoTestDTO);
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public List<QuestionInfo> selectTestK14QuestionInfoList(QuestionInfoTestDTO qt) {
|
|
|
+ public List<QuestionInfo> selectTestK14QuestionInfoList2(QuestionInfoTestDTO qt) {
|
|
|
|
|
|
int total = 100;
|
|
|
if ("mtc".equals(qt.getGs())) { //如果是摩托车取题50
|
|
@@ -392,12 +390,98 @@ public class QuestionInfoServiceImpl extends ServiceImpl<QuestionInfoMapper, Que
|
|
|
allList.addAll(judgeList);
|
|
|
allList.addAll(choiceList);
|
|
|
allList.addAll(multipleList);
|
|
|
- System.out.println("judgeList = "+judgeList.size());
|
|
|
+ System.out.println("judgeList = " + judgeList.size());
|
|
|
System.out.println("choiceList = " + choiceList.size());
|
|
|
System.out.println("multipleList = " + multipleList.size());
|
|
|
return allList;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<QuestionInfo> selectTestK14QuestionInfoList(QuestionInfoTestDTO qt) {
|
|
|
+
|
|
|
+ if ("mtc".equals(qt.getGs())) {
|
|
|
+ qt.setLiceMoto("1");
|
|
|
+ } else if ("xc".equals(qt.getGs())) {
|
|
|
+ qt.setLiceCar("1");
|
|
|
+ } else if ("hc".equals(qt.getGs())) {
|
|
|
+ qt.setLiceTruck("1");
|
|
|
+ } else if ("kc".equals(qt.getGs())) {
|
|
|
+ qt.setLiceBus("1");
|
|
|
+ }
|
|
|
+ //全题库
|
|
|
+ List<QuestionInfo> allList = new ArrayList<QuestionInfo>();
|
|
|
+ TAppExamRule tAppExamRule = new TAppExamRule();
|
|
|
+ tAppExamRule.setKemu(qt.getSubject());
|
|
|
+ tAppExamRule.setGs(qt.getGs());
|
|
|
+ tAppExamRule.setAreacode(0);
|
|
|
+
|
|
|
+ List<TAppExamRule> list = appExamRuleService.selectTAppExamRuleList(tAppExamRule);
|
|
|
+ if (list.size() == 0) {
|
|
|
+ return allList;
|
|
|
+ }
|
|
|
+ int total = 0;
|
|
|
+ StringBuffer sql = new StringBuffer();
|
|
|
+ sql.append("SELECT * FROM (");
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ TAppExamRule er = list.get(i);
|
|
|
+ int easyJudge = er.getJudgeCount(); //判断
|
|
|
+ int easyChoice = er.getChoiceCount(); //选择
|
|
|
+ int easyMultiple = er.getMultipleChoiceCount(); //多选
|
|
|
+
|
|
|
+ total = total + easyJudge + easyChoice + easyMultiple;
|
|
|
+
|
|
|
+ int difficult = er.getDifficultCount(); //难题数
|
|
|
+ int chapterId = er.getChapterId();
|
|
|
+
|
|
|
+ Random random = new Random();
|
|
|
+ int diffJudeg = 0; //判断题
|
|
|
+ int diffChoice = 0; //单选题
|
|
|
+ int diffMultiple = 0; //多选题
|
|
|
+ for (int j = 0; j < difficult; j++) {
|
|
|
+ if (random.nextInt(9) <= 2) { //判断题
|
|
|
+ diffJudeg++;
|
|
|
+ easyJudge--;
|
|
|
+ } else if (random.nextInt(9) <= 5) { //单选题
|
|
|
+ diffChoice++;
|
|
|
+ easyChoice--;
|
|
|
+ } else if (random.nextInt(9) <= 8) { //多选题
|
|
|
+ diffMultiple++;
|
|
|
+ easyMultiple--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(i!=0){
|
|
|
+ sql.append(" union ");
|
|
|
+ }
|
|
|
+ //判断题
|
|
|
+ sql.append(" (SELECT * FROM question_info WHERE chapter_id = " + chapterId + " AND subject = "+qt.getSubject()+" AND question_type = '1' AND diff_degree in (1,2,3) ORDER BY RAND() LIMIT " + easyJudge + ") ");
|
|
|
+ sql.append(" union ");
|
|
|
+ sql.append(" (SELECT * FROM question_info WHERE chapter_id = " + chapterId + " AND subject = "+qt.getSubject()+" AND question_type = '1' AND diff_degree in (4,5) ORDER BY RAND() LIMIT "+ diffJudeg + ") ");
|
|
|
+ sql.append(" union ");
|
|
|
+ //选择题
|
|
|
+ sql.append(" (SELECT * FROM question_info WHERE chapter_id = " + chapterId + " AND subject = "+qt.getSubject()+" AND question_type = '2' AND diff_degree in (1,2,3) ORDER BY RAND() LIMIT " + easyChoice + ") ");
|
|
|
+ sql.append(" union ");
|
|
|
+ sql.append(" (SELECT * FROM question_info WHERE chapter_id = " + chapterId + " AND subject = "+qt.getSubject()+" AND question_type = '2' AND diff_degree in (4,5) ORDER BY RAND() LIMIT "+ diffChoice + ") ");
|
|
|
+ //多选题
|
|
|
+ if(qt.getSubject()==4){
|
|
|
+ sql.append(" union ");
|
|
|
+ sql.append(" (SELECT * FROM question_info WHERE chapter_id = " + chapterId + " AND subject = "+qt.getSubject()+" AND question_type = '3' AND diff_degree in (1,2,3) ORDER BY RAND() LIMIT "+ easyMultiple + ") ");
|
|
|
+ sql.append(" union ");
|
|
|
+ sql.append(" (SELECT * FROM question_info WHERE chapter_id = " + chapterId + " AND subject = "+qt.getSubject()+" AND question_type = '3' AND diff_degree in (4,5) ORDER BY RAND() LIMIT "+ diffMultiple + ") ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sql.append(" ) as db");
|
|
|
+ System.out.println(sql.toString());
|
|
|
+ allList = questionInfoMapper.selectTestK14QuestionInfoList(sql.toString());
|
|
|
+ if(allList.size()==total) {
|
|
|
+ return allList;
|
|
|
+ } else {
|
|
|
+ new CustomException("模拟考试取题出错,请重试。");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<QuestionInfo> selectMiQuestionInfoList(QuestionInfoMiDTO questionInfoMiDTO) {
|
|
|
return questionInfoMapper.selectMiQuestionInfoList(questionInfoMiDTO);
|