瀏覽代碼

fix:creative number limit

syh 4 年之前
父節點
當前提交
abb3d992ce

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AiKuaishouAdvertiserStrategyController.java

@@ -106,6 +106,7 @@ public class AiKuaishouAdvertiserStrategyController {
             if(null!=allocation){
                 aiKuaishouAdvertiserStrategy.setUserId(allocation.getUserId());
             }
+            aiKuaishouAdvertiserStrategy.setDescription(aiKuaishouAdvertiserStrategy.getDescription().trim());
             Integer singleAppId = aiKuaishouAdvertiserStrategy.getSingleAppid();
             if (null != singleAppId && singleAppId == 1) {
                 Integer appId = Integer.parseInt(JSONArray.parseArray(aiKuaishouAdvertiserStrategy.getAppIdArray()).getString(0));

+ 13 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -1279,4 +1279,17 @@ public class TestController {
         ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
         return result;
     }
+
+    @GetMapping("testCreateCreativeLimit")
+    public Map<String,Object>testCreateCreativeLimit(Long accountId,Integer hour) throws ParseException {
+        Map<String,Object>result = new HashMap<>();
+        AiKuaishouAdvertiserStrategy strategy = strategyService.getByAccountId(accountId);
+        if(strategy == null){
+            ResultMapUtils.setResultMap(result,StatusCode.COMMON_PARAM_ERROR);
+            return result;
+        }
+        createCreativeService.customCreativeSupplement(strategy,hour);
+        ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
+        return result;
+    }
 }

+ 0 - 25
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouAlarmRuleHourlyCheckJob.java

@@ -1,25 +0,0 @@
-//package cn.com.ctop.job.kuaishou.handler;
-//
-//import cn.com.ctop.alarm.modules.service.IAlarmEventSendService;
-//import com.xxl.job.core.handler.annotation.XxlJob;
-//import org.quartz.JobExecutionException;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.stereotype.Component;
-//
-//@Component
-//public class KuaiShouAlarmRuleHourlyCheckJob {
-//    @Autowired
-//    private IAlarmEventSendService alarmEventSendService;
-//
-//    /**
-//     * 定时获取成本数据
-//     *
-//     * @throws JobExecutionException
-//     */
-//    @XxlJob("kuaiShouAlarmRuleHourlyCheckJob")
-//    public void execute() throws Exception {
-//        //检查频率 HOUR - 每小时;HALF_HOUR-每半小时
-//        alarmEventSendService.matchAlarmRules("HOUR");
-//    }
-//}
-//

+ 0 - 25
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouAlarmRuleMinuteCheckJob.java

@@ -1,25 +0,0 @@
-//package cn.com.ctop.job.kuaishou.handler;
-//
-//import cn.com.ctop.alarm.modules.service.IAlarmEventSendService;
-//import com.xxl.job.core.handler.annotation.XxlJob;
-//import org.quartz.JobExecutionException;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.stereotype.Component;
-//
-//@Component
-//public class KuaiShouAlarmRuleMinuteCheckJob {
-//    @Autowired
-//    private IAlarmEventSendService alarmEventSendService;
-//
-//    /**
-//     * 定时获取成本数据
-//     *
-//     * @throws JobExecutionException
-//     */
-//    @XxlJob("kuaiShouAlarmRuleMinuteCheckJob")
-//    public void execute(String param) throws Exception {
-//        //检查频率 HOUR - 每小时;HALF_HOUR-每半小时
-//        alarmEventSendService.matchAlarmRules("HALF_HOUR");
-//    }
-//}
-//

+ 1 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAiCreativeJob.java

@@ -48,7 +48,7 @@ public class KuaishouAiCreativeJob {
         strategies.forEach(strategy -> {
             if(null!=strategy.getOpenProgramCreate()&&strategy.getOpenProgramCreate()!=1){
                 try {
-                    createCreativeService.customCreativeSupplement(strategy);
+                    createCreativeService.customCreativeSupplement(strategy,1);
                 } catch (ParseException e) {
                     e.printStackTrace();
                 }

+ 55 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/enums/KuaishouCreativeCreateTypeEnum.java

@@ -0,0 +1,55 @@
+package cn.com.ctop.kuaishou.modules.ai.enums;
+
+import cn.com.ctop.kuaishou.modules.batch.Enums.CampaignTypeEnum;
+
+/**
+ * @author syh
+ */
+public enum KuaishouCreativeCreateTypeEnum {
+    /**
+     * 快手创意创建方式
+     */
+    KUAISHOU_CREATIVE_CREATETYPE_ENUM_PROGRAM(1,"程序化"),
+    KUAISHOU_CREATIVE_CREATETYPE_ENUM_UNLIMITED(2,"不限"),
+    KUAISHOU_CREATIVE_CREATETYPE_ENUM_CUSTOM(0,"自定义");
+
+    /**
+     * 类型
+     */
+    private Integer type;
+    /**
+     * 名称
+     */
+    private String value;
+
+    KuaishouCreativeCreateTypeEnum(Integer type, String value) {
+        this.type = type;
+        this.value = value;
+    }
+
+    public static String getNameByType(Integer type) {
+        for (KuaishouCreativeCreateTypeEnum createTypeEnum : KuaishouCreativeCreateTypeEnum.values()) {
+            if (createTypeEnum.getType().equals(type)) {
+                return createTypeEnum.getValue();
+            }
+        }
+        return "";
+    }
+
+
+    public Integer getType() {
+        return type;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouCreateCreativeService.java

@@ -9,5 +9,5 @@ public interface IAiKuaishouCreateCreativeService {
 
     void autoCreateProgramCreative(AiKuaishouAdvertiserStrategy strategy,Integer createType,Long videoCnt);
 
-    void customCreativeSupplement(AiKuaishouAdvertiserStrategy strategy) throws ParseException;
+    void customCreativeSupplement(AiKuaishouAdvertiserStrategy strategy,Integer hour) throws ParseException;
 }

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

@@ -4,11 +4,15 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.MaterialCutFrame;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
-import cn.com.ctop.common.module.utils.*;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaiShouAppInfo;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyMapCreative;
 import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAccountCreativeOverrunInfo;
+import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeCreateTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaiShouAppInfoService;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreateCreativeService;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouStrategyMapCreativeService;
@@ -85,7 +89,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
      *
      * @param strategy   账户配置信息
      * @param createType 创意创建类型 1:素材上新 2:历史高质量 3:历史遗漏素材 4:历史打捞
-     * @param videoCnt
+     * @param videoCnt 视频数量
      */
     @Override
     public Long autoCreateCreative(AiKuaishouAdvertiserStrategy strategy, Integer createType, Long videoCnt) {
@@ -373,19 +377,28 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
     }
 
     @Override
-    public void customCreativeSupplement(AiKuaishouAdvertiserStrategy strategy) throws ParseException {
-        //获取当前小时数 ,计算截止当前应当创建的组数量
-        Integer hour = DateUtils.getNowHour();
+    public void customCreativeSupplement(AiKuaishouAdvertiserStrategy strategy,Integer hour) throws ParseException {
         Long unitNum = strategy.getCustomUnitCnt()/20*hour;
+        log.info("当前时间内需要创建组总数:{}",unitNum);
         //查询当前账户创建自定义类型组数量
         int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId());
+        log.info("截止目前创建组总数:{}",unitCreateCnt);
         long remindCnt = unitNum-unitCreateCnt;
         if(remindCnt>=1){
+            log.info("组创建不足,剩余需要创建个数{},使用历史遗漏素材创建",remindCnt);
             //优先创建历史遗漏素材
             remindCnt = this.autoCreateCreative(strategy,3,remindCnt);
         }
-
-
+        if(remindCnt>=1){
+            log.info("组创建不足,剩余需要创建个数{},使用高质量素材创建",remindCnt);
+            //高质量素材
+            remindCnt = this.autoCreateCreative(strategy,2,remindCnt);
+        }
+        if(remindCnt>=1){
+            //历史打捞素材
+            log.info("组创建不足,剩余需要创建个数{},使用历史打捞素材创建",remindCnt);
+            remindCnt = this.autoCreateCreative(strategy,4,remindCnt);
+        }
     }
 
     private void createProgramCreative(CtopOauthToken token, JSONObject creativeParams) {
@@ -1040,4 +1053,42 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         mapCreative.setCreativeId(creativeId);
         mapCreativeService.save(mapCreative);
     }
+
+    /**
+     * @param wildcard  计划名称
+     * @param strategy  账户id
+     * @return
+     */
+    private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy,Integer num) {
+        if(wildcard.contains("{{定向包}}")){
+            String targetName = "";
+        }
+        if(wildcard.contains("{{日期}}")){
+            String date = DateUtils.getNowDate("yyyyMMddHHmmss");
+            wildcard.replace("{{日期}}","-"+date+"-");
+        }
+        if(wildcard.contains("{{下标号}}")){
+            String numString = num.toString();
+            wildcard.replace("{{下标号}}","-"+numString+"-");
+        }
+        if(wildcard.contains("{{应用包名}}")){
+            String targetName = "";
+        }
+        if(wildcard.contains("{{创意制作方式}}")){
+            String creatype = KuaishouCreativeCreateTypeEnum.getNameByType(strategy.getOpenProgramCreate());
+            wildcard.replace("{{创意制作方式}}","-"+creatype+"-");
+        }
+        if(wildcard.contains("{{广告位置}}")){
+            String adsence = getAdSenceByParams(strategy.getSceneId());
+        }
+        if(wildcard.contains("{{自定义}}")){
+            String targetName = "";
+        }
+        return wildcard;
+    }
+
+    private String getAdSenceByParams(String sceneId) {
+        String adsence = "";
+        return adsence;
+    }
 }