|
@@ -17,11 +17,22 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.http.client.ClientProtocolException;
|
|
|
+import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
|
|
|
+import org.apache.http.entity.ContentType;
|
|
|
+import org.apache.http.entity.StringEntity;
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
+import org.apache.http.impl.client.HttpClientBuilder;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Primary;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStreamReader;
|
|
|
+import java.net.URI;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -44,19 +55,6 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
|
|
|
|
|
|
@Override
|
|
|
public void searchLog(Long accountId, CtopOauthToken token, Integer operationTarget, String startDate, String endDate){
|
|
|
-
|
|
|
- //int campaignCount = byteDanceCampaignService.count(parameterQueryWrapper);
|
|
|
- //int campaignPageSize = 20;
|
|
|
- //int campaignPage = 1;
|
|
|
- //
|
|
|
- //Integer campaignTotalPage = (campaignCount - 1) / campaignPageSize + 1;
|
|
|
- //if (campaignPage < campaignTotalPage) {
|
|
|
- // QueryWrapper<ByteDanceCampaign> parameterQueryWrapper2 = new QueryWrapper<>();
|
|
|
- // parameterQueryWrapper2.eq("account_id", accountId);
|
|
|
- // parameterQueryWrapper2.last("limit" + (campaignPage-1) + "," + campaignPageSize);
|
|
|
- // parameterQueryWrapper2.select("id");
|
|
|
- //
|
|
|
- //}
|
|
|
int pageNum = 1;
|
|
|
int pageSize = 20;
|
|
|
String startTime = startDate + " 00:00:00";
|
|
@@ -163,7 +161,7 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
|
|
|
}
|
|
|
|
|
|
//按类型入库
|
|
|
- if (records != null && records.size() != 0) {
|
|
|
+ if (records.size() != 0) {
|
|
|
insertLog(operationType, records);
|
|
|
}
|
|
|
|
|
@@ -332,6 +330,55 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
|
|
|
return returnCode;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public JSONObject createAsyncTask(CtopOauthToken token, String startDate, String endDate, JSONArray groupByArray) {
|
|
|
+ // 请求地址
|
|
|
+ String url = "https://ad.toutiao.com/open_api/2/async_task/create/";
|
|
|
+ // 请求参数
|
|
|
+ JSONObject filtering= new JSONObject();
|
|
|
+ filtering.put("start_date",startDate);
|
|
|
+ filtering.put("end_date",endDate);
|
|
|
+ filtering.put("group_by",groupByArray);
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id", token.getAccountId());
|
|
|
+ params.put("task_name", "test");
|
|
|
+ params.put("task_type", "REPORT");
|
|
|
+ params.put("task_params", filtering);
|
|
|
+ return HttpUtils.bytedancePostRequest(token.getAccessToken(),url,params);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject getAsyncTask(CtopOauthToken token, JSONArray taskIds) {
|
|
|
+ // 请求地址
|
|
|
+ String url = "https://ad.toutiao.com/open_api/2/async_task/get/";
|
|
|
+ // 请求参数
|
|
|
+ JSONObject filtering = new JSONObject();
|
|
|
+ filtering.put("task_ids",taskIds);
|
|
|
+
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id", token.getAccountId());
|
|
|
+ params.put("filtering", filtering);
|
|
|
+ return HttpUtils.bytedanceGetRequest(token.getAccessToken(),url,params);
|
|
|
+ }
|
|
|
+
|
|
|
+ public JSONObject dowanloadAsyncTask(CtopOauthToken token,Long taskId) {
|
|
|
+ // 请求地址
|
|
|
+ String url = "https://ad.toutiao.com/open_api/2/async_task/download/";
|
|
|
+ // 请求参数
|
|
|
+ JSONObject filtering = new JSONObject();
|
|
|
+ filtering.put("start_date", "2019-08-08");
|
|
|
+ filtering.put("end_date","2019-08-08");
|
|
|
+ filtering.put("group_by",new String[]{"STAT_GROUP_BY_CAMPAIGN_ID"});
|
|
|
+
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id", token.getAccountId());
|
|
|
+ params.put("task_id", taskId);
|
|
|
+ return HttpUtils.bytedanceGetRequest(token.getAccessToken(),url,params);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|