瀏覽代碼

数据查看 处理值为0

yangzian 4 年之前
父節點
當前提交
c4060666cc

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

@@ -72,7 +72,7 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
         nowCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfo(accountId,startTime,endTime);
         //当前阶段 总花费
         double nowCost = nowCostList.stream().mapToDouble(ReportCostVo::getCost).sum();
-        resultMap.put("nowCost", nowCost);
+        resultMap.put("nowCost", String.format("%.2f", nowCost));
 
         //根据本阶段时间 获取 上阶段 开始-截至 时间
         Map<String,String> lastTimeMap = TimeStartAndEndUtil.getStartEndTime(startTime,endTime);
@@ -80,11 +80,11 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
         lastCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfo(accountId,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
         //上阶段花费
         double lastCost = lastCostList.stream().mapToDouble(ReportCostVo::getCost).sum();
-        resultMap.put("lastCost", lastCost);
+        resultMap.put("lastCost", String.format("%.2f", lastCost));
 
         //环比 =(当前花费 - 上阶段花费 )/ 上阶段花费
         compare = (nowCost - lastCost) / lastCost;
-        resultMap.put("compare", df.format(compare));
+        resultMap.put("compare", Double.isNaN(compare) ? "0" : df.format(compare));
 
         //花费占比 = 花费 / 账户预算
         //获取账户预算
@@ -97,7 +97,7 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
         double accountBudget = Check.isNull(strategy) ? lastCost : strategy.getAccountBudget().doubleValue();
         //花费占比
         double costShare = nowCost / accountBudget;
-        resultMap.put("costShare", df.format(costShare));
+        resultMap.put("costShare", Double.isNaN(costShare) ? "0" : df.format(costShare));
 
         //获取 本阶段  转化成本;转化数;转化率;平均千次展现费用。数据展示
         Map nowMap = getCost(nowCostList);