Pārlūkot izejas kodu

fix 学时列表

he2802 3 gadi atpakaļ
vecāks
revīzija
294c292f49

+ 4 - 2
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMapper.xml

@@ -371,7 +371,7 @@
             (SELECT COUNT(1) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where up.goods_id = g.goods_id AND ups.period_status =1  and (ups.`status` =3 or ups.`status` =0) and up.grade_id = cgu.grade_id) as rebuild,
             (case WHEN (SELECT COUNT(1) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where up.goods_id = g.goods_id AND ups.period_status =1 and ups.`status` =0) >0 then 0 ELSE 1 end) as rebuild_status,
             cgu.grade_id,
-            (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id LEFT JOIN class_grade_goods cgg on cgg.goods_id = c.goods_id where cg.grade_id=cgg.grade_id and m.type = 1 ) as exam_num,
+            IFNULL(ge.exam_num,0) exam_num,
             (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr LEFT JOIN class_grade_goods cgg on cgg.goods_id = ubr.goods_id where ubr.`status`=1 and ubr.report_status =1 and ubr.user_id =cgu.user_id and ubr.grade_id = cg.grade_id and ubr.current_status = 1) as record_num,
             (SELECT COUNT(up.id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where
                 ups.`status` =1 and ups.period_status = 1 and up.goods_id=g.goods_id and up.user_id = cgu.user_id and up.type = 1) as pass,
@@ -386,7 +386,7 @@
                  COUNT(up.id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where ups.`status`
                 =0 and ups.period_status = 1 and up.goods_id=g.goods_id and up.user_id = cgu.user_id and up.type = 2) as exam_cheat,
             (case WHEN (SELECT COUNT(1) FROM exam_apply_goods eag LEFT JOIN exam_apply ea on eag.apply_id = ea.apply_id where eag.goods_id = cgg.goods_id and ea.`status` = 1 and unix_timestamp(now()) BETWEEN ea.apply_start_time and ea.apply_end_time) >0 then 1 ELSE 0 end) as apply_status,
-                (case WHEN (SELECT COUNT(1) FROM exam_before_goods ebg LEFT JOIN exam_before eb on ebg.before_id = eb.before_id where ebg.goods_id = cgg.goods_id and eb.`status` = 1 and unix_timestamp(now()) BETWEEN eb.before_start_time and eb.before_end_time) >0 then 1 ELSE 0 end) as before_status,
+            (case WHEN (SELECT COUNT(1) FROM exam_before_goods ebg LEFT JOIN exam_before eb on ebg.before_id = eb.before_id where ebg.goods_id = cgg.goods_id and eb.`status` = 1 and unix_timestamp(now()) BETWEEN eb.before_start_time and eb.before_end_time) >0 then 1 ELSE 0 end) as before_status,
             (SELECT ea.apply_name FROM exam_apply_goods eag LEFT JOIN exam_apply ea on eag.apply_id = ea.apply_id where eag.goods_id = cgg.goods_id and ea.`status` = 1 and unix_timestamp(now()) BETWEEN ea.apply_start_time and ea.apply_end_time) as apply_name,
             (SELECT eb.before_name FROM exam_before_goods ebg LEFT JOIN exam_before eb on ebg.before_id = eb.before_id where ebg.goods_id = cgg.goods_id and eb.`status` = 1 and unix_timestamp(now()) BETWEEN eb.before_start_time and eb.before_end_time) as before_name
         FROM
@@ -394,6 +394,8 @@
                 LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
                 LEFT JOIN class_grade cg on cg.grade_id = cgu.grade_id
                 LEFT JOIN goods g on g.goods_id=cgg.goods_id
+                LEFT JOIN (SELECT c.goods_id,COUNT(m.id) exam_num FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id   where  m.type = 1 GROUP BY c.goods_id) ge ON
+                cgg.goods_id = ge.goods_id
         WHERE
             cgu.user_id =#{userId}
         AND cg.status=1 AND cgu.`status`=1 AND cgu.change_grade=0