Explorar o código

自动投放调整

yumeng %!s(int64=4) %!d(string=hai) anos
pai
achega
65eef82274

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

@@ -168,31 +168,31 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 if (Check.isNull(allVideos)) {
                 if (Check.isNull(allVideos)) {
                     return videoCnt;
                     return videoCnt;
                 }
                 }
-                for (int i = 0; i < appIdArray.size(); i++) {
-                    Long appId = appIdArray.getLong(i);
-                    if (Check.isNull(appId)) {
-                        continue;
-                    }
-                    KuaiShouAppMultipleBids multipleBids = kuaiShouAppMultipleBidsService.getInfoByAccountAndAppId(accountId, appId);
-                    if (Check.isNull(multipleBids)) {
+                for (KuaiShouVideoGet videoItem : allVideos) {
+                    // 获取视频封面数据
+                    List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
+                    if ((null == cutFrameList || cutFrameList.isEmpty())) {
+                        log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
                         continue;
                         continue;
                     }
                     }
-                    if (!Check.isNull(multipleBids.getTrackUrl())) {
-                        strategy.setClickTrackUrl(multipleBids.getTrackUrl());
-                    }
-                    Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
-                    for (KuaiShouVideoGet videoItem : allVideos) {
+                    for (int i = 0; i < appIdArray.size(); i++) {
+                        Long appId = appIdArray.getLong(i);
+                        if (Check.isNull(appId)) {
+                            continue;
+                        }
+                        KuaiShouAppMultipleBids multipleBids = kuaiShouAppMultipleBidsService.getInfoByAccountAndAppId(accountId, appId);
+                        if (Check.isNull(multipleBids)) {
+                            continue;
+                        }
+                        if (!Check.isNull(multipleBids.getTrackUrl())) {
+                            strategy.setClickTrackUrl(multipleBids.getTrackUrl());
+                        }
                         KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
                         KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
                         if (null != overrunInfo) {
                         if (null != overrunInfo) {
                             log.info("该账户创意创建已超限=>accountId:{}", accountId);
                             log.info("该账户创意创建已超限=>accountId:{}", accountId);
                             return 0L;
                             return 0L;
                         }
                         }
-                        // 获取视频封面数据
-                        List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
-                        if ((null == cutFrameList || cutFrameList.isEmpty())) {
-                            log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
-                            continue;
-                        }
+                        Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
                         //开始创建组+创意
                         //开始创建组+创意
                         String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId);
                         String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId);
                         JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
                         JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
@@ -233,9 +233,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         }
                         }
                     }
                     }
                 }
                 }
-
             }
             }
-
         } else {
         } else {
             //单一应用
             //单一应用
             String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
             String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
@@ -302,7 +300,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         return videoCnt;
         return videoCnt;
     }
     }
 
 
-
     /**
     /**
      * 创建程序化创意
      * 创建程序化创意
      *
      *
@@ -376,7 +373,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                             return;
                             return;
                         }
                         }
                         Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo.getAppId(), strategyUuid);
                         Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo.getAppId(), 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++) {
                         for (int j = 1; j < splitVideos.size() + 1; j++) {
@@ -420,21 +416,9 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 if (Check.isNull(allVideos)) {
                 if (Check.isNull(allVideos)) {
                     return;
                     return;
                 }
                 }
-                for (int i = 0; i < appIdArray.size(); i++) {
-                    Long appId = appIdArray.getLong(i);
-                    if (Check.isNull(appId)) {
-                        continue;
-                    }
-                    KuaiShouAppMultipleBids multipleBids = kuaiShouAppMultipleBidsService.getInfoByAccountAndAppId(accountId, appId);
-                    if (Check.isNull(multipleBids)) {
-                        continue;
-                    }
-                    if (!Check.isNull(multipleBids.getTrackUrl())) {
-                        strategy.setClickTrackUrl(multipleBids.getTrackUrl());
-                    }
-                    Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
-                    List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
-                    for (int j = 1; j < splitVideos.size() + 1; j++) {
+                List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
+                for (int j = 1; j < splitVideos.size() + 1; j++) {
+                    for (int i = 0; i < appIdArray.size(); i++) {
                         Object redisObj = redisUtil.get(key);
                         Object redisObj = redisUtil.get(key);
                         if (!Check.isNull(redisObj)) {
                         if (!Check.isNull(redisObj)) {
                             Integer value = (Integer) redisObj;
                             Integer value = (Integer) redisObj;
@@ -443,6 +427,18 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                                 return;
                                 return;
                             }
                             }
                         }
                         }
+                        Long appId = appIdArray.getLong(i);
+                        if (Check.isNull(appId)) {
+                            continue;
+                        }
+                        KuaiShouAppMultipleBids multipleBids = kuaiShouAppMultipleBidsService.getInfoByAccountAndAppId(accountId, appId);
+                        if (Check.isNull(multipleBids)) {
+                            continue;
+                        }
+                        if (!Check.isNull(multipleBids.getTrackUrl())) {
+                            strategy.setClickTrackUrl(multipleBids.getTrackUrl());
+                        }
+                        Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
                         //创建组
                         //创建组
                         String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId);
                         String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId);
                         JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
                         JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
@@ -483,7 +479,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             if (null == allVideos) {
             if (null == allVideos) {
                 return;
                 return;
             }
             }
-
             Long appId = null;
             Long appId = null;
             String appIdString = strategy.getAppIdArray();
             String appIdString = strategy.getAppIdArray();
             if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
             if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {