Просмотр исходного кода

Merge #73 into master from pingkang

获取素材视频

* pingkang: (2 commits)
  获取素材视频
  获取素材视频

Signed-off-by: 黄平康 <accounts_6361eaad7b63b44dd7833e63@mail.teambition.com>
Merged-by: 黄平康 <accounts_6361eaad7b63b44dd7833e63@mail.teambition.com>

CR-link: https://codeup.aliyun.com/60c06368dbbed34fe0f0c263/job/hr_job-bytedance/change/73
huangpingkang 1 год назад
Родитель
Сommit
91147597a3

+ 1 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/controller/BytedanceController.java

@@ -313,7 +313,7 @@ public class BytedanceController {
             executor10Service1.submit(() -> {
                 Long adverId = jsonObject.getLong("advertiserId");
                 String accessToken = jsonObject.getString("accessToken");
-                bytedanceMaterialReportService.getBytedanceMaterialDailyReport(adverId, accessToken, startDate, endDate, 1, null, 1, 0);
+                bytedanceMaterialReportService.getBytedanceMaterialDailyReport(adverId, accessToken, startDate, endDate, 1, null, 1, 0, 1);
             });
         }
     }

+ 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) {

+ 1 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedancePromoterReportJob.java

@@ -144,7 +144,7 @@ public class BytedancePromoterReportJob {
         dailyExecutorService.submit(new Runnable() {
             @Override
             public void run() {
-                bytedanceMaterialReportService.getBytedanceMaterialDailyReport(advertiserId, accessToken, date, date, 1, null, 1, 0);
+                bytedanceMaterialReportService.getBytedanceMaterialDailyReport(advertiserId, accessToken, date, date, 1, null, 1, 0, 1);
             }
         });
     }

+ 1 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceReportRetryJob.java

@@ -154,7 +154,7 @@ public class BytedanceReportRetryJob {
                         @Override
                         public void run() {
                             if (!Check.isNull(accessToken)) {
-                                bytedanceMaterialReportService.getBytedanceMaterialDailyReport(advertiserId, accessToken, startDate, endDate, 1, id, null, isSend);
+                                bytedanceMaterialReportService.getBytedanceMaterialDailyReport(advertiserId, accessToken, startDate, endDate, 1, id, null, isSend, 1);
                             }
                         }
                     });