|
@@ -46,6 +46,7 @@ import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouProjectVideoGetService;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -84,6 +85,8 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaiShouVideoGetService videoGetService;
|
|
private IKuaiShouVideoGetService videoGetService;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private IKuaishouProjectVideoGetService projectVideoGetService;
|
|
|
|
+ @Autowired
|
|
private IMaterialCutFrameService materialCutFrameService;
|
|
private IMaterialCutFrameService materialCutFrameService;
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaiShouImageGetService imageGetService;
|
|
private IKuaiShouImageGetService imageGetService;
|
|
@@ -151,10 +154,7 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
|
|
//创意制作方式,0-不限,4-自定义,7-程序化创意
|
|
//创意制作方式,0-不限,4-自定义,7-程序化创意
|
|
if (strategy.getUnitType() == 4) {
|
|
if (strategy.getUnitType() == 4) {
|
|
this.autoCreateCreative(strategy, 1, customUnitCnt, 1);
|
|
this.autoCreateCreative(strategy, 1, customUnitCnt, 1);
|
|
- } else if (strategy.getUnitType() == 7) {
|
|
|
|
- this.autoCreateProgramCreative(strategy, 1, programUnitCnt, 1);
|
|
|
|
- } else {
|
|
|
|
- this.autoCreateCreative(strategy, 1, customUnitCnt, 1);
|
|
|
|
|
|
+ } else{
|
|
this.autoCreateProgramCreative(strategy, 1, programUnitCnt, 1);
|
|
this.autoCreateProgramCreative(strategy, 1, programUnitCnt, 1);
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -184,20 +184,20 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
|
|
int remindCnt = unitNum - unitCreateCnt;
|
|
int remindCnt = unitNum - unitCreateCnt;
|
|
int concat = strategy.getSourceMaterial().contains("3") ? 3 : 0;
|
|
int concat = strategy.getSourceMaterial().contains("3") ? 3 : 0;
|
|
if (concat != 0 && remindCnt >= 1) {
|
|
if (concat != 0 && remindCnt >= 1) {
|
|
- log.info("{}组创建不足,剩余需要创建个数{},使用历史遗漏素材创建", strategy.getAccountId(), remindCnt);
|
|
|
|
|
|
+ log.info("{}组创建不足,剩余需要创建个数{},即将使用历史遗漏素材创建...", strategy.getAccountId(), remindCnt);
|
|
//优先创建历史遗漏素材
|
|
//优先创建历史遗漏素材
|
|
remindCnt = this.autoCreateCreative(strategy, 3, remindCnt, 2);
|
|
remindCnt = this.autoCreateCreative(strategy, 3, remindCnt, 2);
|
|
}
|
|
}
|
|
concat = strategy.getSourceMaterial().contains("2") ? 2 : 0;
|
|
concat = strategy.getSourceMaterial().contains("2") ? 2 : 0;
|
|
if (concat != 0 && remindCnt >= 1) {
|
|
if (concat != 0 && remindCnt >= 1) {
|
|
- log.info("{}组创建不足,剩余需要创建个数{},使用高质量素材创建", strategy.getAccountId(), remindCnt);
|
|
|
|
|
|
+ log.info("{}组创建不足,剩余需要创建个数{},正在使用高质量素材创建...", strategy.getAccountId(), remindCnt);
|
|
//高质量素材
|
|
//高质量素材
|
|
remindCnt = this.autoCreateCreative(strategy, 2, remindCnt, 2);
|
|
remindCnt = this.autoCreateCreative(strategy, 2, remindCnt, 2);
|
|
}
|
|
}
|
|
concat = strategy.getSourceMaterial().contains("4") ? 4 : 0;
|
|
concat = strategy.getSourceMaterial().contains("4") ? 4 : 0;
|
|
if (concat != 0 && remindCnt >= 1) {
|
|
if (concat != 0 && remindCnt >= 1) {
|
|
//历史打捞素材
|
|
//历史打捞素材
|
|
- log.info("{}组创建不足,剩余需要创建个数{},使用历史打捞素材创建", strategy.getAccountId(), remindCnt);
|
|
|
|
|
|
+ log.info("{}组创建不足,剩余需要创建个数{},将要使用历史打捞素材创建...", strategy.getAccountId(), remindCnt);
|
|
this.autoCreateCreative(strategy, 4, remindCnt, 2);
|
|
this.autoCreateCreative(strategy, 4, remindCnt, 2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -236,7 +236,7 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
|
|
@Override
|
|
@Override
|
|
public void projectProgramAutomaticCreates(KuaishouProjectStrategy strategy, Integer type) {
|
|
public void projectProgramAutomaticCreates(KuaishouProjectStrategy strategy, Integer type) {
|
|
try {
|
|
try {
|
|
- Integer programUnitCnt = strategy.getCustomUnitCnt();
|
|
|
|
|
|
+ Integer programUnitCnt = strategy.getProgramUnitCnt();
|
|
if (Check.isNull(programUnitCnt)) {
|
|
if (Check.isNull(programUnitCnt)) {
|
|
Integer imageCnt = strategy.getImageCnt();
|
|
Integer imageCnt = strategy.getImageCnt();
|
|
if (imageCnt <= 5) {
|
|
if (imageCnt <= 5) {
|
|
@@ -245,8 +245,7 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
|
|
programUnitCnt = 300 / imageCnt;
|
|
programUnitCnt = 300 / imageCnt;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- log.info("{}可创建组总数:{}", strategy.getAccountId(), programUnitCnt);
|
|
|
|
- this.autoCreateCreative(strategy, type, programUnitCnt, 2);
|
|
|
|
|
|
+ this.autoCreateProgramCreative(strategy, type, programUnitCnt, 2);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("项目自动创建程序化上新异常", e);
|
|
log.error("项目自动创建程序化上新异常", e);
|
|
}
|
|
}
|
|
@@ -285,10 +284,25 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
|
|
if (null != singleAppid && singleAppid == 1) {
|
|
if (null != singleAppid && singleAppid == 1) {
|
|
//单一应用
|
|
//单一应用
|
|
String replaceString = KuaishouProjectCreativeMatTypeEnum.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);
|
|
|
|
-// insertAccountOperationRecord(strategy, "账户在" + startTime + "~" + endTime + "时间段内未获取到相应素材(" + replaceString + ")", operationType, 0);
|
|
|
|
|
|
+ List<KuaiShouVideoGet> newVideoList = getVideosByParams(strategy, startTime, endTime, null, createType, Long.valueOf(videoCnt));
|
|
|
|
+ if (null == newVideoList || newVideoList.isEmpty()) {
|
|
|
|
+ log.info("自定义创建(账户:{}),{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
|
|
|
|
+ return videoCnt;
|
|
|
|
+ }
|
|
|
|
+ //根据素材可用日期过滤
|
|
|
|
+ List<KuaiShouVideoGet> newVideos = new ArrayList<>();
|
|
|
|
+ for (KuaiShouVideoGet newVideo : newVideoList) {
|
|
|
|
+ if (!Check.isNull(newVideo.getPutEndTime()) && !Check.isNull(newVideo.getPutStartTime())) {
|
|
|
|
+ boolean b = DateUtils.checkTimeLimit(new Date(), newVideo.getPutStartTime(), newVideo.getPutEndTime());
|
|
|
|
+ if (b) {
|
|
|
|
+ newVideos.add(newVideo);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ newVideos.add(newVideo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (newVideos.size() == 0) {
|
|
|
|
+ log.info("自定义创建(账户:{}),{} 到 {} 未获取到达标素材({})", accountId, startTime, endTime, replaceString);
|
|
return videoCnt;
|
|
return videoCnt;
|
|
}
|
|
}
|
|
Long appId = null;
|
|
Long appId = null;
|
|
@@ -362,19 +376,19 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
|
|
unitLevelOperationRecord.setMessage(msg);
|
|
unitLevelOperationRecord.setMessage(msg);
|
|
if (unitCode == 0) {
|
|
if (unitCode == 0) {
|
|
Long unitId = (Long) unitCreateResult.get("unitId");
|
|
Long unitId = (Long) unitCreateResult.get("unitId");
|
|
- log.info("(accountId:{})创建自定义组({}).....success....",accountId,unitId);
|
|
|
|
|
|
+ log.info("(accountId:{})创建自定义组({}).....success....", accountId, unitId);
|
|
unitLevelOperationRecord.setUnitId(unitId);
|
|
unitLevelOperationRecord.setUnitId(unitId);
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
videoCnt--;
|
|
videoCnt--;
|
|
JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
|
|
JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
|
|
createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, null);
|
|
createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, null);
|
|
} else {
|
|
} else {
|
|
- log.info("(accountId:{})创建自定义组.....fail....{}",accountId, msg);
|
|
|
|
|
|
+ log.info("(accountId:{})创建自定义组.....fail....{}", accountId, msg);
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
redisUtil.set(redisKey, redisValue - 1, 100000L);
|
|
redisUtil.set(redisKey, redisValue - 1, 100000L);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- log.info("(accountId:{})创建自定义组.....fail....{}",accountId, msg);
|
|
|
|
|
|
+ log.info("(accountId:{})创建自定义组.....fail....{}", accountId, msg);
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
unitLevelOperationRecord.setStatus(unitCode);
|
|
unitLevelOperationRecord.setMessage(msg);
|
|
unitLevelOperationRecord.setMessage(msg);
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
@@ -436,11 +450,29 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
|
|
if (null != singleAppid && singleAppid == 1) {
|
|
if (null != singleAppid && singleAppid == 1) {
|
|
String replaceString = KuaishouProjectCreativeMatTypeEnum.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) {
|
|
|
|
|
|
+ List<KuaiShouVideoGet> allVideoList = getVideosByParams(strategy, startTime, endTime, null, createType, Long.valueOf(videoCnt));
|
|
|
|
+ if (null == allVideoList) {
|
|
|
|
+ log.info("程序化账户:{},{} 到 {} 时间段内未获取到相应素材({})", accountId, startTime, endTime, replaceString);
|
|
// insertAccountOperationRecord(strategy, "账户在" + startTime + "~" + endTime + "时间段内未获取到相应素材(" + replaceString + ")", operationType, 0);
|
|
// insertAccountOperationRecord(strategy, "账户在" + startTime + "~" + endTime + "时间段内未获取到相应素材(" + replaceString + ")", operationType, 0);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ //根据素材可用日期过滤
|
|
|
|
+ List<KuaiShouVideoGet> allVideos = new ArrayList<>();
|
|
|
|
+ for (KuaiShouVideoGet newVideo : allVideoList) {
|
|
|
|
+ if (!Check.isNull(newVideo.getPutEndTime()) && !Check.isNull(newVideo.getPutStartTime())) {
|
|
|
|
+ boolean b = DateUtils.checkTimeLimit(new Date(), newVideo.getPutStartTime(), newVideo.getPutEndTime());
|
|
|
|
+ if (b) {
|
|
|
|
+ allVideos.add(newVideo);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ allVideos.add(newVideo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (allVideos.size() == 0) {
|
|
|
|
+ log.info("程序化账户:{},{} 到 {} 未获取到达标素材({})", accountId, startTime, endTime, replaceString);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
Long appId = null;
|
|
Long appId = null;
|
|
//appId,当计划类型为2时必填
|
|
//appId,当计划类型为2时必填
|
|
if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
|
|
if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
|
|
@@ -698,7 +730,7 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
|
|
|
|
|
|
private List<KuaiShouVideoGet> getNewVideoListByParams(KuaishouProjectStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo) {
|
|
private List<KuaiShouVideoGet> getNewVideoListByParams(KuaishouProjectStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo) {
|
|
if (null == appInfo) {
|
|
if (null == appInfo) {
|
|
- return videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), null, null);
|
|
|
|
|
|
+ return projectVideoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType());
|
|
} else {
|
|
} else {
|
|
//查询通用素材
|
|
//查询通用素材
|
|
List<KuaiShouVideoGet> generalVideos = new ArrayList<>();
|
|
List<KuaiShouVideoGet> generalVideos = new ArrayList<>();
|
|
@@ -729,7 +761,7 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
|
|
if (null != strategy.getChannelType() && strategy.getChannelType() != 2) {
|
|
if (null != strategy.getChannelType() && strategy.getChannelType() != 2) {
|
|
channelType = strategy.getChannelType();
|
|
channelType = strategy.getChannelType();
|
|
}
|
|
}
|
|
- return videoGetService.getZeroVideoByParams(strategy.getAccountId(), startTime, endTime, videoCnt, appVersion, channelType, relativeCnt);
|
|
|
|
|
|
+ return projectVideoGetService.getZeroVideoByParams(strategy.getAccountId(), startTime, endTime, videoCnt, appVersion, channelType, relativeCnt);
|
|
}
|
|
}
|
|
|
|
|
|
private List<KuaiShouVideoGet> getHistoryTopVideoListByParams(KuaishouProjectStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo, Long videoCnt) {
|
|
private List<KuaiShouVideoGet> getHistoryTopVideoListByParams(KuaishouProjectStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo, Long videoCnt) {
|
|
@@ -738,7 +770,7 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
|
|
if (null != strategy.getChannelType() && strategy.getChannelType() != 2) {
|
|
if (null != strategy.getChannelType() && strategy.getChannelType() != 2) {
|
|
channelType = strategy.getChannelType();
|
|
channelType = strategy.getChannelType();
|
|
}
|
|
}
|
|
- return videoGetService.getHistoryTopVideoByParams(strategy.getAccountId(), startTime, endTime, videoCnt, appVersion, channelType);
|
|
|
|
|
|
+ return projectVideoGetService.getHistoryTopVideoByParams(strategy.getAccountId(), startTime, endTime, videoCnt, appVersion, channelType);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|