yumeng před 4 roky
rodič
revize
b7820fa3de

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

@@ -28,17 +28,18 @@ public class KuaishouAiCreativeJob {
     static ExecutorService customCreativeSupplementExecutorService = Executors.newFixedThreadPool(5);
     static ExecutorService programCreativeAutoExecutorService = Executors.newFixedThreadPool(5);
     static ExecutorService programCreativeTopExecutorService = Executors.newFixedThreadPool(5);
+
     /**
      * 自定义上新创意
      */
     @XxlJob("kuaishouCustomCreativeAuto")
     public void kuaishouCustomCreativeAuto() {
         List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
-        if(null==strategies||strategies.isEmpty()){
+        if (null == strategies || strategies.isEmpty()) {
             return;
         }
-        strategies.forEach(strategy -> customCreativeAutoExecutorService.submit(()->{
-            if(null!=strategy.getOpenProgramCreate()&&strategy.getOpenProgramCreate()!=1){
+        strategies.forEach(strategy -> customCreativeAutoExecutorService.submit(() -> {
+            if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 1) {
                 createCreativeService.customCreativeLimit(strategy);
             }
         }));
@@ -50,15 +51,15 @@ public class KuaishouAiCreativeJob {
     @XxlJob("kuaishouCustomCreativeSupplement")
     public void kuaishouCustomCreativeSupplement() {
         List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
-        if(null==strategies||strategies.isEmpty()){
+        if (null == strategies || strategies.isEmpty()) {
             return;
         }
         try {
             int hour = DateUtils.getNowHour();
-            strategies.forEach(strategy -> customCreativeSupplementExecutorService.submit(()->{
-                if(null!=strategy.getOpenProgramCreate()&&strategy.getOpenProgramCreate()!=1){
+            strategies.forEach(strategy -> customCreativeSupplementExecutorService.submit(() -> {
+                if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 1) {
                     try {
-                        createCreativeService.customCreativeSupplement(strategy,hour);
+                        createCreativeService.customCreativeSupplement(strategy, hour);
                     } catch (ParseException e) {
                         e.printStackTrace();
                     }
@@ -75,13 +76,13 @@ public class KuaishouAiCreativeJob {
     @XxlJob("kuaishouProgramCreativeAuto")
     public void kuaishouProgramCreativeAuto() {
         List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
-        if(null==strategies||strategies.isEmpty()){
+        if (null == strategies || strategies.isEmpty()) {
             return;
         }
-        strategies.forEach(strategy -> programCreativeAutoExecutorService.submit(()->{
-            if(null!=strategy.getOpenProgramCreate()&&strategy.getOpenProgramCreate()!=0){
-                long videoCnt = strategy.getProgramUnitCnt()*5/2;
-                createCreativeService.autoCreateProgramCreative(strategy,1,videoCnt);
+        strategies.forEach(strategy -> programCreativeAutoExecutorService.submit(() -> {
+            if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 0) {
+                long videoCnt = strategy.getProgramUnitCnt() * 5 / 2;
+                createCreativeService.autoCreateProgramCreative(strategy, 1, videoCnt);
             }
         }));
     }
@@ -92,13 +93,13 @@ public class KuaishouAiCreativeJob {
     @XxlJob("kuaishouProgramCreativeTop")
     public void kuaishouProgramCreativeTop() {
         List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
-        if(null==strategies||strategies.isEmpty()){
+        if (null == strategies || strategies.isEmpty()) {
             return;
         }
-        strategies.forEach(strategy -> programCreativeTopExecutorService.submit(()->{
-            if(null!=strategy.getOpenProgramCreate()&&strategy.getOpenProgramCreate()!=0){
-                long videoCnt = strategy.getProgramUnitCnt()*5/2;
-                createCreativeService.autoCreateProgramCreative(strategy,2,videoCnt);
+        strategies.forEach(strategy -> programCreativeTopExecutorService.submit(() -> {
+            if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 0) {
+                long videoCnt = strategy.getProgramUnitCnt() * 5 / 2;
+                createCreativeService.autoCreateProgramCreative(strategy, 2, videoCnt);
             }
         }));
     }

+ 361 - 194
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAdvertiserStrategy.java

@@ -1,6 +1,9 @@
 package cn.com.ctop.kuaishou.modules.ai.entity;
 
-import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
@@ -8,207 +11,371 @@ import java.util.Date;
 
 /**
  * 快手账户策略设置信息表
+ *
  * @author jeecg-boot
- * @date   2021-01-25
  * @version V1.0
+ * @date 2021-01-25
  */
 @Data
 @TableName("ctop_ai_kuaishou_advertiser_strategy")
 @EqualsAndHashCode(callSuper = false)
 public class AiKuaishouAdvertiserStrategy {
 
-	/**客户策略ID*/
-	@TableId(type = IdType.AUTO)
-	private Long id;
-	/**账户ID*/
-	private Long accountId;
-	private String userId;
-	private Integer channelType;
-	/**策略状态 1-使用 0-停用*/
-	private Integer status;
-	/**客户要求的计划名称规范*/
-	private String campaignName;
-	/**计划类型 2-提升应用安装 3-获取电商下单 4-推广品牌活动 5-收集销售线索 7-提高应用活跃*/
-	private Integer campaignType;
-	/**客户要求的广告组名称规范*/
-	private String groupName;
-	/**定向模板id*/
-	private Integer templateId;
-	/**优化目标出价类型*/
-	private Integer bidType;
-	/**优先从系统应用商店下载*/
-	private Integer useAppMarket;
-	/**应用商店列表*/
-	private String appStore;
-	/**出价*/
-	private Integer bid;
-	/**深度出价*/
-	private Long cpaBid;
-	private Long deepConversionBid;
-	/**优先低成本出价*/
-	private Integer smartBid;
-	/**优化目标*/
-	private Integer ocpxActionType;
-	/**深度转化目标*/
-	private Integer deepConversionType;
-	/**付费ROI系数*/
-	private Float roiRatio;
-	/**资源位置*/
-	private String sceneId;
-	/** 创意制作方式 4-自定义 5-程序化创意 7-程序化创意2.0*/
-	private Integer unitType;
-	/**投放开始时间*/
-	private String beginTime;
-	/**投放结束时间*/
-	private String endTime;
-	/**投放时间段*/
-	private String scheduleTime;
-	/**转化目标ID*/
-	private Integer convertId;
-	/**url类型*/
-	private Integer urlType;
-	/**url类型*/
-	private Integer webUriType;
-	/**投放链接*/
-	private String url;
-	/**调起链接*/
-	private String schemaUri;
-	/**应用ID*/
-	private Integer appId;
-	/**创意展现方式 1-轮播  2-优选*/
-	private Integer showMode;
-	/**投放方式 1-加速投放  2-平滑投放 3-优先低成本*/
-	private Integer speed;
-	/**预约广告*/
-	private Integer siteType;
-	/**游戏礼包码*/
-	private String giftData;
-	/**是否使用落地页前置功能*/
-	private Integer videoLandingPage;
-	/**智能定向*/
-	private Integer autoTarget;
-	/**是否开启自动生成视频*/
-	private Integer autoCreatePhoto;
-	/**地域*/
-	private String region;
-	/**商圈定向*/
-	private String districtIds;
-	/**用户类型*/
-	private Integer userType;
-	/**最大年龄*/
-	private Integer ageMin;
-	/**最小年龄*/
-	private Integer ageMax;
-	/**固定年龄段*/
-	private String agesRange;
-	/**性别*/
-	private Integer gender;
-	/**操作系统*/
-	private Integer platformOs;
-	/**Android版本*/
-	private Integer androidOsv;
-	/**iOS版本*/
-	private Integer iosOsv;
-	/**网络环境*/
-	private Integer network;
-	/**设备品牌*/
-	private String deviceBrand;
-	/**设备价格*/
-	private String devicePrice;
-	/**商业兴趣类型*/
-	private Integer businessInterestType;
-	/**商业兴趣*/
-	private String businessInterest;
-	/**网红粉丝*/
-	private String fansStar;
-	/**兴趣视频用户*/
-	private String interestVideo;
-	/**APP行为-按分类*/
-	private String appInterest;
-	/**APP行为-按APP名称*/
-	private String appIds;
-	/**过滤已转化人群纬度*/
-	private Integer filterConvertedLevel;
-	/**人群包定向*/
-	private String population;
-	/**人群包排除*/
-	private String excludePopulation;
-	/**付费人群包id*/
-	private String paidAudience;
-	/**开启智能扩量*/
-	private Integer isOpen;
-	/**不可突破年龄*/
-	private Integer noAgeBreak;
-	/**不可突破性别*/
-	private Integer noGenderBreak;
-	/**不可突破地域*/
-	private Integer noAreaBreak;
-	/**行为兴趣定向*/
-	private String behaviorInterest;
-	/**创意名称*/
-	private String creativeName;
-	/**行动号召按钮文案*/
-	private String actionBarText;
-	/**广告语*/
-	private String description;
-	/**便利贴创意短广告语*/
-	private String shortSlogan;
-	/**封面广告语标题*/
-	private String stickerTitle;
-	/**贴纸样式类型*/
-	private String overlayType;
-	/**广告标签*/
-	private String exposeTag;
-	/**广告标签2期*/
-	private String newExposeTag;
-	/**安卓下载中间页ID*/
-	private Integer siteId;
-	/**第三方点击检测链接*/
-	private String clickTrackUrl;
-	/**第三方开始播放监测链接*/
-	private String impressionUrl;
-	private Integer generalTrack;
-	/**第三方有效播放监测链接*/
-	private String adPhotoPlayedT3sUrl;
-	/**第三方点击按钮监测链接*/
-	private String actionbarClickUrl;
-	/**创意分类*/
-	private Integer creativeCategory;
-	/**创意标签*/
-	private String creativeTag;
-	/**物料关联的封面个数*/
-	private Integer imageCnt;
-	/**创建时间*/
-	private Date createTime;
-	/**生效时间*/
-	private Date effectiveTime;
-	/**失效时间*/
-	private Date expiryTime;
-	/**
-	 * 是否开启智能封面
-	 */
-	private Integer smartCover;
-	/**
-	 * 是否开启素材挖掘
-	 */
-	private Integer assetMining;
-	/**
-	 * 是否单应用
-	 */
-	private Integer singleAppid;
-	/**
-	 * 投放中的appId数组
-	 */
-	private String appIdArray;
-	private Integer openProgramCreate;
+    /**
+     * 客户策略ID
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    /**
+     * 账户ID
+     */
+    private Long accountId;
+    private String userId;
+    private Integer channelType;
+    /**
+     * 策略状态 1-使用 0-停用
+     */
+    private Integer status;
+    /**
+     * 客户要求的计划名称规范
+     */
+    private String campaignName;
+    /**
+     * 计划类型 2-提升应用安装 3-获取电商下单 4-推广品牌活动 5-收集销售线索 7-提高应用活跃
+     */
+    private Integer campaignType;
+    /**
+     * 客户要求的广告组名称规范
+     */
+    private String groupName;
+    /**
+     * 定向模板id
+     */
+    private Integer templateId;
+    /**
+     * 优化目标出价类型
+     */
+    private Integer bidType;
+    /**
+     * 优先从系统应用商店下载
+     */
+    private Integer useAppMarket;
+    /**
+     * 应用商店列表
+     */
+    private String appStore;
+    /**
+     * 出价
+     */
+    private Integer bid;
+    /**
+     * 深度出价
+     */
+    private Long cpaBid;
+    private Long deepConversionBid;
+    /**
+     * 优先低成本出价
+     */
+    private Integer smartBid;
+    /**
+     * 优化目标
+     */
+    private Integer ocpxActionType;
+    /**
+     * 深度转化目标
+     */
+    private Integer deepConversionType;
+    /**
+     * 付费ROI系数
+     */
+    private Float roiRatio;
+    /**
+     * 资源位置
+     */
+    private String sceneId;
+    /**
+     * 创意制作方式 4-自定义 5-程序化创意 7-程序化创意2.0
+     */
+    private Integer unitType;
+    /**
+     * 投放开始时间
+     */
+    private String beginTime;
+    /**
+     * 投放结束时间
+     */
+    private String endTime;
+    /**
+     * 投放时间段
+     */
+    private String scheduleTime;
+    /**
+     * 转化目标ID
+     */
+    private Integer convertId;
+    /**
+     * url类型
+     */
+    private Integer urlType;
+    /**
+     * url类型
+     */
+    private Integer webUriType;
+    /**
+     * 投放链接
+     */
+    private String url;
+    /**
+     * 调起链接
+     */
+    private String schemaUri;
+    /**
+     * 应用ID
+     */
+    private Integer appId;
+    /**
+     * 创意展现方式 1-轮播  2-优选
+     */
+    private Integer showMode;
+    /**
+     * 投放方式 1-加速投放  2-平滑投放 3-优先低成本
+     */
+    private Integer speed;
+    /**
+     * 预约广告
+     */
+    private Integer siteType;
+    /**
+     * 游戏礼包码
+     */
+    private String giftData;
+    /**
+     * 是否使用落地页前置功能
+     */
+    private Integer videoLandingPage;
+    /**
+     * 智能定向
+     */
+    private Integer autoTarget;
+    /**
+     * 是否开启自动生成视频
+     */
+    private Integer autoCreatePhoto;
+    /**
+     * 地域
+     */
+    private String region;
+    /**
+     * 商圈定向
+     */
+    private String districtIds;
+    /**
+     * 用户类型
+     */
+    private Integer userType;
+    /**
+     * 最大年龄
+     */
+    private Integer ageMin;
+    /**
+     * 最小年龄
+     */
+    private Integer ageMax;
+    /**
+     * 固定年龄段
+     */
+    private String agesRange;
+    /**
+     * 性别
+     */
+    private Integer gender;
+    /**
+     * 操作系统
+     */
+    private Integer platformOs;
+    /**
+     * Android版本
+     */
+    private Integer androidOsv;
+    /**
+     * iOS版本
+     */
+    private Integer iosOsv;
+    /**
+     * 网络环境
+     */
+    private Integer network;
+    /**
+     * 设备品牌
+     */
+    private String deviceBrand;
+    /**
+     * 设备价格
+     */
+    private String devicePrice;
+    /**
+     * 商业兴趣类型
+     */
+    private Integer businessInterestType;
+    /**
+     * 商业兴趣
+     */
+    private String businessInterest;
+    /**
+     * 网红粉丝
+     */
+    private String fansStar;
+    /**
+     * 兴趣视频用户
+     */
+    private String interestVideo;
+    /**
+     * APP行为-按分类
+     */
+    private String appInterest;
+    /**
+     * APP行为-按APP名称
+     */
+    private String appIds;
+    /**
+     * 过滤已转化人群纬度
+     */
+    private Integer filterConvertedLevel;
+    /**
+     * 人群包定向
+     */
+    private String population;
+    /**
+     * 人群包排除
+     */
+    private String excludePopulation;
+    /**
+     * 付费人群包id
+     */
+    private String paidAudience;
+    /**
+     * 开启智能扩量
+     */
+    private Integer isOpen;
+    /**
+     * 不可突破年龄
+     */
+    private Integer noAgeBreak;
+    /**
+     * 不可突破性别
+     */
+    private Integer noGenderBreak;
+    /**
+     * 不可突破地域
+     */
+    private Integer noAreaBreak;
+    /**
+     * 行为兴趣定向
+     */
+    private String behaviorInterest;
+    /**
+     * 创意名称
+     */
+    private String creativeName;
+    /**
+     * 行动号召按钮文案
+     */
+    private String actionBarText;
+    /**
+     * 广告语
+     */
+    private String description;
+    /**
+     * 便利贴创意短广告语
+     */
+    private String shortSlogan;
+    /**
+     * 封面广告语标题
+     */
+    private String stickerTitle;
+    /**
+     * 贴纸样式类型
+     */
+    private String overlayType;
+    /**
+     * 广告标签
+     */
+    private String exposeTag;
+    /**
+     * 广告标签2期
+     */
+    private String newExposeTag;
+    /**
+     * 安卓下载中间页ID
+     */
+    private Integer siteId;
+    /**
+     * 第三方点击检测链接
+     */
+    private String clickTrackUrl;
+    /**
+     * 第三方开始播放监测链接
+     */
+    private String impressionUrl;
+    private Integer generalTrack;
+    /**
+     * 第三方有效播放监测链接
+     */
+    private String adPhotoPlayedT3sUrl;
+    /**
+     * 第三方点击按钮监测链接
+     */
+    private String actionbarClickUrl;
+    /**
+     * 创意分类
+     */
+    private Integer creativeCategory;
+    /**
+     * 创意标签
+     */
+    private String creativeTag;
+    /**
+     * 物料关联的封面个数
+     */
+    private Integer imageCnt;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+    /**
+     * 生效时间
+     */
+    private Date effectiveTime;
+    /**
+     * 失效时间
+     */
+    private Date expiryTime;
+    /**
+     * 是否开启智能封面
+     */
+    private Integer smartCover;
+    /**
+     * 是否开启素材挖掘
+     */
+    private Integer assetMining;
+    /**
+     * 是否单应用
+     */
+    private Integer singleAppid;
+    /**
+     * 投放中的appId数组
+     */
+    private String appIdArray;
+    private Integer openProgramCreate;
 
-	private Long campaignDayBudget;
-	private String campaignDayBudgetSchedule;
-	private Long unitDayBudget;
-	private String unitDayBudgetSchedule;
-	private Long customUnitCnt;
-	private Long programUnitCnt;
+    private Long campaignDayBudget;
+    private String campaignDayBudgetSchedule;
+    private Long unitDayBudget;
+    private String unitDayBudgetSchedule;
+    private Long customUnitCnt;
+    private Long programUnitCnt;
+    private String materialKeyword;
 
-	@TableField(exist = false)
-	private String authName;
+    @TableField(exist = false)
+    private String authName;
 }

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

@@ -64,7 +64,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) {
@@ -78,8 +78,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         //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 = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + createType.toString());
+        Long timeEnd = KuaishouCreativeMatTypeEnum.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);
@@ -92,7 +92,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             JSONArray appIdArray = JSON.parseArray(appidString);
             if (null != appIdArray && !appIdArray.isEmpty()) {
                 for (int i = 0; i < appIdArray.size(); i++) {
-                    String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString()+createType.toString());
+                    String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
                     AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(), appIdArray.getLong(i));
                     if (null == appInfo) {
                         log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
@@ -104,12 +104,12 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     }
                     replaceString = appInfo.getAppVersion() + "-" + replaceString;
                     //1:查询素材
-                    List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType,videoCnt);
+                    List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType, videoCnt);
                     if (null == allVideos || allVideos.isEmpty()) {
-                        log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime,replaceString);
+                        log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
                         continue;
                     }
-                    Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN",createType,appInfo,strategyUuid);
+                    Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo, strategyUuid);
                     int unitCnt = 0;
                     for (KuaiShouVideoGet videoItem : allVideos) {
                         KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
@@ -126,13 +126,13 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         unitCnt++;
                         //开始创建组+创意
                         String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
-                        String unitName = getName(strategy.getGroupName(),strategy,createType,appInfo,timestamp,unitCnt);
+                        String unitName = getName(strategy.getGroupName(), strategy, createType, appInfo, timestamp, unitCnt);
                         JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
                         Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                         Integer unitCode = (Integer) unitCreateResult.get("code");
                         String unitMessage = (String) unitCreateResult.get("message");
                         AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
-                        BeanUtils.copyProperties(strategy,unitLevelOperationRecord);
+                        BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
                         unitLevelOperationRecord.setGroupName(unitName);
                         unitLevelOperationRecord.setCreateTime(new Date());
                         unitLevelOperationRecord.setStatus(unitCode);
@@ -147,10 +147,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         Long unitId = (Long) unitCreateResult.get("unitId");
                         unitLevelOperationRecord.setUnitId(unitId);
                         unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                        videoCnt --;
+                        videoCnt--;
                         JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
-                        createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(),strategy,strategyUuid);
-                        if(videoCnt<=0){
+                        createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid);
+                        if (videoCnt <= 0) {
                             return videoCnt;
                         }
                     }
@@ -158,13 +158,13 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             }
         } else {
             //单一应用
-            String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString()+createType.toString());
-            List<KuaiShouVideoGet> newVideos = getVideosByParams(strategy, startTime, endTime, null, createType,videoCnt);
+            String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
+            List<KuaiShouVideoGet> newVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
             if (null == newVideos || newVideos.isEmpty()) {
-                log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime,replaceString);
+                log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
                 return videoCnt;
             }
-            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY",createType,null,strategyUuid);
+            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, null, strategyUuid);
             if (null == newCampaignId) {
                 return videoCnt;
             }
@@ -184,14 +184,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 }
                 unitCnt++;
                 String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
-                String unitName = getName(strategy.getGroupName(),strategy,createType,null,timestamp,unitCnt);
+                String unitName = getName(strategy.getGroupName(), strategy, createType, null, timestamp, unitCnt);
                 Long appId = JSON.parseArray(strategy.getAppIdArray()).getLong(0);
                 JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
                 Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                 Integer unitCode = (Integer) unitCreateResult.get("code");
                 String unitMessage = (String) unitCreateResult.get("message");
                 AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
-                BeanUtils.copyProperties(strategy,unitLevelOperationRecord);
+                BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
                 unitLevelOperationRecord.setGroupName(unitName);
                 unitLevelOperationRecord.setCreateTime(new Date());
                 unitLevelOperationRecord.setStatus(unitCode);
@@ -206,10 +206,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 Long unitId = (Long) unitCreateResult.get("unitId");
                 unitLevelOperationRecord.setUnitId(unitId);
                 unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                videoCnt -- ;
+                videoCnt--;
                 JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
-                createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(),strategy,strategyUuid);
-                if(videoCnt<=0){
+                createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid);
+                if (videoCnt <= 0) {
                     return 0L;
                 }
             }
@@ -234,8 +234,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         //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 = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + createType.toString());
+        Long timeEnd = KuaishouCreativeMatTypeEnum.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);
@@ -258,11 +258,11 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         strategy.setClickTrackUrl(appInfo.getTrackUrl());
                         strategy.setImpressionUrl(appInfo.getTrackUrl());
                     }
-                    String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString()+createType.toString());
+                    String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
                     replaceString = appInfo.getAppVersion() + "-" + replaceString;
                     //1:查询可用素材
-                    List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType,videoCnt);
-                    if (null == allVideos||allVideos.isEmpty()) {
+                    List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType, videoCnt);
+                    if (null == allVideos || allVideos.isEmpty()) {
                         return;
                     }
                     //判定创意创建是否超限
@@ -271,20 +271,20 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         log.info("该账户创意创建已超限=>accountId:{}", accountId);
                         return;
                     }
-                    Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN",createType,appInfo,strategyUuid);
+                    Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo, strategyUuid);
 
                     //创建组+创意
-                    List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos,5);
+                    List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
                     for (int j = 1; j < splitVideos.size() + 1; j++) {
                         //创建组
                         String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
-                        String unitName = getName(strategy.getGroupName(),strategy,createType,appInfo,timestamp,null);
+                        String unitName = getName(strategy.getGroupName(), strategy, createType, appInfo, timestamp, null);
                         JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
                         Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                         Integer unitCode = (Integer) unitCreateResult.get("code");
                         String unitMessage = (String) unitCreateResult.get("message");
                         AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
-                        BeanUtils.copyProperties(strategy,unitLevelOperationRecord);
+                        BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
                         unitLevelOperationRecord.setGroupName(unitName);
                         unitLevelOperationRecord.setCreateTime(new Date());
                         unitLevelOperationRecord.setStatus(unitCode);
@@ -300,32 +300,32 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         unitLevelOperationRecord.setUnitId(unitId);
                         unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                         JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j);
-                        createProgramCreative(token, creativeParams,strategy);
+                        createProgramCreative(token, creativeParams, strategy);
                     }
                 }
             }
         } else {
-            String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString()+createType.toString());
+            String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
             //单一应用
-            List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, null, createType,videoCnt);
+            List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
             if (null == allVideos) {
                 return;
             }
 
-            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY",createType,null,strategyUuid);
+            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, null, strategyUuid);
             if (null == newCampaignId) {
                 return;
             }
 
             //创意
-            List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos,5);
+            List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
             for (int j = 1; j < splitVideos.size() + 1; j++) {
                 //创建组
                 String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
-                String unitName = getName(strategy.getGroupName(),strategy,createType,null,timestamp,null);
+                String unitName = getName(strategy.getGroupName(), strategy, createType, null, timestamp, null);
                 String appIdString = strategy.getAppIdArray();
                 Long appId = null;
-                if(!Check.isNull(appIdString)&&!Check.isNull(JSON.parseArray(appIdString))){
+                if (!Check.isNull(appIdString) && !Check.isNull(JSON.parseArray(appIdString))) {
                     appId = JSON.parseArray(appIdString).getLong(0);
                 }
                 JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
@@ -333,7 +333,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 Integer unitCode = (Integer) unitCreateResult.get("code");
                 String unitMessage = (String) unitCreateResult.get("message");
                 AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
-                BeanUtils.copyProperties(strategy,unitLevelOperationRecord);
+                BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
                 unitLevelOperationRecord.setGroupName(unitName);
                 unitLevelOperationRecord.setCreateTime(new Date());
                 unitLevelOperationRecord.setStatus(unitCode);
@@ -349,51 +349,72 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 unitLevelOperationRecord.setUnitId(unitId);
                 unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                 JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j);
-                createProgramCreative(token, creativeParams,strategy);
+                createProgramCreative(token, creativeParams, strategy);
             }
         }
     }
 
     @Override
