Browse Source

Merge remote-tracking branch 'origin/master'

yumeng 3 years ago
parent
commit
84ec173228

+ 172 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAccountAutoCreativeJob.java

@@ -0,0 +1,172 @@
+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.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
+public class KuaishouAccountAutoCreativeJob {
+
+    @Value("${xxl-job.requestUrl}")
+    private String jobUrl;
+
+    @Autowired
+    private IAiKuaishouAdvertiserStrategyService strategyService;
+
+    /**
+     * 自定义上新创意
+     */
+    @XxlJob("kuaishouCustomCreativeAuto")
+    public void kuaishouCustomCreativeAuto() {
+        List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
+        if (null == strategies || strategies.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());
+                }
+            }
+        }
+
+
+    }
+
+    /**
+     * 补充创意
+     */
+    @XxlJob("kuaishouCustomCreativeSupplement")
+    public void kuaishouCustomCreativeSupplement() {
+        List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
+        if (null == strategies || strategies.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();
+        }
+    }
+
+    /**
+     * 程序化上新创意
+     */
+    @XxlJob("kuaishouProgramCreativeAuto")
+    public void kuaishouProgramCreativeAuto() {
+        List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
+        if (null == strategies || strategies.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());
+                }
+
+
+            }
+        }
+
+
+    }
+
+    /**
+     * 程序化高质量创意
+     */
+    @XxlJob("kuaishouProgramCreativeTop")
+    public void kuaishouProgramCreativeTop() {
+        List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
+        if (null == strategies || strategies.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());
+                }
+            }
+        }
+
+    }
+}

+ 41 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAccountAutoVideoJob.java

@@ -0,0 +1,41 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
+import cn.com.ctop.common.module.utils.Check;
+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 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;
+
+/**
+ * 自动投放账户_素材
+ */
+@Component
+@Slf4j
+public class KuaishouAccountAutoVideoJob {
+
+    @Value("${xxl-job.requestUrl}")
+    private String jobUrl;
+
+    @Autowired
+    private IAiKuaishouAdvertiserStrategyService strategyService;
+
+    @XxlJob("kuaishouAccountAutoVideo")
+    public void kuaishouCustomCreativeAuto() {
+        List<Long> accountIds = strategyService.getKuaishouAccountAutoStrategy();
+        if (null == accountIds || accountIds.isEmpty()) {
+            return;
+        }
+        accountIds.forEach(accountId -> {
+            String url = jobUrl + "/jeecg-boot/auto/aiKuaishouAccountAutoVideo/insertAutoVideo?accountId=" + accountId;
+            HttpUtils.httpGet(url, null, null);
+        });
+    }
+}

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

@@ -3,6 +3,8 @@ package cn.com.ctop.kuaishou.modules.ai.mapper;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
+import java.util.List;
+
 /**
  * 快手账户策略设置信息表
  * @author: jeecg-boot
@@ -11,4 +13,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface AiKuaishouAdvertiserStrategyMapper extends BaseMapper<AiKuaishouAdvertiserStrategy> {
 
+    List<Long> getKuaishouAccountAutoStrategy();
 }

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

@@ -2,4 +2,13 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <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>
+
 </mapper>

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

@@ -26,4 +26,6 @@ public interface IAiKuaishouAdvertiserStrategyService extends IService<AiKuaisho
     Map<String, Object> aiHistoricalMissingMaterial(Long accountId);
 
     List<AiKuaishouAdvertiserStrategy> getAllEffectStrategy();
+
+    List<Long> getKuaishouAccountAutoStrategy();
 }

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

@@ -37,6 +37,8 @@ public class AiKuaishouAdvertiserStrategyServiceImpl extends ServiceImpl<AiKuais
     private IKuaiShouVideoGetService videoGetService;
     @Autowired
     private IKuaishouVideoRelateCreativesService relateCreativesService;
+    @Autowired
+    private AiKuaishouAdvertiserStrategyMapper kuaishouAdvertiserStrategyMapper;
 
     @Override
     public AiKuaishouAdvertiserStrategy getByAccountId(Long accountId) {
@@ -106,6 +108,11 @@ public class AiKuaishouAdvertiserStrategyServiceImpl extends ServiceImpl<AiKuais
         return this.list(queryWrapper);
     }
 
+    @Override
+    public List<Long> getKuaishouAccountAutoStrategy() {
+        return kuaishouAdvertiserStrategyMapper.getKuaishouAccountAutoStrategy();
+    }
+
     private Map<String,Object> historicalMissingMaterialCreateCreative(AiKuaishouAdvertiserStrategy strategy) {
         Map<String,Object>result =new HashMap<>();
         //判定是否单一应用