小么熊🐻 2 роки тому
батько
коміт
32f74e6dc8
16 змінених файлів з 161 додано та 51 видалено
  1. 0 1
      nbjk-admin/src/main/java/com/miaxis/app/controller/question/QuestionCollectionController.java
  2. 0 1
      nbjk-admin/src/main/java/com/miaxis/app/controller/question/QuestionWrongController.java
  3. 10 0
      nbjk-admin/src/main/java/com/miaxis/open/controller/CommonQuestionInfoController.java
  4. 40 0
      nbjk-admin/src/test/java/com/miaxis/test/NormalTest3.java
  5. 2 8
      nbjk-service/src/main/java/com/miaxis/question/domain/QuestionCollection.java
  6. 0 5
      nbjk-service/src/main/java/com/miaxis/question/domain/QuestionWrong.java
  7. 0 3
      nbjk-service/src/main/java/com/miaxis/question/dto/QuestionCollectionListDTO.java
  8. 0 4
      nbjk-service/src/main/java/com/miaxis/question/dto/QuestionWrongDTO.java
  9. 0 4
      nbjk-service/src/main/java/com/miaxis/question/dto/QuestionWrongDelDTO.java
  10. 0 4
      nbjk-service/src/main/java/com/miaxis/question/dto/QuestionWrongListDTO.java
  11. 1 0
      nbjk-service/src/main/java/com/miaxis/question/mapper/QuestionInfoMapper.java
  12. 2 0
      nbjk-service/src/main/java/com/miaxis/question/service/IQuestionInfoService.java
  13. 97 13
      nbjk-service/src/main/java/com/miaxis/question/service/impl/QuestionInfoServiceImpl.java
  14. 0 3
      nbjk-service/src/main/resources/mapper/question/QuestionCollectionMapper.xml
  15. 8 0
      nbjk-service/src/main/resources/mapper/question/QuestionInfoMapper.xml
  16. 1 5
      nbjk-service/src/main/resources/mapper/question/QuestionWrongMapper.xml

+ 0 - 1
nbjk-admin/src/main/java/com/miaxis/app/controller/question/QuestionCollectionController.java

@@ -131,7 +131,6 @@ public class QuestionCollectionController extends BaseController {
     /**
      * 修改collection
      */
-//    @PreAuthorize("@ss.hasPermi('question:collection:edit')")
     @Log(title = "collection", businessType = BusinessTypeEnum.UPDATE)
     @PutMapping
     @ApiOperation("修改collection")

+ 0 - 1
nbjk-admin/src/main/java/com/miaxis/app/controller/question/QuestionWrongController.java

@@ -172,7 +172,6 @@ public class QuestionWrongController extends BaseController{
         QueryWrapper<QuestionWrong> queryWrapper= new QueryWrapper<QuestionWrong>();
         queryWrapper.eq("user_id",userId);
         queryWrapper.eq("km",questionWrongDelDTO.getKm());
-        queryWrapper.eq("car_type",questionWrongDelDTO.getCarType());
         questionWrongService.remove(queryWrapper);
         return Response.success();
     }

+ 10 - 0
nbjk-admin/src/main/java/com/miaxis/open/controller/CommonQuestionInfoController.java

@@ -39,5 +39,15 @@ public class CommonQuestionInfoController extends BaseController {
         return toResponsePageInfo(list);
     }
 
+    /**
+     * 查询模拟考试科目1与4题库
+     */
+    @GetMapping("/selectTestK14QuestionInfoList2")
+    @ApiOperation("取模拟考试题库 旧版")
+    public ResponsePageInfo<QuestionInfo> selectTestK14QuestionInfoList2(@ModelAttribute QuestionInfoTestDTO questionInfoTestDTO){
+        List<QuestionInfo> list = questionInfoService.selectTestK14QuestionInfoList2(questionInfoTestDTO);
+        return toResponsePageInfo(list);
+    }
+
 }
 

+ 40 - 0
nbjk-admin/src/test/java/com/miaxis/test/NormalTest3.java