-    public void customCreativeSupplement(AiKuaishouAdvertiserStrategy strategy,Integer hour) throws ParseException {
-        Long unitNum = strategy.getCustomUnitCnt()*hour/20;
-        log.info("{}当前时间内需要创建组总数:{}",strategy.getAccountId(),unitNum);
+    public void customCreativeSupplement(AiKuaishouAdvertiserStrategy strategy, Integer hour) throws ParseException {
+
+        Long customUnitCnt = strategy.getCustomUnitCnt();
+        if (Check.isNull(customUnitCnt)) {
+            Integer imageCnt = strategy.getImageCnt();
+            if (imageCnt <= 1) {
+                customUnitCnt = 600L;
+            } else {
+                customUnitCnt = 2000L / imageCnt;
+            }
+
+        }
+
+        Long unitNum = customUnitCnt * hour / 20;
+        log.info("{}当前时间内需要创建组总数:{}", strategy.getAccountId(), unitNum);
         //查询当前账户创建自定义类型组数量
         int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId());
-        log.info("{}截止目前创建组总数:{}",strategy.getAccountId(),unitCreateCnt);
-        long remindCnt = unitNum-unitCreateCnt;
-        if(remindCnt>=1){
-            log.info("{}组创建不足,剩余需要创建个数{},使用历史遗漏素材创建",strategy.getAccountId(),remindCnt);
+        log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
+        long remindCnt = unitNum - unitCreateCnt;
+        if (remindCnt >= 1) {
+            log.info("{}组创建不足,剩余需要创建个数{},使用历史遗漏素材创建", strategy.getAccountId(), remindCnt);
             //优先创建历史遗漏素材
-            remindCnt = this.autoCreateCreative(strategy,3,remindCnt);
+            remindCnt = this.autoCreateCreative(strategy, 3, remindCnt);
         }
-        if(remindCnt>=1){
-            log.info("{}组创建不足,剩余需要创建个数{},使用高质量素材创建",strategy.getAccountId(),remindCnt);
+        if (remindCnt >= 1) {
+            log.info("{}组创建不足,剩余需要创建个数{},使用高质量素材创建", strategy.getAccountId(), remindCnt);
             //高质量素材
-            remindCnt = this.autoCreateCreative(strategy,2,remindCnt);
+            remindCnt = this.autoCreateCreative(strategy, 2, remindCnt);
         }
-        if(remindCnt>=1){
+        if (remindCnt >= 1) {
             //历史打捞素材
-            log.info("{}组创建不足,剩余需要创建个数{},使用历史打捞素材创建",strategy.getAccountId(),remindCnt);
-            this.autoCreateCreative(strategy,4,remindCnt);
+            log.info("{}组创建不足,剩余需要创建个数{},使用历史打捞素材创建", strategy.getAccountId(), remindCnt);
+            this.autoCreateCreative(strategy, 4, remindCnt);
         }
     }
 
     @Override
     public void customCreativeLimit(AiKuaishouAdvertiserStrategy strategy) {
         Long unitNum = strategy.getCustomUnitCnt();
-        log.info("{}当天可创建组总数:{}",strategy.getAccountId(),unitNum);
+        if (Check.isNull(unitNum)) {
+            Integer imageCnt = strategy.getImageCnt();
+            if (imageCnt <= 1) {
+                unitNum = 600L;
+            } else {
+                unitNum = 2000L / imageCnt;
+            }
+        }
+        log.info("{}当天可创建组总数:{}", strategy.getAccountId(), unitNum);
         //查询当前账户创建自定义类型组数量
         int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId());
-        log.info("{}截止目前创建组总数:{}",strategy.getAccountId(),unitCreateCnt);
-        long remindCnt = unitNum-unitCreateCnt;
-        if(remindCnt>=1){
-            log.info("{}组创建不足,剩余需要创建个数{},开始上新素材创建",strategy.getAccountId(),remindCnt);
-            this.autoCreateCreative(strategy,1,remindCnt);
+        log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
+        long remindCnt = unitNum - unitCreateCnt;
+        if (remindCnt >= 1) {
+            log.info("{}组创建不足,剩余需要创建个数{},开始上新素材创建", strategy.getAccountId(), remindCnt);
+            this.autoCreateCreative(strategy, 1, remindCnt);
         }
     }
 
-    private void createProgramCreative(CtopOauthToken token, JSONObject creativeParams,AiKuaishouAdvertiserStrategy strategy) {
+
+    private void createProgramCreative(CtopOauthToken token, JSONObject creativeParams, AiKuaishouAdvertiserStrategy strategy) {
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", "application/json");
         headers.put("Access-Token", token.getAccessToken());
@@ -463,7 +484,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         JSONArray captions = new JSONArray();
         captions.add(strategy.getDescription());
-        programJson.put("captions",captions);
+        programJson.put("captions", captions);
         if (!Check.isNull(strategy.getCreativeCategory())) {
             programJson.put("creative_category", strategy.getCreativeCategory());
             programJson.put("creative_tag", JSON.parseArray(strategy.getCreativeTag()));
@@ -472,21 +493,33 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
     }
 
     private List<KuaiShouVideoGet> getNewVideoListByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo) {
-        if(null == appInfo){
-            return videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), null, null);
-        }else{
+        if (null == appInfo) {
+            if (Check.isNull(strategy.getMaterialKeyword())) { // 素材名称为空 不需要标注特殊素材
+                return videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), null, null);
+            } else {//  tt语音特殊素材查询
+                return videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), strategy.getMaterialKeyword(), null);
+            }
+        } else {
             //查询通用素材
-            List<KuaiShouVideoGet> generalVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), "all", null);
-            //2:查询特定素材
-            List<KuaiShouVideoGet> customVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), appInfo.getAppVersion(), null);
+            List<KuaiShouVideoGet> generalVideos = new ArrayList<>();
+            List<KuaiShouVideoGet> customVideos = new ArrayList<>();
+
+            if (Check.isNull(strategy.getMaterialKeyword())) {
+                generalVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), "all", null);
+                //2:查询特定素材
+                customVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), appInfo.getAppVersion(), null);
+            } else { //  tt语音特殊素材查询
+                generalVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), strategy.getMaterialKeyword(), null);
+
+            }
             if (Check.isNull(generalVideos) && Check.isNull(customVideos)) {
-            log.info("账户:{},appId({}){}到{}这段时间没有上新素材", strategy.getAccountId(), appInfo.getAppId(), startTime, endTime);
+                log.info("账户:{},appId({}){}到{}这段时间没有上新素材", strategy.getAccountId(), appInfo.getAppId(), startTime, endTime);
                 return new ArrayList<>();
             }
             //合并
