瀏覽代碼

组;计划;添加通配符-序号

yangzian 4 年之前
父節點
當前提交
baf4ad2fc9

+ 14 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/AiBytedanceAdvertiserStrategyServiceImpl.java

@@ -28,6 +28,7 @@ import org.jeecg.modules.bytedance.common.entity.MaterialInfo;
 import org.jeecg.modules.bytedance.common.entity.UserAllocation;
 import org.jeecg.modules.bytedance.common.service.*;
 import org.jeecg.modules.bytedance.common.utils.Check;
+import org.jeecg.modules.bytedance.common.utils.GetCampaignNum;
 import org.jeecg.modules.bytedance.common.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -189,6 +190,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                     adDplinkInfo.setDpLinkIndex(adDplinkInfo.getDpLinkIndex()+1);
                 }
                 dpIndex = adDplinkInfo.getDpLinkIndex();
+                // 已创建计划 > 账户配置结束下标
                 if(dpIndex>strategy.getDpLinkEndIndex()){
                     log.info("此账户策略创建结束=>账户id:{};策略id:{}", token.getAccountId(),strategy.getId());
                     return 0L;
@@ -889,6 +891,10 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 adName = adName.replace("{{素材名称}}",info.getMaterialName());
             }
         }
+        if(adName.contains("{{序号}}")){
+            int i = adDplinkInfoService.getDpLinkInfoCount(strategy.getAccountId());
+            adName = adName.replace("{{序号}}",String.valueOf(i+1));
+        }
 
         adName = adName.replace("--","-");
         if(adName.startsWith("-")){
@@ -952,6 +958,14 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
             result = result + "-" + date;
         }
 
+        if(result.contains("{{序号}}")){
+            //查询当天已有计划数量
+            int i = adDplinkInfoService.getDpLinkInfoCount(strategy.getAccountId());
+            Long num = GetCampaignNum.getCampaignNameNum(strategy.getCampaignCnt(),strategy.getCampaignAdCnt(),i);
+            result = result.replace("{{序号}}",String.valueOf(num));
+        }
+
+
         result = result.replace("--","-");
         if(result.startsWith("-")){
             result = result.substring(1);

+ 39 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/utils/GetCampaignNum.java

@@ -0,0 +1,39 @@
+package org.jeecg.modules.bytedance.common.utils;
+
+/**
+ * Administrator
+ * 2021/6/3
+ **/
+public class GetCampaignNum {
+
+
+    /**
+     *
+     * @param campaignCnt 组数量
+     * @param campaignAdCnt 每个组最大创建计划数
+     * @param countNum 当天已创建条数
+     * @return
+     */
+    public static Long getCampaignNameNum(int campaignCnt,Long campaignAdCnt, int countNum){
+/*
+        countNum = 61;
+        campaignAdCnt = 10L;
+        campaignCnt = 1;*/
+
+        Long zu = countNum / campaignAdCnt;
+        Long yu = countNum % campaignAdCnt;
+        System.out.println("余---"+yu);
+        // 不能整除 有余数 则 组 = 商 + 1
+        // 整除 组 = 商
+        Long count = yu != 0 ? zu.intValue()+1 : zu;
+       // 账户配置中的组数量 < 当前 组序号
+        if (count.intValue() < campaignCnt){
+            System.out.println("序号----------"+count);
+        }else {
+            System.out.println("序号-超过了最大值-----"+count);
+        }
+        return count;
+    }
+
+
+}