瀏覽代碼

项目自动化调试,调整策略

zhaoxian 4 年之前
父節點
當前提交
abb9f021ab

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

@@ -0,0 +1,101 @@
+package cn.com.ctop.kuaishou.modules.ai.enums;
+
+/**
+ * @author syh
+ */
+public enum KuaishouProjectCreativeMatTypeEnum {
+    /**
+     * 13 23 分别是历史遗漏素材,归类到上新素材中
+     * type字段 第一位创意创建方式,第二位素材获取方式
+     * 快手创意素材获取类型
+     */
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_NEW("41","自定义上新",-1*60*24L,-5L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_HIGH_quality("42","自定义高质量",-28*60*24L,-1*60*24L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_MISSING("43","自定义上新",-60*60*24L,-1*60*24L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_HISTORY("44","自定义历史",-60*60*24L,-1*60*24L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_NEW("71","程序化上新",-3*60*24L,-5L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_HIGH_quality("72","程序化高质量",-28*60*24L,-1*60*24L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_MISSING("73","程序化上新",-60*60*24L,-1*60*24L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_HISTORY("74","程序化历史",-60*60*24L,-1*60*24L),;
+
+    /**
+     * 类型
+     */
+    private String type;
+    /**
+     * 名称
+     */
+    private String name;
+    /**
+     * 素材查询的时间区间
+     */
+    private Long videoGetStartTime;
+    private Long videoGetEndTime;
+
+    KuaishouProjectCreativeMatTypeEnum(String type, String name, Long videoGetStartTime, Long videoGetEndTime) {
+        this.type = type;
+        this.name = name;
+        this.videoGetStartTime = videoGetStartTime;
+        this.videoGetEndTime = videoGetEndTime;
+    }
+
+    public static String getNameByType(String type) {
+        for (KuaishouProjectCreativeMatTypeEnum createTypeEnum : KuaishouProjectCreativeMatTypeEnum.values()) {
+            if (createTypeEnum.getType().equals(type)) {
+                return createTypeEnum.getName();
+            }
+        }
+        return "";
+    }
+
+    public static Long getStartTimeByType(String type) {
+        for (KuaishouProjectCreativeMatTypeEnum createTypeEnum : KuaishouProjectCreativeMatTypeEnum.values()) {
+            if (createTypeEnum.getType().equals(type)) {
+                return createTypeEnum.getVideoGetStartTime();
+            }
+        }
+        return -10L;
+    }
+
+    public static Long getEndTimeByType(String type) {
+        for (KuaishouProjectCreativeMatTypeEnum createTypeEnum : KuaishouProjectCreativeMatTypeEnum.values()) {
+            if (createTypeEnum.getType().equals(type)) {
+                return createTypeEnum.getVideoGetEndTime();
+            }
+        }
+        return -5L;
+    }
+
+
+    public String getType() {
+        return this.type;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public void setName(String value) {
+        this.name = value;
+    }
+
+    public Long getVideoGetStartTime() {
+        return videoGetStartTime;
+    }
+
+    public void setVideoGetStartTime(Long videoGetStartTime) {
+        this.videoGetStartTime = videoGetStartTime;
+    }
+
+    public Long getVideoGetEndTime() {
+        return videoGetEndTime;
+    }
+
+    public void setVideoGetEndTime(Long videoGetEndTime) {
+        this.videoGetEndTime = videoGetEndTime;
+    }
+}

+ 17 - 13
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouProjectCreateCreativeServiceImpl.java

@@ -20,7 +20,8 @@ import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage;
 import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouProjectStrategy;
 import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouVideoDirectionalPackage;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeAdsenceTypeEnum;
-import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeMatTypeEnum;
+import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouProjectCreativeMatTypeEnum;
+import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouProjectCreativeMatTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouVideoDirectionalPackageMapper;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountLevelOperationRecordService;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCampaignLevelOperationRecordService;
@@ -177,6 +178,7 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
         try {
             String strategyUuid = UUID.randomUUID().toString();
             strategy.setStrategyUuid(strategyUuid);
+            strategy.setUnitType(4);
             Long accountId = strategy.getAccountId();
             CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId.toString());
             if (null == token) {
@@ -186,8 +188,8 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
             }
             //1:获取视频信息
             kuaishouInterfaceService.getVideoList(token, DateUtils.date2Str(), DateUtils.date2Str());
-            Long timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + createType.toString());
-            Long timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + createType.toString());
+            Long timeStart = KuaishouProjectCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + createType.toString());
+            Long timeEnd = KuaishouProjectCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + createType.toString());
             Long now = System.currentTimeMillis();
             String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
             String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
@@ -196,7 +198,7 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
             //单/多应用,1单应用,2多应用
             if (null != singleAppid && singleAppid == 1) {
                 //单一应用
-                String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
+                String replaceString = KuaishouProjectCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
                 List<KuaiShouVideoGet> newVideos = getVideosByParams(strategy, startTime, endTime, null, createType, Long.valueOf(videoCnt));
                 if (null == newVideos || newVideos.isEmpty()) {
                     log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
@@ -319,8 +321,8 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
                 timeStart = -7 * 60 * 24L;
                 timeEnd = -5L;
             } else {
-                timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + createType.toString());
-                timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + createType.toString());
+                timeStart = KuaishouProjectCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + createType.toString());
+                timeEnd = KuaishouProjectCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + createType.toString());
             }
             Long now = System.currentTimeMillis();
             String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
@@ -330,7 +332,7 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
 
             //单/多应用,1单应用,2多应用
             if (null != singleAppid && singleAppid == 1) {
-                String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
+                String replaceString = KuaishouProjectCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
                 //单一应用
                 List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, null, createType, Long.valueOf(videoCnt));
                 if (null == allVideos) {
@@ -1139,6 +1141,7 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
                                        int imageNumber, KuaishouProjectStrategy strategy, String uuid, String appVersion) {
         if ((null != cutFrameList && !cutFrameList.isEmpty())) {
             for (int i = 0; i < cutFrameList.size(); i++) {
+                creativeParams.put("action_bar_text", getActionBar(strategy.getActionBarText()));
                 String imageCode = cutFrameList.get(i).getSignature();
                 String imageUrl = cutFrameList.get(i).getUrl();
                 String imageToken = getImageToken(imageUrl, imageCode, token.getAccountId(), token.getAccessToken());
@@ -1171,7 +1174,6 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
         creativeParams.put("unit_id", unitId);
         creativeParams.put("photo_id", videoItem.getPhotoId());
         creativeParams.put("creative_material_type", videoItem.getMaterialType());
-        creativeParams.put("action_bar_text", getActionBar(strategy.getActionBarText()));
         JSONArray descArr = JSONArray.parseArray(strategy.getDescription());
         int index = new Random().nextInt(descArr.size());
         String description = descArr.getString(index);
@@ -1334,11 +1336,7 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
         } else if ("unit".equals(type)) {
             wildcard = wildcard.replace("{{日期}}", nowDate);
         }
-        String HOUR = DateUtils.formatDate(date, DateUtils.TIME_FORMAT);
-        if (wildcard.contains("{{时分}}")) {
-            wildcard = wildcard.replace("{{时分}}", HOUR);
-        }
-        String targetName = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
+        String targetName = KuaishouProjectCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
         wildcard = wildcard.replace("{{自定义}}", targetName);
         if (!Check.isNull(campaignId)) {
             Integer count = null;
@@ -1365,6 +1363,12 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
             }
             wildcard = wildcard + "-" + count;
         }
+        String HOUR = DateUtils.formatDate(date, DateUtils.TIME_FORMAT);
+        if (wildcard.contains("{{时分}}")) {
+            wildcard = wildcard.replace("{{时分}}", HOUR);
+        }else{
+            wildcard = wildcard.concat(HOUR.substring(0,4));
+        }
         wildcard = wildcard.replace("--", "-");
         if (wildcard.startsWith("-")) {
             wildcard = wildcard.substring(1, wildcard.length());