瀏覽代碼

Merge #47 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-kuaishou/change/47
huangpingkang 1 年之前
父節點
當前提交
7b04bbf708

+ 1 - 1
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/controller/HistoryController.java

@@ -44,7 +44,7 @@ public class HistoryController {
                 }
 /*                kuaiShouAccountReportService.queryAccountReportDaily(token, advertiserId, startDate, endDate, 1);
                 groupReportService.queryGroupReportDaily(token, advertiserId, startDate, endDate, 1);*/
-                kuaiShouAccountReportService.queryAccountDailyFlows(token, advertiserId, startDate, endDate, 1, 1, null, 2);
+                kuaiShouAccountReportService.queryAccountDailyFlows(token, advertiserId, startDate, endDate, 1, 1, null, 2, 1);
             }
         });
         json.put("code", 200);

+ 1 - 1
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/controller/KuaiShouController.java

@@ -88,7 +88,7 @@ public class KuaiShouController {
             for (JSONObject jsonObject : jsonObjects) {
                 Long advertiserId = jsonObject.getLong("advertiser_id");
                 String accessToken = jsonObject.getString("access_token");
-                accountReportService.queryAccountDailyFlows(accessToken, advertiserId, day, day, 1, 1, null, 2);
+                accountReportService.queryAccountDailyFlows(accessToken, advertiserId, day, day, 1, 1, null, 2, 1);
 
             }
         }

+ 1 - 1
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/IKuaiShouAccountReportService.java

@@ -9,7 +9,7 @@ public interface IKuaiShouAccountReportService {
 
     void updateClAccountStatus();
 
-    void queryAccountDailyFlows(String accessToken, Long advertiserId, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend);
+    void queryAccountDailyFlows(String accessToken, Long advertiserId, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend, int retry);
 
     String getTokenByAdvertiserId(Long advertiserId);
 }

+ 13 - 5
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/impl/KuaiShouAccountReportServiceImpl.java

@@ -149,7 +149,7 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
     }
 
     @Override
-    public void queryAccountDailyFlows(String accessToken, Long advertiserId, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend) {
+    public void queryAccountDailyFlows(String accessToken, Long advertiserId, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend, int retry) {
         String url = "https://ad.e.kuaishou.com/rest/openapi/v1/advertiser/fund/daily_flows";
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", "application/json");
@@ -177,9 +177,17 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
         Integer code = resultJson.getInteger("code");
         String message = resultJson.getString("message");
         if (null == code || code != 0) {
-            log.error("获取快手广告账户流水信息异常:{},accountId:{} {}~{}", message, advertiserId,startDate,endDate);
-            if (isLog != null && isLog == 1 && (null == code || code != 400002)) {
-                errorLogService.addError(advertiserId, startDate, endDate, "daily_flows", "daily", message, 2);
+            if (retry <= 3) {
+                try {
+                    Thread.sleep(800);
+                } catch (InterruptedException ignored) {
+                }
+                queryAccountDailyFlows(accessToken, advertiserId, startDate, endDate, page,isLog, errId, isSend, retry + 1);
+            }else {
+                log.error("获取快手广告账户流水信息异常:{},accountId:{} {}~{}", message, advertiserId,startDate,endDate);
+                if (isLog != null && isLog == 1 && (null == code || code != 400002)) {
+                    errorLogService.addError(advertiserId, startDate, endDate, "daily_flows", "daily", message, 2);
+                }
             }
             return;
         }
@@ -203,7 +211,7 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
         //    accountReportMapper.replaceKuaiShouDailyFlows(addList);
         //}
         if (page < totalPage) {
-            queryAccountDailyFlows(accessToken, advertiserId, startDate, endDate, page + 1,isLog, errId, isSend);
+            queryAccountDailyFlows(accessToken, advertiserId, startDate, endDate, page + 1,isLog, errId, isSend, 1);
         } else {
             if (errId != null) {
                 errorLogService.deleteInfoByErrorId(errId);

+ 2 - 2
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouAccountReportJob.java

@@ -120,7 +120,7 @@ public class KuaiShouAccountReportJob {
         yesAccountExecutorService.submit(new Runnable() {
             @Override
             public void run() {
-                accountReportService.queryAccountDailyFlows(accessToken, advertiserId, yesDate, yesDate, 1,1,null,2);
+                accountReportService.queryAccountDailyFlows(accessToken, advertiserId, yesDate, yesDate, 1,1,null,2, 1);
             }
         });
     }
@@ -141,7 +141,7 @@ public class KuaiShouAccountReportJob {
         yesAccountExecutorService.submit(new Runnable() {
             @Override
             public void run() {
-                accountReportService.queryAccountDailyFlows(accessToken, advertiserId, nowDate, nowDate, 1,1,null,2);
+                accountReportService.queryAccountDailyFlows(accessToken, advertiserId, nowDate, nowDate, 1,1,null,2,1);
             }
         });
     }

+ 1 - 1
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouRetryReportJob.java

@@ -110,7 +110,7 @@ public class KuaiShouRetryReportJob {
                         @Override
                         public void run() {
                             if (!Check.isNull(accessToken)) {
-                                accountReportService.queryAccountDailyFlows(accessToken, advertiserId, startDate, endDate, 1, null, id, isSend);
+                                accountReportService.queryAccountDailyFlows(accessToken, advertiserId, startDate, endDate, 1, null, id, isSend, 1);
                             }
                         }
                     });