Quellcode durchsuchen

模拟考取题

小么熊🐻 vor 2 Jahren
Ursprung
Commit
407eadb18f
17 geänderte Dateien mit 987 neuen und 7 gelöschten Zeilen
  1. 12 0
      zzjs-admin/src/main/java/com/miaxis/app/controller/question/QuestionInfoController.java
  2. 3 3
      zzjs-admin/src/test/java/com/miaxis/test/KTRename.java
  3. 26 0
      zzjs-admin/src/test/java/com/miaxis/test/Test04.java
  4. 303 0
      zzjs-admin/src/test/java/com/miaxis/test/TestRule.java
  5. 117 0
      zzjs-service/src/main/java/com/miaxis/question/controller/TAppExamRuleController.java
  6. 13 0
      zzjs-service/src/main/java/com/miaxis/question/domain/QuestionInfo.java
  7. 93 0
      zzjs-service/src/main/java/com/miaxis/question/domain/TAppExamRule.java
  8. 54 0
      zzjs-service/src/main/java/com/miaxis/question/dto/QuestionInfoTestDTO.java
  9. 40 0
      zzjs-service/src/main/java/com/miaxis/question/dto/TAppExamRuleDTO.java
  10. 2 0
      zzjs-service/src/main/java/com/miaxis/question/mapper/QuestionInfoMapper.java
  11. 22 0
      zzjs-service/src/main/java/com/miaxis/question/mapper/TAppExamRuleMapper.java
  12. 4 0
      zzjs-service/src/main/java/com/miaxis/question/service/IQuestionInfoService.java
  13. 21 0
      zzjs-service/src/main/java/com/miaxis/question/service/ITAppExamRuleService.java
  14. 181 3
      zzjs-service/src/main/java/com/miaxis/question/service/impl/QuestionInfoServiceImpl.java
  15. 36 0
      zzjs-service/src/main/java/com/miaxis/question/service/impl/TAppExamRuleServiceImpl.java
  16. 19 1
      zzjs-service/src/main/resources/mapper/question/QuestionInfoMapper.xml
  17. 41 0
      zzjs-service/src/main/resources/mapper/rule/TAppExamRuleMapper.xml

+ 12 - 0
zzjs-admin/src/main/java/com/miaxis/app/controller/question/QuestionInfoController.java

@@ -6,6 +6,7 @@ import com.miaxis.common.core.domain.Response;
 import com.miaxis.common.core.page.ResponsePageInfo;
 import com.miaxis.question.domain.QuestionInfo;
 import com.miaxis.question.dto.QuestionInfoDTO;
+import com.miaxis.question.dto.QuestionInfoTestDTO;
 import com.miaxis.question.service.IQuestionInfoService;
 import io.swagger.annotations.*;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -83,5 +84,16 @@ public class QuestionInfoController extends BaseController {
         return toResponsePageInfo(list);
     }
 
+
+    /**
+     * 查询模拟考试科目1与4题库
+     */
+    @GetMapping("/selectTestK14QuestionInfoList")
+    @ApiOperation("取模拟考试题库")
+    public ResponsePageInfo<QuestionInfo> selectTestK14QuestionInfoList(@ModelAttribute QuestionInfoTestDTO questionInfoTestDTO){
+        List<QuestionInfo> list = questionInfoService.selectTestK14QuestionInfoList(questionInfoTestDTO);
+        return toResponsePageInfo(list);
+    }
+
 }
 

+ 3 - 3
zzjs-admin/src/test/java/com/miaxis/test/KTRename.java

