Преглед изворни кода

Merge branch 'master_mat' into test

songyh пре 4 година
родитељ
комит
d258addfbb

+ 16 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/BytedanceAiVideoCreativeLog.java

@@ -6,8 +6,10 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import org.jeecg.common.util.DateUtils;
 
 import java.util.Date;
+import java.util.UUID;
 
 /**
  * 视频创建创意记录信息
@@ -26,6 +28,8 @@ public class BytedanceAiVideoCreativeLog {
 	private Long id;
 	/**videoCode*/
 	private String videoCode;
+	private Long campaignId;
+	private Long adId;
 	/**creativeUuid*/
 	private String creativeUuid;
 	/**strategyId*/
@@ -38,4 +42,16 @@ public class BytedanceAiVideoCreativeLog {
 	private Date createTime;
 	/**updateTime*/
 	private Date updateTime;
+
+	public BytedanceAiVideoCreativeLog(AiBytedanceAdvertiserStrategy strategy, Long adId, Long campaignId, ByteDanceVideoInfo video) {
+		this.strategyId = strategy.getId();
+		this.adId = adId;
+		this.campaignId = campaignId;
+		this.videoCode = video.getSignature();
+		this.creativeUuid = UUID.randomUUID().toString();
+		this.stateDate = DateUtils.formatDate();
+		this.createTime = new Date();
+		this.updateTime = new Date();
+		this.status = 1;
+	}
 }

+ 5 - 6
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/enums/BytedanceCreativeMatTypeEnum.java

@@ -2,14 +2,13 @@ package org.jeecg.modules.bytedance.advertise.enums;
 
 public enum BytedanceCreativeMatTypeEnum {
     /**
-     * 13 23 分别是历史遗漏素材,归类到上新素材中
-     * type字段 第一位创意创建方式,第二位素材获取方式
-     * 快手创意素材获取类型
+     * 创意素材类型
+     * 0 表示当天
      */
-    BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_NEW("1","上新",-60*8L,-5L),
+    BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_NEW("1","上新",0L,0L),
     BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_HIGH_QUALITY("2","高质量",-14*60*24L,-1*60*24L),
-    BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_MISSING("3","上新",-60*60*24L,-1*60*24L),
-    BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_HISTORY("4","历史",-14*60*24L,-1*60*24L);
+    BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_MISSING("3","遗漏",-60*60*24L,-1*60*24L),
+    BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_HISTORY("4","打捞",-14*60*24L,-1*60*24L);
 
     /**
      * 类型

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

@@ -62,6 +62,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
     @Autowired
     private IBytedanceImageInfoService bytedanceImageInfoService;
     @Autowired
+    private IBytedanceAiVideoCreativeLogService videoCreativeLogService;
+    @Autowired
     private IMaterialInfoService materialInfoService;
     @Autowired
     private IByteDanceCampaignService campaignService;
@@ -91,11 +93,17 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         Long timeStart = BytedanceCreativeMatTypeEnum.getStartTimeByType(createType.toString());
         Long timeEnd = BytedanceCreativeMatTypeEnum.getEndTimeByType(createType.toString());
         Long now = System.currentTimeMillis();
-        String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
-        String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
+        String startTime = DateUtils.formatDate()+" 00:00:00";
+        String endTime = DateUtils.formatDate()+" 23:59:59";
+        if(timeStart != 0){
+            startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
+        }
+        if(timeEnd != 0){
+            endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
+        }
         List<ByteDanceVideoInfo> videoInfos = getVideoInfoByCreateType(userAllocation.getProjectId(),strategy,startTime,endTime,createType,videoCnt);
         if(null == videoInfos||videoInfos.isEmpty()){
-            log.info("获取视频素材为空=>accountId:{}", token.getAccountId());
+            log.info("获取{}视频素材为空=>accountId:{}",BytedanceCreativeMatTypeEnum.getNameByType(createType+""),token.getAccountId());
             return videoCnt;
         }
 
@@ -217,6 +225,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                     log.info("创意创建失败:code==>{};message==>{}",code,message);
                     continue;
                 }
+                BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
+                videoCreativeLogService.saveOrUpdate(creativeLog);
                 videoCnt --;
                 if(videoCnt<=0){
                     return 0L;
@@ -224,7 +234,6 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
             }
         }
         return videoCnt;
-
     }
     private JSONObject getCreativeParams(AiBytedanceAdvertiserStrategy strategy, Long adId,ByteDanceVideoInfo videoInfo,CtopOauthToken token) {
         JSONObject params = new JSONObject();
@@ -447,7 +456,6 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
             return info.getId();
         }
         return null;
-        //图片上传头条巨量后台
     }
 
     private String getSuggestImageId(CtopOauthToken token, String vid) {
@@ -855,8 +863,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
             adName = adName.replace("{{dp链接标识}}",dplinkCode);
         }
         if(adName.contains("{{出价方式}}")){
-            String pricing = strategy.getAdPricing().replace("PRICING_","");
-            adName = adName.replace("{{出价方式}}",pricing).toLowerCase(Locale.ROOT);
+            String pricing = strategy.getAdPricing().replace("PRICING_","").toLowerCase(Locale.ROOT);
+            adName = adName.replace("{{出价方式}}",pricing);
         }
         if(adName.contains("{{素材名称}}")){
             MaterialInfo info = materialInfoService.getParams(videoInfo.getSignature(),null);
@@ -1263,6 +1271,11 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
         long remindCnt = unitNum - unitCreateCnt;
         if (remindCnt >= 1) {
+            log.info("{}计划创建不足,剩余需要创建个数{},使用上新素材创建", strategy.getAccountId(), remindCnt);
+            //优先创建历史遗漏素材
+            remindCnt = this.createCreative(strategy, 1, remindCnt,openUrl);
+        }
+        if (remindCnt >= 1) {
             log.info("{}计划创建不足,剩余需要创建个数{},使用历史遗漏素材创建", strategy.getAccountId(), remindCnt);
             //优先创建历史遗漏素材
             remindCnt = this.createCreative(strategy, 3, remindCnt,openUrl);

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/AiBytedanceAdvertiserStrategyController.java

@@ -132,6 +132,7 @@ public class AiBytedanceAdvertiserStrategyController {
 	@ApiOperation(value="头条智能投放账户配置信息表-编辑", notes="头条智能投放账户配置信息表-编辑")
 	@PutMapping(value = "/edit")
 	public Result<AiBytedanceAdvertiserStrategy> edit(@RequestBody AiBytedanceAdvertiserStrategy aiBytedanceAdvertiserStrategy) {
+		aiBytedanceAdvertiserStrategy.setUserId(null);
 		//商品卖点
 		aiBytedanceAdvertiserStrategy.setCreativeProductSellingPoints(org.apache.commons.lang3.StringUtils.join(aiBytedanceAdvertiserStrategy.getProductSellingPoints(), ","));
 		//广告位置