zhaoxian пре 3 година
родитељ
комит
fd713c9269

+ 47 - 145
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAccountAutoCreativeJob.java

@@ -1,28 +1,15 @@
-/*
 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.common.module.utils.HttpUtils;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
-import com.alibaba.fastjson.JSONObject;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
-import java.text.ParseException;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
-*/
-/**
- * @author syh
- * 自动投放定时任务
- *//*
 
 @Component
 @Slf4j
@@ -34,151 +21,66 @@ public class KuaishouAccountAutoCreativeJob {
     @Autowired
     private IAiKuaishouAdvertiserStrategyService strategyService;
 
-    */
-/**
-     * 自定义上新创意
-     *//*
 
-    @XxlJob("kuaishouCustomCreativeAuto")
-    public void kuaishouCustomCreativeAuto() {
-        List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
-        if (null == strategies || strategies.isEmpty()) {
+    /**
+     * 创建自定义上新广告创意 、频率 20分钟/次
+     */
+
+    @XxlJob("autoCreateCustomUpNewCreative")
+    public void createCustomUpNewCreative() {
+        List<Long> ids = strategyService.getKuaishouAccountAutoStrategyIds();
+        if (null == ids || ids.isEmpty()) {
             return;
         }
-        String url = jobUrl + "/jeecg-boot/ai/create/customCreativeLimit";
-        for (AiKuaishouAdvertiserStrategy strategy : strategies) {
-            if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 1) {
-                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());
-                }
-            }
-        }
-
-
+        ids.forEach(id -> {
+            String url = jobUrl + "/jeecg-boot/auto/create/createCustomUpNewCreative?id=" + id;
+            HttpUtils.httpGet(url, null, null);
+        });
     }
 
-    */
-/**
-     * 补充创意
-     *//*
-
-    @XxlJob("kuaishouCustomCreativeSupplement")
-    public void kuaishouCustomCreativeSupplement() {
-        List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
-        if (null == strategies || strategies.isEmpty()) {
+    /**
+     * 创建自定义非上新广告创意 、频率 60分钟/次
+     */
+    @XxlJob("autoCreateCustomCreative")
+    public void createCustomCreative() {
+        List<Long> ids = strategyService.getKuaishouAccountAutoStrategyIds();
+        if (null == ids || ids.isEmpty()) {
             return;
         }
-        try {
-            String url = jobUrl + "/jeecg-boot/ai/create/kuaishouCustomCreativeSupplement";
-            int hour = DateUtils.getNowHour();
-            for (AiKuaishouAdvertiserStrategy strategy : strategies) {
-                if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 1) {
-                    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) {
-            e.printStackTrace();
-        }
+        ids.forEach(id -> {
+            String url = jobUrl + "/jeecg-boot/auto/create/createCustomCreative?id=" + id;
+            HttpUtils.httpGet(url, null, null);
+        });
     }
 
-    */
-/**
-     * 程序化上新创意
-     *//*
-
-    @XxlJob("kuaishouProgramCreativeAuto")
-    public void kuaishouProgramCreativeAuto() {
-        List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
-        if (null == strategies || strategies.isEmpty()) {
+    /**
+     * 创建程序化广告创意 频率 60分钟/次
+     */
+    @XxlJob("autoCreateProgramCreative")
+    public void createProgramCreative() {
+        List<Long> ids = strategyService.getKuaishouAccountAutoStrategyIds();
+        if (null == ids || ids.isEmpty()) {
             return;
         }
-        String url = jobUrl + "/jeecg-boot/ai/create/kuaishouProgramCreativeAuto";
-        for (AiKuaishouAdvertiserStrategy strategy : strategies) {
-            if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 0) {
-                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());
-                    } else {
-                        log.error("快手上新程序化异步执行失败,accountId:{}", strategy.getAccountId());
-                    }
-                } else {
-                    log.error("快手上新程序化充返回结果为空,accountId:{}", strategy.getAccountId());
-                }
-
-
-            }
-        }
-
-
+        ids.forEach(id -> {
+            String url = jobUrl + "/jeecg-boot/auto/create/createProgramCreative?id=" + id;
+            HttpUtils.httpGet(url, null, null);
+        });
     }
 
