Bladeren bron

、修改

yumeng 2 maanden geleden
bovenliggende
commit
6fb2245173

+ 21 - 8
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -796,12 +796,14 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         JSONObject params = JSONObject.parseObject(JSON.toJSONString(conditions, config));
         // 请求地址
         String url = bytedanceApiUrl + BytedanceConstant.BYTEDANCE_V3_REPORT_INTEGRATED_GET;
-
         Map<String, String> headers = new HashMap<>();
         headers.put("Access-Token", token.getAccessToken());
+        String s = null;
+        if (rateLimitUtil.acquire("1635316529903624", url)) {
+            s = HttpUtils.httpGet(url, params, headers);
+        }
 
-        String info = HttpUtils.httpGet(url, params, headers);
-        JSONObject result = JSONObject.parseObject(info, JSONObject.class);
+        JSONObject result = JSONObject.parseObject(s, JSONObject.class);
 //        System.out.println("【请求参数】:" + params + "\n【返回信息】:" + result);
 
         if (Check.isNull(result)) {
@@ -927,11 +929,20 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         // 请求地址
         String url = bytedanceApiUrl + BytedanceConstant.BYTEDANCE_V3_REPORT_INTEGRATED_GET;
 
+
+
+
         Map<String, String> headers = new HashMap<>();
         headers.put("Access-Token", token.getAccessToken());
 
-        String info = HttpUtils.httpGet(url, params, headers);
-        JSONObject result = JSONObject.parseObject(info, JSONObject.class);
+
+
+        String s = null;
+        if (rateLimitUtil.acquire("1635316529903624", url)) {
+            s = HttpUtils.httpGet(url, params, headers);
+        }
+
+        JSONObject result = JSONObject.parseObject(s, JSONObject.class);
 //        System.out.println("【请求参数】:" + params + "\n【返回信息】:" + result);
 
         if (Check.isNull(result)) {
@@ -1070,9 +1081,11 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
 
         Map<String, String> headers = new HashMap<>();
         headers.put("Access-Token", token.getAccessToken());
-
-        String info = HttpUtils.httpGet(url, params, headers);
-        JSONObject result = JSONObject.parseObject(info, JSONObject.class);
+        String s = null;
+        if (rateLimitUtil.acquire("1635316529903624", url)) {
+            s = HttpUtils.httpGet(url, params, headers);
+        }
+        JSONObject result = JSONObject.parseObject(s, JSONObject.class);
 //        System.out.println("【请求参数】:" + params + "\n【返回信息】:" + result);
 
         if (Check.isNull(result)) {

+ 18 - 4
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/BytedanceMaterialReportDailyServiceImpl.java

@@ -10,11 +10,13 @@ import cn.com.ctop.job.bytedance.data.service.IBytedanceMaterialReportDailyServi
 import cn.com.ctop.job.bytedance.data.utils.Check;
 import cn.com.ctop.job.bytedance.data.utils.DateUtils;
 import cn.com.ctop.job.bytedance.data.utils.HttpUtils;
+import cn.com.ctop.job.bytedance.data.utils.RateLimitUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
@@ -44,7 +46,8 @@ public class BytedanceMaterialReportDailyServiceImpl implements IBytedanceMateri
 
     @Resource
     private BytedanceNewMaterialReportMapper bytedanceNewMaterialReportMapper;
-
+    @Autowired
+    private RateLimitUtil rateLimitUtil;
     private static final ObjectMapper mapper = new ObjectMapper();
 
     @Override
@@ -155,8 +158,13 @@ public class BytedanceMaterialReportDailyServiceImpl implements IBytedanceMateri
         ord.put("type", "ASC");
         orderBy.add(ord);
         param.put("order_by", mapper.writeValueAsString(orderBy));
-        String result = HttpUtils.httpGet(url, param, header);
-        JSONObject resultObject = JSONObject.parseObject(result);
+        String s = null;
+        if (rateLimitUtil.acquire("1635316529903624", url)) {
+            s = HttpUtils.httpGet(url, param, header);
+        }
+
+
+        JSONObject resultObject = JSONObject.parseObject(s);
         Integer code = resultObject.getInteger("code");
         if (null == code || !code.equals(0)) {
             log.error("获取体验版-视频-素材日报接口异常==》accountId:{},message:{}", oauthToken.getAccountId(), resultObject.getString("message"));
@@ -232,7 +240,13 @@ public class BytedanceMaterialReportDailyServiceImpl implements IBytedanceMateri
         filtering.put("image_material", image_material);
 
         param.put("filtering", filtering);
-        JSONObject resultObject = JSONObject.parseObject(HttpUtils.httpGet(url, param, header));
+        String s = null;
+        if (rateLimitUtil.acquire("1635316529903624", url)) {
+            s = HttpUtils.httpGet(url, param, header);
+        }
+
+
+        JSONObject resultObject = JSONObject.parseObject(s);
 
         Integer code = resultObject.getInteger("code");
         if (null == code || !code.equals(0)) {