@@ -0,0 +1,40 @@
+package com.miaxis.test;
+
+import com.miaxis.NbjkApplication;
+import com.miaxis.question.domain.QuestionInfo;
+import com.miaxis.question.dto.QuestionInfoTestDTO;
+import com.miaxis.question.service.IQuestionInfoService;
+import com.miaxis.score.service.IScoreInfoService;
+import com.miaxis.vip.service.IVipUserExamService;
+import com.miaxis.wx.service.IWxGzhService;
+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.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.List;
+
+@ActiveProfiles("dev")
+@SpringBootTest(classes = NbjkApplication.class)
+@RunWith(SpringRunner.class)
+public class NormalTest3 {
+
+
+    @Autowired
+    private IQuestionInfoService questionInfoService;
+
+    @Test
+    public void test1() throws Exception {
+        QuestionInfoTestDTO questionInfoTestDTO = new QuestionInfoTestDTO();
+        questionInfoTestDTO.setSubject(4);
+        questionInfoTestDTO.setGs("hc");
+
+        List<QuestionInfo> list = questionInfoService.selectTestK14QuestionInfoList2(questionInfoTestDTO);
+        System.out.println(list.size());
+
+    }
+
+
+}

+ 2 - 8
nbjk-service/src/main/java/com/miaxis/question/domain/QuestionCollection.java

@@ -25,8 +25,8 @@ public class QuestionCollection extends BaseBusinessEntity{
     private static final long serialVersionUID = 1L;
 
     /** 主键 */
-//    @TableId(value = "id")
-//    @ApiModelProperty(value = "主键")
+    @TableId(value = "id")
+   @ApiModelProperty(value = "主键")
     private Long id;
 
     /** 用户ID */
@@ -41,16 +41,10 @@ public class QuestionCollection extends BaseBusinessEntity{
     @ApiModelProperty(value = "题目ID")
     private Long questionId;
 
-
     /** 科目 */
     @Excel(name = "科目")
     @TableField("km")
     @ApiModelProperty(value = "考试科目(科目一、科目二、科目三、科目四)")
     private String km;
 
-    /** 车型 */
-    @Excel(name = "车型")
-    @TableField("car_type")
-    @ApiModelProperty(value = "车型(小车 、客车、货车、摩托车)")
-    private String carType;
 }

+ 0 - 5
nbjk-service/src/main/java/com/miaxis/question/domain/QuestionWrong.java

@@ -48,11 +48,6 @@ public class QuestionWrong extends BaseBusinessEntity{
     @ApiModelProperty(value = "考试科目(科目一、科目二、科目三、科目四)")
     private String km;
 
-    /** 车型 */
-    @Excel(name = "车型")
-    @TableField("car_type")
-    @ApiModelProperty(value = "车型(小车 、客车、货车、摩托车)")
-    private String carType;
 
 
 }

+ 0 - 3
nbjk-service/src/main/java/com/miaxis/question/dto/QuestionCollectionListDTO.java

@@ -29,7 +29,4 @@ public class QuestionCollectionListDTO extends BaseBusinessEntity {
     @ApiModelProperty(value = "考试科目(科目一、科目二、科目三、科目四)")
     private String km;
 
-    /** 车型 */
-    @ApiModelProperty(value = "车型(小车 、客车、货车、摩托车)")
-    private String carType;
 }

+ 0 - 4
nbjk-service/src/main/java/com/miaxis/question/dto/QuestionWrongDTO.java

@@ -26,8 +26,4 @@ public class QuestionWrongDTO {
     @ApiModelProperty(value = "考试科目(科目一、科目二、科目三、科目四)",required=true)
     private String km;
 
-    /** 车型 */
-    @ApiModelProperty(value = "车型(小车 、客车、货车、摩托车)",required=true)
-    private String carType;
-
 }

+ 0 - 4
nbjk-service/src/main/java/com/miaxis/question/dto/QuestionWrongDelDTO.java

@@ -19,10 +19,6 @@ public class QuestionWrongDelDTO {
     @ApiModelProperty(value = "考试科目(科目一、科目二、科目三、科目四)")
     private String km;
 
-    /** 车型 */
-    @ApiModelProperty(value = "车型(小车 、客车、货车、摩托车)")
-    private String carType;
-
 
 
 }

+ 0 - 4
nbjk-service/src/main/java/com/miaxis/question/dto/QuestionWrongListDTO.java

@@ -24,10 +24,6 @@ public class QuestionWrongListDTO extends BaseBusinessEntity {
     @ApiModelProperty(value = "考试科目(科目一、科目二、科目三、科目四)")
     private String km;
 
-    /** 车型 */
-    @ApiModelProperty(value = "车型(小车 、客车、货车、摩托车)")
-    private String carType;
-
 
 
 }

+ 1 - 0
nbjk-service/src/main/java/com/miaxis/question/mapper/QuestionInfoMapper.java

@@ -65,4 +65,5 @@ public interface QuestionInfoMapper extends BaseMapper<QuestionInfo> {
 
     List<QuestionInfo> selectMiQuestionInfoList(QuestionInfoMiDTO questionInfoMiDTO);
 
+    List<QuestionInfo> selectTestK14QuestionInfoList(String sql);
 }

+ 2 - 0
nbjk-service/src/main/java/com/miaxis/question/service/IQuestionInfoService.java

@@ -41,6 +41,8 @@ public interface IQuestionInfoService extends IService<QuestionInfo>{
 
     List<QuestionInfo> selectTestK14QuestionInfoList(QuestionInfoTestDTO questionInfoTestDTO);
 
+    List<QuestionInfo> selectTestK14QuestionInfoList2(QuestionInfoTestDTO questionInfoTestDTO);
+
     List<QuestionInfo> selectMiQuestionInfoList(QuestionInfoMiDTO questionInfoMiDTO);
 }
 

+ 97 - 13
nbjk-service/src/main/java/com/miaxis/question/service/impl/QuestionInfoServiceImpl.java

@@ -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);