-    */
-/**
-     * 程序化高质量创意
-     *//*
-
-    @XxlJob("kuaishouProgramCreativeTop")
-    public void kuaishouProgramCreativeTop() {
-        List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
-        if (null == strategies || strategies.isEmpty()) {
+    /**
+     * 每日补充创建创意 、频率 每天22点05分钟执行1次
+     */
+    @XxlJob("aotoSupplementCreatives")
+    public void aotoSupplementCreatives() {
+        List<Long> ids = strategyService.getKuaishouAccountAutoStrategyIds();
+        if (null == ids || ids.isEmpty()) {
             return;
         }
-        String url = jobUrl + "/jeecg-boot/ai/create/autoCreateProgramHistoryTopCreative";
-        for (AiKuaishouAdvertiserStrategy strategy : strategies) {
-            if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 0) {
-                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());
-                    } else {
-                        log.error("快手历史高质量程序化异步执行失败,accountId:{}", strategy.getAccountId());
-                    }
-                } else {
-                    log.error("快手历史高质量程序化充返回结果为空,accountId:{}", strategy.getAccountId());
-                }
-            }
-        }
-
+        ids.forEach(id -> {
+            String url = jobUrl + "/jeecg-boot/auto/create/supplementTodayCreatives?id=" + id;
+            HttpUtils.httpGet(url, null, null);
+        });
     }
+
 }
-*/

+ 12 - 3
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAccountAutoVideoJob.java

@@ -16,12 +16,21 @@ import java.util.List;
 import java.util.Map;
 
 */
+
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
 /**
  * 自动投放账户_素材
- *//*
+ */
 
 @Component
-@Slf4j
 public class KuaishouAccountAutoVideoJob {
 
     @Value("${xxl-job.requestUrl}")
@@ -42,4 +51,4 @@ public class KuaishouAccountAutoVideoJob {
         });
     }
 }
-*/
+

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouAdvertiserStrategyMapper.java

@@ -14,4 +14,6 @@ import java.util.List;
 public interface AiKuaishouAdvertiserStrategyMapper extends BaseMapper<AiKuaishouAdvertiserStrategy> {
 
     List<Long> getKuaishouAccountAutoStrategy();
+
+    List<Long> getKuaishouAccountAutoStrategyIds();
 }

+ 9 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAdvertiserStrategyMapper.xml

@@ -3,12 +3,15 @@
 <mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.AiKuaishouAdvertiserStrategyMapper">
 
     <select id="getKuaishouAccountAutoStrategy" resultType="java.lang.Long">
-        SELECT
-            account_id
-        FROM
-            ctop_ai_kuaishou_account_auto_strategy
-        WHERE
-            status = 1
+        SELECT account_id
+        FROM ctop_ai_kuaishou_account_auto_strategy
+        GROUP BY account_id
+    </select>
+
+    <select id="getKuaishouAccountAutoStrategyIds" resultType="java.lang.Long">
+        SELECT id
+        FROM ctop_ai_kuaishou_account_auto_strategy
+        WHERE status = 1
     </select>
 
 </mapper>

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAdvertiserStrategyService.java

@@ -28,4 +28,6 @@ public interface IAiKuaishouAdvertiserStrategyService extends IService<AiKuaisho
     List<AiKuaishouAdvertiserStrategy> getAllEffectStrategy();
 
     List<Long> getKuaishouAccountAutoStrategy();
+
+    List<Long> getKuaishouAccountAutoStrategyIds();
 }

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAdvertiserStrategyServiceImpl.java

@@ -116,6 +116,11 @@ public class AiKuaishouAdvertiserStrategyServiceImpl extends ServiceImpl<AiKuais
         return kuaishouAdvertiserStrategyMapper.getKuaishouAccountAutoStrategy();
     }
 
+    @Override
+    public List<Long> getKuaishouAccountAutoStrategyIds() {
+        return kuaishouAdvertiserStrategyMapper.getKuaishouAccountAutoStrategyIds();
+    }
+
     private Map<String,Object> historicalMissingMaterialCreateCreative(AiKuaishouAdvertiserStrategy strategy) {
         Map<String,Object>result =new HashMap<>();
         //判定是否单一应用