소스 검색

图片素材自动投放

yangzian 4 년 전
부모
커밋
a0b1c66378
13개의 변경된 파일351개의 추가작업 그리고 63개의 파일을 삭제
  1. 3 0
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/AiBytedanceAdDplinkInfo.java
  2. 5 0
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/ByteDanceVideoInfo.java
  3. 42 1
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/enums/BytedanceCreativeMatTypeEnum.java
  4. 23 3
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/ByteDanceVideoInfoMapper.java
  5. 99 5
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/ByteDanceVideoInfoMapper.xml
  6. 2 2
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/IAiBytedanceAdDplinkInfoService.java
  7. 26 3
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/IByteDanceVideoInfoService.java
  8. 6 2
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/AiBytedanceAdDplinkInfoServiceImpl.java
  9. 98 34
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/AiBytedanceAdvertiserStrategyServiceImpl.java
  10. 35 6
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/ByteDanceVideoInfoServiceImpl.java
  11. 1 1
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/service/IMaterialInfoService.java
  12. 4 1
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/service/impl/MaterialInfoServiceImpl.java
  13. 7 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/AiBytedanceAdvertiserStrategyController.java

+ 3 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/AiBytedanceAdDplinkInfo.java

@@ -29,6 +29,9 @@ public class AiBytedanceAdDplinkInfo {
 	private Long adId;
 	/**accountId*/
 	private Long accountId;
+
+	private String imageMode;
+
 	private BigDecimal adBid;
 	/**strategyId*/
 	private Long strategyId;

+ 5 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/ByteDanceVideoInfo.java

@@ -80,6 +80,11 @@ public class ByteDanceVideoInfo {
     private String filename;
     private Integer type;
 
+
+    //素材类型  video-视频;image-图片
+    private String materialType;
+
+
     public ByteDanceVideoInfo(JSONObject data, CtopOauthToken token) {
         this.id = data.getString("id")+token.getAccountId();
         this.vid = data.getString("id");

+ 42 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/enums/BytedanceCreativeMatTypeEnum.java

@@ -8,7 +8,19 @@ public enum BytedanceCreativeMatTypeEnum {
     BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_NEW("1","上新",0L,0L),
     BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_HIGH_QUALITY("2","高质量",-4*60*24L,-1*60*24L),
     BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_MISSING("3","遗漏",-8*60*24L,-1*60*24L),
-    BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_HISTORY("4","打捞",-8*60*24L,-1*60*24L);
+    BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_HISTORY("4","打捞",-8*60*24L,-1*60*24L),
+
+
+
+
+    BYTEDANCE_CREATIVE_IMAGE_MODE_LARGE("CREATIVE_IMAGE_MODE_LARGE","1","大图横图"),
+    BYTEDANCE_CREATIVE_IMAGE_MODE_LARGE_VERTICAL("CREATIVE_IMAGE_MODE_LARGE_VERTICAL","2","大图竖图"),
+    BYTEDANCE_CREATIVE_IMAGE_MODE_VIDEO("CREATIVE_IMAGE_MODE_VIDEO","2","横版视频"),
+    BYTEDANCE_CREATIVE_IMAGE_MODE_VIDEO_VERTICAL("CREATIVE_IMAGE_MODE_VIDEO_VERTICAL","1","竖版视频");
+
+
+
+
 
     /**
      * 类型
@@ -24,6 +36,8 @@ public enum BytedanceCreativeMatTypeEnum {
     private Long videoGetStartTime;
     private Long videoGetEndTime;
 
+    private String imageMode;
+
     BytedanceCreativeMatTypeEnum(String type, String name,Long videoGetStartTime,Long videoGetEndTime) {
         this.type = type;
         this.name = name;
@@ -89,4 +103,31 @@ public enum BytedanceCreativeMatTypeEnum {
     public void setVideoGetEndTime(Long videoGetEndTime) {
         this.videoGetEndTime = videoGetEndTime;
     }
+
+
+    public String getImageMode() {
+        return imageMode;
+    }
+
+    public void setImageMode(String imageMode) {
+        this.imageMode = imageMode;
+    }
+
+
+    BytedanceCreativeMatTypeEnum(String type, String name,String imageMode) {
+        this.type = type;
+        this.name = name;
+        this.imageMode = imageMode;
+    }
+
+
+    public static String getImageModeByType(String type) {
+        for (BytedanceCreativeMatTypeEnum createTypeEnum : BytedanceCreativeMatTypeEnum.values()) {
+            if (createTypeEnum.getType().equals(type)) {
+                return createTypeEnum.getImageMode();
+            }
+        }
+        return "";
+    }
+
 }

+ 23 - 3
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/ByteDanceVideoInfoMapper.java

@@ -25,9 +25,29 @@ public interface ByteDanceVideoInfoMapper extends BaseMapper<ByteDanceVideoInfo>
      * @param videoCnt
      * @return
      */
-    List<ByteDanceVideoInfo> getNewVideoByParams(@Param(value = "projectId") Long projectId,@Param(value = "accountId") Long accountId, @Param(value = "startTime")String startTime, @Param(value = "endTime")String endTime, @Param(value = "videoCnt")Long videoCnt,@Param(value = "creativeCnt")Long creativeCnt,@Param(value = "now") String now);
+    List<ByteDanceVideoInfo> getNewVideoByParams(@Param(value = "projectId") Long projectId,@Param(value = "accountId") Long accountId, @Param(value = "imageMode") String imageMode,@Param(value = "startTime")String startTime, @Param(value = "endTime")String endTime, @Param(value = "videoCnt")Long videoCnt,@Param(value = "creativeCnt")Long creativeCnt,@Param(value = "now") String now);
+
+    List<ByteDanceVideoInfo> topMatByParams(@Param(value = "projectId")Long projectId, @Param(value = "accountId")Long accountId, @Param(value = "imageMode") String imageMode,@Param(value = "startTime")String startTime, @Param(value = "endTime")String endTime, @Param(value = "videoCnt")Long videoCnt,@Param(value = "now") String now);
+
+    List<ByteDanceVideoInfo>historyMatByParams(@Param(value = "projectId")Long projectId, @Param(value = "accountId")Long accountId, @Param(value = "imageMode") String imageMode,@Param(value = "startTime")String startTime, @Param(value = "endTime")String endTime, @Param(value = "videoCnt")Long videoCnt,@Param(value = "now") String now);
+
+
+    /**
+     *图片 上新 遗漏
+     */
+    List<ByteDanceVideoInfo> imageListByParams(@Param(value = "projectId") Long projectId,@Param(value = "accountId") Long accountId, @Param(value = "imageMode") String imageMode,@Param(value = "startTime")String startTime, @Param(value = "endTime")String endTime, @Param(value = "videoCnt")Long videoCnt,@Param(value = "creativeCnt")Long creativeCnt,@Param(value = "now") String now);
+
+    /**
+     * 图片 跑量
+     */
+    List<ByteDanceVideoInfo> imageTopMatByParams(@Param(value = "projectId")Long projectId, @Param(value = "accountId")Long accountId, @Param(value = "imageMode") String imageMode,@Param(value = "startTime")String startTime, @Param(value = "endTime")String endTime, @Param(value = "videoCnt")Long videoCnt,@Param(value = "now") String now);
+
+    /**
+     * 图片 打捞
+     */
+    List<ByteDanceVideoInfo>imageHistoryMatByParams(@Param(value = "projectId")Long projectId, @Param(value = "accountId")Long accountId, @Param(value = "imageMode") String imageMode,@Param(value = "startTime")String startTime, @Param(value = "endTime")String endTime, @Param(value = "videoCnt")Long videoCnt,@Param(value = "now") String now);
+
+
 
-    List<ByteDanceVideoInfo> topMatByParams(@Param(value = "projectId")Long projectId, @Param(value = "accountId")Long accountId, @Param(value = "startTime")String startTime, @Param(value = "endTime")String endTime, @Param(value = "videoCnt")Long videoCnt,@Param(value = "now") String now);
 
-    List<ByteDanceVideoInfo>historyMatByParams(@Param(value = "projectId")Long projectId, @Param(value = "accountId")Long accountId, @Param(value = "startTime")String startTime, @Param(value = "endTime")String endTime, @Param(value = "videoCnt")Long videoCnt,@Param(value = "now") String now);
 }

+ 99 - 5
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/ByteDanceVideoInfoMapper.xml

@@ -71,12 +71,14 @@
         select distinct video.*,
         (select count(1) from ctop_bytedance_ai_video_creative_log l where l.video_code = video.signature and l.account_id = video.account_id and l.state_date = #{now}) as creativeNum,
         (select count(1) from ctop_bytedance_creative c where c.video_id = video.vid and c.account_id = '${accountId}') as creativeCnt,
-        (select count(1) from ctop_bytedance_video_slogen_info s where s.video_code = video.signature) as slogens
+        (select count(1) from ctop_bytedance_video_slogen_info s where s.video_code = video.signature) as slogens,
+         'video' As materialType
         from ctop_bytedance_video_info video
         left join ctop_material_info cmi on video.signature = cmi.code and cmi.project_id = #{projectId}
         where account_id = #{accountId}
         and cmi.code is not null
         and cmi.offline_flag = 0
+        and video.type = #{imageMode}
         and material_upload_time &gt;= #{startTime}
         and material_upload_time &lt;= #{endTime}
         having creativeCnt &lt;= #{creativeCnt} and slogens >0 and creativeNum = 0
@@ -88,7 +90,8 @@
         a.totalCost,
         (select count(1) from ctop_bytedance_ai_video_creative_log l where l.video_code = video.signature and l.account_id = video.account_id and l.state_date = #{now}) as creativeNum,
         (select count(1) from ctop_bytedance_creative c where c.video_id = video.vid and c.account_id = '${accountId}') as creativeCnt,
-        (select count(1) from ctop_bytedance_video_slogen_info s where s.video_code = video.signature ) as slogens
+        (select count(1) from ctop_bytedance_video_slogen_info s where s.video_code = video.signature ) as slogens,
+         'video' As materialType
         from (select report.material_id, sum(cost) as totalCost
         from ctop_bytedance_report_material_daily report
         left join ctop_user_allocation cua on report.account_id = cua.account_id
@@ -97,7 +100,7 @@
         and report.stat_datetime &lt;= #{endTime}
         group by report.material_id
         order by sum(report.cost) desc ) a
-        left join (select distinct a.* from ctop_bytedance_video_info a where a.account_id = #{accountId})as video
+        left join (select distinct a.* from ctop_bytedance_video_info a where a.account_id = #{accountId} and a.type = #{imageMode})as video
         on a.material_id = video.material_id
         left join ctop_material_info cmi on cmi.code = video.signature and cmi.project_id = #{projectId}
         where cmi.id is not null
@@ -116,7 +119,8 @@
                a.totalCost,
                (select count(1) from ctop_bytedance_ai_video_creative_log l where l.video_code = video.signature and l.account_id = video.account_id and l.state_date = #{now}) as creativeNum,
                (select count(1) from ctop_bytedance_creative c where c.video_id = video.vid and c.account_id = '${accountId}') as creativeCnt,
-               (select count(1) from ctop_bytedance_video_slogen_info s where s.video_code = video.signature) as slogens
+               (select count(1) from ctop_bytedance_video_slogen_info s where s.video_code = video.signature) as slogens,
+               'video' As materialType
         from (select report.material_id, sum(cost) as totalCost
               from ctop_bytedance_report_material_daily report
                        left join ctop_user_allocation cua on report.account_id = cua.account_id
@@ -125,7 +129,7 @@
                 and report.stat_datetime &lt;= #{endTime}
               group by report.material_id
               order by sum(report.cost) desc ) a
-                 left join (select distinct a.* from ctop_bytedance_video_info a where a.account_id = #{accountId})as video
+                 left join (select distinct a.* from ctop_bytedance_video_info a where a.account_id = #{accountId} and a.type = #{imageMode})as video
                            on a.material_id = video.material_id
                  left join ctop_material_info cmi on cmi.code = video.signature and cmi.project_id = #{projectId}
         where cmi.id is not null
@@ -138,4 +142,94 @@
         order by a.material_id desc
             limit #{videoCnt}
     </select>
+
+
+    <!-- 图片 上新 遗漏 -->
+    <select id="imageListByParams" resultType="org.jeecg.modules.bytedance.advertise.entity.ByteDanceVideoInfo">
+        select distinct image.*,
+        (select count(1) from ctop_bytedance_ai_video_creative_log l
+        where l.video_code = image.signature
+        and l.account_id = image.account_id
+        and l.state_date = #{now}) as creativeNum,
+        (select count(1) from ctop_bytedance_creative c
+        where SUBSTRING_INDEX(SUBSTRING_INDEX(image_ids,'["',-1),'"]',1) in(image.id)
+        and c.account_id = '${accountId}') as creativeCnt,
+        'image' as materialType
+        from ctop_bytedance_image_info image
+        where account_id = #{accountId}
+        and image.type = #{imageMode}
+        and image.create_time &gt;= #{startTime}
+        and image.create_time &lt;= #{endTime}
+        having creativeCnt &lt;= #{creativeCnt}
+        and creativeNum = 0
+        order by create_time desc
+            limit #{videoCnt}
+    </select>
+
+
+    <!-- 图片 跑量-->
+    <select id="imageTopMatByParams" resultType="org.jeecg.modules.bytedance.advertise.entity.ByteDanceVideoInfo">
+        select distinct image.*,
+        a.totalCost,
+        (select count(1) from ctop_bytedance_ai_video_creative_log l
+        where l.video_code = image.signature
+        and l.account_id = image.account_id
+        and l.state_date =#{now}) as creativeNum,
+        (select count(1)
+        from ctop_bytedance_creative c
+        where SUBSTRING_INDEX(SUBSTRING_INDEX(image_ids,'["',-1),'"]',1) in(image.id)
+        and c.account_id = '${accountId}')  as creativeCnt
+        from (select report.material_id, sum(cost) as totalCost,
+         'image' as materialType
+        from ctop_bytedance_report_image_daily report
+        left join ctop_user_allocation cua on report.account_id = cua.account_id
+        where cua.project_id = #{projectId}
+        and report.stat_datetime &gt;= #{startTime}
+        and report.stat_datetime &lt;= #{endTime}
+        group by report.material_id
+        order by sum(report.cost) desc ) a
+        left join (select distinct a.* from ctop_bytedance_image_info a where a.account_id = #{accountId} and a.type = #{imageMode})as image
+        on a.material_id = image.material_id
+        where 1=1
+        and a.totalCost &gt; 500
+        having creativeCnt &lt;= 100
+        and creativeNum = 0
+        order by a.material_id desc
+            limit #{videoCnt}
+    </select>
+
+
+    <!-- 图片 打捞-->
+    <select id="imageHistoryMatByParams" resultType="org.jeecg.modules.bytedance.advertise.entity.ByteDanceVideoInfo">
+        select distinct image.*,
+        a.totalCost,
+        (select count(1)
+        from ctop_bytedance_ai_video_creative_log l
+        where l.video_code = image.signature
+        and l.account_id = image.account_id
+        and l.state_date = #{now}) as creativeNum,
+        (select count(1)
+        from ctop_bytedance_creative c
+        where SUBSTRING_INDEX(SUBSTRING_INDEX(image_ids,'["',-1),'"]',1) in(image.id)
+        and c.account_id = '${accountId}') as creativeCnt
+        from (select report.material_id, sum(cost) as totalCost,
+        'image' as materialType
+        from ctop_bytedance_report_image_daily report
+        left join ctop_user_allocation cua on report.account_id = cua.account_id
+        where cua.project_id = #{projectId}
+        and report.stat_datetime &gt;= #{startTime}
+        and report.stat_datetime &lt;= #{endTime}
+        group by report.material_id
+        order by sum(report.cost) desc) a
+        left join (select distinct a.* from ctop_bytedance_image_info a where a.account_id =#{accountId} and a.type = #{imageMode}) as image
+        on a.material_id = image.material_id
+        where 1=1
+        and a.totalCost &lt;= 100
+        having creativeCnt &lt; 20
+        and creativeNum = 0
+        order by a.material_id desc
+            limit #{videoCnt}
+    </select>
+
+
 </mapper>

+ 2 - 2
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/IAiBytedanceAdDplinkInfoService.java

@@ -11,7 +11,7 @@ import org.jeecg.modules.bytedance.advertise.entity.AiBytedanceAdDplinkInfo;
  */
 public interface IAiBytedanceAdDplinkInfoService extends IService<AiBytedanceAdDplinkInfo> {
 
-    AiBytedanceAdDplinkInfo getlatestDpLinkInfo(Long strategyId, Long accountId, Integer status);
+    AiBytedanceAdDplinkInfo getlatestDpLinkInfo(Long strategyId, Long accountId,String imageMode,Integer status);
 
-    int getDpLinkInfoCount(Long accountId);
+    int getDpLinkInfoCount(Long accountId,String imageMode);
 }

+ 26 - 3
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/IByteDanceVideoInfoService.java

@@ -19,9 +19,32 @@ public interface IByteDanceVideoInfoService extends IService<ByteDanceVideoInfo>
 
     void updateMaterialType();
 
-    List<ByteDanceVideoInfo> listByParams(Long projectId,Long accountId, String startTime, String endTime, Long videoCnt,long creativeCnt);
+    List<ByteDanceVideoInfo> listByParams(Long projectId,Long accountId, String imageMode,String startTime, String endTime, Long videoCnt,long creativeCnt);
+
+    List<ByteDanceVideoInfo> topMatByParams(Long projectId, Long accountId, String imageMode,String startTime, String endTime, Long videoCnt);
+
+    List<ByteDanceVideoInfo> historyMatByParams(Long projectId, Long accountId, String imageMode,String startTime, String endTime, Long videoCnt);
+
+
+    /**
+     * 图片 上新 遗漏
+     */
+    List<ByteDanceVideoInfo> imageListByParams(Long projectId,Long accountId, String imageMode,String startTime, String endTime, Long videoCnt,long creativeCnt);
+
+    /**
+     * 图片 跑量
+     */
+    List<ByteDanceVideoInfo> imageTopMatByParams(Long projectId, Long accountId, String imageMode,String startTime, String endTime, Long videoCnt);
+
+    /**
+     * 图片 打捞
+     */
+    List<ByteDanceVideoInfo> imageHistoryMatByParams(Long projectId, Long accountId,String imageMode, String startTime, String endTime, Long videoCnt);
+
+
+
+
+
 
-    List<ByteDanceVideoInfo> topMatByParams(Long projectId, Long accountId, String startTime, String endTime, Long videoCnt);
 
-    List<ByteDanceVideoInfo> historyMatByParams(Long projectId, Long accountId, String startTime, String endTime, Long videoCnt);
 }

+ 6 - 2
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/AiBytedanceAdDplinkInfoServiceImpl.java

@@ -24,7 +24,7 @@ public class AiBytedanceAdDplinkInfoServiceImpl extends ServiceImpl<AiBytedanceA
     private AiBytedanceAdDplinkInfoMapper aiBytedanceAdDplinkInfoMapper;
 
     @Override
-    public AiBytedanceAdDplinkInfo getlatestDpLinkInfo(Long strategyId, Long accountId, Integer status) {
+    public AiBytedanceAdDplinkInfo getlatestDpLinkInfo(Long strategyId, Long accountId, String imageMode,Integer status) {
         QueryWrapper<AiBytedanceAdDplinkInfo> queryWrapper = new QueryWrapper<>();
         if(null!=strategyId&&strategyId!=0){
             queryWrapper.eq("strategy_id",strategyId);
@@ -35,6 +35,9 @@ public class AiBytedanceAdDplinkInfoServiceImpl extends ServiceImpl<AiBytedanceA
         if(null!=status){
             queryWrapper.eq("status",status);
         }
+        if(null!=imageMode){
+            queryWrapper.eq("image_mode",imageMode);
+        }
         queryWrapper.orderByDesc("id").last("limit 1");
         return this.getOne(queryWrapper);
     }
@@ -48,13 +51,14 @@ public class AiBytedanceAdDplinkInfoServiceImpl extends ServiceImpl<AiBytedanceA
      * @author: zianY
      */
     @Override
-    public int getDpLinkInfoCount(Long accountId) {
+    public int getDpLinkInfoCount(Long accountId,String imageMode) {
         QueryWrapper<AiBytedanceAdDplinkInfo> queryWrapper = new QueryWrapper<>();
         Date date = new Date();
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         String format = sdf.format(date);
         queryWrapper.eq("account_id",accountId);
         queryWrapper.ge("create_time",format);
+        queryWrapper.eq("image_mode",imageMode);
         return aiBytedanceAdDplinkInfoMapper.selectCount(queryWrapper);
 
     }

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

@@ -102,21 +102,30 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         if(timeEnd != 0){
             endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
         }
-        List<ByteDanceVideoInfo> videoInfos = getVideoInfoByCreateType(userAllocation.getProjectId(),strategy,startTime,endTime,createType,videoCnt);
+        //List<ByteDanceVideoInfo> videoInfos = getVideoInfoByCreateType(userAllocation.getProjectId(),strategy,startTime,endTime,createType,videoCnt);
+        List<ByteDanceVideoInfo> videoInfos = getvideoOrImageInfoByCreateType(userAllocation.getProjectId(),strategy,startTime,endTime,createType,videoCnt);
+
         if(null == videoInfos||videoInfos.isEmpty()){
-            log.info("获取{}视频素材为空=>accountId:{}",BytedanceCreativeMatTypeEnum.getNameByType(createType+""),token.getAccountId());
+            log.info("获取{}素材{}为空=>accountId:{}===》素材类型{}",BytedanceCreativeMatTypeEnum.getNameByType(createType+""),strategy.getCreativeImageMode(),token.getAccountId(),BytedanceCreativeMatTypeEnum.getImageModeByType(strategy.getCreativeImageMode()));
             return videoCnt;
         }
-        log.info("获取{}视频素材个数:{}=>accountId:{}",BytedanceCreativeMatTypeEnum.getNameByType(createType+""),videoInfos.size(),token.getAccountId());
+        log.info("获取{}素材个数:{}=>accountId:{}",BytedanceCreativeMatTypeEnum.getNameByType(createType+""),videoInfos.size(),token.getAccountId());
+
 
         for (ByteDanceVideoInfo video:videoInfos) {
-            Integer isLowQuality = bytedanceMaterialRejectReasonMapper.getIsLowQualityByVideoId(video.getVid());    //判断次视频是否是低质视频,为1跳过
-            if(1 == isLowQuality){
-                continue;
+            //判断此素材为视频
+            if ("video".equalsIgnoreCase(video.getMaterialType())){
+                //视频是否是低质视频,为1跳过
+                Integer isLowQuality = bytedanceMaterialRejectReasonMapper.getIsLowQualityByVideoId(video.getVid());
+                if(1 == isLowQuality){
+                    continue;
+                }
             }
+
             Integer useDplinkIndex = strategy.getDpLinkIndexUsed();
             if(null==useDplinkIndex||useDplinkIndex.equals(0)){
-                AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),1);
+                //查看已使用的dp链接
+                AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),strategy.getCreativeImageMode(),1);
                 if(null == adDplinkInfo){
                     adDplinkInfo = new AiBytedanceAdDplinkInfo();
                     if("FIX".equalsIgnoreCase(strategy.getAdBidCreateType())){
@@ -140,7 +149,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                     return videoCnt;
                 }
                 //计划名称
-                String adName = getAdName(strategy,null,video);
+                String adName = getAdName(strategy,null,video,userAllocation.getProjectId());
                 //计算本次出价
                 BigDecimal currentCpaBid = StringUtils.getRandomAdCpaBid(strategy.getAdBidCreateType(),strategy.getAdMaxBid(),strategy.getAdMinBid(),strategy.getAdStepBid(),adDplinkInfo.getAdBid(),strategy.getAdCpaBid());
                 JSONObject adParams = getAdParams(strategy,adName,campaignId,currentCpaBid);
@@ -172,6 +181,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 adDplinkInfo.setAccountId(strategy.getAccountId());
                 adDplinkInfo.setStatus(1);
                 adDplinkInfo.setStrategyId(strategy.getId());
+                adDplinkInfo.setImageMode(strategy.getCreativeImageMode());
                 adDplinkInfoService.save(adDplinkInfo);
 
                 BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
@@ -182,7 +192,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 }
             }else{
                 Long dpIndex ;
-                AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),1);
+                AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),strategy.getCreativeImageMode(),1);
                 if(null == adDplinkInfo){
                     adDplinkInfo = new AiBytedanceAdDplinkInfo();
                     if("FIX".equalsIgnoreCase(strategy.getAdBidCreateType())){
@@ -211,7 +221,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 strategy.setAdOpenUrl(openUrl.replace("{{dp链接下标}}",dpIndex.toString()));
                 String dplinkCode = StringUtils.getParamFromUrl(strategy.getAdOpenUrl(),"bc_fl_src");
                 //计划名称
-                String adName = getAdName(strategy,dplinkCode,video);
+                String adName = getAdName(strategy,dplinkCode,video,userAllocation.getProjectId());
                 //计算本次出价
                 BigDecimal currentCpaBid = StringUtils.getRandomAdCpaBid(strategy.getAdBidCreateType(),strategy.getAdMaxBid(),strategy.getAdMinBid(),strategy.getAdStepBid(),adDplinkInfo.getAdBid(),strategy.getAdCpaBid());
                 adDplinkInfo.setAdBid(currentCpaBid);
@@ -243,6 +253,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 adDplinkInfo.setAccountId(strategy.getAccountId());
                 adDplinkInfo.setStatus(1);
                 adDplinkInfo.setStrategyId(strategy.getId());
+                adDplinkInfo.setImageMode(strategy.getCreativeImageMode());
                 adDplinkInfoService.save(adDplinkInfo);
                 BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
                 videoCreativeLogService.saveOrUpdate(creativeLog);
@@ -289,21 +300,25 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         //视频素材
         JSONArray imageArray = new JSONArray();
         JSONObject imageObject = new JSONObject();
-        //视频类型
-        if(videoInfo.getType() == 1){
-            //竖版视频
-            imageObject.put("image_mode","CREATIVE_IMAGE_MODE_VIDEO_VERTICAL");
-        }
-        if(videoInfo.getType() == 2){
-            //横版视频
-            imageObject.put("image_mode","CREATIVE_IMAGE_MODE_VIDEO");
-        }
-        imageObject.put("video_id",videoInfo.getVid());
-        //获取视频封面id
-        String imageId = getSuggestImageId(token,videoInfo.getVid());
-        if(!Check.isNull(imageId)){
-            imageObject.put("image_id",imageId);
+
+        if ("video".equalsIgnoreCase(videoInfo.getMaterialType())){
+            //视频类型
+            //1-竖版视频 2-横版视频
+            String imageMode = videoInfo.getType() == 1 ? "CREATIVE_IMAGE_MODE_VIDEO_VERTICAL" : "CREATIVE_IMAGE_MODE_VIDEO";
+            imageObject.put("image_mode",imageMode);
+            imageObject.put("video_id",videoInfo.getVid());
+            //获取视频封面id
+            String imageId = getSuggestImageId(token,videoInfo.getVid());
+            if(!Check.isNull(imageId)){
+                imageObject.put("image_id",imageId);
+            }
+        }else if ("image".equalsIgnoreCase(videoInfo.getMaterialType())){
+            //1-大图横图; 2-大图竖图
+            String imageMode = videoInfo.getType() == 1 ? "CREATIVE_IMAGE_MODE_LARGE" : "CREATIVE_IMAGE_MODE_LARGE_VERTICAL";
+            imageObject.put("image_mode",imageMode);
+            imageObject.put("image_ids",new String[]{videoInfo.getId()});
         }
+
         imageArray.add(imageObject);
         params.put("image_list",imageArray);
         JSONArray titleArray = new JSONArray();
@@ -925,7 +940,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         return params;
     }
 
-    private String getAdName(AiBytedanceAdvertiserStrategy strategy, String dplinkCode, ByteDanceVideoInfo videoInfo) {
+    private String getAdName(AiBytedanceAdvertiserStrategy strategy, String dplinkCode, ByteDanceVideoInfo videoInfo,Long projectId) {
         String adName = strategy.getAdName();
         if(null == adName|| "".equals(adName.trim())){
             return null;
@@ -944,14 +959,20 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
             String pricing = strategy.getAdPricing().replace("PRICING_","").toLowerCase(Locale.ROOT);
             adName = adName.replace("{{出价方式}}",pricing);
         }
+
         if(adName.contains("{{素材名称}}")){
-            MaterialInfo info = materialInfoService.getParams(videoInfo.getSignature(),null);
-            if(null!=info&&null!=info.getMaterialName()){
-                adName = adName.replace("{{素材名称}}",info.getMaterialName());
+            if ("video".equals(videoInfo.getMaterialType())){
+                MaterialInfo info = materialInfoService.getParams(videoInfo.getSignature(),null,projectId);
+                if(null!=info&&null!=info.getMaterialName()){
+                    adName = adName.replace("{{素材名称}}",info.getMaterialName());
+                }
+            }else {
+                adName = adName.replace("{{素材名称}}",videoInfo.getFilename());
             }
         }
+
         if(adName.contains("{{序号}}")){
-            int i = adDplinkInfoService.getDpLinkInfoCount(strategy.getAccountId());
+            int i = adDplinkInfoService.getDpLinkInfoCount(strategy.getAccountId(),strategy.getCreativeImageMode());
             adName = adName.replace("{{序号}}",String.valueOf(i+1));
         }
 
@@ -1018,8 +1039,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         }
 
         if(result.contains("{{序号}}")){
-            //查询当天已有计划数量
-            int i = adDplinkInfoService.getDpLinkInfoCount(strategy.getAccountId());
+            //查询同素材类型当天已有计划数量
+            int i = adDplinkInfoService.getDpLinkInfoCount(strategy.getAccountId(),strategy.getCreativeImageMode());
             Long num = GetCampaignNum.getCampaignNameNum(strategy.getCampaignCnt(),strategy.getCampaignAdCnt(), i == 0 ? i+1 : i);
             result = result.replace("{{序号}}",String.valueOf(num));
         }
@@ -1062,18 +1083,61 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
     //TODO -- 高质量素材 一天只能创建一次 两周内总消耗》=500
     //TODO -- 打捞素材  两周消耗 <500 并且总关联创意数<20
     private List<ByteDanceVideoInfo> getVideoInfoByCreateType(Long projectId,AiBytedanceAdvertiserStrategy strategy, String startTime, String endTime, Integer createType, Long videoCnt) {
+        //根据 imageMode 获取素材类型
+        //1-竖版视频 2-横板视频
+        String imageMode = BytedanceCreativeMatTypeEnum.getNameByType(strategy.getCreativeImageMode());
         //1:上新素材 2:跑量素材 3:遗漏素材 4:打捞素材
         if(createType == 1||createType == 3){
-            return videoInfoService.listByParams(projectId,strategy.getAccountId(),startTime,endTime,videoCnt,0);
+            return videoInfoService.listByParams(projectId,strategy.getAccountId(),imageMode,startTime,endTime,videoCnt,0);
         }else if(createType == 2){
             startTime = startTime.substring(0,10);
             endTime = endTime.substring(0,10);
-            return videoInfoService.topMatByParams(projectId,strategy.getAccountId(),startTime,endTime,videoCnt);
+            return videoInfoService.topMatByParams(projectId,strategy.getAccountId(),imageMode,startTime,endTime,videoCnt);
+        }else if(createType == 4){
+            return videoInfoService.historyMatByParams(projectId,strategy.getAccountId(),imageMode,startTime,endTime,videoCnt);
+        }
+        return null;
+    }
+
+    /**
+     * 图片素材
+     */
+    private List<ByteDanceVideoInfo> getImageInfoByCreateType(Long projectId,AiBytedanceAdvertiserStrategy strategy, String startTime, String endTime, Integer createType, Long videoCnt) {
+        //根据 imageMode 获取素材类型
+        //1-大图横图; 2-大图竖图
+        String imageMode = BytedanceCreativeMatTypeEnum.getNameByType(strategy.getCreativeImageMode());
+        //1:上新素材 2:跑量素材 3:遗漏素材 4:打捞素材
+        if(createType == 1||createType == 3){
+            return videoInfoService.imageListByParams(projectId,strategy.getAccountId(),imageMode,startTime,endTime,videoCnt,0);
+        }else if(createType == 2){
+            return videoInfoService.imageTopMatByParams(projectId,strategy.getAccountId(),imageMode,startTime,endTime,videoCnt);
         }else if(createType == 4){
-            return videoInfoService.listByParams(projectId,strategy.getAccountId(),startTime,endTime,videoCnt,20);
+            return videoInfoService.imageHistoryMatByParams(projectId,strategy.getAccountId(),imageMode,startTime,endTime,videoCnt);
         }
         return null;
     }
+
+    private List<ByteDanceVideoInfo> getvideoOrImageInfoByCreateType(Long projectId,AiBytedanceAdvertiserStrategy strategy, String startTime, String endTime, Integer createType, Long videoCnt) {
+        //横板视频 || 竖版视频
+        if (strategy.getCreativeImageMode().equalsIgnoreCase("CREATIVE_IMAGE_MODE_VIDEO")
+                || strategy.getCreativeImageMode().equalsIgnoreCase("CREATIVE_IMAGE_MODE_VIDEO_VERTICAL")){
+            //获取 视频 素材
+            return getVideoInfoByCreateType(projectId,strategy,startTime,endTime,createType,videoCnt);
+        }
+        //获取 图片 素材
+        return getImageInfoByCreateType(projectId,strategy,startTime,endTime,createType,videoCnt);
+    }
+
+
+
+
+
+
+
+
+
+
+
     /**
      *  修改状态 (0开-1关)
      *  同一账户下只能有一条数据信息为开启,可以全部关闭

+ 35 - 6
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/ByteDanceVideoInfoServiceImpl.java

@@ -44,20 +44,49 @@ public class ByteDanceVideoInfoServiceImpl extends ServiceImpl<ByteDanceVideoInf
     }
 
     @Override
-    public List<ByteDanceVideoInfo> listByParams(Long projectId,Long accountId, String startTime, String endTime, Long videoCnt,long creativeCnt) {
+    public List<ByteDanceVideoInfo> listByParams(Long projectId,Long accountId, String imageMode,String startTime, String endTime, Long videoCnt,long creativeCnt) {
         String now = DateUtils.formatDate();
-        return videoInfoMapper.getNewVideoByParams(projectId,accountId,startTime,endTime,videoCnt,creativeCnt,now);
+        return videoInfoMapper.getNewVideoByParams(projectId,accountId,imageMode,startTime,endTime,videoCnt,creativeCnt,now);
     }
 
     @Override
-    public List<ByteDanceVideoInfo> topMatByParams(Long projectId, Long accountId, String startTime, String endTime, Long videoCnt) {
+    public List<ByteDanceVideoInfo> topMatByParams(Long projectId, Long accountId, String imageMode,String startTime, String endTime, Long videoCnt) {
         String now = DateUtils.formatDate();
-        return videoInfoMapper.topMatByParams(projectId,accountId,startTime,endTime,videoCnt,now);
+        return videoInfoMapper.topMatByParams(projectId,accountId,imageMode,startTime,endTime,videoCnt,now);
     }
 
     @Override
-    public List<ByteDanceVideoInfo> historyMatByParams(Long projectId, Long accountId, String startTime, String endTime, Long videoCnt) {
+    public List<ByteDanceVideoInfo> historyMatByParams(Long projectId, Long accountId, String imageMode,String startTime, String endTime, Long videoCnt) {
         String now = DateUtils.formatDate();
-        return videoInfoMapper.historyMatByParams(projectId,accountId,startTime,endTime,videoCnt,now);
+        return videoInfoMapper.historyMatByParams(projectId,accountId,imageMode,startTime,endTime,videoCnt,now);
+    }
+
+
+    /**
+     * 图片 上新 遗漏
+     */
+    @Override
+    public List<ByteDanceVideoInfo> imageListByParams(Long projectId, Long accountId, String imageMode,String startTime, String endTime, Long videoCnt, long creativeCnt) {
+        String now = DateUtils.formatDate();
+        return videoInfoMapper.imageListByParams(projectId,accountId,imageMode,startTime,endTime,videoCnt,creativeCnt,now);
+
+    }
+
+    /**
+     * 图片 跑量
+     */
+    @Override
+    public List<ByteDanceVideoInfo> imageTopMatByParams(Long projectId, Long accountId, String imageMode,String startTime, String endTime, Long videoCnt) {
+        String now = DateUtils.formatDate();
+        return videoInfoMapper.imageTopMatByParams(projectId,accountId,imageMode,startTime,endTime,videoCnt,now);
+    }
+
+    /**
+     * 图片 打捞
+     */
+    @Override
+    public List<ByteDanceVideoInfo> imageHistoryMatByParams(Long projectId, Long accountId, String imageMode,String startTime, String endTime, Long videoCnt) {
+        String now = DateUtils.formatDate();
+        return videoInfoMapper.imageHistoryMatByParams(projectId,accountId,imageMode,startTime,endTime,videoCnt,now);
     }
 }

+ 1 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/service/IMaterialInfoService.java

@@ -14,7 +14,7 @@ import java.util.List;
  * @date 2019-10-11
  */
 public interface IMaterialInfoService extends IService<MaterialInfo> {
-    MaterialInfo getParams(String signature, Integer status);
+    MaterialInfo getParams(String signature, Integer status,Long projectId);
 
 
     Result updMaterialOfflineById(List<String> ids, Integer offlineFlag);

+ 4 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/service/impl/MaterialInfoServiceImpl.java

@@ -31,7 +31,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
 
 
     @Override
-    public MaterialInfo getParams(String signature, Integer status) {
+    public MaterialInfo getParams(String signature, Integer status,Long projectId) {
         QueryWrapper<MaterialInfo>queryWrapper = new QueryWrapper<>();
         if(null!=signature&&!"".equals(signature.trim())){
             queryWrapper.eq("code",signature);
@@ -39,6 +39,9 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         if(null!=status){
             queryWrapper.eq("status",status);
         }
+        if(null!=projectId){
+            queryWrapper.eq("project_id",projectId);
+        }
         queryWrapper.orderByDesc("create_time").last("limit 1");
         return this.getOne(queryWrapper);
     }

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

@@ -128,10 +128,11 @@ public class AiBytedanceAdvertiserStrategyController {
 			//复制功能 防止前端传id到后台
 			aiBytedanceAdvertiserStrategy.setId(null);
 			// 组名称 计划名称 是否重复
-			Result<AiBytedanceAdvertiserStrategy> resultName = aiBytedanceAdvertiserStrategyService.getStrategyInfoByName(aiBytedanceAdvertiserStrategy);
+			/*Result<AiBytedanceAdvertiserStrategy> resultName = aiBytedanceAdvertiserStrategyService.getStrategyInfoByName(aiBytedanceAdvertiserStrategy);
 			if (!resultName.isSuccess()) {
 				return Result.error(resultName.getMessage());
-			}
+			}*/
+
 			return aiBytedanceAdvertiserStrategyService.addBytedanceStrategy(aiBytedanceAdvertiserStrategy);
 		} catch (Exception e) {
 			log.error(e.getMessage(),e);
@@ -148,10 +149,12 @@ public class AiBytedanceAdvertiserStrategyController {
 	@PutMapping(value = "/edit")
 	public Result<AiBytedanceAdvertiserStrategy> edit(@RequestBody AiBytedanceAdvertiserStrategy aiBytedanceAdvertiserStrategy) {
 		// 组名称 计划名称 是否重复
+		/*
 		Result<AiBytedanceAdvertiserStrategy> resultName = aiBytedanceAdvertiserStrategyService.getStrategyInfoByName(aiBytedanceAdvertiserStrategy);
 		if (!resultName.isSuccess()) {
 			return Result.errorMsg(resultName.getMessage());
 		}
+		*/
 		CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(aiBytedanceAdvertiserStrategy.getAccountId()));
 		//修改后预算金额不能低于当前已消费金额的105%
 		QueryWrapper<RuleDataAccount> ruleDataAccountQueryWrapper = new QueryWrapper<>();
@@ -278,10 +281,9 @@ public class AiBytedanceAdvertiserStrategyController {
 	@PutMapping(value = "/updStaById")
 	public Result updStaById(@RequestParam("id")String id,
 							 @ApiParam("状态(0开-1关)") @RequestParam("state") String state,
-							 @ApiParam("账户id") @RequestParam("accountId") String accountId,
-							 @ApiParam("素材类型") @RequestParam("creativeImageMode") String creativeImageMode) {
+							 @ApiParam("账户id") @RequestParam("accountId") String accountId) {
 		try {
-			return aiBytedanceAdvertiserStrategyService.updStaById(id,state,accountId,creativeImageMode);
+			return aiBytedanceAdvertiserStrategyService.updStaById(id,state,accountId);
 		}catch (Exception e){
 			log.error("修改状态(0开-1关)失败",e);
 			return Result.error("请求失败,请联系开发人员!");