瀏覽代碼

sql优化

zhouzeyu@c-top.com.cn 3 年之前
父節點
當前提交
32fd5bae4a

+ 6 - 6
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/MaterialReportOverViewV3Mapper.xml

@@ -622,9 +622,9 @@
         <where>
             t1.stat_date  between #{startDate} and  #{endDate}
         </where>
-        <if test="type == 1">AND t1.shot_id is not null and t1.shot_id != '' GROUP BY t1.shot_id</if>
-        <if test="type == 2">AND t1.clip_id is not null and t1.clip_id != '' GROUP BY t1.clip_id</if>
-        <if test="type == 3">AND t1.plan_id is not null and t1.plan_id != '' GROUP BY t1.plan_id</if>
+        <if test="type == 1">AND t1.shot_id is not null and t1.shot_id != '' AND t1.shot_name is not null and t1.shot_name != ''  GROUP BY t1.shot_id</if>
+        <if test="type == 2">AND t1.clip_id is not null and t1.clip_id != '' AND t1.clip_name is not null and t1.clip_name != '' GROUP BY t1.clip_id</if>
+        <if test="type == 3">AND t1.plan_id is not null and t1.plan_id != '' AND t1.plan_name is not null and t1.plan_name != '' GROUP BY t1.plan_id</if>
         ORDER BY cost desc
 
     </select>
@@ -648,9 +648,9 @@
         <where>
             t1.stat_datetime BETWEEN #{startDate} and #{endDate} and t.company_id=#{companyId}
         </where>
-        <if test="type == 1">AND t.shot_id is not null and t.shot_id != '' GROUP BY t.shot_id</if>
-        <if test="type == 2">AND t.clip_id is not null and t.clip_id != '' GROUP BY t.clip_id</if>
-        <if test="type == 3">AND t.plan_id is not null and t.plan_id != '' GROUP BY t.plan_id</if>
+        <if test="type == 1">AND t1.shot_id is not null and t1.shot_id != '' AND t1.shot_name is not null and t1.shot_name != ''  GROUP BY t1.shot_id</if>
+        <if test="type == 2">AND t1.clip_id is not null and t1.clip_id != '' AND t1.clip_name is not null and t1.clip_name != '' GROUP BY t1.clip_id</if>
+        <if test="type == 3">AND t1.plan_id is not null and t1.plan_id != '' AND t1.plan_name is not null and t1.plan_name != '' GROUP BY t1.plan_id</if>
         ORDER BY sort desc
     </select>