|
|
@@ -7,6 +7,7 @@ import cn.com.ctop.job.bytedance.data.mapper.AccountReportNewMapper;
|
|
|
import cn.com.ctop.job.bytedance.data.service.IBytedanceReportNewService;
|
|
|
import cn.com.ctop.job.bytedance.data.utils.Check;
|
|
|
import cn.com.ctop.job.bytedance.data.utils.HttpUtils;
|
|
|
+import cn.com.ctop.job.bytedance.data.utils.RateLimitUtil;
|
|
|
import cn.com.ctop.job.bytedance.utils.FieldsConfig;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
@@ -21,6 +22,9 @@ import java.util.*;
|
|
|
public class BytedanceReportNewServiceImpl implements IBytedanceReportNewService {
|
|
|
@Autowired
|
|
|
private AccountReportNewMapper accountReportNewMapper;
|
|
|
+ @Autowired
|
|
|
+ private RateLimitUtil rateLimitUtil;
|
|
|
+
|
|
|
private String urlPath = "http://192.168.0.85:8765/webhook/bytedance_account_report";
|
|
|
private static JSONArray metrics = new JSONArray();
|
|
|
|
|
|
@@ -42,7 +46,12 @@ public class BytedanceReportNewServiceImpl implements IBytedanceReportNewService
|
|
|
paramsMap.put("page_size", 100);
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Access-Token", accessToken);
|
|
|
- String s = HttpUtils.httpGet(url, paramsMap, headers);
|
|
|
+ String s = null;
|
|
|
+ if (rateLimitUtil.acquire("1635316529903624", url)) {
|
|
|
+ s = HttpUtils.httpGet(url, paramsMap, headers);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
JSONObject result = JSONObject.parseObject(s);
|
|
|
List<BytedanceAdvertiserReportHourly> hours = new ArrayList<>();
|
|
|
Integer code = result.getInteger("code");
|
|
|
@@ -117,8 +126,8 @@ public class BytedanceReportNewServiceImpl implements IBytedanceReportNewService
|
|
|
log.info("账户ID:{},开始日期:{},结束日期:{},广告日报(账户粒度)数据请求成功", advertiserId, startDate, endDate);
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("advertiser_id", advertiserId);
|
|
|
- param.put("start_date", startDate.replace("-",""));
|
|
|
- param.put("end_date", endDate.replace("-",""));
|
|
|
+ param.put("start_date", startDate.replace("-", ""));
|
|
|
+ param.put("end_date", endDate.replace("-", ""));
|
|
|
param.put("date_type", "hourly");
|
|
|
HttpUtils.httpPostRequest(urlPath, param, null);
|
|
|
}
|
|
|
@@ -145,7 +154,10 @@ public class BytedanceReportNewServiceImpl implements IBytedanceReportNewService
|
|
|
paramsMap.put("page_size", 100);
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Access-Token", oauthToken);
|
|
|
- String s = HttpUtils.httpGet(url, paramsMap, headers);
|
|
|
+ String s = null;
|
|
|
+ if (rateLimitUtil.acquire("1635316529903624", url)) {
|
|
|
+ s = HttpUtils.httpGet(url, paramsMap, headers);
|
|
|
+ }
|
|
|
JSONObject result = JSONObject.parseObject(s);
|
|
|
List<BytedanceAdvertiserReportDaily> dailies = new ArrayList<>();
|
|
|
Integer code = result.getInteger("code");
|