|
@@ -1,34 +1,34 @@
|
|
package cn.com.ctop.job.kuaishou.handler;
|
|
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.AiKuaishouAdvertiserStrategy;
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreateCreativeService;
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreateCreativeService;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.concurrent.ExecutorService;
|
|
|
|
-import java.util.concurrent.Executors;
|
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author syh
|
|
* @author syh
|
|
* 自动投放定时任务
|
|
* 自动投放定时任务
|
|
*/
|
|
*/
|
|
@Component
|
|
@Component
|
|
|
|
+@Slf4j
|
|
public class KuaishouAiCreativeJob {
|
|
public class KuaishouAiCreativeJob {
|
|
@Autowired
|
|
@Autowired
|
|
private IAiKuaishouAdvertiserStrategyService strategyService;
|
|
private IAiKuaishouAdvertiserStrategyService strategyService;
|
|
@Autowired
|
|
@Autowired
|
|
private IAiKuaishouCreateCreativeService createCreativeService;
|
|
private IAiKuaishouCreateCreativeService createCreativeService;
|
|
|
|
|
|
- static ExecutorService customCreativeAutoExecutorService = Executors.newFixedThreadPool(5);
|
|
|
|
- static ExecutorService customCreativeSupplementExecutorService = Executors.newFixedThreadPool(5);
|
|
|
|
- static ExecutorService programCreativeAutoExecutorService = Executors.newFixedThreadPool(5);
|
|
|
|
- static ExecutorService programCreativeTopExecutorService = Executors.newFixedThreadPool(5);
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 自定义上新创意
|
|
* 自定义上新创意
|
|
*/
|
|
*/
|
|
@@ -38,11 +38,27 @@ public class KuaishouAiCreativeJob {
|
|
if (null == strategies || strategies.isEmpty()) {
|
|
if (null == strategies || strategies.isEmpty()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- strategies.forEach(strategy -> customCreativeAutoExecutorService.submit(() -> {
|
|
|
|
|
|
+ String url = "http://api.tjyourong.com.cn/jeecg-boot/ai/create/customCreativeLimit";
|
|
|
|
+ for (AiKuaishouAdvertiserStrategy strategy : strategies) {
|
|
if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 1) {
|
|
if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 1) {
|
|
- createCreativeService.customCreativeLimit(strategy);
|
|
|
|
|
|
+ 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 == 0) {
|
|
|
|
+ log.info("快手自动上新异步执行中,accountId:{}", strategy.getAccountId());
|
|
|
|
+ } else {
|
|
|
|
+ log.error("快手自动上新异执行失败,accountId:{}", strategy.getAccountId());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.error("快手自动上新返回结果为空,accountId:{}", strategy.getAccountId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }));
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -55,16 +71,27 @@ public class KuaishouAiCreativeJob {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
|
|
+ String url = "http://api.tjyourong.com.cn/jeecg-boot/ai/create/customCreativeSupplement";
|
|
int hour = DateUtils.getNowHour();
|
|
int hour = DateUtils.getNowHour();
|
|
- strategies.forEach(strategy -> customCreativeSupplementExecutorService.submit(() -> {
|
|
|
|
- if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 1) {
|
|
|
|
- try {
|
|
|
|
- createCreativeService.customCreativeSupplement(strategy, hour);
|
|
|
|
- } catch (ParseException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ for (AiKuaishouAdvertiserStrategy strategy : strategies) {
|
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
|
+ requestMap.put("id", strategy.getId());
|
|
|
|
+ requestMap.put("hour", hour);
|
|
|
|
+ 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());
|
|
|
|
+ } else {
|
|
|
|
+ log.error("快手创意补充异步执行失败,accountId:{}", strategy.getAccountId());
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ log.error("快手创意补充返回结果为空,accountId:{}", strategy.getAccountId());
|
|
}
|
|
}
|
|
- }));
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
} catch (ParseException e) {
|
|
} catch (ParseException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
@@ -79,12 +106,31 @@ public class KuaishouAiCreativeJob {
|
|
if (null == strategies || strategies.isEmpty()) {
|
|
if (null == strategies || strategies.isEmpty()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- strategies.forEach(strategy -> programCreativeAutoExecutorService.submit(() -> {
|
|
|
|
|
|
+ String url = "http://api.tjyourong.com.cn/jeecg-boot/ai/create/kuaishouProgramCreativeAuto";
|
|
|
|
+ for (AiKuaishouAdvertiserStrategy strategy : strategies) {
|
|
if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 0) {
|
|
if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 0) {
|
|
long videoCnt = strategy.getProgramUnitCnt() * 5 / 2;
|
|
long videoCnt = strategy.getProgramUnitCnt() * 5 / 2;
|
|
- createCreativeService.autoCreateProgramCreative(strategy, 1, videoCnt);
|
|
|
|
|
|
+ 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());
|
|
|
|
+ } else {
|
|
|
|
+ log.error("快手上新程序化异步执行失败,accountId:{}", strategy.getAccountId());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.error("快手上新程序化充返回结果为空,accountId:{}", strategy.getAccountId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
- }));
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -96,11 +142,27 @@ public class KuaishouAiCreativeJob {
|
|
if (null == strategies || strategies.isEmpty()) {
|
|
if (null == strategies || strategies.isEmpty()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- strategies.forEach(strategy -> programCreativeTopExecutorService.submit(() -> {
|
|
|
|
|
|
+ String url = "http://api.tjyourong.com.cn/jeecg-boot/ai/create/autoCreateProgramHistoryTopCreative";
|
|
|
|
+ for (AiKuaishouAdvertiserStrategy strategy : strategies) {
|
|
if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 0) {
|
|
if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 0) {
|
|
long videoCnt = strategy.getProgramUnitCnt() * 5 / 2;
|
|
long videoCnt = strategy.getProgramUnitCnt() * 5 / 2;
|
|
- createCreativeService.autoCreateProgramCreative(strategy, 2, videoCnt);
|
|
|
|
|
|
+ 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());
|
|
|
|
+ } else {
|
|
|
|
+ log.error("快手历史高质量程序化异步执行失败,accountId:{}", strategy.getAccountId());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.error("快手历史高质量程序化充返回结果为空,accountId:{}", strategy.getAccountId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }));
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|