浏览代码

数据查看账户数据空值判断

yangzian 4 年之前
父节点
当前提交
89b2e24277

+ 18 - 3
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/mapper/xml/BytedanceAdvertiserHourlyReportMapper.xml

@@ -44,10 +44,16 @@
             create_time
         FROM
             ctop_bytedance_report_advertiser_hourly
-        WHERE
-            advertiser_id = #{accountId}
+        WHERE 1 = 1
+        <if test="accountId !=null and accountId != ''">
+            AND advertiser_id = #{accountId}
+        </if>
+        <if test="startTime !=null and startTime != ''">
             AND stat_datetime &gt;= #{startTime}
+        </if>
+        <if test="endTime !=null and endTime != ''">
             AND stat_datetime &lt;= #{endTime}
+        </if>
         GROUP BY
             stat_hour
         ORDER BY
@@ -69,10 +75,19 @@
         FROM
             ctop_bytedance_report_advertiser_hourly
         WHERE
-            advertiser_id = #{accountId}
+        1 = 1
+        <if test="accountId !=null and accountId != ''">
+            AND advertiser_id = #{accountId}
+        </if>
+        <if test="startTime !=null and startTime != ''">
             AND stat_datetime &gt;= #{startTime}
+        </if>
+        <if test="endTime !=null and endTime != ''">
             AND stat_datetime &lt;= #{endTime}
+        </if>
+        <if test="statHour !=null and statHour != ''">
             AND stat_hour &lt;= #{statHour}
+        </if>
         GROUP BY
             stat_hour
         ORDER BY

+ 18 - 5
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/service/impl/BytedanceAdvertiserHourlyReportServiceImpl.java

@@ -91,7 +91,10 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
         }else{
             // 账户 当前时间段数据
             nowCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStage(accountId,startTime,endTime);
-            ReportCostVo statHourVo = nowCostList.get(nowCostList.size()-1);
+            ReportCostVo statHourVo = new ReportCostVo();
+            if (nowCostList.size() > 0){
+                statHourVo = nowCostList.get(nowCostList.size()-1);
+            }
             //上阶段数据
             lastCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStageLast(accountId,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"),statHourVo.getTime());
         }
@@ -131,10 +134,20 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
         // 上阶段数据
         Map lastMap = getCost(lastCostList);
 
-        //当前阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
-        nowMap.put("costList", getCostList(nowCostList,startTime,endTime,lastTimeMap.get("daysBetween")));
-        //上个阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
-        lastMap.put("costList", getCostList(lastCostList,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"),lastTimeMap.get("daysBetween")));
+        if (nowCostList.size() > 0){
+            //当前阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
+            nowMap.put("costList", getCostList(nowCostList,startTime,endTime,lastTimeMap.get("daysBetween")));
+        }else {
+            nowMap.put("costList",Arrays.asList());
+        }
+
+        if (lastCostList.size() > 0){
+            //上个阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
+            lastMap.put("costList", getCostList(lastCostList,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"),lastTimeMap.get("daysBetween")));
+        }else {
+            lastMap.put("costList",Arrays.asList());
+        }
+
 
         resultMap.put("nowMap", nowMap);
         resultMap.put("lastMap", lastMap);