he2802 2 years ago
parent
commit
722609616d

+ 7 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/ExamTempServiceImpl.java

@@ -121,6 +121,12 @@ public class ExamTempServiceImpl extends ServiceImpl<ExamTempMapper, ExamTemp> i
         add.setCreateTime(DateUtils.getNowTime());
         add.setCreateTime(DateUtils.getNowTime());
         add.setUpdateTime(DateUtils.getNowTime());
         add.setUpdateTime(DateUtils.getNowTime());
         boolean result = this.save(add);
         boolean result = this.save(add);
+        System.out.println(result);
+        System.out.println(add.getExamId());
+        System.out.println(questionlist.size());
+        if(questionlist.size()==0){
+            throw new CustomException("没有题目数可生成试卷");
+        }
         if(questionlist!=null){
         if(questionlist!=null){
             Collection<ExamTempQuestion> coll = new HashSet<>();
             Collection<ExamTempQuestion> coll = new HashSet<>();
             for(int i=0;i<questionlist.size();i++){
             for(int i=0;i<questionlist.size();i++){
@@ -130,6 +136,7 @@ public class ExamTempServiceImpl extends ServiceImpl<ExamTempMapper, ExamTemp> i
                 addItem.setQuestionId(questionVo.getQuestionId());
                 addItem.setQuestionId(questionVo.getQuestionId());
                 addItem.setSort(new Long(i));
                 addItem.setSort(new Long(i));
                 coll.add(addItem);
                 coll.add(addItem);
+                System.out.println(addItem);
             }
             }
             if(!iExamTempQuestionService.saveBatch(coll)){
             if(!iExamTempQuestionService.saveBatch(coll)){
                 throw new CustomException("试卷绑定错误");
                 throw new CustomException("试卷绑定错误");

+ 1 - 1
zhongzheng-system/src/main/resources/mapper/modules/bank/ExamTempMapper.xml

@@ -78,7 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                   AND NOT FIND_IN_SET(
                   AND NOT FIND_IN_SET(
                         question_id,(
                         question_id,(
                             SELECT
                             SELECT
-                                IFNULL(GROUP_CONCAT( do_question_ids ),'')
+                                IFNULL(GROUP_CONCAT( right_question_ids ),'')
                             FROM
                             FROM
                                 user_exam_record uer
                                 user_exam_record uer
                             WHERE
                             WHERE

+ 61 - 2
zhongzheng-system/src/main/resources/mapper/modules/user/UserExamRecordMapper.xml

@@ -142,7 +142,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ue.exam_id,
         ue.exam_id,
         ue.module_exam_id,
         ue.module_exam_id,
         ue.chapter_exam_id,
         ue.chapter_exam_id,
-        MAX( UE.record_id ) record_id
+        MAX( UE.record_id ) record_id,
+        1 as do_mode
         FROM
         FROM
         user_exam_record ue
         user_exam_record ue
         LEFT JOIN exam e ON ue.exam_id = e.exam_id
         LEFT JOIN exam e ON ue.exam_id = e.exam_id
@@ -161,6 +162,62 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         LEFT JOIN goods g ON g.goods_id = ue.goods_id
         LEFT JOIN goods g ON g.goods_id = ue.goods_id
         WHERE
         WHERE
         ue.user_id = #{userId}
         ue.user_id = #{userId}
+        AND ue.do_mode = 1
+        <if test="paperId != null and paperId != ''">
+            AND ep.paper_id = #{paperId}
+        </if>
+        <if test="goodsId != null and goodsId != ''">
+            AND ue.goods_id = #{goodsId}
+        </if>
+        <if test="examId != null and examId != ''">
+            AND ue.exam_id = #{examId}
+        </if>
+        <if test="moduleExamId != null and moduleExamId != ''">
+            AND ue.module_exam_id = #{moduleExamId}
+        </if>
+        <if test="orderGoodsId != null and orderGoodsId != ''">
+            AND ue.order_goods_id = #{orderGoodsId}
+        </if>
+        <if test="chapterExamId != null and chapterExamId != ''">
+            AND ue.chapter_exam_id = #{chapterExamId}</if>-- ORDER by ue.record_id DESC
+        UNION ALL
+        SELECT * FROM (
+        SELECT
+        ue.record_id ,ue.user_id ,ue.exam_id ,1 AS courseType,null as type,ue.`status`,ue.goods_id
+        ,ue.report_status,ue.performance,ue.history_exam_json,
+        ue.update_time,ue.total_question_num,ue.right_question_num,ue.do_question_num,ue.module_exam_id as moduleExamId,
+        ue.chapter_exam_id as chapterExamId,NULL as courseId,NULL as moduleId,NULL as chapterId,NULL as sectionId,NULL
+        as gradeId,
+        ue.do_time,ue.exam_time,ue.total_score,ue.do_question_ids,ue.right_question_ids,ue.score,ue.all_question_num,ue.order_goods_id,
+        ue.less_question_num,ue.create_time,e.exam_name,ep.paper_name
+        FROM
+        (
+        SELECT
+        ue.goods_id,
+        ue.exam_id,
+        ue.module_exam_id,
+        ue.chapter_exam_id,
+        MAX( UE.record_id ) record_id,
+        2 as do_mode
+        FROM
+        user_exam_record ue
+        LEFT JOIN exam e ON ue.exam_id = e.exam_id
+        LEFT JOIN exam_paper ep ON e.exam_paper_id = ep.paper_id
+        WHERE
+        ue.user_id = #{userId}
+        GROUP BY
+        ue.goods_id,
+        ue.exam_id,
+        ue.module_exam_id,
+        ue.chapter_exam_id
+        ) t
+        LEFT JOIN user_exam_record ue ON t.record_id = ue.record_id
+        LEFT JOIN exam_temp e ON ue.exam_id = e.exam_id
+        LEFT JOIN exam_paper ep ON e.exam_paper_id = ep.paper_id
+        LEFT JOIN goods g ON g.goods_id = ue.goods_id
+        WHERE
+        ue.user_id = #{userId}
+        AND ue.do_mode = 2
         <if test="paperId != null and paperId != ''">
         <if test="paperId != null and paperId != ''">
             AND ep.paper_id = #{paperId}
             AND ep.paper_id = #{paperId}
         </if>
         </if>
@@ -193,7 +250,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT
         SELECT
         ue.goods_id,
         ue.goods_id,
         ue.exam_id,
         ue.exam_id,
-        MAX( ue.record_id ) record_id
+        MAX( ue.record_id ) record_id,
+        1 as do_mode
         FROM
         FROM
         user_bank_record ue
         user_bank_record ue
         LEFT JOIN exam e ON ue.exam_id = e.exam_id
         LEFT JOIN exam e ON ue.exam_id = e.exam_id
@@ -214,6 +272,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         LEFT JOIN goods g ON g.goods_id = ue.goods_id
         LEFT JOIN goods g ON g.goods_id = ue.goods_id
         WHERE
         WHERE
         ue.user_id = #{userId}
         ue.user_id = #{userId}
+        AND ue.do_mode = 1
         <if test="paperId != null and paperId != ''">
         <if test="paperId != null and paperId != ''">
             AND ep.paper_id = #{paperId}
             AND ep.paper_id = #{paperId}
         </if>
         </if>