Przeglądaj źródła

获取素材视频

hpk 1 rok temu
rodzic
commit
a7a61f7cef

+ 1 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IBytedanceMaterialReportService.java

@@ -4,7 +4,7 @@ import java.util.Set;
 
 public interface IBytedanceMaterialReportService {
     void getBytedanceMaterialDailyReport(Long advertiserId, String accessToken, String startDate, String endDate, Integer page,
-                                         Long errorId, Integer isLog, Integer isSend);
+                                         Long errorId, Integer isLog, Integer isSend, int retry);
 
     void getBytedanceMaterialVideo(Long advertiserId, Set<Long> materialIds, String accessToken, String startTime, String endTime, Integer page, Long errorId, Integer isLog, Integer isSend, int retry);
 }

+ 10 - 2
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/BytedanceMaterialReportServiceImpl.java

@@ -32,7 +32,7 @@ public class BytedanceMaterialReportServiceImpl implements IBytedanceMaterialRep
     private RedisTemplate redisTemplate_db2;
 
     @Override
-    public void getBytedanceMaterialDailyReport(Long advertiserId, String accessToken, String startDate, String endDate, Integer page, Long errorId, Integer isLog, Integer isSend) {
+    public void getBytedanceMaterialDailyReport(Long advertiserId, String accessToken, String startDate, String endDate, Integer page, Long errorId, Integer isLog, Integer isSend, int retry) {
         try {
             String url = "https://api.oceanengine.com/open_api/v3.0/report/custom/get/";
             Map<String, Object> paramsMap = new HashMap<>();
@@ -93,6 +93,14 @@ public class BytedanceMaterialReportServiceImpl implements IBytedanceMaterialRep
                     }
                 }
             } else {
+                if (retry <= 5) {
+                    try {
+                        Thread.sleep(800);
+                    } catch (Exception ignored) {
+                    }
+                    getBytedanceMaterialDailyReport(advertiserId, accessToken, startDate, endDate, page, errorId, isLog, isSend, retry + 1);
+                    return;
+                }
                 log.info("账户id:{},日期:{}素材日报请求结果失败,返回数据:{}", advertiserId, startDate, result);
                 if (isLog == 1) {
                     BytedanceErrorLog errorInfo = new BytedanceErrorLog();
@@ -112,7 +120,7 @@ public class BytedanceMaterialReportServiceImpl implements IBytedanceMaterialRep
             }
 
             if (page < totalPage) {
-                getBytedanceMaterialDailyReport(advertiserId, accessToken, startDate, endDate, page + 1, errorId, isLog, isSend);
+                getBytedanceMaterialDailyReport(advertiserId, accessToken, startDate, endDate, page + 1, errorId, isLog, isSend, 1);
             } else {
                 log.info("账户ID:{}, 开始日期:{}, 结束日期:{}, totalPage:{}, 素材日报数据请求成功", advertiserId, startDate, endDate, totalPage);
                 if (errorId != null) {