+ 0 - 3
nbjk-service/src/main/resources/mapper/question/QuestionCollectionMapper.xml

@@ -22,7 +22,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null and userId !='' "> and user_id = #{userId}</if>
             <if test="questionId != null and questionId !=''  "> and question_id = #{questionId}</if>
             <if test="km != null and km !='' "> and km = #{km}</if>
-            <if test="carType != null and carType !='' "> and car_type = #{carType}</if>
         </where>
         order by create_time asc
     </select>
@@ -35,7 +34,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null and userId !='' "> and q2.user_id = #{userId}</if>
             <if test="questionId != null and questionId != '' "> and q2.question_id = #{questionId}</if>
             <if test="km != null and km!='' "> and q2.km = #{km}</if>
-            <if test="carType != null and carType !='' "> and q2.car_type = #{carType}</if>
         </where>
         order by q2.create_time asc
 
@@ -49,7 +47,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null and userId !='' "> and q2.user_id = #{userId}</if>
             <if test="questionId != null and questionId != '' "> and q2.question_id = #{questionId}</if>
             <if test="km != null and km!='' "> and q2.km = #{km}</if>
-            <if test="carType != null and carType !='' "> and q2.car_type = #{carType}</if>
         </where>
 
     </select>

+ 8 - 0
nbjk-service/src/main/resources/mapper/question/QuestionInfoMapper.xml

@@ -431,4 +431,12 @@
     </select>
 
 
+
+
+    <select id="selectTestK14QuestionInfoList" resultType="com.miaxis.question.domain.QuestionInfo">
+        ${sql}
+    </select>
+
+
+
 </mapper>

+ 1 - 5
nbjk-service/src/main/resources/mapper/question/QuestionWrongMapper.xml

@@ -22,14 +22,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null and userId !='' "> and user_id = #{userId}</if>
             <if test="questionId != null and questionId != '' "> and question_id = #{questionId}</if>
             <if test="km != null and km!='' "> and km = #{km}</if>
-            <if test="carType != null and carType !='' "> and car_type = #{carType}</if>
         </where>
     </select>
 
 
 
-
-
     <select id="selectWrongByUserId" resultType="com.miaxis.question.domain.QuestionInfo">
 
         select q1.* from question_info q1 join question_wrong q2 on q1.id = q2.question_id
@@ -37,10 +34,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null and userId !='' "> and q2.user_id = #{userId}</if>
             <if test="questionId != null and questionId != '' "> and q2.question_id = #{questionId}</if>
             <if test="km != null and km!='' "> and q2.km = #{km}</if>
-            <if test="carType != null and carType !='' "> and q2.car_type = #{carType}</if>
         </where>
         order by q2.create_time
     </select>
+
     <select id="selectWrongCountByUserId" resultType="int">
 
         select count(1) from question_info q1 join question_wrong q2 on q1.id = q2.question_id
@@ -48,7 +45,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null and userId !='' "> and q2.user_id = #{userId}</if>
             <if test="questionId != null and questionId != '' "> and q2.question_id = #{questionId}</if>
             <if test="km != null and km!='' "> and q2.km = #{km}</if>
-            <if test="carType != null and carType !='' "> and q2.car_type = #{carType}</if>
         </where>
 
     </select>