|
@@ -113,20 +113,74 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
@Autowired
|
|
|
private IKuaiShouCampaignService campaignService;
|
|
|
|
|
|
+ @Override
|
|
|
+ public void createCustomUpNewCreative(AiKuaishouAccountAutoStrategy strategy) {
|
|
|
+ Long accountId = strategy.getAccountId();
|
|
|
+ //==========账户{}执行自定义上新自动创建==========start==========
|
|
|
+ String date = DateUtils.formatDate(new Date());
|
|
|
+ //当前需要创建广告组数量
|
|
|
+ int unitNum = strategy.getCustomPlanCnt() * strategy.getCustomUnitCnt();
|
|
|
+ //获取自定义已创建广告组数量
|
|
|
+ Integer customUnitCnt = (Integer) redisUtil.get(date + "_auto_custom_cnt_" + accountId);
|
|
|
+ if (Check.isNull(customUnitCnt)) {
|
|
|
+ if (unitNum > 600) {
|
|
|
+ unitNum = 600;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ unitNum = unitNum - customUnitCnt;
|
|
|
+ }
|
|
|
+ if (unitNum == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ log.info("----- (自定义上新)账户:{},已建组数:{};剩余待建组数:{}", strategy.getAccountId(), customUnitCnt, unitNum);
|
|
|
+ Integer hours = 0;
|
|
|
+ try {
|
|
|
+ //当前剩余小时数 (2~21)
|
|
|
+ hours = 22 - DateUtils.getHour(DateUtils.formatDateTime());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ JSONObject cnt = getCnt(strategy.getSourceMaterial(), unitNum, hours);
|
|
|
+ Integer upNewCnt = cnt.getInteger("upNewCnt");
|
|
|
+ if (upNewCnt == 0) {
|
|
|
+ return;
|
|
|
+ } else if (upNewCnt >= 3) {
|
|
|
+ //上新每小时执行3次
|
|
|
+ upNewCnt = upNewCnt / 3;
|
|
|
+ } else {
|
|
|
+ upNewCnt = 1;
|
|
|
+ }
|
|
|
+ if (upNewCnt > 0) {
|
|
|
+ // 1上新
|
|
|
+ log.info("----- (自定义上新)账户:{},本次可建组数:{}", strategy.getAccountId(), upNewCnt);
|
|
|
+ unitNum = this.autoCreateCreative(strategy, 1, upNewCnt);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
- * 创建自定义广告创意
|
|
|
+ * 创建自定义高质量、打捞、遗漏广告创意
|
|
|
*/
|
|
|
@Override
|
|
|
public void createCustomCreative(AiKuaishouAccountAutoStrategy strategy) {
|
|
|
Long accountId = strategy.getAccountId();
|
|
|
- log.info("==========账户{}执行自定义自动创建==========start==========");
|
|
|
-// String date = DateUtils.formatDate(new Date());
|
|
|
-// Integer customUnitCnt = (Integer) redisUtil.get(accountId + date + "_custom_count");
|
|
|
- //获取自定义待创建数量
|
|
|
- Integer customUnitCnt = strategy.getCustomUnitCnt();
|
|
|
- //查询当前账户创建自定义类型组数量
|
|
|
- int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(), 4);
|
|
|
- log.info("--------- 账户{}截止目前创建自定义组总数:{}", strategy.getAccountId(), unitCreateCnt);
|
|
|
+ //==========账户{}执行自定义(高质量、打捞、遗漏)自动创建==========start==========
|
|
|
+ String date = DateUtils.formatDate(new Date());
|
|
|
+ //当前需要创建广告组数量
|
|
|
+ int unitNum = strategy.getCustomPlanCnt() * strategy.getCustomUnitCnt();
|
|
|
+ //获取自定义已创建广告组数量
|
|
|
+ Integer customUnitCnt = (Integer) redisUtil.get(date + "_auto_custom_cnt_" + accountId);
|
|
|
+ if (Check.isNull(customUnitCnt)) {
|
|
|
+ if (unitNum > 600) {
|
|
|
+ unitNum = 600;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ unitNum = unitNum - customUnitCnt;
|
|
|
+ }
|
|
|
+ if (unitNum == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ log.info("----- (自定义)账户:{},已建组数:{};剩余待建组数:{}", strategy.getAccountId(), customUnitCnt, unitNum);
|
|
|
Integer hours = 0;
|
|
|
try {
|
|
|
//当前剩余小时数 (2~21)
|
|
@@ -134,30 +188,35 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
} catch (ParseException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- //计算当前需要创建广告组数量
|
|
|
- int unitNum = customUnitCnt - unitCreateCnt;
|
|
|
+
|
|
|
+ //高质量待建数
|
|
|
+ int highCnt = 0;
|
|
|
+ //遗漏
|
|
|
+ int omitCnt = 0;
|
|
|
+ //打捞
|
|
|
+ int salvageCnt = 0;
|
|
|
+ //1-上新素材,2-高质量素材,3-遗漏素材,4-历史打捞
|
|
|
+ String material = strategy.getSourceMaterial();
|
|
|
if (hours > 0) {
|
|
|
- unitNum = unitNum / hours;
|
|
|
- }
|
|
|
- log.info("--------- 账户{}当前小时需要创建自定义组数:{},剩余可创建总数:{}", strategy.getAccountId(), unitNum, customUnitCnt - unitCreateCnt);
|
|
|
- if (unitNum >= 1) {
|
|
|
- //1上新
|
|
|
- unitNum = this.autoCreateCreative(strategy, 1, unitNum);
|
|
|
+ JSONObject cnt = getCnt(material, unitNum, hours);
|
|
|
+ highCnt = cnt.getInteger("highCnt");
|
|
|
+ omitCnt = cnt.getInteger("omitCnt");
|
|
|
+ salvageCnt = cnt.getInteger("salvageCnt");
|
|
|
}
|
|
|
- if (unitNum >= 1 && "3".contains(strategy.getSourceMaterial())) {
|
|
|
- log.info("{}自定义组创建不足,剩余需要创建个数{},使用高质量素材创建", strategy.getAccountId(), unitNum);
|
|
|
+ if (omitCnt > 0 && material.contains("3")) {
|
|
|
//3历史遗漏
|
|
|
- unitNum = this.autoCreateCreative(strategy, 3, unitNum);
|
|
|
+ log.info("----- (自定义历史遗漏)账户:{},本次可建组数:{}", strategy.getAccountId(), omitCnt);
|
|
|
+ unitNum = this.autoCreateCreative(strategy, 3, omitCnt);
|
|
|
}
|
|
|
- if (unitNum >= 1 && "2".contains(strategy.getSourceMaterial())) {
|
|
|
- log.info("{}自定义组创建不足,剩余需要创建个数{},使用高质量素材创建", strategy.getAccountId(), unitNum);
|
|
|
+ if (highCnt > 0 && material.contains("2")) {
|
|
|
//2高质量素材
|
|
|
- unitNum = this.autoCreateCreative(strategy, 2, unitNum);
|
|
|
+ log.info("----- (自定义高质量)账户:{},本次可建组数:{}", strategy.getAccountId(), highCnt);
|
|
|
+ unitNum = this.autoCreateCreative(strategy, 2, highCnt);
|
|
|
}
|
|
|
- if (unitNum >= 1 && "4".contains(strategy.getSourceMaterial())) {
|
|
|
+ if (salvageCnt > 0 && material.contains("4")) {
|
|
|
//4历史打捞素材
|
|
|
- log.info("{}自定义组创建不足,剩余需要创建个数{},使用历史打捞素材创建", strategy.getAccountId(), unitNum);
|
|
|
- this.autoCreateCreative(strategy, 4, unitNum);
|
|
|
+ log.info("----- (自定义历史打捞)账户:{},本次可建组数:{}", strategy.getAccountId(), salvageCnt);
|
|
|
+ this.autoCreateCreative(strategy, 4, salvageCnt);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -459,12 +518,23 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
@Override
|
|
|
public void createProgramCreative(AiKuaishouAccountAutoStrategy strategy) {
|
|
|
Long accountId = strategy.getAccountId();
|
|
|
- log.info("==========账户{}执行程序化自动创建==========start==========");
|
|
|
- //获取程序化待创建数量
|
|
|
- Integer customUnitCnt = strategy.getCustomUnitCnt();
|
|
|
- //查询当前账户创建程序化类型组数量
|
|
|
- int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(), 7);
|
|
|
- log.info("--------- 账户{}截止目前创建程序化组总数:{}", strategy.getAccountId(), unitCreateCnt);
|
|
|
+ //==========账户{}执行自定义(高质量、打捞、遗漏)自动创建==========start==========
|
|
|
+ String date = DateUtils.formatDate(new Date());
|
|
|
+ //当前需要创建广告组数量
|
|
|
+ int unitNum = strategy.getProgramPlanCnt() * strategy.getProgramUnitCnt();
|
|
|
+ //获取自定义已创建广告组数量
|
|
|
+ Integer programUnitCnt = (Integer) redisUtil.get(date + "_auto_program_cnt_" + accountId);
|
|
|
+ if (Check.isNull(programUnitCnt)) {
|
|
|
+ if (unitNum > 300) {
|
|
|
+ unitNum = 300;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ unitNum = unitNum - programUnitCnt;
|
|
|
+ }
|
|
|
+ if (unitNum == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ log.info("----- (程序化)账户:{},已建组数:{};剩余待建组数:{}", strategy.getAccountId(), programUnitCnt, unitNum);
|
|
|
Integer hours = 0;
|
|
|
try {
|
|
|
//当前剩余小时数 (2~21)
|
|
@@ -472,20 +542,29 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
} catch (ParseException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- //计算当前需要创建广告组数量
|
|
|
- int unitNum = customUnitCnt - unitCreateCnt;
|
|
|
- if (hours > 0) {
|
|
|
- unitNum = unitNum / hours;
|
|
|
+ int highCnt = 0;
|
|
|
+ int upNewCnt = unitNum;
|
|
|
+ String matchType = strategy.getSourceMaterial();
|
|
|
+ //包含高质量,则按照 上新:高质量 = 75%:25% 分配
|
|
|
+ if (matchType.contains("2")) {
|
|
|
+ highCnt = (int) (unitNum * 0.25);
|
|
|
+ upNewCnt = (int) (unitNum * 0.75);
|
|
|
+ }
|
|
|
+ if (hours > upNewCnt) {
|
|
|
+ upNewCnt = 1;
|
|
|
+ } else {
|
|
|
+ highCnt = highCnt / hours;
|
|
|
+ upNewCnt = upNewCnt / hours;
|
|
|
}
|
|
|
- log.info("--------- 账户{}当前小时需要创建程序化组数:{},剩余可创建总数:{}", strategy.getAccountId(), unitNum, customUnitCnt - unitCreateCnt);
|
|
|
- if (unitNum >= 1) {
|
|
|
+ if (upNewCnt > 0) {
|
|
|
//1上新
|
|
|
- unitNum = this.autoCreateProgramCreative(strategy, 1, unitNum);
|
|
|
+ log.info("----- (程序化上新)账户:{},本次可建组数:{}", strategy.getAccountId(), upNewCnt);
|
|
|
+ unitNum = this.autoCreateProgramCreative(strategy, 1, upNewCnt);
|
|
|
}
|
|
|
- if (unitNum >= 1 && "2".contains(strategy.getSourceMaterial())) {
|
|
|
- log.info("{}程序化组创建不足,剩余需要创建个数{},使用高质量素材创建", strategy.getAccountId(), unitNum);
|
|
|
+ if (highCnt > 0 && matchType.contains("2")) {
|
|
|
+ log.info("----- (程序化高质量)账户:{},本次可建组数:{}", strategy.getAccountId(), highCnt);
|
|
|
//2高质量素材
|
|
|
- unitNum = this.autoCreateProgramCreative(strategy, 2, unitNum);
|
|
|
+ unitNum = this.autoCreateProgramCreative(strategy, 2, highCnt);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1704,7 +1783,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
|
|
|
if (!Check.isNull(scenceIdString) && !Check.isNull(JSONArray.parseArray(scenceIdString))) {
|
|
|
JSONArray scenceArray = JSONArray.parseArray(scenceIdString);
|
|
|
- sceneId = scenceArray.getInteger( 0);
|
|
|
+ sceneId = scenceArray.getInteger(0);
|
|
|
unitParams.put("scene_id", scenceArray);
|
|
|
}
|
|
|
Integer campaignType = strategy.getCampaignType();
|
|
@@ -2335,4 +2414,100 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取创建比例
|
|
|
+ */
|
|
|
+ private JSONObject getCnt(String material, int unitNum, int hours) {
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ int upNewCnt = unitNum;
|
|
|
+ //高质量待建数
|
|
|
+ int highCnt = 0;
|
|
|
+ //遗漏
|
|
|
+ int omitCnt = 0;
|
|
|
+ //打捞
|
|
|
+ int salvageCnt = 0;
|
|
|
+
|
|
|
+ //如果当前待建数低于循环次数(hours),则待建数 = 1
|
|
|
+ if (unitNum < hours) {
|
|
|
+ unitNum = 1;
|
|
|
+ }
|
|
|
+ /*素材优先级以及百分比:1上新、2高质量、3遗漏、4打捞
|
|
|
+ *全选的情况:上新(70%):高质量(20%):遗漏(5%):打捞(5%)
|
|
|
+ *部分选择:上新:高质量=75%:25%;上新:遗漏/+打捞=85%:15%
|
|
|
+ *上新:高质量:遗漏/打捞=70%:20%:10% */
|
|
|
+ if (material.contains("2")) {
|
|
|
+ if (material.contains("3") && material.contains("4")) {
|
|
|
+ /*----------全选的情况:上新(70%):高质量(20%):遗漏(5%):打捞(5%)----------*/
|
|
|
+ //上新
|
|
|
+ upNewCnt = getRealCnt(unitNum, hours, 0.7);
|
|
|
+ //高质量
|
|
|
+ highCnt = getRealCnt(unitNum, hours, 0.2);
|
|
|
+ //遗漏
|
|
|
+ omitCnt = getRealCnt(unitNum, hours, 0.05);
|
|
|
+ //打捞
|
|
|
+ salvageCnt = getRealCnt(unitNum, hours, 0.05);
|
|
|
+ } else if (material.contains("3") || material.contains("4")) {
|
|
|
+ /*----------上新:高质量:遗漏/打捞=70%:20%:10% ----------*/
|
|
|
+ //上新
|
|
|
+ upNewCnt = getRealCnt(unitNum, hours, 0.7);
|
|
|
+ //高质量
|
|
|
+ highCnt = getRealCnt(unitNum, hours, 0.2);
|
|
|
+ //遗漏
|
|
|
+ omitCnt = getRealCnt(unitNum, hours, 0.1);
|
|
|
+ //打捞
|
|
|
+ salvageCnt = getRealCnt(unitNum, hours, 0.1);
|
|
|
+ } else {
|
|
|
+ /*----------部分选择:上新:高质量=75%:25%;----------*/
|
|
|
+ //上新
|
|
|
+ upNewCnt = getRealCnt(unitNum, hours, 0.75);
|
|
|
+ //高质量
|
|
|
+ highCnt = getRealCnt(unitNum, hours, 0.25);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (material.contains("3") && material.contains("4")) {
|
|
|
+ /*---------- 上新:遗漏:打捞=80%:10%:10%----------*/
|
|
|
+ //上新
|
|
|
+ upNewCnt = getRealCnt(unitNum, hours, 0.8);
|
|
|
+ //遗漏
|
|
|
+ omitCnt = getRealCnt(unitNum, hours, 0.1);
|
|
|
+ //打捞
|
|
|
+ salvageCnt = getRealCnt(unitNum, hours, 0.1);
|
|
|
+
|
|
|
+ } else if (material.contains("3") || material.contains("4")) {
|
|
|
+ /*---------- 上新:遗漏/+打捞=85%:15%----------*/
|
|
|
+ //上新
|
|
|
+ upNewCnt = getRealCnt(unitNum, hours, 0.85);
|
|
|
+ //遗漏
|
|
|
+ omitCnt = getRealCnt(unitNum, hours, 0.15);
|
|
|
+ //打捞
|
|
|
+ salvageCnt = getRealCnt(unitNum, hours, 0.15);
|
|
|
+ } else {
|
|
|
+ /*---------- 100%上新----------*/
|
|
|
+ //上新
|
|
|
+ upNewCnt = getRealCnt(unitNum, hours, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ object.put("upNewCnt", upNewCnt);
|
|
|
+ object.put("highCnt", highCnt);
|
|
|
+ object.put("omitCnt", omitCnt);
|
|
|
+ object.put("salvageCnt", salvageCnt);
|
|
|
+ System.out.println("upNewCnt:" + upNewCnt + ",highCnt:" + highCnt + "omitCnt:" + omitCnt + ",salvageCnt:" + salvageCnt);
|
|
|
+ return object;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int getRealCnt(int unitNum, int hours, double i) {
|
|
|
+ //上新总的待建数
|
|
|
+ int upNewCnt = (int) (unitNum * i);
|
|
|
+ if (upNewCnt > hours) {
|
|
|
+ //总待建数大于循环次数
|
|
|
+ upNewCnt = upNewCnt / hours;
|
|
|
+ } else if (upNewCnt != 0) {
|
|
|
+ //总待建数大于1时,本次执行创建一个高质量
|
|
|
+ upNewCnt = 1;
|
|
|
+ } else {
|
|
|
+ upNewCnt = 0;
|
|
|
+ }
|
|
|
+ return upNewCnt;
|
|
|
+ }
|
|
|
}
|