-            if (null == generalVideos||generalVideos.isEmpty()) {
+            if (null == generalVideos || generalVideos.isEmpty()) {
                 return customVideos;
-            } else if (null == customVideos||customVideos.isEmpty()) {
+            } else if (null == customVideos || customVideos.isEmpty()) {
                 return generalVideos;
             } else {
                 generalVideos.addAll(customVideos);
@@ -495,27 +528,37 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
     }
 
-    private List<KuaiShouVideoGet> getRelateZeroVideoList(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo,Integer relativeCnt,Long videoCnt) {
+    private List<KuaiShouVideoGet> getRelateZeroVideoList(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo, Integer relativeCnt, Long videoCnt) {
         Integer channelType = null;
         if (null != strategy.getChannelType() && strategy.getChannelType() != 2) {
             channelType = strategy.getChannelType();
         }
-        String appVersion  = null;
-        if(null!=appInfo&&null!=appInfo.getAppVersion()){
-            appVersion = appInfo.getAppVersion();
+        String appVersion = null;
+        if (Check.isNull(strategy.getMaterialKeyword())) {
+            if (null != appInfo && null != appInfo.getAppVersion()) {
+                appVersion = appInfo.getAppVersion();
+            }
+        } else { //  tt语音特殊素材查询
+            appVersion = strategy.getMaterialKeyword();
         }
-        return videoGetService.getZeroVideoByParams(strategy.getAccountId(), startTime, endTime, videoCnt, appVersion, channelType,relativeCnt);
+
+        return videoGetService.getZeroVideoByParams(strategy.getAccountId(), startTime, endTime, videoCnt, appVersion, channelType, relativeCnt);
     }
 
-    private List<KuaiShouVideoGet> getHistoryTopVideoListByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo,Long videoCnt) {
+    private List<KuaiShouVideoGet> getHistoryTopVideoListByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo, Long videoCnt) {
         Integer channelType = null;
         if (null != strategy.getChannelType() && strategy.getChannelType() != 2) {
             channelType = strategy.getChannelType();
         }
-        String appVersion  = null;
-        if(null!=appInfo&&null!=appInfo.getAppVersion()){
-            appVersion = appInfo.getAppVersion();
+        String appVersion = null;
+        if (Check.isNull(strategy.getMaterialKeyword())) {
+            if (null != appInfo && null != appInfo.getAppVersion()) {
+                appVersion = appInfo.getAppVersion();
+            }
+        } else { //  tt语音 特殊素材查询
+            appVersion = strategy.getMaterialKeyword();
         }
+
         return videoGetService.getHistoryTopVideoByParams(strategy.getAccountId(), startTime, endTime, videoCnt, appVersion, channelType);
     }
 
@@ -527,19 +570,19 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
      * @param startTime  开始时间
      * @param endTime    结束时间
      */
-    private List<KuaiShouVideoGet> getVideosByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo, Integer createType,Long videoCnt) {
+    private List<KuaiShouVideoGet> getVideosByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo, Integer createType, Long videoCnt) {
         if (createType == 1) {
             return getNewVideoListByParams(strategy, startTime, endTime, appInfo);
         } else if (createType == 2) {
-            return getHistoryTopVideoListByParams(strategy, startTime, endTime, appInfo,videoCnt);
-        } else if(createType==3){
-            return getRelateZeroVideoList(strategy, startTime, endTime, appInfo,0,videoCnt);
-        }else{
-            return getRelateZeroVideoList(strategy, startTime, endTime, appInfo,20,videoCnt);
+            return getHistoryTopVideoListByParams(strategy, startTime, endTime, appInfo, videoCnt);
+        } else if (createType == 3) {
+            return getRelateZeroVideoList(strategy, startTime, endTime, appInfo, 0, videoCnt);
+        } else {  //  type == 4 历史素材打捞
+            return getRelateZeroVideoList(strategy, startTime, endTime, appInfo, 20, videoCnt);
         }
     }
 
-    private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType,Integer createType,AiKuaiShouAppInfo appInfo,String uuid) {
+    private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType, Integer createType, AiKuaiShouAppInfo appInfo, String uuid) {
         JSONArray campaignList;
         String timestamp = null;
         if ("ALL_CAMPAIGN".equals(checkType)) {
@@ -560,16 +603,16 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         // 不存在“上新”计划,则创建一个计划
         JSONObject campaignParams = new JSONObject();
         campaignParams.put("advertiser_id", token.getAccountId());
-        String campaignName = getName(strategy.getCampaignName(),strategy,createType,appInfo,timestamp,null);
+        String campaignName = getName(strategy.getCampaignName(), strategy, createType, appInfo, timestamp, null);
         campaignParams.put("campaign_name", campaignName);
         campaignParams.put("type", strategy.getCampaignType());
-        if(null!=strategy.getCampaignDayBudget()&&strategy.getCampaignDayBudget()!=0){
+        if (null != strategy.getCampaignDayBudget() && strategy.getCampaignDayBudget() != 0) {
             campaignParams.put("day_budget", strategy.getCampaignDayBudget());
         }
         Map<String, Object> campaignCreateResult = kuaishouInterfaceService.campaignCreate(token.getAccessToken(), token.getAccountId(), campaignParams);
         Integer code = (Integer) campaignCreateResult.get("code");
         String message = (String) campaignCreateResult.get("message");
-        AiKuaishouCampaignLevelOperationRecord record = new AiKuaishouCampaignLevelOperationRecord(strategy,null,code,message);
+        AiKuaishouCampaignLevelOperationRecord record = new AiKuaishouCampaignLevelOperationRecord(strategy, null, code, message);
         record.setAiStrategyUuid(uuid);
         record.setCampaignName(campaignName);
         if (code != 0) {
@@ -601,10 +644,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             unitParams.put("use_app_market", strategy.getUseAppMarket());
         }
         //组单日预算
-        if(null!=strategy.getUnitDayBudget()&&strategy.getUnitDayBudget()!=0){
-            unitParams.put("day_budget",strategy.getUnitDayBudget());
-        }else{
-            unitParams.put("day_budget",0);
+        if (null != strategy.getUnitDayBudget() && strategy.getUnitDayBudget() != 0) {
+            unitParams.put("day_budget", strategy.getUnitDayBudget());
+        } else {
+            unitParams.put("day_budget", 0);
         }
         //应用商店列表
         if (null != strategy.getAppStore() && !"".equals(strategy.getAppStore())) {
@@ -643,10 +686,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         Integer sceneId = null;
         String scenceIdString = strategy.getSceneId();
         if (!Check.isNull(scenceIdString) && !Check.isNull(JSON.parseArray(scenceIdString))) {
-            JSONArray scenceArray =  JSON.parseArray(scenceIdString);
+            JSONArray scenceArray = JSON.parseArray(scenceIdString);
             sceneId = scenceArray.getInteger(0);
             //资源位置
-            if(unitType == 7){
+            if (unitType == 7) {
                 //程序化
                 scenceArray = cleanPramgramErrorScence(scenceArray);
             }
@@ -656,8 +699,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         //投放开始时间
         if (!Check.isNull(strategy.getBeginTime())) {
             unitParams.put("begin_time", strategy.getBeginTime());
-        }else {
-            unitParams.put("begin_time",DateUtils.formatDate());
+        } else {
+            unitParams.put("begin_time", DateUtils.formatDate());
         }
         //投放结束时间
         if (!Check.isNull(strategy.getEndTime())) {
@@ -750,7 +793,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         if (null != strategy.getAgesRange() && !"".equals(strategy.getAgesRange())) {
             JSONArray agesRange = JSON.parseArray(strategy.getAgesRange());
-            if(null!=agesRange&&!agesRange.isEmpty()){
+            if (null != agesRange && !agesRange.isEmpty()) {
                 targetJsonObject.put("ages_range", JSON.parseArray(strategy.getAgesRange()));
             }
         }
@@ -799,18 +842,18 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             targetJsonObject.put("intelli_extend", intelliExtend);
         }
         unitParams.put("target", targetJsonObject);
-        log.info("广告组创建参数:{}",unitParams.toJSONString());
+        log.info("广告组创建参数:{}", unitParams.toJSONString());
         return unitParams;
     }
 
     private JSONArray cleanPramgramErrorScence(JSONArray scenceArray) {
         JSONArray result = new JSONArray();
-        if(null==scenceArray||scenceArray.isEmpty()){
+        if (null == scenceArray || scenceArray.isEmpty()) {
             return result;
         }
-        for (int i=0;i<scenceArray.size();i++){
-            Integer senceId =scenceArray.getInteger(i);
-            if(senceId!=5&&senceId!=3){
+        for (int i = 0; i < scenceArray.size(); i++) {
+            Integer senceId = scenceArray.getInteger(i);
+            if (senceId != 5 && senceId != 3) {
                 result.add(senceId);
             }
         }
@@ -963,16 +1006,16 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 
     private void createCreativeByImage(List<MaterialCutFrame> cutFrameList, CtopOauthToken token, JSONObject creativeParams,
                                        Long campaignId, Long unitId, KuaiShouVideoGet videoItem,
-                                       int imageNumber,AiKuaishouAdvertiserStrategy strategy,String uuid) {
+                                       int imageNumber, AiKuaishouAdvertiserStrategy strategy, String uuid) {
         if ((null != cutFrameList && !cutFrameList.isEmpty())) {
             for (int i = 0; i < cutFrameList.size(); i++) {
                 String imageCode = cutFrameList.get(i).getSignature();
                 String imageUrl = cutFrameList.get(i).getUrl();
                 String imageToken = getImageToken(imageUrl, imageCode, token.getAccountId(), token.getAccessToken());
                 creativeParams.put("image_token", imageToken);
-                createCreative(token, creativeParams, campaignId, unitId, i+1, videoItem,strategy,uuid);
-                imageNumber --;
-                if (imageNumber<=0) {
+                createCreative(token, creativeParams, campaignId, unitId, i + 1, videoItem, strategy, uuid);
+                imageNumber--;
+                if (imageNumber <= 0) {
                     break;
                 }
             }
@@ -1044,14 +1087,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 
 
     private void createCreative(CtopOauthToken token, JSONObject creativeParams, Long campaignId, Long unitId,
-                                int creativeCnt, KuaiShouVideoGet videoGet,AiKuaishouAdvertiserStrategy strategy,String uuid) {
-        String creativeName = "自定义创意_"+creativeCnt;
+                                int creativeCnt, KuaiShouVideoGet videoGet, AiKuaishouAdvertiserStrategy strategy, String uuid) {
+        String creativeName = "自定义创意_" + creativeCnt;
         creativeParams.put("creative_name", creativeName);
         Map<String, Object> creativeCreateResult = kuaishouInterfaceService.creativeCreate(token.getAccessToken(), token.getAccountId(), creativeParams, 1);
         Integer creativeCode = (Integer) creativeCreateResult.get("code");
         String creativeMessage = (String) creativeCreateResult.get("message");
-        AiKuaishouCreativeLevelOperationRecord record  = new AiKuaishouCreativeLevelOperationRecord();
-        BeanUtils.copyProperties(strategy,record);
+        AiKuaishouCreativeLevelOperationRecord record = new AiKuaishouCreativeLevelOperationRecord();
+        BeanUtils.copyProperties(strategy, record);
         record.setCreativeName(creativeName);
         record.setStatus(creativeCode);
         record.setMessage(creativeMessage);
@@ -1068,68 +1111,68 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
     }
 
     /**
-     * @param wildcard  计划名称/组名称
-     * @param strategy  账户id
+     * @param wildcard 计划名称/组名称
+     * @param strategy 账户id
      * @return
      */
-    private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy,Integer createType,AiKuaiShouAppInfo appInfo,String timestamp,Integer cnt) {
-        if(wildcard.contains("{{应用包名}}")){
+    private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy, Integer createType, AiKuaiShouAppInfo appInfo, String timestamp, Integer cnt) {
+        if (wildcard.contains("{{应用包名}}")) {
             String appName = "";
-            if(null!=appInfo){
+            if (null != appInfo) {
                 appName = appInfo.getAppName();
             }
-            wildcard = wildcard.replace("{{应用包名}}",appName);
+            wildcard = wildcard.replace("{{应用包名}}", appName);
         }
-        if(wildcard.contains("{{创意制作方式}}")){
+        if (wildcard.contains("{{创意制作方式}}")) {
 //            String creatype = KuaishouCreativeCreateTypeEnum.getNameByType(strategy.getOpenProgramCreate());
 //            wildcard = wildcard.replace("{{创意制作方式}}",creatype);
-            if(strategy.getUnitType()  ==  4){
-                wildcard = wildcard.replace("{{创意制作方式}}","自定义");
-            }else if(strategy.getUnitType()  ==  7){
-                wildcard = wildcard.replace("{{创意制作方式}}","程序化");
+            if (strategy.getUnitType() == 4) {
+                wildcard = wildcard.replace("{{创意制作方式}}", "自定义");
+            } else if (strategy.getUnitType() == 7) {
+                wildcard = wildcard.replace("{{创意制作方式}}", "程序化");
             }
         }
-        if(wildcard.contains("{{广告位置}}")){
+        if (wildcard.contains("{{广告位置}}")) {
             String adsence = getAdSenceByParams(strategy.getSceneId());
-            wildcard = wildcard.replace("{{广告位置}}",adsence);
+            wildcard = wildcard.replace("{{广告位置}}", adsence);
         }
-        if(!wildcard.contains("{{自定义}}")){
-            wildcard = wildcard+"{{自定义}}";
+        if (!wildcard.contains("{{自定义}}")) {
+            wildcard = wildcard + "{{自定义}}";
         }
-        String targetName = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString()+createType.toString());
-        if(null!=appInfo){
-            targetName = appInfo.getAppVersion()+"-"+targetName;
+        String targetName = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
+        if (null != appInfo) {
+            targetName = appInfo.getAppVersion() + "-" + targetName;
         }
-        wildcard = wildcard.replace("{{自定义}}",targetName);
+        wildcard = wildcard.replace("{{自定义}}", targetName);
 
-        if(null!=timestamp&&!"".equals(timestamp.trim())){
-            wildcard = wildcard+"-"+timestamp;
+        if (null != timestamp && !"".equals(timestamp.trim())) {
+            wildcard = wildcard + "-" + timestamp;
         }
-        if(null!=cnt){
-            wildcard = wildcard+"-"+cnt.toString();
+        if (null != cnt) {
+            wildcard = wildcard + "-" + cnt.toString();
         }
-        wildcard = wildcard.replace("--","-");
-        if(wildcard.startsWith("-")){
-            wildcard = wildcard.substring(1,wildcard.length());
+        wildcard = wildcard.replace("--", "-");
+        if (wildcard.startsWith("-")) {
+            wildcard = wildcard.substring(1, wildcard.length());
         }
-        if(wildcard.endsWith("-")){
-            wildcard = wildcard.substring(0,wildcard.length()-1);
+        if (wildcard.endsWith("-")) {
+            wildcard = wildcard.substring(0, wildcard.length() - 1);
         }
         return wildcard;
     }
 
     private String getAdSenceByParams(String sceneIdString) {
         String adsence = "";
-        if(null==sceneIdString||"".equals(sceneIdString)){
+        if (null == sceneIdString || "".equals(sceneIdString)) {
             return adsence;
         }
         JSONArray sceneIdArray = JSON.parseArray(sceneIdString);
-        if(null == sceneIdArray||sceneIdArray.isEmpty()){
+        if (null == sceneIdArray || sceneIdArray.isEmpty()) {
             return adsence;
         }
-        for (int i=0;i < sceneIdArray.size();i++){
-            adsence += KuaishouCreativeAdsenceTypeEnum.getNameByType(sceneIdArray.getInteger(i))+",";
+        for (int i = 0; i < sceneIdArray.size(); i++) {
+            adsence += KuaishouCreativeAdsenceTypeEnum.getNameByType(sceneIdArray.getInteger(i)) + ",";
         }
-        return adsence.substring(0,adsence.length()-1);
+        return adsence.substring(0, adsence.length() - 1);
     }
 }