Browse Source

kuaishou_ad_social_task_order_report_daily重试

huangpingkang 1 năm trước cách đây
mục cha
commit
51eb0a0f5b

+ 2 - 2
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/controller/KuaiShouAdSocialController.java

@@ -82,7 +82,7 @@ public class KuaiShouAdSocialController {
             Long taskId = info.getLong("task_id");
             String orderIds = info.getString("order_id");
             String accessToken = info.getString("access_token");
-            kuaiShouAdSocialService.getOrderDailyData(accessToken, advId, taskId, Arrays.asList(orderIds.split(",")), startDate, endDate, 1, null, null);
+            kuaiShouAdSocialService.getOrderDailyData(accessToken, advId, taskId, Arrays.asList(orderIds.split(",")), startDate, endDate, 1, null, null, 1);
         }
         return MessageModel.ok();
     }
@@ -129,7 +129,7 @@ public class KuaiShouAdSocialController {
                         @Override
                         public void run() {
                             if (!Check.isNull(accessToken)) {
-                                kuaiShouAdSocialService.getOrderDailyData(accessToken, advertiserId, msg.getLong("taskId"), msg.getJSONArray("orderIds").toJavaList(String.class), startDate, endDate, null, id, isSend);
+                                kuaiShouAdSocialService.getOrderDailyData(accessToken, advertiserId, msg.getLong("taskId"), msg.getJSONArray("orderIds").toJavaList(String.class), startDate, endDate, null, id, isSend, 1);
                             }
                         }
                     });

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

@@ -7,7 +7,7 @@ import java.util.List;
 public interface IKuaiShouAdSocialService {
     void getTaskList(String accessToken, Long advertiserId, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend);
     void getOrderList(String accessToken, Long advertiserId, Long taskId, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend);
-    void getOrderDailyData(String accessToken, Long advertiserId, Long taskId, List<String> orderIds, String startDate, String endDate, Integer isLog, Long errId, Integer isSend);
+    void getOrderDailyData(String accessToken, Long advertiserId, Long taskId, List<String> orderIds, String startDate, String endDate, Integer isLog, Long errId, Integer isSend, Integer retry);
 
     List<JSONObject> queryAdSocialAdvertiserToken(Long advertiserId);
 

+ 12 - 1
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/impl/KuaiShouAdSocialServiceImpl.java

@@ -163,7 +163,7 @@ public class KuaiShouAdSocialServiceImpl implements IKuaiShouAdSocialService {
     }
 
 
-    public void getOrderDailyData(String accessToken, Long advertiserId, Long taskId, List<String> orderIds, String startDate, String endDate, Integer isLog, Long errId, Integer isSend) {
+    public void getOrderDailyData(String accessToken, Long advertiserId, Long taskId, List<String> orderIds, String startDate, String endDate, Integer isLog, Long errId, Integer isSend, Integer retry) {
         String url = KuaishouLinkConstants.KS_PREFIX + KuaishouLinkConstants.AD_SOCIAL_ORDER_DAILY_DATA;
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", "application/json");
@@ -189,6 +189,17 @@ public class KuaiShouAdSocialServiceImpl implements IKuaiShouAdSocialService {
         Integer code = resultJson.getInteger("code");
         String message = resultJson.getString("message");
         if (null == code || code != 0) {
+            if (retry <= 3) {
+                try {
+                    Thread.sleep(500L);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+                log.info("获取快手星任务(视频)-订单分天数据异常重试次数:{},accountId:{},taskId:{},orderIds:{}", retry, advertiserId, taskId, orderIds);
+                retry++;
+                getOrderDailyData(accessToken, advertiserId, taskId, orderIds, startDate, endDate, isLog, errId, isSend, retry);
+                return;
+            }
             log.error("获取快手星任务(视频)-订单分天数据异常:{},accountId:{},taskId:{},orderIds:{}", message, advertiserId, taskId, orderIds);
             if (isLog != null && isLog == 1) {
                 errorLogService.addError(System.currentTimeMillis(), startDate, endDate, "ad_social_order_daily_data", "daily",

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

@@ -58,7 +58,7 @@ public class KuaiShouAdSocialJob {
             Long taskId = info.getLong("task_id");
             String orderIds = info.getString("order_id");
             String accessToken = info.getString("access_token");
-            kuaiShouAdSocialService.getOrderDailyData(accessToken, advId, taskId, Arrays.asList(orderIds.split(",")), yesDate, nowDate, 1, null, null);
+            kuaiShouAdSocialService.getOrderDailyData(accessToken, advId, taskId, Arrays.asList(orderIds.split(",")), yesDate, nowDate, 1, null, null, 1);
         }
     }
 

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

@@ -225,7 +225,7 @@ public class KuaiShouRetryReportJob {
                         @Override
                         public void run() {
                             if (!Check.isNull(accessToken)) {
-                                kuaiShouAdSocialService.getOrderDailyData(accessToken, advertiserId, msg.getLong("taskId"), msg.getJSONArray("orderIds").toJavaList(String.class), startDate, endDate, null, id, isSend);
+                                kuaiShouAdSocialService.getOrderDailyData(accessToken, advertiserId, msg.getLong("taskId"), msg.getJSONArray("orderIds").toJavaList(String.class), startDate, endDate, null, id, isSend, 1);
                             }
                         }
                     });