Browse Source

项目自动化定时修改

zhaoxian 3 years ago
parent
commit
1998008efe

+ 64 - 46
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAiProjectCreativeJob.java

@@ -41,21 +41,26 @@ public class KuaishouAiProjectCreativeJob {
             return;
         }
         String url = jobUrl + "/jeecg-boot/ai/projectCreate/projectCreative";
-        for (KuaishouProjectStrategy strategy : strategies) {
-            Map<String, Object> requestMap = new HashMap<>();
-            requestMap.put("id", strategy.getId());
-            String result = HttpUtils2.httpGet(url, requestMap, null);
-            JSONObject jsonObject = JSONObject.parseObject(result);
-            if (!Check.isNull(jsonObject)) {
-                Integer code = jsonObject.getInteger("code");
-                if (code == 200) {
-                    log.info("快手自动上新异步执行中,accountId:{}", strategy.getProjectId());
+        JSONObject jsonObject = null;
+        try {
+            for (KuaishouProjectStrategy strategy : strategies) {
+                Map<String, Object> requestMap = new HashMap<>();
+                requestMap.put("id", strategy.getId());
+                String result = HttpUtils2.httpGet(url, requestMap, null);
+                jsonObject = JSONObject.parseObject(result);
+                if (!Check.isNull(jsonObject)) {
+                    Integer code = jsonObject.getInteger("code");
+                    if (!Check.isNull(code) && code == 0) {
+                        log.info("快手自动上新异步执行中,accountId:{}", strategy.getProjectId());
+                    } else {
+                        log.error("快手自动上新异步执行失败,accountId:{}", strategy.getProjectId());
+                    }
                 } else {
-                    log.error("快手自动上新异执行失败,accountId:{}", strategy.getProjectId());
+                    log.info("快手自动上新返回结果为空,accountId:{}", strategy.getProjectId());
                 }
-            } else {
-                log.error("快手自动上新返回结果为空,accountId:{}", strategy.getProjectId());
             }
+        } catch (Exception e) {
+            log.error("自定义上新异常,返回结果:{}", jsonObject);
         }
     }
 
@@ -68,6 +73,7 @@ public class KuaishouAiProjectCreativeJob {
         if (null == strategies || strategies.isEmpty()) {
             return;
         }
+        JSONObject jsonObject = null;
         try {
             String url = jobUrl + "/jeecg-boot/ai/projectCreate/projectCreativeSupplement";
             int hour = DateUtils.getNowHour();
@@ -76,10 +82,10 @@ public class KuaishouAiProjectCreativeJob {
                 requestMap.put("id", strategy.getId());
                 requestMap.put("hour", hour);
                 String result = HttpUtils2.httpGet(url, requestMap, null);
-                JSONObject jsonObject = JSONObject.parseObject(result);
+                jsonObject = JSONObject.parseObject(result);
                 if (!Check.isNull(jsonObject)) {
                     Integer code = jsonObject.getInteger("code");
-                    if (code == 0) {
+                    if (!Check.isNull(code) && code == 0) {
                         log.info("快手创意补充异步执行中,accountId:{}", strategy.getAccountId());
                     } else {
                         log.error("快手创意补充异步执行失败,accountId:{}", strategy.getAccountId());
@@ -90,6 +96,7 @@ public class KuaishouAiProjectCreativeJob {
             }
         } catch (ParseException e) {
             e.printStackTrace();
+            log.error("自定义创意补充异常,返回结果:{}", jsonObject);
         }
     }
 
@@ -102,27 +109,31 @@ public class KuaishouAiProjectCreativeJob {
         if (null == strategies || strategies.isEmpty()) {
             return;
         }
-        String url = jobUrl + "/jeecg-boot/ai/projectCreate/projectProgramAutomaticCreates";
-        for (KuaishouProjectStrategy strategy : strategies) {
-            long videoCnt = strategy.getProgramUnitCnt() * 5 / 2;
-            Map<String, Object> requestMap = new HashMap<>();
-            requestMap.put("id", strategy.getId());
-            requestMap.put("videoCnt", videoCnt);
-            String result = HttpUtils2.httpGet(url, requestMap, null);
-            JSONObject jsonObject = JSONObject.parseObject(result);
-            if (!Check.isNull(jsonObject)) {
-                Integer code = jsonObject.getInteger("code");
-                if (code == 0) {
-                    log.info("快手上新程序化创意补充异步执行中,accountId:{}", strategy.getAccountId());
+        JSONObject jsonObject = null;
+        try {
+            String url = jobUrl + "/jeecg-boot/ai/projectCreate/projectProgramAutomaticCreates";
+            for (KuaishouProjectStrategy strategy : strategies) {
+                long videoCnt = strategy.getProgramUnitCnt() * 5 / 2;
+                Map<String, Object> requestMap = new HashMap<>();
+                requestMap.put("id", strategy.getId());
+                requestMap.put("videoCnt", videoCnt);
+                String result = HttpUtils2.httpGet(url, requestMap, null);
+                jsonObject = JSONObject.parseObject(result);
+                if (!Check.isNull(jsonObject)) {
+                    Integer code = jsonObject.getInteger("code");
+                    if (!Check.isNull(code) && code == 0) {
+                        log.info("程序化创意上新异步执行中,accountId:{}", strategy.getAccountId());
+                    } else {
+                        log.error("程序化创意上新异步执行失败,accountId:{}", strategy.getAccountId());
+                    }
                 } else {
-                    log.error("快手上新程序化异步执行失败,accountId:{}", strategy.getAccountId());
+                    log.error("程序化创意上新返回结果为空,accountId:{}", strategy.getAccountId());
                 }
-            } else {
-                log.error("快手上新程序化充返回结果为空,accountId:{}", strategy.getAccountId());
             }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("程序化创意上新异常,返回结果:{}", jsonObject);
         }
-
-
     }
 
     /**
@@ -134,24 +145,31 @@ public class KuaishouAiProjectCreativeJob {
         if (null == strategies || strategies.isEmpty()) {
             return;
         }
-        String url = jobUrl + "/jeecg-boot/ai/projectCreate/projectProgramCreativeTop";
-        for (KuaishouProjectStrategy strategy : strategies) {
-            long videoCnt = strategy.getProgramUnitCnt() * 5 / 2;
-            Map<String, Object> requestMap = new HashMap<>();
-            requestMap.put("id", strategy.getId());
-            requestMap.put("videoCnt", videoCnt);
-            String result = HttpUtils2.httpGet(url, requestMap, null);
-            JSONObject jsonObject = JSONObject.parseObject(result);
-            if (!Check.isNull(jsonObject)) {
-                Integer code = jsonObject.getInteger("code");
-                if (code == 0) {
-                    log.info("快手历史高质量程序化创意补充异步执行中,accountId:{}", strategy.getAccountId());
+        JSONObject jsonObject = null;
+
+        try {
+            String url = jobUrl + "/jeecg-boot/ai/projectCreate/projectProgramCreativeTop";
+            for (KuaishouProjectStrategy strategy : strategies) {
+                long videoCnt = strategy.getProgramUnitCnt() * 5 / 2;
+                Map<String, Object> requestMap = new HashMap<>();
+                requestMap.put("id", strategy.getId());
+                requestMap.put("videoCnt", videoCnt);
+                String result = HttpUtils2.httpGet(url, requestMap, null);
+                jsonObject = JSONObject.parseObject(result);
+                if (!Check.isNull(jsonObject)) {
+                    Integer code = jsonObject.getInteger("code");
+                    if (!Check.isNull(code) && code == 0) {
+                        log.info("程序化高质量创建异步执行中,accountId:{}", strategy.getAccountId());
+                    } else {
+                        log.error("程序化高质量创建异步执行失败,accountId:{}", strategy.getAccountId());
+                    }
                 } else {
-                    log.error("快手历史高质量程序化异步执行失败,accountId:{}", strategy.getAccountId());
+                    log.error("程序化高质量创建返回结果为空,accountId:{}", strategy.getAccountId());
                 }
-            } else {
-                log.error("快手历史高质量程序化充返回结果为空,accountId:{}", strategy.getAccountId());
             }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("程序化高质量创建异常,返回结果:{}", jsonObject);
         }
 
     }