|
@@ -23,6 +23,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.http.client.ClientProtocolException;
|
|
import org.apache.http.client.ClientProtocolException;
|
|
|
|
+import org.apache.http.client.config.RequestConfig;
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
|
|
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
|
|
import org.apache.http.entity.ContentType;
|
|
import org.apache.http.entity.ContentType;
|
|
@@ -974,6 +975,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
public void bytedanceMaterialReport(CtopOauthToken token, String startDate, String endDate){
|
|
public void bytedanceMaterialReport(CtopOauthToken token, String startDate, String endDate){
|
|
//CtopOauthToken token = ctopOauthTokenService.getTokenByAccountId(accountId);
|
|
//CtopOauthToken token = ctopOauthTokenService.getTokenByAccountId(accountId);
|
|
Long accountId = token.getAccountId();
|
|
Long accountId = token.getAccountId();
|
|
|
|
+ log.info("头条素材报表当前accountId为:" + accountId);
|
|
Integer page = 1;
|
|
Integer page = 1;
|
|
Integer pageSize = 500;
|
|
Integer pageSize = 500;
|
|
bytedanceMaterialReportByPage(page, pageSize, token, accountId, startDate, endDate);
|
|
bytedanceMaterialReportByPage(page, pageSize, token, accountId, startDate, endDate);
|
|
@@ -1002,10 +1004,6 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
put("page",page);
|
|
put("page",page);
|
|
put("page_size",pageSize);
|
|
put("page_size",pageSize);
|
|
put("group_by", new String[]{"STAT_GROUP_BY_MATERIAL_ID","STAT_GROUP_BY_INVENTORY","STAT_GROUP_BY_IMAGE_MODE","STAT_GROUP_BY_TIME_DAY"});
|
|
put("group_by", new String[]{"STAT_GROUP_BY_MATERIAL_ID","STAT_GROUP_BY_INVENTORY","STAT_GROUP_BY_IMAGE_MODE","STAT_GROUP_BY_TIME_DAY"});
|
|
- //put("group_by", new String[]{"STAT_GROUP_BY_MATERIAL_ID"});
|
|
|
|
- //put("filtering",filtering);
|
|
|
|
- //put("order_field","stat_datetime");
|
|
|
|
- //put("order_type","ASC");
|
|
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
@@ -1027,6 +1025,12 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
httpEntity.setURI(URI.create(open_api_domain + path));
|
|
httpEntity.setURI(URI.create(open_api_domain + path));
|
|
httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
|
|
httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
|
|
|
|
|
|
|
|
+ //RequestConfig requestConfig = RequestConfig.custom()
|
|
|
|
+ // .setConnectTimeout(60000).setConnectionRequestTimeout(60000)
|
|
|
|
+ // .setSocketTimeout(60000).build();
|
|
|
|
+
|
|
|
|
+ //httpEntity.setConfig(requestConfig);
|
|
|
|
+
|
|
response = client.execute(httpEntity);
|
|
response = client.execute(httpEntity);
|
|
//System.out.println(response);
|
|
//System.out.println(response);
|
|
if (response != null && response.getStatusLine().getStatusCode() == 200) {
|
|
if (response != null && response.getStatusLine().getStatusCode() == 200) {
|
|
@@ -1045,7 +1049,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
if(!Check.isNull(json)){
|
|
if(!Check.isNull(json)){
|
|
Integer code = json.getInteger("code");
|
|
Integer code = json.getInteger("code");
|
|
if(code != 0){
|
|
if(code != 0){
|
|
- log.info("获取任务列表返回信息错误,错误码为:" + code + ",头条accountId:" + accountId );
|
|
|
|
|
|
+ log.info("获取任务列表返回信息错误,错误码为:" + code + ",头条accountId:" + accountId + ";返回json为:" + jsonString);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1058,6 +1062,10 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
Integer currentPage = pageInfo.getInteger("page");
|
|
Integer currentPage = pageInfo.getInteger("page");
|
|
|
|
|
|
JSONArray jsonArrayay = jsonData.getJSONArray("list");
|
|
JSONArray jsonArrayay = jsonData.getJSONArray("list");
|
|
|
|
+ if(jsonArrayay.size() == 0){
|
|
|
|
+ log.info("accountId:" + accountId + ";没有数据。总页数为:" + totalPage + "当前页数为:" + currentPage);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
List<BytedanceReportMaterialDaily> bytedanceReportMaterialDailyList = new ArrayList<>();
|
|
List<BytedanceReportMaterialDaily> bytedanceReportMaterialDailyList = new ArrayList<>();
|
|
for (int i = 0; i < jsonArrayay.size(); i++) {
|
|
for (int i = 0; i < jsonArrayay.size(); i++) {
|
|
BytedanceReportMaterialDaily daily = new BytedanceReportMaterialDaily();
|
|
BytedanceReportMaterialDaily daily = new BytedanceReportMaterialDaily();
|
|
@@ -1170,6 +1178,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
|
|
|
|
bytedanceReportMaterialDailyMapper.replaceIntoBatch(bytedanceReportMaterialDailyList);
|
|
bytedanceReportMaterialDailyMapper.replaceIntoBatch(bytedanceReportMaterialDailyList);
|
|
if(currentPage >= totalPage){
|
|
if(currentPage >= totalPage){
|
|
|
|
+ log.info("accountId:" + accountId + "数据同步完成");
|
|
return;
|
|
return;
|
|
}else{
|
|
}else{
|
|
bytedanceMaterialReportByPage(page + 1, pageSize, token, accountId, startDate, endDate);
|
|
bytedanceMaterialReportByPage(page + 1, pageSize, token, accountId, startDate, endDate);
|