|
@@ -0,0 +1,61 @@
|
|
|
|
+package cn.com.ctop.job.kuaishou.handler;
|
|
|
|
+
|
|
|
|
+import cn.com.ctop.common.module.utils.Check;
|
|
|
|
+import cn.com.ctop.common.module.utils.HttpUtils2;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouProjectStrategy;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouProjectStrategyService;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
+
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author syh
|
|
|
|
+ * 自动投放定时任务
|
|
|
|
+ */
|
|
|
|
+@Component
|
|
|
|
+@Slf4j
|
|
|
|
+public class KuaishouAiProjectCreativeJob {
|
|
|
|
+
|
|
|
|
+ @Value("${xxl-job.requestUrl}")
|
|
|
|
+ private String jobUrl;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaishouProjectStrategyService kuaishouProjectStrategyService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 项目自动化
|
|
|
|
+ */
|
|
|
|
+ @XxlJob("kuaishouAiProjectCreativeJob")
|
|
|
|
+ public void execute() {
|
|
|
|
+ List<KuaishouProjectStrategy> strategies = kuaishouProjectStrategyService.getAllEffectStrategy();
|
|
|
|
+ if (null == strategies || strategies.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ String url = jobUrl + "/jeecg-boot/ai/projectCreate/projectAutomaticCreates";
|
|
|
|
+ for (KuaishouProjectStrategy strategy : strategies) {
|
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
|
+ requestMap.put("id", strategy.getId());
|
|
|
|
+ // operationType 1检查反馈,2创建时信息
|
|
|
|
+ requestMap.put("operationType", 2);
|
|
|
|
+ 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("项目自动化创建执行中,projectId:{}", strategy.getProjectId());
|
|
|
|
+ } else {
|
|
|
|
+ log.error("项目自动化创建执行失败,projectId:{}", strategy.getProjectId());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.error("项目自动化创建返回结果为空,projectId:{}", strategy.getProjectId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|