Parcourir la source

fix 模拟随机做题

he2802 il y a 2 ans
Parent
commit
e0e700da6f

+ 102 - 0
zhongzheng-system/src/main/resources/mapper/modules/user/UserExamRecordMapper.xml

@@ -236,6 +236,59 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND ue.chapter_exam_id = #{chapterExamId}</if>-- ORDER by ue.record_id DESC
         UNION ALL
         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,3 AS do_mode
+        FROM
+        (
+        SELECT
+        ue.goods_id,
+        ue.exam_id,
+        ue.module_exam_id,
+        ue.chapter_exam_id,
+        MAX( UE.record_id ) record_id
+        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_simulate e ON ue.simulate_exam_id = e.simulate_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 = 3
+        <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>
+        UNION ALL
+        SELECT
         ue.record_id,ue.user_id ,ue.exam_id,2 AS courseType,ue.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,NULL as moduleExamId,NULL as
@@ -283,6 +336,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="orderGoodsId != null and orderGoodsId != ''">
             AND ue.order_goods_id = #{orderGoodsId}
         </if>
+        UNION ALL
+        SELECT
+        ue.record_id,ue.user_id ,ue.exam_id,2 AS courseType,ue.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,NULL as moduleExamId,NULL as
+        chapterExamId,
+        ue.course_id as courseId,ue.module_id as moduleId,ue.chapter_id as chapterId,ue.section_id as
+        sectionId,ue.grade_id 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,3 AS do_mode
+        FROM
+        (
+        SELECT
+        ue.goods_id,
+        ue.exam_id,
+        MAX( ue.record_id ) record_id
+        FROM
+        user_bank_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.course_id,
+        ue.module_id,
+        ue.chapter_id,
+        ue.section_id
+        ) t
+        LEFT JOIN user_bank_record ue ON t.record_id = ue.record_id
+        LEFT JOIN exam_simulate e ON ue.simulate_exam_id = e.simulate_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 = 3
+        <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="orderGoodsId != null and orderGoodsId != ''">
+            AND ue.order_goods_id = #{orderGoodsId}
+        </if>
         ) a ORDER by a.create_time DESC
         -- ORDER by ue.record_id DESC
     </select>