|
@@ -26,6 +26,7 @@ import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 广告主小时级别报表信息
|
|
@@ -39,6 +40,10 @@ import java.util.*;
|
|
|
public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<BytedanceAdvertiserHourlyReportMapper, BytedanceAdvertiserHourlyReport> implements IBytedanceAdvertiserHourlyReportService {
|
|
|
|
|
|
|
|
|
+ //时段数组
|
|
|
+ private final static List<String> TIMES = Arrays.asList("0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23");
|
|
|
+
|
|
|
+
|
|
|
@Resource
|
|
|
private BytedanceAdvertiserHourlyReportMapper bytedanceAdvertiserHourlyReportMapper;
|
|
|
|
|
@@ -114,9 +119,9 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
|
lastCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStage(accountId,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
|
|
|
}
|
|
|
//当前阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
|
|
|
- nowMap.put("costList", getCostList(nowCostList));
|
|
|
+ nowMap.put("costList", getCostList(nowCostList,lastTimeMap.get("daysBetween")));
|
|
|
//上个阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
|
|
|
- lastMap.put("costList", getCostList(lastCostList));
|
|
|
+ lastMap.put("costList", getCostList(lastCostList,lastTimeMap.get("daysBetween")));
|
|
|
|
|
|
resultMap.put("nowMap", nowMap);
|
|
|
resultMap.put("lastMap", lastMap);
|
|
@@ -150,7 +155,7 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
|
}
|
|
|
|
|
|
//获取 数据 (时间段)
|
|
|
- public List<ReportCostVo> getCostList(List<ReportCostVo> list){
|
|
|
+ public List<ReportCostVo> getCostList(List<ReportCostVo> list,String daysBetween){
|
|
|
list.forEach(reportCostVo -> {
|
|
|
//花费
|
|
|
double cost = reportCostVo.getCost();
|
|
@@ -170,6 +175,24 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
|
double show = (cost / showNum) * 1000 ;
|
|
|
reportCostVo.setAverageShow( showNum == 0 ? "0" : String.format("%.2f", show));
|
|
|
});
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 时间间隔为0 则表示获取当天数据 0-23时段
|
|
|
+ */
|
|
|
+ if (daysBetween.equals("0")){
|
|
|
+ //返回数据中 time 的集合
|
|
|
+ List<String> voTimes = list.stream().map(ReportCostVo::getTime).collect(Collectors.toList());
|
|
|
+ // 获取0-23时段 和 已有时段的 差集 (times - voTimes)
|
|
|
+ List<String> reduceList = TIMES.stream().filter(item -> !voTimes.contains(item)).collect(Collectors.toList());
|
|
|
+ //补充差集时段数据
|
|
|
+ if (!Check.isNull(reduceList)){
|
|
|
+ reduceList.forEach(reduce ->{
|
|
|
+ ReportCostVo vo = new ReportCostVo();
|
|
|
+ vo.setTime(reduce);
|
|
|
+ list.add(vo);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
return list;
|
|
|
}
|
|
|
|