|
@@ -1,9 +1,14 @@
|
|
|
package com.miaxis.question.service.impl;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Random;
|
|
|
+
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.miaxis.common.exception.CustomException;
|
|
|
+import com.miaxis.question.domain.TAppExamRule;
|
|
|
import com.miaxis.question.dto.*;
|
|
|
+import com.miaxis.question.service.ITAppExamRuleService;
|
|
|
import com.miaxis.question.vo.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -21,7 +26,8 @@ import com.miaxis.question.service.IQuestionInfoService;
|
|
|
public class QuestionInfoServiceImpl extends ServiceImpl<QuestionInfoMapper, QuestionInfo> implements IQuestionInfoService {
|
|
|
@Autowired
|
|
|
private QuestionInfoMapper questionInfoMapper;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private ITAppExamRuleService appExamRuleService;
|
|
|
/**
|
|
|
* 查询题库列表
|
|
|
*
|
|
@@ -85,10 +91,7 @@ public class QuestionInfoServiceImpl extends ServiceImpl<QuestionInfoMapper, Que
|
|
|
return questionInfoMapper.selectSxQuestionInfo(questionInfoFlDTO);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<QuestionInfo> selectMiQuestionInfoList(QuestionInfoMiDTO questionInfoMiDTO) {
|
|
|
- return questionInfoMapper.selectMiQuestionInfoList(questionInfoMiDTO);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -176,21 +179,228 @@ public class QuestionInfoServiceImpl extends ServiceImpl<QuestionInfoMapper, Que
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+ public List<QuestionInfo> selectTestQuestionInfoList(QuestionInfoTestDTO questionInfoTestDTO) {
|
|
|
+ return questionInfoMapper.selectTestQuestionInfoList(questionInfoTestDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<QuestionInfo> selectTestK14QuestionInfoList(QuestionInfoTestDTO qt) {
|
|
|
+
|
|
|
+ int total = 100;
|
|
|
+ if ("mtc".equals(qt.getGs())) { //如果是摩托车取题50
|
|
|
+ total = 50;
|
|
|
+ } else if (qt.getSubject() == 1) {
|
|
|
+ total = 100;
|
|
|
+ } else if (qt.getSubject() == 4) {
|
|
|
+ total = 50;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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>();
|
|
|
+
|
|
|
+ //判断题
|
|
|
+ List<QuestionInfo> judgeList = new ArrayList<QuestionInfo>();
|
|
|
+ //选择题
|
|
|
+ List<QuestionInfo> choiceList = new ArrayList<QuestionInfo>();
|
|
|
+ //多选题
|
|
|
+ List<QuestionInfo> multipleList = new ArrayList<QuestionInfo>();
|
|
|
+
|
|
|
+ //简单题
|
|
|
+ List<Integer> easyDegree = new ArrayList<Integer>();
|
|
|
+ easyDegree.add(1);
|
|
|
+ easyDegree.add(2);
|
|
|
+ easyDegree.add(3);
|
|
|
+ //难题
|
|
|
+ List<Integer> diffDegree = new ArrayList<Integer>();
|
|
|
+ diffDegree.add(4);
|
|
|
+ diffDegree.add(5);
|
|
|
+ //科目一通用
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ 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();
|
|
|
+ int chapterId = er.getChapterId();
|
|
|
+
|
|
|
+ int total2 = easyJudge + easyChoice + easyMultiple;
|
|
|
+
|
|
|
+ QuestionInfoTestDTO questionInfoTestDTO = new QuestionInfoTestDTO();
|
|
|
+ questionInfoTestDTO.setChapterId(chapterId);
|
|
|
+ questionInfoTestDTO.setDiffDegree(diffDegree);
|
|
|
+ questionInfoTestDTO.setQuestionType(1);
|
|
|
+
|
|
|
+ if ("mtc".equals(qt.getGs())) {
|
|
|
+ questionInfoTestDTO.setLiceMoto("1");
|
|
|
+ } else if ("xc".equals(qt.getGs())) {
|
|
|
+ questionInfoTestDTO.setLiceCar("1");
|
|
|
+ } else if ("hc".equals(qt.getGs())) {
|
|
|
+ questionInfoTestDTO.setLiceTruck("1");
|
|
|
+ } else if ("kc".equals(qt.getGs())) {
|
|
|
+ questionInfoTestDTO.setLiceBus("1");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ int judgeTotal = questionInfoMapper.selectQuestionInfoCount(questionInfoTestDTO); //章节判断难题总数
|
|
|
+ questionInfoTestDTO.setQuestionType(2);
|
|
|
+ int choiceTotal = questionInfoMapper.selectQuestionInfoCount(questionInfoTestDTO); //章节选择难题总数
|
|
|
+ questionInfoTestDTO.setQuestionType(3);
|
|
|
+ int multipleTotal = questionInfoMapper.selectQuestionInfoCount(questionInfoTestDTO); //章节多选难题总数
|
|
|
+
|
|
|
+
|
|
|
+ int x = i + 1;
|
|
|
+ System.out.println("第" + x + "轮easyJudge:" + easyJudge);
|
|
|
+
|
|
|
+ Random random = new Random();
|
|
|
+ int p = 0; //判断题
|
|
|
+ int d = 0; //单选题
|
|
|
+ int m = 0; //多选题
|
|
|
+ for (int j = 0; j < er.getDifficultCount(); j++) {
|
|
|
+ if (random.nextInt(9) <= 2) { //判断题
|
|
|
+ if (easyJudge - 1 < 0 || judgeTotal - p <= 0) {
|
|
|
+ j--;
|
|
|
+ } else {
|
|
|
+ p++;
|
|
|
+ easyJudge--;
|
|
|
+ }
|
|
|
+ } else if (random.nextInt(9) <= 5) { //单选题
|
|
|
+ if (easyChoice - 1 < 0 || choiceTotal - d <= 0) {
|
|
|
+ j--;
|
|
|
+ } else {
|
|
|
+ d++;
|
|
|
+ easyChoice--;
|
|
|
+ }
|
|
|
+ } else if (random.nextInt(9) <= 8) { //多选题
|
|
|
+ if (easyMultiple - 1 < 0 || multipleTotal - m <= 0) {
|
|
|
+ j--;
|
|
|
+ } else {
|
|
|
+ m++;
|
|
|
+ easyMultiple--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ System.out.println("简单判断:" + easyJudge);
|
|
|
+ System.out.println("简单选择:" + easyChoice);
|
|
|
+ System.out.println("简单多选:" + easyMultiple);
|
|
|
+ System.out.println("难题判断:" + p);
|
|
|
+ System.out.println("难题选择:" + d);
|
|
|
+ System.out.println("难题多择:" + m);
|
|
|
+ System.out.println("总题数:" + total2);
|
|
|
+
|
|
|
+ System.out.println("---------------------------------------------");
|
|
|
+
|
|
|
+ //判断简单
|
|
|
+ qt.setChapterId(er.getChapterId()); //章节ID
|
|
|
+ qt.setDiffDegree(easyDegree); //简单难度
|
|
|
+ qt.setQuestionType(1); //判断题
|
|
|
+ qt.setNum(easyJudge); //题数
|
|
|
+ List<QuestionInfo> easyJudgeList = this.selectTestQuestionInfoList(qt);
|
|
|
+ if (easyJudge != easyJudgeList.size()) { //简单题不够的情况下,加到难题上
|
|
|
+ System.out.println("easyJudge != easyJudgeList.size()");
|
|
|
+ int easyJudgeQ = easyJudge - easyJudgeList.size();
|
|
|
+ d = d + easyJudgeQ;
|
|
|
+ qt.setNum(easyJudgeList.size());
|
|
|
+ }
|
|
|
+ //单选简单
|
|
|
+ qt.setChapterId(er.getChapterId()); //章节ID
|
|
|
+ qt.setDiffDegree(easyDegree); //简单难度
|
|
|
+ qt.setQuestionType(2); //判断题
|
|
|
+ qt.setNum(easyChoice); //题数
|
|
|
+ List<QuestionInfo> easyChoiceList = this.selectTestQuestionInfoList(qt);
|
|
|
+ if (easyChoice != easyChoiceList.size()) { //简单题不够的情况下,加到难题上
|
|
|
+ System.out.println("easyChoice != easyChoiceList.size()");
|
|
|
+ int easyChoiceQ = easyChoice - easyChoiceList.size();
|
|
|
+ d = d + easyChoiceQ;
|
|
|
+ qt.setNum(easyChoiceList.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ //多选简单
|
|
|
+ qt.setChapterId(er.getChapterId()); //章节ID
|
|
|
+ qt.setDiffDegree(easyDegree); //简单难度
|
|
|
+ qt.setQuestionType(3); //判断题
|
|
|
+ qt.setNum(easyMultiple); //题数
|
|
|
+ List<QuestionInfo> easyMultipleList = this.selectTestQuestionInfoList(qt);
|
|
|
+ if (easyMultiple != easyMultipleList.size()) { //简单题不够的情况下,加到难题上
|
|
|
+ System.out.println("easyMultiple != easyMultipleList.size()");
|
|
|
+ int easyMultipleQ = easyMultiple - easyMultipleList.size();
|
|
|
+ m = m + easyMultipleQ;
|
|
|
+ qt.setNum(easyMultipleList.size());
|
|
|
+ }
|
|
|
+ //判断难题
|
|
|
+ qt.setChapterId(er.getChapterId()); //章节ID
|
|
|
+ qt.setDiffDegree(diffDegree); //高难度
|
|
|
+ qt.setQuestionType(1); //判断题
|
|
|
+ qt.setNum(p); //题数
|
|
|
+ List<QuestionInfo> diffJudgeList = this.selectTestQuestionInfoList(qt);
|
|
|
+ if (p != diffJudgeList.size()) {
|
|
|
+ System.out.println("p!=diffJudgeList.size()");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ //单选难题
|
|
|
+ qt.setChapterId(er.getChapterId()); //章节ID
|
|
|
+ qt.setDiffDegree(diffDegree); //高难度
|
|
|
+ qt.setQuestionType(2); //判断题
|
|
|
+ qt.setNum(d); //题数
|
|
|
+ List<QuestionInfo> diffChoiceList = this.selectTestQuestionInfoList(qt);
|
|
|
+ if (d != diffChoiceList.size()) {
|
|
|
+ System.out.println("d!=diffChoiceList.size()");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //多选简单
|
|
|
+ qt.setChapterId(er.getChapterId()); //章节ID
|
|
|
+ qt.setDiffDegree(diffDegree); //高难度
|
|
|
+ qt.setQuestionType(3); //判断题
|
|
|
+ qt.setNum(m); //题数
|
|
|
+ List<QuestionInfo> diffMultipleList = this.selectTestQuestionInfoList(qt);
|
|
|
+ if (m != diffMultipleList.size()) {
|
|
|
+ System.out.println("m!=diffMultipleList.size()");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ judgeList.addAll(easyJudgeList);
|
|
|
+ judgeList.addAll(diffJudgeList);
|
|
|
+ choiceList.addAll(easyChoiceList);
|
|
|
+ choiceList.addAll(diffChoiceList);
|
|
|
+ multipleList.addAll(easyMultipleList);
|
|
|
+ multipleList.addAll(diffMultipleList);
|
|
|
+ System.out.println("easyMultipleList = " + easyMultipleList.size());
|
|
|
+ System.out.println("diffMultipleList = " + diffMultipleList.size());
|
|
|
+ }
|
|
|
+ allList.addAll(judgeList);
|
|
|
+ allList.addAll(choiceList);
|
|
|
+ allList.addAll(multipleList);
|
|
|
+ System.out.println("judgeList = "+judgeList.size());
|
|
|
+ System.out.println("choiceList = " + choiceList.size());
|
|
|
+ System.out.println("multipleList = " + multipleList.size());
|
|
|
+ return allList;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
- public List<QuestionInfo> selectFreeQuestionInfo() {
|
|
|
- QuestionInfoFreeDTO freeDTO = new QuestionInfoFreeDTO();
|
|
|
- freeDTO.setNum(10);
|
|
|
- freeDTO.setQuestionType(1);
|
|
|
- freeDTO.setSubject(1);
|
|
|
- List<QuestionInfo> list1 = questionInfoMapper.selectFreeQuestionInfoList(freeDTO);
|
|
|
- freeDTO.setQuestionType(2);
|
|
|
- List<QuestionInfo> list2 = questionInfoMapper.selectFreeQuestionInfoList(freeDTO);
|
|
|
- freeDTO.setSubject(4);
|
|
|
- freeDTO.setQuestionType(3);
|
|
|
- List<QuestionInfo> list3 = questionInfoMapper.selectFreeQuestionInfoList(freeDTO);
|
|
|
- list1.addAll(list2);
|
|
|
- list1.addAll(list3);
|
|
|
- return list1;
|
|
|
+ public List<QuestionInfo> selectMiQuestionInfoList(QuestionInfoMiDTO questionInfoMiDTO) {
|
|
|
+ return questionInfoMapper.selectMiQuestionInfoList(questionInfoMiDTO);
|
|
|
}
|
|
|
|
|
|
}
|