|
@@ -27,6 +27,7 @@ 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.jeecg.modules.bytedance.report.utils.TimeStartAndEndUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -103,7 +104,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
//获取素材 账户所在的项目id 为空
|
|
|
List<ByteDanceVideoInfo> videoInfos = getvideoOrImageInfoByCreateType(null,strategy,startTime,endTime,createType,videoCnt);
|
|
|
if(null == videoInfos||videoInfos.isEmpty()){
|
|
|
- log.info("获取{}视频素材为空=>accountId:{}",BytedanceCreativeMatTypeEnum.getNameByType(createType+""),token.getAccountId());
|
|
|
+ log.info("获取{}素材为空=>accountId:{}",BytedanceCreativeMatTypeEnum.getNameByType(createType+""),token.getAccountId());
|
|
|
return videoCnt;
|
|
|
}
|
|
|
log.info("获取{}素材个数:{}=>accountId:{}",BytedanceCreativeMatTypeEnum.getNameByType(createType+""),videoInfos.size(),token.getAccountId());
|
|
@@ -416,11 +417,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
}
|
|
|
JSONObject titleObject = new JSONObject();
|
|
|
titleObject.put("title",byteDanceGeneralCopywriter.get(i).getTextCopywriter());
|
|
|
-
|
|
|
String creativeWordsIds = byteDanceGeneralCopywriter.get(i).getCreativeWordIds();
|
|
|
-
|
|
|
JSONArray wordsArr = new JSONArray();
|
|
|
-
|
|
|
if(null != creativeWordsIds && !creativeWordsIds.trim().equals("")){
|
|
|
JSONArray creativeWordsArray = JSON.parseArray(creativeWordsIds);
|
|
|
for (Object creative : creativeWordsArray) {
|
|
@@ -429,7 +427,6 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
wordsArr.add(creativeObject);
|
|
|
}
|
|
|
titleObject.put("word_list",wordsArr);
|
|
|
-
|
|
|
}
|
|
|
titleArray.add(titleObject);
|
|
|
}
|
|
@@ -457,7 +454,6 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
}
|
|
|
titleArray.add(titleObject);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
if (Check.isNull(titleArray)){
|
|
@@ -471,11 +467,9 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
iBytedanceAutocreateLogService.save(iBytedanceAutocreateLog);
|
|
|
}
|
|
|
creObj.put("title_materials",titleArray);
|
|
|
-
|
|
|
JSONArray imageMaterials = new JSONArray();
|
|
|
JSONObject object = new JSONObject();
|
|
|
//类型
|
|
|
-
|
|
|
if ("image".equalsIgnoreCase(videoInfo.getMaterialType())){
|
|
|
//图片素材
|
|
|
object.put("image_mode",strategy.getCreativeImageMode());
|
|
@@ -505,12 +499,60 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
}
|
|
|
object.put("image_info",imgObj);
|
|
|
object.put("video_info",videoObj);
|
|
|
-
|
|
|
imageMaterials.add(object);
|
|
|
-
|
|
|
creObj.put("video_materials",imageMaterials);
|
|
|
}
|
|
|
|
|
|
+ //通投智选 竖版视频 横版视频 横图大图
|
|
|
+ if (!Check.isNull(strategy.getAdDeliveryRange()) && "UNIVERSAL".equalsIgnoreCase(strategy.getAdDeliveryRange())){
|
|
|
+ List<ByteDanceVideoInfo> resultList = new ArrayList<>();
|
|
|
+ //获取 最近14天的时间 开始 和截至时间点
|
|
|
+ Map<String,String> map = TimeStartAndEndUtil.getNowFourTeenTime();
|
|
|
+ //横板视频
|
|
|
+ if (strategy.getCreativeImageMode().contains("CREATIVE_IMAGE_MODE_VIDEO")){
|
|
|
+ List<ByteDanceVideoInfo> listMode = byteDanceVideoInfoMapper.getModeVideo(strategy.getAccountId(),map.get("startTime"),map.get("endTime"),1L);
|
|
|
+ if (!Check.isNull(listMode)){
|
|
|
+ for (ByteDanceVideoInfo info : listMode) {
|
|
|
+ //横板视频
|
|
|
+ object.put("image_mode","CREATIVE_IMAGE_MODE_VIDEO");
|
|
|
+ JSONObject videoObj = new JSONObject();
|
|
|
+ videoObj.put("video_id",info.getVid());
|
|
|
+ //视频封面
|
|
|
+ JSONObject imgObj = new JSONObject();
|
|
|
+ //获取视频封面id
|
|
|
+ String imageId = getSuggestImageId(token,info.getVid());
|
|
|
+ if(!Check.isNull(imageId)){
|
|
|
+ imgObj.put("image_id",imageId);
|
|
|
+ }
|
|
|
+ object.put("image_info",imgObj);
|
|
|
+ object.put("video_info",videoObj);
|
|
|
+ imageMaterials.add(object);
|
|
|
+ creObj.put("video_materials",imageMaterials);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //横图大图
|
|
|
+ if (strategy.getCreativeImageMode().contains("CREATIVE_IMAGE_MODE_LARGE")){
|
|
|
+ List<ByteDanceVideoInfo> listImage = byteDanceVideoInfoMapper.getModeImageLarge(strategy.getAccountId(),map.get("startTime"),map.get("endTime"),1L);
|
|
|
+ if (!Check.isNull(listImage)){
|
|
|
+ for (ByteDanceVideoInfo info : listImage) {
|
|
|
+ //图片素材
|
|
|
+ object.put("image_mode","CREATIVE_IMAGE_MODE_LARGE");
|
|
|
+ String[] imageIds = new String[]{info.getId()};
|
|
|
+ JSONArray image_info = new JSONArray();
|
|
|
+ for (String imgId : imageIds) {
|
|
|
+ JSONObject imageObject = new JSONObject();
|
|
|
+ imageObject.put("image_id",imgId);
|
|
|
+ image_info.add(imageObject);
|
|
|
+ }
|
|
|
+ object.put("image_info",image_info);
|
|
|
+ imageMaterials.add(object);
|
|
|
+ creObj.put("image_materials",imageMaterials);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//副标题
|
|
|
String subTitle = strategy.getCreativeSubTitle();
|
|
|
if(!Check.isNull(subTitle)){
|
|
@@ -530,7 +572,6 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
}
|
|
|
creObj.put("component_materials",component);
|
|
|
}
|
|
|
-
|
|
|
params.put("creative",creObj);
|
|
|
return params;
|
|
|
|
|
@@ -1209,7 +1250,15 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ByteDanceVideoInfoMapper byteDanceVideoInfoMapper;
|
|
|
+
|
|
|
private List<ByteDanceVideoInfo> getvideoOrImageInfoByCreateType(Long projectId,AiBytedanceAdvertiserStrategy strategy, String startTime, String endTime, Integer createType, Long videoCnt) {
|
|
|
+ //通投智选 (以 竖版视频 类型为主)
|
|
|
+ if (!Check.isNull(strategy.getAdDeliveryRange()) && "UNIVERSAL".equalsIgnoreCase(strategy.getAdDeliveryRange())){
|
|
|
+ strategy.setCreativeImageMode("CREATIVE_IMAGE_MODE_VIDEO_VERTICAL");
|
|
|
+ return getVideoInfoByCreateType(projectId,strategy,startTime,endTime,createType,videoCnt);
|
|
|
+ }
|
|
|
//横板视频 || 竖版视频
|
|
|
if (strategy.getCreativeImageMode().equalsIgnoreCase("CREATIVE_IMAGE_MODE_VIDEO")
|
|
|
|| strategy.getCreativeImageMode().equalsIgnoreCase("CREATIVE_IMAGE_MODE_VIDEO_VERTICAL")){
|