Browse Source

批量2.0 程序化 优化创建频繁异常

zhaoxian 2 years ago
parent
commit
2a3b7fa541

+ 11 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupTemplateServiceImpl.java

@@ -932,6 +932,11 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
             photoList.add(photo);
         }
         createJson.put("photo_list", photoList);
+        try {
+            Thread.sleep(1000);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
         Map<String, Object> creativeMap = this.createProgramCreatives(accountId, accessToken, createJson, 1);
         Integer code = (Integer) creativeMap.get("code");
         if (code == 0) {
@@ -973,11 +978,16 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
                 returnMap.put("success", true);
             } else {
                 log.error("批量2.0创建程序化创意失败,入参:{},返回结果:{}", creativeParams.toString(), resultJson.toString());
-                if ("系统错误".equals(message) && count <= 3) {
+                if ("系统错误".equals(message) && count <= 4) {
                     log.info("第{}次重新创建程序化创意", count);
                     //系统错误,则重新执行
                     return createProgramCreatives(accountId, token, creativeParams, count + 1);
                 }
+                if ("message".contains("过于频繁") && count <= 4) {
+                    Thread.sleep(1000);
+                    //该请求接口「/rest/openapi/v2/creative/advanced/program/create」过于频繁,则重新执行
+                    return createProgramCreatives(accountId, token, creativeParams, count + 1);
+                }
                 returnMap.put("code", -1);
                 returnMap.put("message", resultJson.getString("message"));
                 returnMap.put("success", false);