@@ -27,8 +27,8 @@ public class KTRename {
     @Test
     public void testExcel() throws Exception {
 
-        String saveDir = "G:\\中正\\题库图\\image_new";
-        File winDir = new File("G:\\中正\\题库图\\需改名");
+        String saveDir = "G:\\中正\\题库图\\不要水印背景2";
+        File winDir = new File("G:\\中正\\题库图\\不要水印背景");
         File[] files = winDir.listFiles();
 
         for (int i = 0; i < files.length; i++) {
@@ -37,7 +37,7 @@ public class KTRename {
             System.out.println(files[i].getName());
 
             String fileName = files[i].getName();
-            String fileNameNew = "image"+fileName;
+            String fileNameNew = "explain"+fileName;
 
             File file = new File(saveDir + File.separator + fileNameNew);
 

+ 26 - 0
zzjs-admin/src/test/java/com/miaxis/test/Test04.java

@@ -0,0 +1,26 @@
+package com.miaxis.test;
+
+import java.util.Random;
+
+public class Test04 {
+
+
+    public static void main(String[] args) {
+        int x = 1;
+
+        while (true) {
+
+
+            for (int i = 0; i < 10; i++) {
+                if(i/2==0) {
+                    System.out.println(i);
+                    continue;
+                } else {
+                    System.out.println(i);
+                }
+            }
+
+        }
+    }
+
+}

+ 303 - 0
zzjs-admin/src/test/java/com/miaxis/test/TestRule.java

@@ -0,0 +1,303 @@
+package com.miaxis.test;
+
+import com.miaxis.ZzjsApplication;
+import com.miaxis.question.domain.QuestionInfo;
+import com.miaxis.question.domain.TAppExamRule;
+import com.miaxis.question.dto.QuestionInfoTestDTO;
+import com.miaxis.question.service.IQuestionInfoService;
+import com.miaxis.question.service.ITAppExamRuleService;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.sql.Array;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+@SpringBootTest(classes = ZzjsApplication.class)
+@RunWith(SpringRunner.class)
+public class TestRule {
+
+
+    @Autowired
+    private ITAppExamRuleService appExamRuleService;
+
+    @Autowired
+    private IQuestionInfoService questionInfoService;
+
+    @Test
+    public void test() throws Exception {
+
+        //全题库
+        List<QuestionInfo> allList = new ArrayList<QuestionInfo>();
+        //选择
+        List<QuestionInfo> judgeList = new ArrayList<QuestionInfo>();
+        //判断题
+        List<QuestionInfo> choiceList = 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(1);
+        tAppExamRule.setGs("xc");
+        tAppExamRule.setAreacode(0);
+
+        List<TAppExamRule> list = appExamRuleService.selectTAppExamRuleList(tAppExamRule);
+        int total = 0;
+        for (int i = 0; i < list.size(); i++) {
+            TAppExamRule er = list.get(i);
+            int easyJudge = er.getJudgeCount();
+            int easyChoice = er.getChoiceCount();
+
+            Random random = new Random();
+            int d = 0; //单选题
+            int p = 0; //判断题
+            for (int j = 0; j < er.getDifficultCount(); j++) {
+                if (random.nextInt(10) >= 5) {   //单选题
+                    if (easyJudge - 1 < 0) {
+                        j--;
+                    } else {
+                        d++;
+                        easyJudge--;
+                    }
+                } else {  //判断题
+                    if (easyChoice - 1 < 0) {
+                        j--;
+                    } else {
+                        p++;
+                        easyChoice--;
+                    }
+                }
+            }
+
+            System.out.println("简单判断:" + easyJudge);
+            System.out.println("简单选择:" + easyChoice);
+            System.out.println("难题判断:" + p);
+            System.out.println("难题选择:" + d);
+            total += easyJudge + easyChoice + p + d;
+            System.out.println("---------------------------------------------");
+
+
+            //判断简单
+            QuestionInfoTestDTO qt = new QuestionInfoTestDTO();
+            qt.setChapterId(er.getChapterId()); //章节ID
+            qt.setDiffDegree(easyDegree);       //简单难度
+            qt.setQuestionType(1);              //判断题
+            qt.setLiceCar("1");                 //车型
+            qt.setNum(easyJudge);               //题数
+            List<QuestionInfo> easyJudgeList = questionInfoService.selectTestQuestionInfoList(qt);
+
+            //单选简单
+            qt.setChapterId(er.getChapterId()); //章节ID
+            qt.setDiffDegree(easyDegree);       //简单难度
+            qt.setQuestionType(2);              //判断题
+            qt.setLiceCar("1");                 //车型
+            qt.setNum(easyChoice);              //题数
+            List<QuestionInfo> easyChoiceList = questionInfoService.selectTestQuestionInfoList(qt);
+
+
+            //判断难题
+            qt.setChapterId(er.getChapterId()); //章节ID
+            qt.setDiffDegree(diffDegree);       //高难度
+            qt.setQuestionType(1);              //判断题
+            qt.setLiceCar("1");                 //车型
+            qt.setNum(p);                       //题数
+            List<QuestionInfo> diffJudgeList = questionInfoService.selectTestQuestionInfoList(qt);
+
+
+            //单选难题
+            qt.setChapterId(er.getChapterId()); //章节ID
+            qt.setDiffDegree(diffDegree);       //高难度
+            qt.setQuestionType(1);              //判断题
+            qt.setLiceCar("1");                 //车型
+            qt.setNum(d);                       //题数
+            List<QuestionInfo> diffChoiceList = questionInfoService.selectTestQuestionInfoList(qt);
+
+
+            judgeList.addAll(easyJudgeList);
+            judgeList.addAll(diffJudgeList);
+            choiceList.addAll(easyChoiceList);
+            choiceList.addAll(diffChoiceList);
+        }
+
+        allList.addAll(judgeList);
+        allList.addAll(choiceList);
+        System.out.println("judgeList:" + judgeList.size());
+        System.out.println("choiceList:" + choiceList.size());
+        System.out.println("allList:" + allList.size());
+
+
+    }
+
+
+    @Test
+    public void test2() throws Exception {
+        //全题库
+        List<QuestionInfo> allList = new ArrayList<QuestionInfo>();
+        int error = 0;
+        while (allList.size()!=50 && error<10) {
+            System.out.println("error:"+error);
+            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(4);
+            tAppExamRule.setGs("hc");
+            tAppExamRule.setAreacode(0);
+
+            List<TAppExamRule> list = appExamRuleService.selectTAppExamRuleList(tAppExamRule);
+            int total = 0;
+            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 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) {
+                            j--;
+                        } else {
+                            p++;
+                            easyJudge--;
+                        }
+                    } else if (random.nextInt(9) <= 5) {  //单选题
+                        if (easyChoice - 1 < 0) {
+                            j--;
+                        } else {
+                            d++;
+                            easyChoice--;
+                        }
+                    } else if (random.nextInt(9) <= 8) {    //多选题
+                        if (easyMultiple - 1 < 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);
+                total += easyJudge + easyChoice + easyMultiple + p + d + m;
+                System.out.println("---------------------------------------------");
+
+
+                //判断简单
+                QuestionInfoTestDTO qt = new QuestionInfoTestDTO();
+                qt.setChapterId(er.getChapterId()); //章节ID
+                qt.setDiffDegree(easyDegree);       //简单难度
+                qt.setQuestionType(1);              //判断题
+                qt.setLiceTruck("1");                 //车型
+                qt.setNum(easyJudge);               //题数
+                List<QuestionInfo> easyJudgeList = questionInfoService.selectTestQuestionInfoList(qt);
+                //单选简单
+                qt.setChapterId(er.getChapterId()); //章节ID
+                qt.setDiffDegree(easyDegree);       //简单难度
+                qt.setQuestionType(2);              //判断题
+                qt.setNum(easyChoice);              //题数
+                List<QuestionInfo> easyChoiceList = questionInfoService.selectTestQuestionInfoList(qt);
+                //多选简单
+                qt.setChapterId(er.getChapterId()); //章节ID
+                qt.setDiffDegree(easyDegree);       //简单难度
+                qt.setQuestionType(3);              //判断题
+                qt.setNum(easyMultiple);              //题数
+                List<QuestionInfo> easyMultipleList = questionInfoService.selectTestQuestionInfoList(qt);
+
+                //判断难题
+                qt.setChapterId(er.getChapterId()); //章节ID
+                qt.setDiffDegree(diffDegree);       //高难度
+                qt.setQuestionType(1);              //判断题
+                qt.setNum(p);                       //题数
+                List<QuestionInfo> diffJudgeList = questionInfoService.selectTestQuestionInfoList(qt);
+                if(p!=diffJudgeList.size()){
+                    System.out.println("p!=diffJudgeList.size()");
+                    error++;
+                    break;
+                }
+
+                //单选难题
+                qt.setChapterId(er.getChapterId()); //章节ID
+                qt.setDiffDegree(diffDegree);       //高难度
+                qt.setQuestionType(2);              //判断题
+                qt.setNum(d);                       //题数
+                List<QuestionInfo> diffChoiceList = questionInfoService.selectTestQuestionInfoList(qt);
+                if(d!=diffChoiceList.size()){
+                    System.out.println("d!=diffChoiceList.size()");
+                    error++;
+                    break;
+                }
+                //多选简单
+                qt.setChapterId(er.getChapterId()); //章节ID
+                qt.setDiffDegree(diffDegree);       //高难度
+                qt.setQuestionType(3);              //判断题
+                qt.setNum(m);                       //题数
+                List<QuestionInfo> diffMultipleList = questionInfoService.selectTestQuestionInfoList(qt);
+                if(m!=diffMultipleList.size()){
+                    System.out.println("m!=diffMultipleList.size()");
+                    error++;
+                    break;
+                }
+
+                judgeList.addAll(easyJudgeList);
+                judgeList.addAll(diffJudgeList);
+                int judge = easyJudgeList.size() + diffJudgeList.size();
+                System.out.println("第" + x + "轮:" + judge);
+
+                choiceList.addAll(easyChoiceList);
+                choiceList.addAll(diffChoiceList);
+                multipleList.addAll(easyMultipleList);
+                multipleList.addAll(diffMultipleList);
+
+
+            }
+
+            allList.addAll(judgeList);
+            allList.addAll(choiceList);
+            allList.addAll(multipleList);
+            System.out.println("error:"+error);
+            System.out.println("allList:" + allList.size());
+        }
+
+
+    }
+
+
+}

+ 117 - 0
zzjs-service/src/main/java/com/miaxis/question/controller/TAppExamRuleController.java

@@ -0,0 +1,117 @@
+package com.miaxis.question.controller;
+
+import com.miaxis.common.constant.Constants;
+import java.util.List;
+import java.util.Arrays;
+import io.swagger.annotations.*;
+import com.miaxis.common.core.domain.Response;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import com.miaxis.common.annotation.Log;
+import com.miaxis.common.core.controller.BaseController;
+import com.miaxis.common.enums.BusinessTypeEnum;
+import com.miaxis.question.domain.TAppExamRule;
+import com.miaxis.question.service.ITAppExamRuleService;
+import com.miaxis.common.utils.poi.ExcelUtil;
+import com.miaxis.common.core.page.ResponsePageInfo;
+
+/**
+ * 【考试取题】Controller
+ *
+ * @author miaxis
+ * @date 2022-05-23
+ */
+@RestController
+@RequestMapping("/rule/rule")
+@Api(tags={"【小程序-考试取题】"})
+public class TAppExamRuleController extends BaseController{
+    @Autowired
+    private ITAppExamRuleService tAppExamRuleService;
+
+    /**
+     * 查询考试取题列表
+     */
+    @PreAuthorize("@ss.hasPermi('rule:rule:list')")
+    @GetMapping("/list")
+    @ApiOperation("查询考试取题列表")
+        @ApiImplicitParams({
+            @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
+            @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
+    })
+    public ResponsePageInfo<TAppExamRule> list(@ModelAttribute TAppExamRule tAppExamRule){
+        startPage();
+        List<TAppExamRule> list = tAppExamRuleService.selectTAppExamRuleList(tAppExamRule);
+        return toResponsePageInfo(list);
+    }
+    
+    /**
+     * 导出考试取题列表
+     */
+    @PreAuthorize("@ss.hasPermi('rule:rule:export')")
+    @Log(title = "考试取题", businessType = BusinessTypeEnum.EXPORT)
+    @GetMapping("/export")
+    @ApiOperation("导出考试取题列表Excel")
+    public Response<String> export(@ModelAttribute TAppExamRule tAppExamRule){
+        List<TAppExamRule> list = tAppExamRuleService.selectTAppExamRuleList(tAppExamRule);
+        ExcelUtil<TAppExamRule> util = new ExcelUtil<TAppExamRule>(TAppExamRule.class);
+        return util.exportExcel(list, "rule");
+    }
+
+    /**
+     * 获取考试取题详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('rule:rule:query')")
+    @GetMapping(value = "/{id}")
+    @ApiOperation("获取考试取题详细信息")
+    public Response<TAppExamRule> getInfo(
+            @ApiParam(name = "id", value = "考试取题参数", required = true)
+            @PathVariable("id") Long id
+    ){
+        return Response.success(tAppExamRuleService.getById(id));
+    }
+
+    /**
+     * 新增考试取题
+     */
+    @PreAuthorize("@ss.hasPermi('rule:rule:add')")
+    @Log(title = "考试取题", businessType = BusinessTypeEnum.INSERT)
+    @PostMapping
+    @ApiOperation("新增考试取题")
+    public Response<Integer> add(@RequestBody TAppExamRule tAppExamRule){
+        return toResponse(tAppExamRuleService.save(tAppExamRule) ? 1 : 0);
+    }
+
+    /**
+     * 修改考试取题
+     */
+    @PreAuthorize("@ss.hasPermi('rule:rule:edit')")
+    @Log(title = "考试取题", businessType = BusinessTypeEnum.UPDATE)
+    @PutMapping
+    @ApiOperation("修改考试取题")
+    public Response<Integer> edit(@RequestBody TAppExamRule tAppExamRule){
+        return toResponse(tAppExamRuleService.updateById(tAppExamRule) ? 1 : 0);
+    }
+
+    /**
+     * 删除考试取题
+     */
+    @PreAuthorize("@ss.hasPermi('rule:rule:remove')")
+    @Log(title = "考试取题", businessType = BusinessTypeEnum.DELETE)
+	@DeleteMapping("/{ids}")
+    @ApiOperation("删除考试取题")
+    public  Response<Integer> remove(
+            @ApiParam(name = "ids", value = "考试取题ids参数", required = true)
+            @PathVariable Long[] ids
+    ){
+        return toResponse(tAppExamRuleService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
+    }
+}

+ 13 - 0
zzjs-service/src/main/java/com/miaxis/question/domain/QuestionInfo.java

@@ -249,4 +249,17 @@ public class QuestionInfo extends BaseBusinessEntity {
     private Integer placeSort;
 
 
+    /** 章节ID */
+    @Excel(name = "章节ID")
+    @TableField("chapter_id")
+    @ApiModelProperty(value = "地方专题排序字段")
+    private Integer chapterId;
+
+    /** 章节ID */
+    @Excel(name = "章节ID")
+    @TableField("diff_degree")
+    @ApiModelProperty(value = "地方专题排序字段")
+    private Integer DiffDegree;
+
+
 }

+ 93 - 0
zzjs-service/src/main/java/com/miaxis/question/domain/TAppExamRule.java

@@ -0,0 +1,93 @@
+package com.miaxis.question.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.miaxis.common.annotation.Excel;
+import com.miaxis.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.miaxis.common.core.domain.BaseBusinessEntity;
+import lombok.Data;
+/**
+ * 考试取题对象 t_app_exam_rule
+ *
+ * @author miaxis
+ * @date 2022-05-23
+ */
+@Data
+@TableName("t_app_exam_rule")
+@ApiModel(value = "TAppExamRule", description = "考试取题对象 t_app_exam_rule")
+public class TAppExamRule extends BaseBusinessEntity{
+    private static final long serialVersionUID = 1L;
+
+    /** $column.columnComment */
+    @TableField("id")
+    @ApiModelProperty(value = "$column.columnComment")
+    private Long id;
+
+    /** 车型 */
+    @Excel(name = "车型")
+    @TableField("gs")
+    @ApiModelProperty(value = "车型")
+    private String gs;
+
+    /** 科目 */
+    @Excel(name = "科目")
+    @TableField("kemu")
+    @ApiModelProperty(value = "科目")
+    private Integer kemu;
+
+    /** 章节ID */
+    @Excel(name = "章节ID")
+    @TableField("chapter_id")
+    @ApiModelProperty(value = "章节ID")
+    private Integer chapterId;
+
+    /** 总题库 */
+    @Excel(name = "总题库")
+    @TableField("total_count")
+    @ApiModelProperty(value = "总题库")
+    private Integer totalCount;
+
+    /** 判断题数 */
+    @Excel(name = "判断题数")
+    @TableField("judge_count")
+    @ApiModelProperty(value = "判断题数")
+    private Integer judgeCount;
+
+    /** 选择题数 */
+    @Excel(name = "选择题数")
+    @TableField("choice_count")
+    @ApiModelProperty(value = "选择题数")
+    private Integer choiceCount;
+
+    /** 多择题数 */
+    @Excel(name = "多择题数")
+    @TableField("multiple_choice_count")
+    @ApiModelProperty(value = "多择题数")
+    private Integer multipleChoiceCount;
+
+    /** 困难题数 */
+    @Excel(name = "困难题数")
+    @TableField("difficult_count")
+    @ApiModelProperty(value = "困难题数")
+    private Integer difficultCount;
+
+    /** 地区编号 */
+    @Excel(name = "地区编号")
+    @TableField("areacode")
+    @ApiModelProperty(value = "地区编号")
+    private Integer areacode;
+
+    /** 城市ID */
+    @Excel(name = "城市ID")
+    @TableField("city_id")
+    @ApiModelProperty(value = "城市ID")
+    private Integer cityId;
+
+
+}

+ 54 - 0
zzjs-service/src/main/java/com/miaxis/question/dto/QuestionInfoTestDTO.java

@@ -0,0 +1,54 @@
+package com.miaxis.question.dto;
+
+import com.miaxis.common.core.domain.BaseBusinessEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 地方题选分类返回对象
+ * @author miaxis
+ * @date 2021-10-20
+ */
+@Data
+@ApiModel(value = "QuestionInfoTestDTO", description = "模拟考试输入对象")
+public class QuestionInfoTestDTO {
+    private static final long serialVersionUID = 1L;
+
+
+    @ApiModelProperty(value = "科目")
+    private Integer subject;
+
+    @ApiModelProperty(hidden = true)
+    private String liceCar;
+
+    @ApiModelProperty(hidden = true)
+    private String liceBus;
+
+    @ApiModelProperty(hidden = true)
+    private String liceTruck;
+
+    @ApiModelProperty(hidden = true)
+    private String liceMoto;
+
+    @ApiModelProperty(value = "取题车型 小车:xc;客车:kc;货车:hc;摩托车:mtc")
+    private String gs;
+
+    @ApiModelProperty(hidden = true)
+    private String excellIssueName;
+
+    @ApiModelProperty(hidden = true)
+    private Integer questionType;
+
+    @ApiModelProperty(hidden = true)
+    private Integer chapterId;
+
+    @ApiModelProperty(hidden = true)
+    private List<Integer> diffDegree;
+
+    @ApiModelProperty(hidden = true)
+    private Integer num;
+
+}

+ 40 - 0
zzjs-service/src/main/java/com/miaxis/question/dto/TAppExamRuleDTO.java

@@ -0,0 +1,40 @@
+package com.miaxis.question.dto;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.miaxis.common.annotation.Excel;
+import com.miaxis.common.core.domain.BaseBusinessEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 考试取题对象 t_app_exam_rule
+ *
+ * @author miaxis
+ * @date 2022-05-23
+ */
+@Data
+@ApiModel(value = "TAppExamRuleDTO", description = "t_app_exam_rule")
+public class TAppExamRuleDTO {
+    private static final long serialVersionUID = 1L;
+
+
+    /** 车型 */
+    @ApiModelProperty(value = "车型")
+    private String gs;
+
+    /** 科目 */
+    @ApiModelProperty(value = "科目")
+    private Long kemu;
+
+    /** 章节ID */
+    @ApiModelProperty(value = "章节ID")
+    private Long chapterId;
+
+
+
+
+}

+ 2 - 0
zzjs-service/src/main/java/com/miaxis/question/mapper/QuestionInfoMapper.java

@@ -24,4 +24,6 @@ public interface QuestionInfoMapper extends BaseMapper<QuestionInfo> {
     List<QuestionInfo> selectQuestionInfoListByYdtIds(Long[] ids);
 
     List<QuestionInfo> selectQuestionInfoListByIds(Long[] ids);
+
+    List<QuestionInfo> selectTestQuestionInfoList(QuestionInfoTestDTO questionInfoTestDTO);
 }

+ 22 - 0
zzjs-service/src/main/java/com/miaxis/question/mapper/TAppExamRuleMapper.java

@@ -0,0 +1,22 @@
+package com.miaxis.question.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.miaxis.question.domain.TAppExamRule;
+
+/**
+ * 考试取题Mapper接口
+ *
+ * @author miaxis
+ * @date 2022-05-23
+ */
+public interface TAppExamRuleMapper extends BaseMapper<TAppExamRule> {
+    /**
+     * 查询考试取题列表
+     *
+     * @param tAppExamRule 考试取题
+     * @return 考试取题集合
+     */
+    public List<TAppExamRule> selectTAppExamRuleList(TAppExamRule tAppExamRule);
+
+}

+ 4 - 0
zzjs-service/src/main/java/com/miaxis/question/service/IQuestionInfoService.java

@@ -25,5 +25,9 @@ public interface IQuestionInfoService extends IService<QuestionInfo>{
 
     List<QuestionInfo> selectQuestionInfoListByYdtIds(Long[] ids);
 
+    List<QuestionInfo> selectTestQuestionInfoList(QuestionInfoTestDTO questionInfoTestDTO);
+
+    List<QuestionInfo> selectTestK14QuestionInfoList(QuestionInfoTestDTO questionInfoTestDTO);
+
 }
 

+ 21 - 0
zzjs-service/src/main/java/com/miaxis/question/service/ITAppExamRuleService.java

@@ -0,0 +1,21 @@
+package com.miaxis.question.service;
+
+import java.util.List;
+import com.miaxis.question.domain.TAppExamRule;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 考试取题Service接口
+ *
+ * @author miaxis
+ * @date 2022-05-23
+ */
+public interface ITAppExamRuleService extends IService<TAppExamRule>{
+    /**
+     * 查询考试取题列表
+     *
+     * @param tAppExamRule 考试取题
+     * @return 考试取题集合
+     */
+    public List<TAppExamRule> selectTAppExamRuleList(TAppExamRule tAppExamRule);
+}

+ 181 - 3
zzjs-service/src/main/java/com/miaxis/question/service/impl/QuestionInfoServiceImpl.java

@@ -3,13 +3,17 @@ package com.miaxis.question.service.impl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.miaxis.common.exception.CustomException;
 import com.miaxis.question.domain.QuestionInfo;
+import com.miaxis.question.domain.TAppExamRule;
 import com.miaxis.question.dto.*;
 import com.miaxis.question.mapper.QuestionInfoMapper;
 import com.miaxis.question.service.IQuestionInfoService;
+import com.miaxis.question.service.ITAppExamRuleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Random;
 
 /**
  * 题库Service业务层处理
@@ -22,6 +26,9 @@ public class QuestionInfoServiceImpl extends ServiceImpl<QuestionInfoMapper, Que
     @Autowired
     private QuestionInfoMapper questionInfoMapper;
 
+    @Autowired
+    private ITAppExamRuleService appExamRuleService;
+
     /**
      * 查询题库列表
      *
@@ -29,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;
@@ -64,10 +71,181 @@ public class QuestionInfoServiceImpl extends ServiceImpl<QuestionInfoMapper, Que
         return questionInfoMapper.selectQuestionInfoListByYdtIds(ids);
     }
 
+    @Override
+    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>();
+        int error = 0;
+        while (allList.size() != total && error < 10) {
+            System.out.println("error:" + error);
+            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 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) {
+                            j--;
+                        } else {
+                            p++;
+                            easyJudge--;
+                        }
+                    } else if (random.nextInt(9) <= 5) {  //单选题
+                        if (easyChoice - 1 < 0) {
+                            j--;
+                        } else {
+                            d++;
+                            easyChoice--;
+                        }
+                    } else if (random.nextInt(9) <= 8) {    //多选题
+                        if (easyMultiple - 1 < 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("---------------------------------------------");
 
+                //判断简单
+                qt.setChapterId(er.getChapterId()); //章节ID
+                qt.setDiffDegree(easyDegree);       //简单难度
+                qt.setQuestionType(1);              //判断题
+                qt.setNum(easyJudge);               //题数
+                List<QuestionInfo> easyJudgeList = this.selectTestQuestionInfoList(qt);
+                //单选简单
+                qt.setChapterId(er.getChapterId()); //章节ID
+                qt.setDiffDegree(easyDegree);       //简单难度
+                qt.setQuestionType(2);              //判断题
+                qt.setNum(easyChoice);              //题数
+                List<QuestionInfo> easyChoiceList = this.selectTestQuestionInfoList(qt);
+                //多选简单
+                qt.setChapterId(er.getChapterId()); //章节ID
+                qt.setDiffDegree(easyDegree);       //简单难度
+                qt.setQuestionType(3);              //判断题
+                qt.setNum(easyMultiple);              //题数
+                List<QuestionInfo> easyMultipleList = this.selectTestQuestionInfoList(qt);
 
+                //判断难题
+                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()");
+                    error++;
+                    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()");
+                    error++;
+                    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()");
+                    error++;
+                    break;
+                }
 
+                judgeList.addAll(easyJudgeList);
+                judgeList.addAll(diffJudgeList);
+                choiceList.addAll(easyChoiceList);
+                choiceList.addAll(diffChoiceList);
+                multipleList.addAll(easyMultipleList);
+                multipleList.addAll(diffMultipleList);
+            }
+            allList.addAll(judgeList);
+            allList.addAll(choiceList);
+            allList.addAll(multipleList);
+//            System.out.println("error:" + error);
+//            System.out.println("allList:" + allList.size());
+        }
+        return allList;
+    }
 
 
 }

+ 36 - 0
zzjs-service/src/main/java/com/miaxis/question/service/impl/TAppExamRuleServiceImpl.java

@@ -0,0 +1,36 @@
+package com.miaxis.question.service.impl;
+
+import java.util.List;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.apache.commons.lang3.StringUtils;
+import com.miaxis.question.mapper.TAppExamRuleMapper;
+import com.miaxis.question.domain.TAppExamRule;
+import com.miaxis.question.service.ITAppExamRuleService;
+
+/**
+ * 考试取题Service业务层处理
+ *
+ * @author miaxis
+ * @date 2022-05-23
+ */
+@Service
+public class TAppExamRuleServiceImpl extends ServiceImpl<TAppExamRuleMapper, TAppExamRule> implements ITAppExamRuleService {
+
+    @Autowired
+    private TAppExamRuleMapper tAppExamRuleMapper;
+
+    /**
+     * 查询考试取题列表
+     *
+     * @param tAppExamRule 考试取题
+     * @return 考试取题
+     */
+    @Override
+    public List<TAppExamRule> selectTAppExamRuleList(TAppExamRule tAppExamRule){
+        return tAppExamRuleMapper.selectTAppExamRuleList(tAppExamRule);
+    }
+}

+ 19 - 1
zzjs-service/src/main/resources/mapper/question/QuestionInfoMapper.xml

@@ -114,7 +114,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
 
-
+    <select id="selectTestQuestionInfoList"   resultMap="QuestionInfoResult">
+        select * from question_info
+        <where>
+            <if test="subject != null"> and subject = #{subject}</if>
+            <if test="questionType != null"> and question_type = #{questionType}</if>
+            <if test="liceCar != null  and liceCar != ''"> and lice_car = #{liceCar} </if>
+            <if test="liceBus != null  and liceBus != ''"> and lice_bus = #{liceBus}</if>
+            <if test="liceTruck != null  and liceTruck != ''"> and lice_truck = #{liceTruck}</if>
+            <if test="liceMoto != null  and liceMoto != ''"> and lice_moto = #{liceMoto}</if>
+            <if test="chapterId != null "> and chapter_id = #{chapterId}</if>
+            <if test="diffDegree != null "> and diff_degree in
+                <foreach item="degree" index="index" collection="diffDegree"
+                         open="(" separator="," close=")">
+                    #{degree}
+                </foreach>
+            </if>
+        </where>
+        ORDER BY rand() limit 0,${num}
+    </select>
 
 
 

+ 41 - 0
zzjs-service/src/main/resources/mapper/rule/TAppExamRuleMapper.xml

@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.miaxis.question.mapper.TAppExamRuleMapper">
+
+    <resultMap type="TAppExamRule" id="TAppExamRuleResult">
+        <result property="id"    column="id"    />
+        <result property="gs"    column="gs"    />
+        <result property="kemu"    column="kemu"    />
+        <result property="chapterId"    column="chapter_id"    />
+        <result property="totalCount"    column="total_count"    />
+        <result property="judgeCount"    column="judge_count"    />
+        <result property="choiceCount"    column="choice_count"    />
+        <result property="multipleChoiceCount"    column="multiple_choice_count"    />
+        <result property="difficultCount"    column="difficult_count"    />
+        <result property="areacode"    column="areacode"    />
+        <result property="cityId"    column="city_id"    />
+    </resultMap>
+
+    <sql id="selectTAppExamRuleVo">
+        select * from t_app_exam_rule
+    </sql>
+
+    <select id="selectTAppExamRuleList" parameterType="TAppExamRule" resultMap="TAppExamRuleResult">
+        <include refid="selectTAppExamRuleVo"/>
+        <where>
+            <if test="gs != null  and gs != ''"> and gs = #{gs}</if>
+            <if test="kemu != null "> and kemu = #{kemu}</if>
+            <if test="chapterId != null "> and chapter_id = #{chapterId}</if>
+            <if test="totalCount != null "> and total_count = #{totalCount}</if>
+            <if test="judgeCount != null "> and judge_count = #{judgeCount}</if>
+            <if test="choiceCount != null "> and choice_count = #{choiceCount}</if>
+            <if test="multipleChoiceCount != null "> and multiple_choice_count = #{multipleChoiceCount}</if>
+            <if test="difficultCount != null "> and difficult_count = #{difficultCount}</if>
+            <if test="areacode != null "> and areacode = #{areacode}</if>
+            <if test="cityId != null "> and city_id = #{cityId}</if>
+        </where>
+    </select>
+
+</mapper>