|
@@ -101,61 +101,4 @@ public class BytedanceVideoReportServiceImpl implements IBytedanceVideoReportSer
|
|
pullVideoReport(oauthToken, startDate, endDate, page + 1);
|
|
pullVideoReport(oauthToken, startDate, endDate, page + 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void pullVideoReportByMaterialId(CtopOauthToken oauthToken, String startDate, String endDate,Long[] materialIds, int page) {
|
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
|
- headers.put("Content-Type", " application/json");
|
|
|
|
- headers.put("Access-Token", oauthToken.getAccessToken());
|
|
|
|
-
|
|
|
|
- JSONObject param = new JSONObject();
|
|
|
|
- param.put("advertiser_id", oauthToken.getAccountId());
|
|
|
|
- param.put("start_date",startDate);
|
|
|
|
- param.put("end_date",endDate);
|
|
|
|
- JSONObject filtering = new JSONObject();
|
|
|
|
- filtering.put("material_id",materialIds);
|
|
|
|
- param.put("filtering",filtering);
|
|
|
|
- param.put("page_size", 200);
|
|
|
|
- param.put("page", page);
|
|
|
|
-
|
|
|
|
- JSONObject resultJson = JSONObject.parseObject(HttpUtils.httpGetRequest("https://ad.oceanengine.com/open_api/2/report/video/get/", headers, param));
|
|
|
|
- if (Check.isNull(resultJson)) {
|
|
|
|
- log.warn("拉取头条视频报表返回结果为空,advertiserId:{}", oauthToken.getAccountId());
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if(resultJson.getInteger("code")!=0){
|
|
|
|
- log.error("拉取头条视频表异常,advertiserId:{},message:{}", oauthToken.getAccountId(),resultJson.getString("message"));
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- JSONObject data = resultJson.getJSONObject("data");
|
|
|
|
- if (null == data || data.size() <= 0) {
|
|
|
|
- log.error("拉取头条视频表异常,data is null");
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- JSONArray list= data.getJSONArray("list");
|
|
|
|
- if(list.isEmpty()){
|
|
|
|
- log.warn("拉取头条视频表,数据为空advertiserId:{}", oauthToken.getAccountId());
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- List<BaseReportBytedanceVideoDaily> batch =new ArrayList<>();
|
|
|
|
- list.forEach(videoReport->{
|
|
|
|
- JSONObject videoReportJSONObject= (JSONObject)videoReport;
|
|
|
|
- Long materialId= videoReportJSONObject.getJSONObject("dimensions").getLong("material_id");
|
|
|
|
- JSONObject metrics= videoReportJSONObject.getJSONObject("metrics");
|
|
|
|
- BaseReportBytedanceVideoDaily temp= JSONObject.toJavaObject(metrics,BaseReportBytedanceVideoDaily.class);
|
|
|
|
- temp.setMaterialShow(metrics.getLong("show"));
|
|
|
|
- temp.setConvertMaterial(metrics.getLong("convert"));
|
|
|
|
- temp.setAccountId(oauthToken.getAccountId());
|
|
|
|
- temp.setMaterialId(materialId);
|
|
|
|
- temp.setStatDatetime(startDate);
|
|
|
|
- batch.add(temp);
|
|
|
|
- });
|
|
|
|
- baseReportBytedanceVideoDailyService.saveBatch(batch);
|
|
|
|
-
|
|
|
|
- if(resultJson.getJSONObject("data").getJSONObject("page_info").getInteger("total_page")>page){
|
|
|
|
- pullVideoReport(oauthToken, startDate, endDate, page + 1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|