Bläddra i källkod

Merge remote-tracking branch 'origin/test'

songyh 4 år sedan
förälder
incheckning
2f4258b160
30 ändrade filer med 981 tillägg och 223 borttagningar
  1. 1 1
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/dockapi/MarketingServiceImpl.java
  2. 108 0
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/ByteDanceCreativeWordPackage.java
  3. 13 0
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/ByteDanceGeneralCopywriter.java
  4. 13 1
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/BytedanceVideoSlogenInfo.java
  5. 4 1
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/ByteDanceGeneralCopywriterMapper.java
  6. 3 1
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/BytedanceVideoSlogenInfoMapper.java
  7. 3 0
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/ByteDanceAdvertisePlanMapper.xml
  8. 24 10
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/ByteDanceGeneralCopywriterMapper.xml
  9. 95 18
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/BytedanceVideoSlogenInfoMapper.xml
  10. 4 1
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/IByteDanceGeneralCopywriterService.java
  11. 2 2
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/IBytedanceVideoSlogenInfoService.java
  12. 62 4
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/AiBytedanceAdvertiserStrategyServiceImpl.java
  13. 59 21
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/ByteDanceGeneralCopywriterServiceImpl.java
  14. 31 10
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/BytedanceVideoSlogenInfoServiceImpl.java
  15. 3 0
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/entity/MaterialInfo.java
  16. 3 7
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/mapper/xml/UserAllocationMapper.xml
  17. 3 0
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/service/IMaterialInfoService.java
  18. 8 2
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/service/impl/MaterialInfoServiceImpl.java
  19. 12 4
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/utils/ExcelUtil.java
  20. 39 0
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/utils/GetCampaignNum.java
  21. 37 0
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/utils/StringUtils.java
  22. 6 2
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/entity/vo/ReportCostVo.java
  23. 11 0
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/mapper/BytedanceAdvertiserHourlyReportMapper.java
  24. 146 9
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/mapper/xml/BytedanceAdvertiserHourlyReportMapper.xml
  25. 5 5
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/mapper/xml/BytedanceReportMaterialDailyMapper.xml
  26. 130 86
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/service/impl/BytedanceAdvertiserHourlyReportServiceImpl.java
  27. 13 5
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/service/impl/BytedanceReportMaterialDailyServiceImpl.java
  28. 65 19
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/BytedanceGeneralCopywriterController.java
  29. 50 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/BytedanceReportController.java
  30. 28 9
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/BytedanceVideoSlogenInfoController.java

+ 1 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/dockapi/MarketingServiceImpl.java

@@ -524,7 +524,7 @@ public class MarketingServiceImpl implements MarketingService{
             log.error("广告计划更新状态接口异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
             return Result.error("广告计划更新状态接口异常");
         }
-        return Result.successMsg("广告状态修改成功",jsonObject.getString("data"));
+        return Result.successMsg("广告计划状态修改成功",jsonObject.getString("data"));
     }
 
 

+ 108 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/ByteDanceCreativeWordPackage.java

@@ -0,0 +1,108 @@
+package org.jeecg.modules.bytedance.advertise.entity;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+@Data
+@TableName("ctop_bytedance_creative_word_package")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_bytedance_creative_word_package对象", description = "今日头条创意词包")
+public class ByteDanceCreativeWordPackage {
+
+
+    /**id*/
+    @TableId(type = IdType.UUID)
+    @ApiModelProperty(value = "id")
+    private Integer id;
+    /**creativeWordId*/
+    @Excel(name = "creativeWordId", width = 15)
+    @ApiModelProperty(value = "creativeWordId")
+    private Integer creativeWordId;
+    /**name*/
+    @Excel(name = "name", width = 15)
+    @ApiModelProperty(value = "name")
+    private String name;
+    /**defaultWord*/
+    @Excel(name = "defaultWord", width = 15)
+    @ApiModelProperty(value = "defaultWord")
+    private String defaultWord;
+    /**words*/
+    @Excel(name = "words", width = 15)
+    @ApiModelProperty(value = "words")
+    private Object words;
+    /**contentType*/
+    @Excel(name = "contentType", width = 15)
+    @ApiModelProperty(value = "contentType")
+    private String contentType;
+    /**maxWordLen*/
+    @Excel(name = "maxWordLen", width = 15)
+    @ApiModelProperty(value = "maxWordLen")
+    private Integer maxWordLen;
+    /**status*/
+    @Excel(name = "status", width = 15)
+    @ApiModelProperty(value = "status")
+    private String status;
+    /**userRate*/
+    @Excel(name = "userRate", width = 15)
+    @ApiModelProperty(value = "userRate")
+    private Float userRate;
+    /**createTime*/
+    @ApiModelProperty(value = "createTime")
+    private Date createTime;
+    /**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+
+
+
+    public ByteDanceCreativeWordPackage(){}
+
+    public ByteDanceCreativeWordPackage(JSONObject jsonObject){
+        int creativeWordId = jsonObject.getInteger("creative_word_id");
+        this.creativeWordId = creativeWordId;
+
+        int maxWordLen = jsonObject.getInteger("max_word_len");
+        this.maxWordLen = maxWordLen;
+
+        String name = jsonObject.getString("name");
+        if (null != name && !"".equals(name.trim())) {
+            this.name = name;
+        }
+
+        String defaultWord = jsonObject.getString("default_word");
+        if (null != defaultWord && !"".equals(defaultWord.trim())) {
+            this.defaultWord = defaultWord;
+        }
+
+        String words = jsonObject.getString("words");
+        if (null != words && !"".equals(words.trim())) {
+            this.words = words;
+        }
+
+        String contentType = jsonObject.getString("content_type");
+        if (null != contentType && !"".equals(contentType.trim())) {
+            this.contentType = contentType;
+        }
+
+        String status = jsonObject.getString("status");
+        if (null != status && !"".equals(status.trim())) {
+            this.status = status;
+        }
+
+        Float userRate = jsonObject.getFloat("user_rate");
+        this.userRate = userRate;
+    }
+
+
+}

+ 13 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/ByteDanceGeneralCopywriter.java

@@ -67,5 +67,18 @@ public class ByteDanceGeneralCopywriter {
 
 	}
 
+	public ByteDanceGeneralCopywriter(Long accountId, String textCopywriter, String creativeWordIds){
+		if (!Check.isNull(accountId)) {
+			this.accountId = accountId;
+		}
+
+		if(!Check.isNull(textCopywriter)){
+			this.textCopywriter = textCopywriter;
+		}
+
+		if(!Check.isNull(creativeWordIds)){
+			this.creativeWordIds = creativeWordIds;
+		}
+	}
 
 }

+ 13 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/BytedanceVideoSlogenInfo.java

@@ -35,7 +35,7 @@ public class BytedanceVideoSlogenInfo {
 	/**status*/
 	private Integer status;
 	private String creativeWordIds;
-
+	private Long projectId;
 	public BytedanceVideoSlogenInfo(String videoCode, String slogan, String userId) {
 		this.videoCode = videoCode;
 		this.slogan = slogan;
@@ -57,6 +57,18 @@ public class BytedanceVideoSlogenInfo {
 		this.creativeWordIds = creativeWordIds;
 	}
 
+	public BytedanceVideoSlogenInfo(Long projectId, String videoCode, String slogan, String userId, String creativeWordIds) {
+		this.videoCode = videoCode;
+		this.slogan = slogan;
+		this.createBy = userId;
+		this.updateBy = userId;
+		this.createTime = new Date();
+		this.updateTime = new Date();
+		this.status = 1;
+		this.creativeWordIds = creativeWordIds;
+		this.projectId = projectId;
+	}
+
 	public BytedanceVideoSlogenInfo() {
 	}
 }

+ 4 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/ByteDanceGeneralCopywriterMapper.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.bytedance.advertise.entity.ByteDanceCreativeWordPackage;
 import org.jeecg.modules.bytedance.advertise.entity.ByteDanceGeneralCopywriter;
 
 /**
@@ -13,5 +14,7 @@ import org.jeecg.modules.bytedance.advertise.entity.ByteDanceGeneralCopywriter;
  * @version V1.0
  */
 public interface ByteDanceGeneralCopywriterMapper extends BaseMapper<ByteDanceGeneralCopywriter> {
-    List<Map<String,Object>> selectGeneralCopywriterReport(String accountId, String keyWord, String startTime, String endTime);
+    List<Map<String,Object>> selectGeneralCopywriterReport(List<String> accountIds, String keyWord, String startTime, String endTime);
+
+    ByteDanceCreativeWordPackage selectCreativeWordPackageByName(String name);
 }

+ 3 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/BytedanceVideoSlogenInfoMapper.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.bytedance.advertise.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.swagger.models.auth.In;
 import org.jeecg.modules.bytedance.advertise.entity.BytedanceVideoSlogenInfo;
 
 import java.util.List;
@@ -13,5 +14,6 @@ import java.util.Map;
  * @version V1.0
  */
 public interface BytedanceVideoSlogenInfoMapper extends BaseMapper<BytedanceVideoSlogenInfo> {
-    List<Map<String,Object>> selectVideoSlogenReportByAccountIdAndTitle(String accountId, String keyWord, String startTime, String endTime);
+    List<Map<String,Object>> selectVideoSlogenReportByAccountIdAndTitle(List<String> projectIds, String keyWord, String startTime, String endTime);
+    List<String> getProjectByUserId(String userId);
 }

+ 3 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/ByteDanceAdvertisePlanMapper.xml

@@ -42,6 +42,9 @@
             <if test="bid != null">
                 bid = #{bid},
             </if>
+            <if test="cpaBid != null and cpaBid!=''">
+                cpa_bid = #{cpaBid},
+            </if>
         </set>
         where id = #{id}
     </update>

+ 24 - 10
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/ByteDanceGeneralCopywriterMapper.xml

@@ -2,27 +2,41 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.bytedance.advertise.mapper.ByteDanceGeneralCopywriterMapper">
     <select id="selectGeneralCopywriterReport" resultType="java.util.HashMap">
+
+
+
+
         SELECT
-            b.account_id,
-            d.creative_id,
-            a.text_copywriter,
-            count(*) AS creative_count,
-            sum(d.cost) AS sum_cost,
-            sum(d.show_num) AS sum_show_material,
-            sum(d.click) AS sum_click,
-            sum(d.show_num) AS sum_convert_material
+            a.account_id as accountId,
+            d.creative_id as creativeId,
+            a.text_copywriter AS textCopywriter,
+            count(*) AS creativeCount,
+            sum(d.cost) AS sumCost,
+            sum(d.show_num) AS sumShowMaterial,
+            sum(d.click) AS sumClick,
+            sum(d.show_num) AS sumConvertMaterial
         FROM
             ctop_bytedance_general_copywriter a
         LEFT JOIN ctop_bytedance_creative b ON a.text_copywriter = b.title and a.account_id = b.account_id
         LEFT JOIN ctop_bytedance_report_creative_daily d ON b.id = d.creative_id
         WHERE
-            b.account_id = #{accountId}
+            a.`status` = 0
             <if test="keyWord!=null and keyWord!=''">and a.text_copywriter like concat('%',#{keyWord},'%')</if>
             <if test="startTime!=null and startTime!=''">and STR_TO_DATE(d.stat_datetime,'%Y-%m-%d') &gt;= STR_TO_DATE(#{startTime},'%Y-%m-%d')</if>
             <if test="endTime!=null and endTime!=''">and STR_TO_DATE(d.stat_datetime,'%Y-%m-%d') &lt;= STR_TO_DATE(#{endTime},'%Y-%m-%d')</if>
-            AND a.`status` = 0
+        <if test="accountIds!=null and accountIds!=''">
+            AND a.account_id IN
+            <foreach item="item" index="index" collection="accountIds"
+                     open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
         GROUP BY
         a.text_copywriter
 
     </select>
+
+    <select id="selectCreativeWordPackageByName" resultType="org.jeecg.modules.bytedance.advertise.entity.ByteDanceCreativeWordPackage">
+        select * from ctop_bytedance_creative_word_package where name = #{name}
+    </select>
 </mapper>

+ 95 - 18
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/BytedanceVideoSlogenInfoMapper.xml

@@ -4,8 +4,8 @@
     <select id="selectVideoSlogenReportByAccountIdAndTitle" resultType="java.util.HashMap">
 
         SELECT
-            b.account_id as accountId,
-            a.slogan ,
+            a.slogan,
+            a.project_id AS projectId,
             count(*) AS count,
             sum(d.cost) AS cost,
             sum(d.show_num) AS showNum,
@@ -14,26 +14,103 @@
         FROM
             ctop_bytedance_video_slogen_info a
         LEFT JOIN (
-            SELECT
-                t1.id,
-                t1.title,
-                t2.signature,
-                t1.account_id
-            FROM
-                ctop_bytedance_creative t1
-            LEFT JOIN ctop_bytedance_video_info t2 ON t1.video_id = t2.vid AND t1.account_id = t2.account_id
-            where t1.account_id = #{accountId}
-        ) b ON a.slogan = b.title AND a.video_code = b.signature
+        SELECT
+            t1.id,
+            t1.title,
+            t2.signature,
+            t1.account_id
+        FROM
+        (
+        SELECT
+            cbc.*
+        FROM
+            ctop_bytedance_creative cbc
+        WHERE
+        account_id IN (
+        SELECT
+        CONCAT(
+        ctop_user_allocation.account_id,
+        ''
+        )
+        FROM
+        ctop_user_allocation
+        WHERE
+        1=1
+        <if test="projectIds!=null">
+            AND project_id IN
+            <foreach item="item" index="index" collection="projectIds"
+                     open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        )
+        ) t1
+        LEFT JOIN (
+        SELECT
+        cbvi.*
+        FROM
+        ctop_bytedance_video_info cbvi
+        WHERE
+        account_id IN (
+        SELECT
+        ctop_user_allocation.account_id
+        FROM
+        ctop_user_allocation
+        WHERE
+        1=1
+        <if test="projectIds!=null">
+            AND project_id IN
+            <foreach item="item" index="index" collection="projectIds"
+                     open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        )
+        ) t2 ON t1.video_id = t2.vid
+        AND t1.account_id = t2.account_id
+        LEFT JOIN ctop_user_allocation cua ON cua.account_id = t1.account_id
+        WHERE
+        1=1
+        <if test="projectIds!=null">
+            AND cua.project_id IN
+            <foreach item="item" index="index" collection="projectIds"
+                     open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        ) b ON a.slogan = b.title
+        AND a.video_code = b.signature
         LEFT JOIN ctop_bytedance_report_creative_daily d ON b.id = d.creative_id
         WHERE
-            b.account_id = #{accountId}
-            <if test="keyWord!=null and keyWord!=''">and a.slogan like concat('%',#{keyWord},'%')</if>
-            <if test="startTime!=null and startTime!=''">and STR_TO_DATE(d.stat_datetime,'%Y-%m-%d') &gt;= STR_TO_DATE(#{startTime},'%Y-%m-%d')</if>
-            <if test="endTime!=null and endTime!=''">and STR_TO_DATE(d.stat_datetime,'%Y-%m-%d') &lt;= STR_TO_DATE(#{endTime},'%Y-%m-%d')</if>
-        AND a.`status` = 1
+        a.`status` = 1
+        <if test="keyWord!=null and keyWord!=''">and a.slogan like concat('%',#{keyWord},'%')</if>
+        <if test="startTime!=null and startTime != ''">and STR_TO_DATE(d.stat_datetime,'%Y-%m-%d') &gt;=
+            STR_TO_DATE(#{startTime},'%Y-%m-%d')
+        </if>
+        <if test="endTime!=null and endTime != ''">and STR_TO_DATE(d.stat_datetime,'%Y-%m-%d') &lt;=
+            STR_TO_DATE(#{endTime},'%Y-%m-%d')
+        </if>
+        <if test="projectIds!=null">
+            AND a.project_id IN
+            <foreach item="item" index="index" collection="projectIds"
+                     open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+
         GROUP BY
-            a.slogan
+        a.slogan
 
 
     </select>
+
+    <select id="getProjectByUserId" resultType="java.lang.String">
+        select
+            project.id
+        from
+            ctop_project_member member left join ctop_project project on project.id = member.project_id
+        where
+            member.user_id = #{userId}
+    </select>
+
 </mapper>

+ 4 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/IByteDanceGeneralCopywriterService.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.bytedance.advertise.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.bytedance.advertise.entity.ByteDanceCreativeWordPackage;
 import org.jeecg.modules.bytedance.advertise.entity.ByteDanceGeneralCopywriter;
 
 /**
@@ -11,5 +12,7 @@ import org.jeecg.modules.bytedance.advertise.entity.ByteDanceGeneralCopywriter;
  * @version V1.0
  */
 public interface IByteDanceGeneralCopywriterService extends IService<ByteDanceGeneralCopywriter> {
-    Result getGeneralCopywriterReport(String accountId, String keyWord, String startTime, String endTime, Integer pageNum, Integer pageSize);
+    Result getGeneralCopywriterReport(String userId, String accountId, String keyWord, String startTime, String endTime, Integer pageNum, Integer pageSize);
+
+    public ByteDanceCreativeWordPackage selectCreativeWordPackageByName(String name);
 }

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

@@ -15,9 +15,9 @@ import java.util.List;
  */
 public interface IBytedanceVideoSlogenInfoService extends IService<BytedanceVideoSlogenInfo> {
 
-    void insertSlogans(String videoCode, JSONArray slogans, String userId);
+    void insertSlogans(Long projectId, String videoCode, JSONArray slogans, String userId);
 
     List<BytedanceVideoSlogenInfo> listByParams(String code, Integer status);
 
-    Result getVideoSlogenReport(String accountId,String keyWord, String startTime, String endTime, Integer pageNum, Integer pageSize);
+    Result getVideoSlogenReport(String userId, String projectId,String keyWord, String startTime, String endTime, Integer pageNum, Integer pageSize);
 }

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

@@ -13,6 +13,7 @@ import org.jeecg.modules.bytedance.advertise.dockapi.MarketingService;
 import org.jeecg.modules.bytedance.advertise.entity.*;
 import org.jeecg.modules.bytedance.advertise.enums.BytedanceCreativeMatTypeEnum;
 import org.jeecg.modules.bytedance.advertise.mapper.AiBytedanceAdvertiserStrategyMapper;
+import org.jeecg.modules.bytedance.advertise.mapper.ByteDanceGeneralCopywriterMapper;
 import org.jeecg.modules.bytedance.advertise.mapper.BytedanceAreaInfoMapper;
 import org.jeecg.modules.bytedance.advertise.mapper.RuleDataAccountMapper;
 import org.jeecg.modules.bytedance.advertise.service.*;
@@ -27,6 +28,7 @@ import org.jeecg.modules.bytedance.common.entity.MaterialInfo;
 import org.jeecg.modules.bytedance.common.entity.UserAllocation;
 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.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -72,7 +74,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
     private IByteDanceVideoInfoService videoInfoService;
     @Autowired
     private MarketingService marketingService;
-
+    @Resource
+    ByteDanceGeneralCopywriterMapper byteDanceGeneralCopywriterMapper;
     @Override
     public Long createCreative(AiBytedanceAdvertiserStrategy strategy, Integer createType, Long videoCnt, String openUrl) {
         CtopOauthToken token = tokenService.getOauthTokenByAccountId(strategy.getAccountId()+"");
@@ -180,6 +183,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                     adDplinkInfo.setDpLinkIndex(adDplinkInfo.getDpLinkIndex()+1);
                 }
                 dpIndex = adDplinkInfo.getDpLinkIndex();
+                // 已创建计划 > 账户配置结束下标
                 if(dpIndex>strategy.getDpLinkEndIndex()){
                     log.info("此账户策略创建结束=>账户id:{};策略id:{}", token.getAccountId(),strategy.getId());
                     return 0L;
@@ -283,9 +287,25 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         imageArray.add(imageObject);
         params.put("image_list",imageArray);
         JSONArray titleArray = new JSONArray();
-        List<BytedanceVideoSlogenInfo>slogenInfos = slogenInfoService.listByParams(videoInfo.getSignature(),1);
+        List<BytedanceVideoSlogenInfo> slogenInfos = slogenInfoService.listByParams(videoInfo.getSignature(),1);
         if(!Check.isNull(slogenInfos)){
-            slogenInfos.forEach(slogenInfo->{
+//            slogenInfos.forEach(slogenInfo->{
+////                JSONObject titleObject = new JSONObject();
+////                titleObject.put("title",slogenInfo.getSlogan());
+////                String creativeWordsIds = slogenInfo.getCreativeWordIds();
+////                if(null!=creativeWordsIds&&!creativeWordsIds.trim().equals("")){
+////                    JSONArray creativeWordsArray = JSON.parseArray(creativeWordsIds);
+////                    if(null!=creativeWordsArray&&!creativeWordsArray.isEmpty()){
+////                        titleObject.put("creative_word_ids",creativeWordsArray);
+////                    }
+////                }
+////                titleArray.add(titleObject);
+////            });
+
+            for (BytedanceVideoSlogenInfo slogenInfo:slogenInfos) {
+                if(titleArray.size() >= 10){    //接口中是要求一个视频最多10个标题
+                    break;
+                }
                 JSONObject titleObject = new JSONObject();
                 titleObject.put("title",slogenInfo.getSlogan());
                 String creativeWordsIds = slogenInfo.getCreativeWordIds();
@@ -296,7 +316,29 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                     }
                 }
                 titleArray.add(titleObject);
-            });
+            }
+            for(int i = 0; i < 3; i++){
+                if(titleArray.size() >= 10){
+                    break;
+                }
+                QueryWrapper<ByteDanceGeneralCopywriter> queryWrapper = new QueryWrapper<>();
+                queryWrapper.eq("account_id",strategy.getAccountId());
+                ByteDanceGeneralCopywriter byteDanceGeneralCopywriter = byteDanceGeneralCopywriterMapper.selectOne(queryWrapper);
+                if(!Check.isNull(byteDanceGeneralCopywriter)){
+                    JSONObject titleObject = new JSONObject();
+                    titleObject.put("title",byteDanceGeneralCopywriter.getTextCopywriter());
+                    String creativeWordsIds = byteDanceGeneralCopywriter.getCreativeWordIds();
+                    if(null!=creativeWordsIds&&!creativeWordsIds.trim().equals("")){
+                        JSONArray creativeWordsArray = JSON.parseArray(creativeWordsIds);
+                        if(null!=creativeWordsArray&&!creativeWordsArray.isEmpty()){
+                            titleObject.put("creative_word_ids",creativeWordsArray);
+                        }
+                    }
+                    titleArray.add(titleObject);
+                }
+
+            }
+
         }
         if(!Check.isNull(titleArray)){
             params.put("title_list",titleArray);
@@ -881,6 +923,10 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 adName = adName.replace("{{素材名称}}",info.getMaterialName());
             }
         }
+        if(adName.contains("{{序号}}")){
+            int i = adDplinkInfoService.getDpLinkInfoCount(strategy.getAccountId());
+            adName = adName.replace("{{序号}}",String.valueOf(i+1));
+        }
 
         adName = adName.replace("--","-");
         if(adName.startsWith("-")){
@@ -944,6 +990,18 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
             result = result + "-" + date;
         }
 
+        if(result.contains("{{序号}}")){
+            //查询当天已有计划数量
+            int i = adDplinkInfoService.getDpLinkInfoCount(strategy.getAccountId());
+            Long num = GetCampaignNum.getCampaignNameNum(strategy.getCampaignCnt(),strategy.getCampaignAdCnt(),i);
+            result = result.replace("{{序号}}",String.valueOf(num));
+        }
+
+        if(result.contains("{{日期}}")){
+            String time = DateUtils.formatDate(new Date(),"yyyyMMdd");
+            result = result.replace("{{日期}}",time);
+        }
+
         result = result.replace("--","-");
         if(result.startsWith("-")){
             result = result.substring(1);

+ 59 - 21
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/ByteDanceGeneralCopywriterServiceImpl.java

@@ -1,20 +1,26 @@
 package org.jeecg.modules.bytedance.advertise.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import org.apache.commons.lang3.StringUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.bytedance.advertise.entity.ByteDanceCreativeWordPackage;
 import org.jeecg.modules.bytedance.advertise.entity.ByteDanceGeneralCopywriter;
 import org.jeecg.modules.bytedance.advertise.mapper.ByteDanceGeneralCopywriterMapper;
 import org.jeecg.modules.bytedance.advertise.mapper.BytedanceVideoSlogenInfoMapper;
 import org.jeecg.modules.bytedance.advertise.service.IByteDanceGeneralCopywriterService;
+import org.jeecg.modules.bytedance.common.service.IUserAllocationService;
 import org.jeecg.modules.bytedance.common.utils.Check;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -28,55 +34,87 @@ import java.util.Map;
 public class ByteDanceGeneralCopywriterServiceImpl extends ServiceImpl<ByteDanceGeneralCopywriterMapper, ByteDanceGeneralCopywriter> implements IByteDanceGeneralCopywriterService {
     @Resource
     ByteDanceGeneralCopywriterMapper byteDanceGeneralCopywriterMapper;
-
+    @Autowired
+    IUserAllocationService IUserAllocationService;
 
     @Override
-    public Result getGeneralCopywriterReport(String accountId, String keyWord, String startTime, String endTime, Integer pageNum, Integer pageSize){
+    public Result getGeneralCopywriterReport(String userId, String accountId, String keyWord, String startTime, String endTime, Integer pageNum, Integer pageSize){
         PageHelper.startPage(pageNum,pageSize);
-        List<Map<String, Object>> generalCopywriteReportList = byteDanceGeneralCopywriterMapper.selectGeneralCopywriterReport(accountId,keyWord, startTime, endTime);
+
+        List<String> accountIds = new ArrayList<>();
+        //查询普通用户的全量查询,当前用户所有项目
+        if(Check.isNull(accountId)){
+            List<JSONObject> jsonObjectList = IUserAllocationService.getAccountIdsByUserId(userId);
+            if(!Check.isNull(jsonObjectList)){
+                for (JSONObject jsonObject:jsonObjectList) {
+                    accountIds.add(jsonObject.getString("account_id"));
+                }
+            }else{
+                return Result.successMsg("当前登录人未绑定账户","");
+            }
+
+        }else if(accountId == "admin"){//管理员的全量查询
+            accountIds = null;
+        }else { //不论什么权限的用户的单独搜索一个项目
+            accountIds.add(accountId);
+        }
+
+
+        List<Map<String, Object>> generalCopywriteReportList = byteDanceGeneralCopywriterMapper.selectGeneralCopywriterReport(accountIds,keyWord, startTime, endTime);
         if(Check.isNull(generalCopywriteReportList)){
-            return Result.error("还没有此文案报表数据,请将此文案投放跑量!");
+            return Result.successMsg("还没有此文案报表数据,请将此文案投放跑量!",generalCopywriteReportList);
         }
 
-        for (Map<String, Object> videoSlogenReportMap: generalCopywriteReportList) {
+        for (Map<String, Object> generalCopywriteReportMap: generalCopywriteReportList) {
 
-            if(videoSlogenReportMap.get("count") == null){
-                videoSlogenReportMap.put("count",0);
+            if(generalCopywriteReportMap.get("count") == null){
+                generalCopywriteReportMap.put("count",0);
             }
 
-            BigDecimal cost = new BigDecimal(Check.isNull(videoSlogenReportMap.get("cost")) ? "0" : videoSlogenReportMap.get("cost").toString());
-            BigDecimal click = new BigDecimal(Check.isNull(videoSlogenReportMap.get("click")) ? "0" : videoSlogenReportMap.get("click").toString());
-            BigDecimal showNum = new BigDecimal(Check.isNull(videoSlogenReportMap.get("showNum")) ? "0" : videoSlogenReportMap.get("showNum").toString());
-            BigDecimal convertNum = new BigDecimal(Check.isNull(videoSlogenReportMap.get("convertNum")) ? "0" : videoSlogenReportMap.get("convertNum").toString());
+            BigDecimal cost = new BigDecimal(Check.isNull(generalCopywriteReportMap.get("cost")) ? "0" : generalCopywriteReportMap.get("cost").toString());
+            BigDecimal click = new BigDecimal(Check.isNull(generalCopywriteReportMap.get("click")) ? "0" : generalCopywriteReportMap.get("click").toString());
+            BigDecimal showNum = new BigDecimal(Check.isNull(generalCopywriteReportMap.get("showNum")) ? "0" : generalCopywriteReportMap.get("showNum").toString());
+            BigDecimal convertNum = new BigDecimal(Check.isNull(generalCopywriteReportMap.get("convertNum")) ? "0" : generalCopywriteReportMap.get("convertNum").toString());
+
+            DecimalFormat decimalFormat = new DecimalFormat("0.00#");
+            generalCopywriteReportMap.put("cost", decimalFormat.format(cost));
+            generalCopywriteReportMap.put("click", click);
+            generalCopywriteReportMap.put("showNum", showNum);
+            generalCopywriteReportMap.put("convertNum", convertNum);
 
             //被除数不能为0
             if (StringUtils.equals("0",showNum.toString())){
-                videoSlogenReportMap.put("costPerThousandShow", 0);
-                videoSlogenReportMap.put("clickRate", 0);
+                generalCopywriteReportMap.put("costPerThousandShow", 0);
+                generalCopywriteReportMap.put("clickRate", 0);
             }else {
                 BigDecimal costPerThousandShow = cost.multiply(new BigDecimal(1000)).divide(showNum, 2, BigDecimal.ROUND_HALF_UP);
-                videoSlogenReportMap.put("costPerThousandShow", costPerThousandShow);
+                generalCopywriteReportMap.put("costPerThousandShow", decimalFormat.format(costPerThousandShow));
                 BigDecimal clickRate = click.multiply(new BigDecimal(100)).divide(showNum, 2, BigDecimal.ROUND_HALF_UP);
-                videoSlogenReportMap.put("clickRate", clickRate);
+                generalCopywriteReportMap.put("clickRate", decimalFormat.format(clickRate));
             }
             if (StringUtils.equals("0", convertNum.toString())) {
-                videoSlogenReportMap.put("costConvert", 0);
+                generalCopywriteReportMap.put("costConvert", 0);
             }else {
                 BigDecimal costConvert = cost.divide(convertNum, 2, BigDecimal.ROUND_HALF_UP);
-                videoSlogenReportMap.put("costConvert", costConvert);
+                generalCopywriteReportMap.put("costConvert", decimalFormat.format(costConvert));
             }
             if (StringUtils.equals("0", click.toString())) {
-                videoSlogenReportMap.put("costPerClick", 0);
-                videoSlogenReportMap.put("convertRate", 0);
+                generalCopywriteReportMap.put("costPerClick", 0);
+                generalCopywriteReportMap.put("convertRate", 0);
             }else {
                 BigDecimal costPerClick = cost.divide(click, 2, BigDecimal.ROUND_HALF_UP);
-                videoSlogenReportMap.put("costPerClick", costPerClick);
+                generalCopywriteReportMap.put("costPerClick", decimalFormat.format(costPerClick));
                 BigDecimal convertRate = convertNum.multiply(new BigDecimal(100)).divide(click,2,BigDecimal.ROUND_HALF_UP);
-                videoSlogenReportMap.put("convertRate", convertRate);
+                generalCopywriteReportMap.put("convertRate", decimalFormat.format(convertRate));
             }
         }
 
         PageInfo<Map<String, Object>> pageInfo = new PageInfo<Map<String, Object>>(generalCopywriteReportList);
         return Result.successMsg("数据加载成功。",pageInfo);
     }
+    @Override
+    public ByteDanceCreativeWordPackage selectCreativeWordPackageByName(String name){
+        return byteDanceGeneralCopywriterMapper.selectCreativeWordPackageByName(name);
+    }
+
 }

+ 31 - 10
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/BytedanceVideoSlogenInfoServiceImpl.java

@@ -16,6 +16,8 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -30,16 +32,19 @@ public class BytedanceVideoSlogenInfoServiceImpl extends ServiceImpl<BytedanceVi
     @Resource
     BytedanceVideoSlogenInfoMapper bytedanceVideoSlogenInfoMapper;
 
+
     @Override
-    public void insertSlogans(String videoCode, JSONArray slogans,String userId){
+    public void insertSlogans(Long projectId, String videoCode, JSONArray slogans,String userId){
         if(null==slogans||slogans.isEmpty()){
             return;
         }
         for(int i=0;i<slogans.size();i++){
             JSONObject sloganObject = slogans.getJSONObject(i);
             String title = sloganObject.getString("title");
+            title = title.replaceAll("\\{\\{","{");
+            title = title.replaceAll("\\}\\}","}");
             String creativeWordIds = Check.isNull(sloganObject.getJSONArray("creative_word_ids")) ? "" : sloganObject.getJSONArray("creative_word_ids").toJSONString();
-            BytedanceVideoSlogenInfo slogenInfo = new BytedanceVideoSlogenInfo(videoCode,title,userId,creativeWordIds);
+            BytedanceVideoSlogenInfo slogenInfo = new BytedanceVideoSlogenInfo(projectId,videoCode,title,userId,creativeWordIds);
             this.save(slogenInfo);
         }
     }
@@ -57,12 +62,22 @@ public class BytedanceVideoSlogenInfoServiceImpl extends ServiceImpl<BytedanceVi
         return this.list(queryWrapper);
     }
     @Override
-    public Result getVideoSlogenReport(String accountId,String keyWord, String startTime, String endTime, Integer pageNum, Integer pageSize){
+    public Result getVideoSlogenReport(String userId, String projectId,String keyWord, String startTime, String endTime, Integer pageNum, Integer pageSize){
         PageHelper.startPage(pageNum,pageSize);
-        List<Map<String, Object>> videoSlogenReportList = bytedanceVideoSlogenInfoMapper.selectVideoSlogenReportByAccountIdAndTitle(accountId,keyWord, startTime, endTime);
+        List<String> projectIdList = new ArrayList<>();
+        //查询普通用户的全量查询,当前用户所有项目
+        if(Check.isNull(projectId)){
+            projectIdList = bytedanceVideoSlogenInfoMapper.getProjectByUserId(userId);
+        }else if(projectId == "admin"){//管理员的全量查询
+            projectIdList = null;
+        }else { //不论什么权限的用户的单独搜索一个项目
+            projectIdList.add(projectId);
+        }
+
+        List<Map<String, Object>> videoSlogenReportList = bytedanceVideoSlogenInfoMapper.selectVideoSlogenReportByAccountIdAndTitle(projectIdList, keyWord, startTime, endTime);
 
         if(Check.isNull(videoSlogenReportList)){
-            return Result.error("还没有此文案报表数据,请将此文案投放跑量!");
+            return Result.successMsg("还没有此文案报表数据,请将此文案投放跑量!",videoSlogenReportList);
         }
 
         for (Map<String, Object> videoSlogenReportMap: videoSlogenReportList) {
@@ -75,30 +90,36 @@ public class BytedanceVideoSlogenInfoServiceImpl extends ServiceImpl<BytedanceVi
             BigDecimal showNum = new BigDecimal(Check.isNull(videoSlogenReportMap.get("showNum")) ? "0" : videoSlogenReportMap.get("showNum").toString());
             BigDecimal convertNum = new BigDecimal(Check.isNull(videoSlogenReportMap.get("convertNum")) ? "0" : videoSlogenReportMap.get("convertNum").toString());
 
+            DecimalFormat decimalFormat = new DecimalFormat("0.00#");
+            videoSlogenReportMap.put("cost", decimalFormat.format(cost));
+            videoSlogenReportMap.put("click", click);
+            videoSlogenReportMap.put("showNum", showNum);
+            videoSlogenReportMap.put("convertNum", convertNum);
+
             //被除数不能为0
             if (StringUtils.equals("0",showNum.toString())){
                 videoSlogenReportMap.put("costPerThousandShow", 0);
                 videoSlogenReportMap.put("clickRate", 0);
             }else {
                 BigDecimal costPerThousandShow = cost.multiply(new BigDecimal(1000)).divide(showNum, 2, BigDecimal.ROUND_HALF_UP);
-                videoSlogenReportMap.put("costPerThousandShow", costPerThousandShow);
+                videoSlogenReportMap.put("costPerThousandShow", decimalFormat.format(costPerThousandShow));
                 BigDecimal clickRate = click.multiply(new BigDecimal(100)).divide(showNum, 2, BigDecimal.ROUND_HALF_UP);
-                videoSlogenReportMap.put("clickRate", clickRate);
+                videoSlogenReportMap.put("clickRate", decimalFormat.format(clickRate));
             }
             if (StringUtils.equals("0", convertNum.toString())) {
                 videoSlogenReportMap.put("costConvert", 0);
             }else {
                 BigDecimal costConvert = cost.divide(convertNum, 2, BigDecimal.ROUND_HALF_UP);
-                videoSlogenReportMap.put("costConvert", costConvert);
+                videoSlogenReportMap.put("costConvert", decimalFormat.format(costConvert));
             }
             if (StringUtils.equals("0", click.toString())) {
                 videoSlogenReportMap.put("costPerClick", 0);
                 videoSlogenReportMap.put("convertRate", 0);
             }else {
                 BigDecimal costPerClick = cost.divide(click, 2, BigDecimal.ROUND_HALF_UP);
-                videoSlogenReportMap.put("costPerClick", costPerClick);
+                videoSlogenReportMap.put("costPerClick", decimalFormat.format(costPerClick));
                 BigDecimal convertRate = convertNum.multiply(new BigDecimal(100)).divide(click,2,BigDecimal.ROUND_HALF_UP);
-                videoSlogenReportMap.put("convertRate", convertRate);
+                videoSlogenReportMap.put("convertRate", decimalFormat.format(convertRate));
             }
         }
 

+ 3 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/entity/MaterialInfo.java

@@ -163,4 +163,7 @@ public class MaterialInfo {
     //视频关联广告语信息--头条
     @TableField(exist = false)
     private JSONArray slogans;
+
+    @TableField(exist = false)
+    private JSONArray materialIds;
 }

+ 3 - 7
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/mapper/xml/UserAllocationMapper.xml

@@ -85,15 +85,11 @@
 
     <select id="getAccountIdsByUserId" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
-            allocation.account_id,
-            allocation.auth_name,
-            project.project_name as project_name
+            allocation.account_id
         FROM
+
             ctop_user_allocation allocation
-            left join ctop_project project on allocation.project_id = project.id
-        WHERE
-            allocation.user_id = #{userId}
-          and allocation.account_status=0
+            where 1 =1 and allocation.project_id in (select DISTINCT project_id from ctop_project_member where user_id = #{userId})
     </select>
 
 

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

@@ -19,4 +19,7 @@ public interface IMaterialInfoService extends IService<MaterialInfo> {
 
     Result updMaterialOfflineById(List<String> ids, Integer offlineFlag);
 
+
+    public MaterialInfo getDetilByMaterialId(String materialId);
+
 }

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

@@ -7,6 +7,7 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.bytedance.common.entity.MaterialInfo;
 import org.jeecg.modules.bytedance.common.mapper.MaterialInfoMapper;
 import org.jeecg.modules.bytedance.common.service.IMaterialInfoService;
+import org.jeecg.modules.bytedance.common.utils.Check;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -42,7 +43,6 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         return this.getOne(queryWrapper);
     }
 
-
     /**
      *
      * @description: 素材下线
@@ -60,7 +60,13 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         return Result.successMsg("素材下线成功。", null);
     }
 
-
+    @Override
+    public MaterialInfo getDetilByMaterialId(String materialId){
+        if(Check.isNull(materialId)){
+            return null;
+        }
+        return this.getById(materialId);
+    }
 }
 
 

+ 12 - 4
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/utils/ExcelUtil.java

@@ -54,12 +54,20 @@ public class ExcelUtil {
                     int lastCellNum = row.getPhysicalNumberOfCells();
 //          String[] cells = new String[row.getPhysicalNumberOfCells()];
                     //循环当前行
-                    for(int cellNum = firstCellNum; cellNum <= lastCellNum;cellNum++){
-                        Cell cell = row.getCell(cellNum);
-//            cells[cellNum] = getCellValue(cell);
-                        String cellValue = getCellValue(cell);
+                    String cellValue = getCellValue(row.getCell(firstCellNum));
+//                        String cellValue = getCellValue(cell);
+                    if(!Check.isNull(cellValue)){ //只要当前行的第一列
                         list.add(cellValue);
                     }
+//                    for(int cellNum = firstCellNum; cellNum <= lastCellNum;cellNum++){
+//                        Cell cell = row.getCell(cellNum);
+////            cells[cellNum] = getCellValue(cell);
+//                        String cellValue = getCellValue(row.getCell(firstCellNum));
+////                        String cellValue = getCellValue(cell);
+//                        if(!Check.isNull(cellValue)){
+//                            list.add(cellValue);
+//                        }
+//                    }
 
                 }
             }

+ 39 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/utils/GetCampaignNum.java

@@ -0,0 +1,39 @@
+package org.jeecg.modules.bytedance.common.utils;
+
+/**
+ * Administrator
+ * 2021/6/3
+ **/
+public class GetCampaignNum {
+
+
+    /**
+     *
+     * @param campaignCnt 组数量
+     * @param campaignAdCnt 每个组最大创建计划数
+     * @param countNum 当天已创建条数
+     * @return
+     */
+    public static Long getCampaignNameNum(int campaignCnt,Long campaignAdCnt, int countNum){
+/*
+        countNum = 61;
+        campaignAdCnt = 10L;
+        campaignCnt = 1;*/
+
+        Long zu = countNum / campaignAdCnt;
+        Long yu = countNum % campaignAdCnt;
+        System.out.println("余---"+yu);
+        // 不能整除 有余数 则 组 = 商 + 1
+        // 整除 组 = 商
+        Long count = yu != 0 ? zu.intValue()+1 : zu;
+       // 账户配置中的组数量 < 当前 组序号
+        if (count.intValue() < campaignCnt){
+            System.out.println("序号----------"+count);
+        }else {
+            System.out.println("序号-超过了最大值-----"+count);
+        }
+        return count;
+    }
+
+
+}

+ 37 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/utils/StringUtils.java

@@ -224,4 +224,41 @@ public class StringUtils {
         }
         return reuslt;
     }
+
+    public static int lengthAsSlogan(String a)  {
+        char[] c = a.toCharArray();
+        int count=0;
+        for (char d : c) {
+            Character.UnicodeBlock ub = Character.UnicodeBlock.of(d);
+            if (ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
+                    || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
+                    || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS
+                    || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_FORMS
+                    || ub == Character.UnicodeBlock.VERTICAL_FORMS
+                    || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
+                    || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
+                    || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
+                    || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C
+                    || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D
+                    || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
+                    || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT) {
+                count++;
+            }
+
+        }
+        BigDecimal strNum = new BigDecimal(count);
+        BigDecimal strlen = new BigDecimal(a.length());
+        BigDecimal res = strlen.subtract(strNum).divide(new BigDecimal(2),0, BigDecimal.ROUND_UP).add(strNum);
+        return res.intValue();
+    }
+
+    public static String replaceCreativeWordPackageText(String str){
+        int left = str.indexOf("{");
+        int right = str.indexOf("}");
+        if(left < 0){
+            return null;
+        }
+        String newStr = str.substring(left+1, right);
+        return newStr;
+    }
 }

+ 6 - 2
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/entity/vo/ReportCostVo.java

@@ -15,6 +15,7 @@ public class ReportCostVo implements Serializable {
     private String id;
     //花费
     private double cost;
+    private String costStr;
     //展示量
     private Integer showNum;
     //点击量
@@ -34,9 +35,9 @@ public class ReportCostVo implements Serializable {
     //计划名称
     private String adName;
     //出价 - 目标转化出价
-    private BigDecimal cpaBid;
+    private String cpaBid;
     // 出价
-    private BigDecimal Bid;
+    private String Bid;
     //平均千次展显费用 = 总花费/展示数 * 1000
     private String averageShow;
     //平均点击单价 = 花费 / 点击数
@@ -56,5 +57,8 @@ public class ReportCostVo implements Serializable {
     //操作状态
     private String optStatus;
 
+    //计划预算
+    private BigDecimal adBudget;
+
 
 }

+ 11 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/mapper/BytedanceAdvertiserHourlyReportMapper.java

@@ -20,12 +20,23 @@ public interface BytedanceAdvertiserHourlyReportMapper extends BaseMapper<Byteda
 
 
     List<ReportCostVo> getReportCostInfo(@Param("accountId") String accountId, @Param("startTime") String startTime, @Param("endTime") String endTime);
+
+    //账户日报 数据
+    List<ReportCostVo> selectPlanCostInfoCount(@Param("accountId") String accountId, @Param("planId") String planId, @Param("startTime") String startTime, @Param("endTime") String endTime);
+    //账户 时报
     List<ReportCostVo> getReportCostInfoStage(@Param("accountId") String accountId, @Param("startTime") String startTime, @Param("endTime") String endTime);
+    //查询上阶段 同时间点的 日报 数据信息
+    List<ReportCostVo> getReportCostInfoStageLast(@Param("accountId") String accountId, @Param("startTime") String startTime, @Param("endTime") String endTime,@Param("statHour") String statHour);
 
     Map<String,Object> selAcountIdCostMax(@Param("userId") String userId, @Param("type") String type);
 
     Map<String,Object> selectAccountCost(@Param("accountId") String accountId);
 
+    //计划日报
+    List<ReportCostVo> selectReportPlanCostInfoDay(@Param("accountId") String accountId, @Param("planId") String planId, @Param("startTime") String startTime, @Param("endTime") String endTime);
+    //计划 时报
     List<ReportCostVo> selectReportPlanCostInfo(@Param("accountId") String accountId, @Param("planId") String planId, @Param("startTime") String startTime, @Param("endTime") String endTime);
+    //查询上阶段 同时间点的 日报 数据信息
+    List<ReportCostVo> selectReportPlanCostHourLast(@Param("accountId") String accountId,@Param("planId") String planId,@Param("startTime") String startTime, @Param("endTime") String endTime,@Param("statHour") Integer statHour);
 
 }

+ 146 - 9
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/mapper/xml/BytedanceAdvertiserHourlyReportMapper.xml

@@ -31,7 +31,7 @@
 
     </select>
 
-    <!-- 阶段 查询  账户时报数据信息 -->
+    <!-- 查询  账户时报 数据信息 -->
     <select id="getReportCostInfoStage" resultType="org.jeecg.modules.bytedance.report.entity.vo.ReportCostVo">
         SELECT
             id,
@@ -39,20 +39,60 @@
             SUM(show_num) AS showNum,
             SUM(click) AS click,
             SUM(convert_num) AS convertNum,
-            SUM(stat_hour) AS statHour,
             stat_datetime,
-            stat_datetime AS time,
+            stat_hour AS time,
+            create_time
+        FROM
+            ctop_bytedance_report_advertiser_hourly
+        WHERE 1 = 1
+        <if test="accountId !=null and accountId != ''">
+            AND advertiser_id = #{accountId}
+        </if>
+        <if test="startTime !=null and startTime != ''">
+            AND stat_datetime &gt;= #{startTime}
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            AND stat_datetime &lt;= #{endTime}
+        </if>
+        GROUP BY
+            stat_hour
+        ORDER BY
+            stat_datetime,
+            stat_hour
+    </select>
+
+    <!-- 查询  账户时报  时间点截至 数据信息 -->
+    <select id="getReportCostInfoStageLast" resultType="org.jeecg.modules.bytedance.report.entity.vo.ReportCostVo">
+        SELECT
+            id,
+            SUM(cost) AS cost,
+            SUM(show_num) AS showNum,
+            SUM(click) AS click,
+            SUM(convert_num) AS convertNum,
+            stat_datetime,
+            stat_hour AS time,
             create_time
         FROM
             ctop_bytedance_report_advertiser_hourly
         WHERE
-            advertiser_id = #{accountId}
+        1 = 1
+        <if test="accountId !=null and accountId != ''">
+            AND advertiser_id = #{accountId}
+        </if>
+        <if test="startTime !=null and startTime != ''">
             AND stat_datetime &gt;= #{startTime}
+        </if>
+        <if test="endTime !=null and endTime != ''">
             AND stat_datetime &lt;= #{endTime}
+        </if>
+        <if test="statHour !=null and statHour != ''">
+            AND stat_hour &lt;= #{statHour}
+        </if>
         GROUP BY
-            stat_datetime
+            stat_hour
         ORDER BY
-            stat_datetime
+            stat_datetime,
+            stat_hour
     </select>
 
 <!-- 查询用户下 花费最高的 账户-->
@@ -108,6 +148,35 @@
         ad_id,
         ad_name,
         create_time,
+        update_time,
+        MAX(stat_hour) as statHour
+        FROM
+        ctop_bytedance_report_plan_hourly
+        where 1 =1
+        <if test="accountId !=null and accountId != ''">
+            and advertiser_id = #{accountId}
+        </if>
+        <if test="planId !=null and planId != ''">
+            and ad_id = #{planId}
+        </if>
+        <if test="startTime !=null and startTime != ''">
+            and DATE_FORMAT(stat_datetime,'%Y-%m-%d') &gt;= #{startTime}
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            and DATE_FORMAT(stat_datetime,'%Y-%m-%d') &lt;= #{endTime}
+        </if>
+         GROUP BY ad_id
+        ORDER BY cost DESC
+
+    </select>
+<!-- 查询  上阶段 计划时报 数据-->
+    <select id="selectReportPlanCostHourLast" resultType="org.jeecg.modules.bytedance.report.entity.vo.ReportCostVo">
+        SELECT
+        stat_datetime,
+        sum(cost) AS cost,
+        ad_id,
+        ad_name,
+        create_time,
         update_time
         FROM
         ctop_bytedance_report_plan_hourly
@@ -119,12 +188,80 @@
             and ad_id = #{planId}
         </if>
         <if test="startTime !=null and startTime != ''">
-            and stat_datetime &gt;= #{startTime}
+            and DATE_FORMAT(stat_datetime,'%Y-%m-%d') &gt;= #{startTime}
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            and DATE_FORMAT(stat_datetime,'%Y-%m-%d') &lt;= #{endTime}
+        </if>
+        <if test="statHour !=null and statHour != ''">
+            and stat_hour &lt;= #{statHour}
+        </if>
+         GROUP BY ad_id
+        ORDER BY cost DESC
+
+    </select>
+
+<!-- 查询 计划日报 数据-->
+    <select id="selectReportPlanCostInfoDay" resultType="org.jeecg.modules.bytedance.report.entity.vo.ReportCostVo">
+        SELECT
+        stat_datetime,
+        sum(show_num) AS showNum,
+        sum(click) AS click,
+        sum(convert_num) AS convertNum,
+        sum(cost) AS cost,
+        ad_id,
+        ad_name,
+        create_time,
+        update_time
+        FROM
+        ctop_bytedance_report_plan_daily
+        where 1 =1
+        <if test="accountId !=null and accountId != ''">
+            and advertiser_id = #{accountId}
+        </if>
+        <if test="planId !=null and planId != ''">
+            and ad_id = #{planId}
+        </if>
+        <if test="startTime !=null and startTime != ''">
+            and DATE_FORMAT(stat_datetime,'%Y-%m-%d') &gt;= #{startTime}
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            and DATE_FORMAT(stat_datetime,'%Y-%m-%d') &lt;= #{endTime}
+        </if>
+        group BY ad_id
+        ORDER BY cost DESC
+
+    </select>
+
+
+
+    <!-- 查询 账户日报 数据 数据-->
+    <select id="selectPlanCostInfoCount" resultType="org.jeecg.modules.bytedance.report.entity.vo.ReportCostVo">
+        SELECT
+        stat_datetime,
+        sum(show_num) AS showNum,
+        sum(click) AS click,
+        sum(convert_num) AS convertNum,
+        sum(cost) AS cost,
+        DATE_FORMAT(stat_datetime,'%Y-%m-%d') AS time,
+        create_time,
+        update_time
+        FROM
+        ctop_bytedance_report_advertiser_daily
+        where 1 =1
+        <if test="accountId !=null and accountId != ''">
+            and advertiser_id = #{accountId}
+        </if>
+        <if test="planId !=null and planId != ''">
+            and ad_id = #{planId}
+        </if>
+        <if test="startTime !=null and startTime != ''">
+            and DATE_FORMAT(stat_datetime,'%Y-%m-%d') &gt;= #{startTime}
         </if>
         <if test="endTime !=null and endTime != ''">
-            and stat_datetime &lt;= #{endTime}
+            and DATE_FORMAT(stat_datetime,'%Y-%m-%d') &lt;= #{endTime}
         </if>
-        GROUP BY ad_id
+        GROUP BY stat_datetime
         ORDER BY cost DESC
 
     </select>

+ 5 - 5
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/mapper/xml/BytedanceReportMaterialDailyMapper.xml

@@ -6,11 +6,11 @@
     <select id="selectMaterialDailyReportByAccountId" resultType="java.util.HashMap">
         SELECT
             video.video_url as videoUrl,
-            report.material_id as materialId,
-            report.cost,
-            report.show_material as showMaterial,
-            report.click,
-            report.convert_material as convertMaterial,
+            concat(report.material_id,'') as materialId,
+            sum(report.cost) as cost,
+            sum(report.show_material) as showMaterial,
+            sum(report.click) as click,
+            sum(report.convert_material) as convertMaterial,
             creative.count,
             video.material_upload_time as materialUploadTime,
             video.poster_url as posterUrl,

+ 130 - 86
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/service/impl/BytedanceAdvertiserHourlyReportServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.sun.xml.bind.v2.TODO;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.bytedance.advertise.entity.AiBytedanceAdvertiserStrategy;
 import org.jeecg.modules.bytedance.advertise.entity.ByteDanceAdvertisePlan;
@@ -43,6 +44,7 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
 
     //时段数组
     private final static List<String> TIMES = Arrays.asList("0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23");
+    public static final String PATTEN_DEFAULT_YMD = "yyyy-MM-dd";
 
 
     @Resource
@@ -74,8 +76,28 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
         List<ReportCostVo> nowCostList = new ArrayList<>();
         List<ReportCostVo> lastCostList = new ArrayList<>();
 
-        //当前时间段数据
-        nowCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfo(accountId,startTime,endTime);
+
+        //根据本阶段时间 获取 上阶段 开始-截至 时间
+        Map<String,String> lastTimeMap = TimeStartAndEndUtil.getStartEndTime(startTime,endTime);
+
+        /**
+         * 日期相差不为 0 则 展示 日报(每天数据总和)数据
+         * 日期相差天数为0  则 展示 24小时 数据
+         */
+        if (!lastTimeMap.get("daysBetween").equals("0")){
+            // 账户 日报 阶段 数据
+            nowCostList = bytedanceAdvertiserHourlyReportMapper.selectPlanCostInfoCount(accountId,null,startTime,endTime);
+            lastCostList = bytedanceAdvertiserHourlyReportMapper.selectPlanCostInfoCount(accountId,null,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
+        }else{
+            // 账户 当前时间段数据
+            nowCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStage(accountId,startTime,endTime);
+            ReportCostVo statHourVo = new ReportCostVo();
+            if (nowCostList.size() > 0){
+                statHourVo = nowCostList.get(nowCostList.size()-1);
+            }
+            //上阶段数据
+            lastCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStageLast(accountId,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"),statHourVo.getTime());
+        }
 
         //更新时间
         List<ReportCostVo> updTimeList = nowCostList.stream().sorted(Comparator.comparing(ReportCostVo::getCreateTime)).collect(Collectors.toList());
@@ -85,10 +107,6 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
         double nowCost = nowCostList.stream().mapToDouble(ReportCostVo::getCost).sum();
         resultMap.put("nowCost", String.format("%.2f", nowCost));
 
-        //根据本阶段时间 获取 上阶段 开始-截至 时间
-        Map<String,String> lastTimeMap = TimeStartAndEndUtil.getStartEndTime(startTime,endTime);
-        //上阶段数据
-        lastCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfo(accountId,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
         //上阶段花费
         double lastCost = lastCostList.stream().mapToDouble(ReportCostVo::getCost).sum();
         resultMap.put("lastCost", String.format("%.2f", lastCost));
@@ -96,7 +114,7 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
         //环比 =(当前花费 - 上阶段花费 )/ 上阶段花费
         compare = (nowCost - lastCost) / lastCost;
         //resultMap.put("compare", Double.isNaN(compare) ? "0" : df.format(compare));
-        resultMap.put("compare", Double.isNaN(compare) ? "0" : String.format("%.2f", compare*100));
+        resultMap.put("compare", new Double(lastCost).intValue() == 0 ? "0" : String.format("%.2f", compare*100));
 
         //花费占比 = 花费 / 账户预算
         //获取账户预算
@@ -106,34 +124,34 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
         strategyQueryWrapper.last("limit 1");
         AiBytedanceAdvertiserStrategy strategy = aiBytedanceAdvertiserStrategyMapper.selectOne(strategyQueryWrapper);
         //没有预算则使用上阶段花费
-        double accountBudget = Check.isNull(strategy) ? lastCost : strategy.getAccountBudget().doubleValue();
+        double accountBudget = Check.isNull(strategy) || strategy.getAccountBudget().intValue() == 0 ? lastCost : strategy.getAccountBudget().doubleValue();
         //花费占比
         double costShare = nowCost / accountBudget;
-        resultMap.put("costShare", Double.isNaN(costShare) ? "0" : df.format(costShare));
+        resultMap.put("costShare",new Double(accountBudget).intValue() == 0 ? "0" : df.format(costShare));
 
         //获取 本阶段  转化成本;转化数;转化率;平均千次展现费用。数据展示
         Map nowMap = getCost(nowCostList);
         // 上阶段数据
         Map lastMap = getCost(lastCostList);
 
-        /**
-         * 日期相差不为 0 则 展示 时间段(每天数据总和)数据
-         * 日期相差天数为0  则 展示 24小时 数据
-         */
-        if (!lastTimeMap.get("daysBetween").equals("0")){
-            //阶段 数据
-          nowCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStage(accountId,startTime,endTime);
-          lastCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStage(accountId,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
+        if (nowCostList.size() > 0){
+            //当前阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
+            nowMap.put("costList", getCostList(nowCostList,startTime,endTime,lastTimeMap.get("daysBetween")));
+        }else {
+            nowMap.put("costList",Arrays.asList());
         }
-        //当前阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
-        nowMap.put("costList", getCostList(nowCostList,startTime,endTime,lastTimeMap.get("daysBetween")));
-        //上个阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
-        lastMap.put("costList", getCostList(lastCostList,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"),lastTimeMap.get("daysBetween")));
+
+        if (lastCostList.size() > 0){
+            //上个阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
+            lastMap.put("costList", getCostList(lastCostList,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"),lastTimeMap.get("daysBetween")));
+        }else {
+            lastMap.put("costList",Arrays.asList());
+        }
+
 
         resultMap.put("nowMap", nowMap);
         resultMap.put("lastMap", lastMap);
 
-
         return Result.successMsg("成功。",resultMap);
     }
 
@@ -150,16 +168,16 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
         //转化成本 = 总花费 / 转化数
         int converNum = list.stream().mapToInt(ReportCostVo::getConvertNum).sum();
         double conver = cost / new Double(converNum);
-        map.put("conver",Double.isNaN(conver) ? "0" : String.format("%.2f", conver));
+        map.put("conver",converNum == 0 ? "0" : String.format("%.2f", conver));
         map.put("converNum", converNum);
         //转化率 = 转化数 / 点击数 * 100
         int clickNum = list.stream().mapToInt(ReportCostVo::getClick).sum();
         double click = Double.valueOf(converNum) /  Double.valueOf(clickNum) * 100;
-        map.put("converRate", Double.isNaN(click) ? "0" : String.format("%.2f", click));
+        map.put("converRate", clickNum == 0 ? "0" : String.format("%.2f", click));
         // 平均千次展显费用 = 总花费/展示数 * 1000
         int showNum = list.stream().mapToInt(ReportCostVo::getShowNum).sum();
         double show = (cost / showNum) * 1000 ;
-        map.put("averageShow", Double.isNaN(show) ? "0" : String.format("%.2f", show));
+        map.put("averageShow", showNum == 0 ? "0" : String.format("%.2f", show));
         return map;
     }
 
@@ -287,70 +305,96 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
      */
     @Override
     public Result getReportPlanCost(String accountId, String startTime, String endTime,Integer pageNum,Integer pageSize) throws Exception {
+        SimpleDateFormat sf = new SimpleDateFormat(PATTEN_DEFAULT_YMD);
         DecimalFormat df = new DecimalFormat("0.00%");
+        DecimalFormat df1 = new DecimalFormat("0.00");
+        List<ReportCostVo> reportCostVoList = new ArrayList<ReportCostVo>();
+        List<ReportCostVo> lastReportCostVoList = new ArrayList<ReportCostVo>();
         //根据本阶段时间 获取 上阶段 开始-截至 时间
         Map<String,String> lastTimeMap = TimeStartAndEndUtil.getStartEndTime(startTime,endTime);
-        PageHelper.startPage(pageNum,pageSize);
-        //查询计划数据时报
-       List<ReportCostVo> reportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostInfo(accountId, null, startTime,endTime);
-       reportCostVoList.forEach(reportCostVo -> {
-           //出价
-           QueryWrapper<ByteDanceAdvertisePlan> planQueryWrapper = new QueryWrapper<>();
-           planQueryWrapper.eq("account_id",accountId);
-           planQueryWrapper.last("limit 1");
-           ByteDanceAdvertisePlan planInfo = byteDanceAdvertisePlanMapper.selectOne(planQueryWrapper);
-           reportCostVo.setCpaBid(planInfo.getCpaBid());
-           reportCostVo.setBid(planInfo.getBid());
-
-           // 平均千次展显费用 = 总花费/展示数 * 1000
-           double show = 0;
-           if (reportCostVo.getShowNum() != 0){
-               show = (reportCostVo.getCost() / reportCostVo.getShowNum()) * 1000 ;
-           }
-           reportCostVo.setAverageShow(String.format("%.2f", show));
-
-           double avgClick = 0;
-           double clickRate = 0;
-           double convetRate = 0;
-           if (reportCostVo.getClick() != 0){
-               //平均点击单价 = 花费 / 点击数
-               avgClick = reportCostVo.getCost() / reportCostVo.getClick().doubleValue();
-               //点击率 = 点击数 / 展示数
-               clickRate = reportCostVo.getClick().doubleValue() / reportCostVo.getShowNum().doubleValue();
-               //转化率 = 转化数 / 点击数 * 100
-               convetRate = Double.valueOf(reportCostVo.getConvertNum()) /  Double.valueOf(reportCostVo.getClick()) * 100;
-           }
-
-           reportCostVo.setAverageClick(String.format("%.2f", avgClick));
-           reportCostVo.setClickRate(df.format(clickRate));
-           reportCostVo.setConverRate(String.format("%.2f", convetRate));
-
-           //转化成本 = 总花费 / 转化数
-           double conver = 0;
-           if (reportCostVo.getConvertNum() != 0){
-               conver = reportCostVo.getCost() / reportCostVo.getConvertNum();
-           }
-           reportCostVo.setConver(String.format("%.2f", conver));
-
-           // 计划id 和 上阶段 时间 查询 上阶段数据
-           List<ReportCostVo> lastReportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostInfo(accountId, reportCostVo.getAdId(), lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
-           double compare = 0;
-           if (lastReportCostVoList.size() > 0){
-               if (lastReportCostVoList.get(0).getCost() !=0){
-                   //环比 =(当前花费 - 上阶段花费 )/ 上阶段花费
-                   compare = (reportCostVo.getCost() - lastReportCostVoList.get(0).getCost()) / lastReportCostVoList.get(0).getCost();
-               }
-           }
-           reportCostVo.setCompare(df.format(compare));
-
-           //操作状态
-           QueryWrapper<ByteDanceAdvertisePlan> advertisePlanQueryWrapper = new QueryWrapper<>();
-           advertisePlanQueryWrapper.eq("account_id",accountId);
-           advertisePlanQueryWrapper.eq("id",reportCostVo.getAdId());
-           advertisePlanQueryWrapper.last("limit 1");
-           ByteDanceAdvertisePlan advertisePlan = byteDanceAdvertisePlanMapper.selectOne(advertisePlanQueryWrapper);
-           reportCostVo.setOptStatus(advertisePlan.getOptStatus());
-       });
+        String nowTime = sf.format(new Date());
+
+        if (!startTime.equals(nowTime)){
+            //日报
+            PageHelper.startPage(pageNum,pageSize);
+            reportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostInfoDay(accountId, null, startTime,endTime);
+        }else {
+            PageHelper.startPage(pageNum,pageSize);
+            //时报
+           reportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostInfo(accountId, null, startTime,endTime);
+
+        }
+
+
+        for (ReportCostVo reportCostVo : reportCostVoList) {
+            reportCostVo.setCostStr(String.format("%.2f",reportCostVo.getCost()));
+            //出价  ctop_bytedance_advertise_plan 广告计划信息表
+            QueryWrapper<ByteDanceAdvertisePlan> planQueryWrapper = new QueryWrapper<>();
+            planQueryWrapper.eq("account_id",accountId);
+            planQueryWrapper.eq("id",reportCostVo.getAdId());
+            planQueryWrapper.last("limit 1");
+            ByteDanceAdvertisePlan planInfo = byteDanceAdvertisePlanMapper.selectOne(planQueryWrapper);
+            reportCostVo.setCpaBid(Check.isNull(planInfo) ? "0" : String.format("%.2f",planInfo.getCpaBid()));
+            reportCostVo.setBid(Check.isNull(planInfo) ? "0" : String.format("%.2f",planInfo.getBid()));
+            //广告预算 (修改出价不能大于广告计划预算)
+            reportCostVo.setAdBudget(Check.isNull(planInfo) ? new BigDecimal(0) : planInfo.getBudget());
+
+            // 平均千次展显费用 = 总花费/展示数 * 1000
+            double show = 0;
+            if (reportCostVo.getShowNum() != 0){
+                show = (reportCostVo.getCost() / reportCostVo.getShowNum()) * 1000 ;
+            }
+            reportCostVo.setAverageShow(String.format("%.2f", show));
+
+            double avgClick = 0;
+            double clickRate = 0;
+            double convetRate = 0;
+            if (reportCostVo.getClick() != 0){
+                //平均点击单价 = 花费 / 点击数
+                avgClick = reportCostVo.getCost() / reportCostVo.getClick().doubleValue();
+                //点击率 = 点击数 / 展示数
+                clickRate = reportCostVo.getClick().doubleValue() / reportCostVo.getShowNum().doubleValue();
+                //转化率 = 转化数 / 点击数 * 100
+                convetRate = Double.valueOf(reportCostVo.getConvertNum()) /  Double.valueOf(reportCostVo.getClick()) * 100;
+            }
+
+            reportCostVo.setAverageClick(String.format("%.2f", avgClick));
+            reportCostVo.setClickRate(df.format(clickRate));
+            reportCostVo.setConverRate(String.format("%.2f", convetRate));
+
+            //转化成本 = 总花费 / 转化数
+            double conver = 0;
+            if (reportCostVo.getConvertNum() != 0){
+                conver = reportCostVo.getCost() / reportCostVo.getConvertNum();
+            }
+            reportCostVo.setConver(String.format("%.2f", conver));
+
+            //日报
+            if (!startTime.equals(nowTime)){
+                // 计划id 和 上阶段 时间 查询 上阶段数据
+                lastReportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostInfoDay(accountId, reportCostVo.getAdId(), lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
+            }else {
+                //时报
+                //查询上阶段 同时间点 之前的 时报 数据信息
+                lastReportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostHourLast(accountId,reportCostVo.getAdId(),lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"),reportCostVo.getStatHour());
+            }
+            double compare = 0;
+            if (lastReportCostVoList.size() > 0){
+                if (lastReportCostVoList.get(0).getCost() !=0){
+                    //环比 =(当前花费 - 上阶段花费 )/ 上阶段花费
+                    compare = (reportCostVo.getCost() - lastReportCostVoList.get(0).getCost()) / lastReportCostVoList.get(0).getCost();
+                }
+            }
+            reportCostVo.setCompare(df.format(compare));
+
+            //操作状态
+            QueryWrapper<ByteDanceAdvertisePlan> advertisePlanQueryWrapper = new QueryWrapper<>();
+            advertisePlanQueryWrapper.eq("account_id",accountId);
+            advertisePlanQueryWrapper.eq("id",reportCostVo.getAdId());
+            advertisePlanQueryWrapper.last("limit 1");
+            ByteDanceAdvertisePlan advertisePlan = byteDanceAdvertisePlanMapper.selectOne(advertisePlanQueryWrapper);
+            reportCostVo.setOptStatus(Check.isNull(advertisePlan) ? "0" : advertisePlan.getOptStatus());
+        }
         PageInfo<ReportCostVo> pageInfo = new PageInfo<ReportCostVo>(reportCostVoList);
         return Result.successMsg("成功。", pageInfo);
     }

+ 13 - 5
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/service/impl/BytedanceReportMaterialDailyServiceImpl.java

@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
@@ -60,30 +61,37 @@ public class BytedanceReportMaterialDailyServiceImpl extends ServiceImpl<Bytedan
             BigDecimal showMaterial = new BigDecimal(Check.isNull(dailyReportMap.get("showMaterial")) ? "0" : dailyReportMap.get("showMaterial").toString());
             BigDecimal convertMaterial = new BigDecimal(Check.isNull(dailyReportMap.get("convertMaterial")) ? "0" : dailyReportMap.get("convertMaterial").toString());
 
+
+            DecimalFormat decimalFormat = new DecimalFormat("0.00#");
+            dailyReportMap.put("cost", decimalFormat.format(cost));
+            dailyReportMap.put("click", click);
+            dailyReportMap.put("showMaterial", showMaterial);
+            dailyReportMap.put("convertMaterial", convertMaterial);
+
             //被除数不能为0
             if (StringUtils.equals("0",showMaterial.toString())){
                 dailyReportMap.put("costPerThousandShow", 0);
                 dailyReportMap.put("clickRate", 0);
             }else {
                 BigDecimal costPerThousandShow = cost.multiply(new BigDecimal(1000)).divide(showMaterial, 2, BigDecimal.ROUND_HALF_UP);
-                dailyReportMap.put("costPerThousandShow", costPerThousandShow);
+                dailyReportMap.put("costPerThousandShow", decimalFormat.format(costPerThousandShow));
                 BigDecimal clickRate = click.multiply(new BigDecimal(100)).divide(showMaterial, 2, BigDecimal.ROUND_HALF_UP);
-                dailyReportMap.put("clickRate", clickRate);
+                dailyReportMap.put("clickRate", decimalFormat.format(clickRate));
             }
             if (StringUtils.equals("0", convertMaterial.toString())) {
                 dailyReportMap.put("costConvert", 0);
             }else {
                 BigDecimal costConvert = cost.divide(convertMaterial, 2, BigDecimal.ROUND_HALF_UP);
-                dailyReportMap.put("costConvert", costConvert);
+                dailyReportMap.put("costConvert", decimalFormat.format(costConvert));
             }
             if (StringUtils.equals("0", click.toString())) {
                 dailyReportMap.put("costPerClick", 0);
                 dailyReportMap.put("convertRate", 0);
             }else {
                 BigDecimal costPerClick = cost.divide(click, 2, BigDecimal.ROUND_HALF_UP);
-                dailyReportMap.put("costPerClick", costPerClick);
+                dailyReportMap.put("costPerClick", decimalFormat.format(costPerClick));
                 BigDecimal convertRate = convertMaterial.multiply(new BigDecimal(100)).divide(click,2,BigDecimal.ROUND_HALF_UP);
-                dailyReportMap.put("convertRate", convertRate);
+                dailyReportMap.put("convertRate", decimalFormat.format(convertRate));
             }
         }
 

+ 65 - 19
jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/BytedanceGeneralCopywriterController.java

@@ -10,9 +10,14 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.bytedance.advertise.entity.ByteDanceCreativeWordPackage;
 import org.jeecg.modules.bytedance.advertise.entity.ByteDanceGeneralCopywriter;
 import org.jeecg.modules.bytedance.advertise.service.IByteDanceGeneralCopywriterService;
+import org.jeecg.modules.bytedance.advertise.service.impl.ByteDanceGeneralCopywriterServiceImpl;
+import org.jeecg.modules.bytedance.common.utils.Check;
 import org.jeecg.modules.bytedance.common.utils.ExcelUtil;
+import org.jeecg.modules.bytedance.common.utils.StringUtils;
+import org.jeecg.modules.system.service.ISysRoleService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -28,8 +33,13 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
 import java.net.URLDecoder;
+import java.text.DecimalFormat;
 import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 /**
  * 头条通用文案上传接口
  * @author jeecg-boot
@@ -43,37 +53,61 @@ import java.util.*;
 public class BytedanceGeneralCopywriterController {
     @Autowired
     private IByteDanceGeneralCopywriterService byteDanceGeneralCopywriterService;
+    @Autowired
+    private ISysRoleService sysRoleService;
+
 
     @ApiOperation(value="通用文案库-上传excel", notes="通用文案库-上传excel")
     @PostMapping("/loadExcel")
     public Result<ByteDanceGeneralCopywriter> loadExcel(
-            @RequestParam("accountId") Long accountId,
+            @RequestParam("accountId") String accountId,
             @RequestParam("excelFile") MultipartFile excelFile){
         Result<ByteDanceGeneralCopywriter> result = new Result<>();
+        List<ByteDanceGeneralCopywriter> byteDanceGeneralCopywriterList = new ArrayList<ByteDanceGeneralCopywriter>();
+        String[] accountIds = new String[]{accountId};
+        if(accountId.contains(",")){
+            accountIds = accountId.split(",");
+        }
         try {
             List<String> list = ExcelUtil.readExcel(excelFile);
-            //去掉null值
-            list.removeIf(Objects::isNull);
-            //去掉空字符串
-            Iterator<String> iterator = list.iterator();
-            while (iterator.hasNext()){
-                if (iterator.next() == ""){
-                    iterator.remove();
+
+            for (String accountIdStr:accountIds) {
+                for (String str: list) {
+                    ByteDanceGeneralCopywriter byteDanceGeneralCopywriter = new ByteDanceGeneralCopywriter(Long.parseLong(accountIdStr),str);
+                    int len = StringUtils.lengthAsSlogan(str);
+                    int left = str.indexOf("{");
+                    int right = str.indexOf("}");
+                    if(left >= 0 && right >= 0){
+                        List<String> strs = new ArrayList<>();
+                        ByteDanceCreativeWordPackage creativeWordPackage = byteDanceGeneralCopywriterService.selectCreativeWordPackageByName(str.substring(left+1, right));
+                        strs.add(creativeWordPackage.getCreativeWordId().toString());
+                        len = len - (right - left) + creativeWordPackage.getMaxWordLen();
+                        String nextStr = str.substring(right+1,str.length());
+                        left = nextStr.indexOf("{");
+                        right = nextStr.indexOf("}");
+                        if(left >= 0 && right >= 0){
+                            ByteDanceCreativeWordPackage creativeWordPackage2 = byteDanceGeneralCopywriterService.selectCreativeWordPackageByName(nextStr.substring(left+1, right));
+                            strs.add(creativeWordPackage2.getCreativeWordId().toString());
+                            len = len - (right - left) + creativeWordPackage2.getMaxWordLen();
+                        }
+                        byteDanceGeneralCopywriter.setCreativeWordIds(Arrays.toString(strs.toArray()).replaceAll(" ",""));
+                    }
+                    //校验标题长度,长度小于5和大于30的全部过滤
+                    if(len<5 || len>30){
+                        continue;
+                    }
+
+                    //截取{}中的内容,匹配动态词包id,拼接数组存储
+                    byteDanceGeneralCopywriterList.add(byteDanceGeneralCopywriter);
                 }
             }
-            List<ByteDanceGeneralCopywriter> byteDanceGeneralCopywriterList = new ArrayList<ByteDanceGeneralCopywriter>();
 
-            //遍历list,查看数据
-            for (String textCopywriter : list) {
-                byteDanceGeneralCopywriterList.add(new ByteDanceGeneralCopywriter(accountId,textCopywriter));
-            }
 
             byteDanceGeneralCopywriterService.saveBatch(byteDanceGeneralCopywriterList);
-            result.success("添加成功!");
-
+            result.success("添加成功"+byteDanceGeneralCopywriterList.size()+"条"+",失败"+(list.size() * accountIds.length - byteDanceGeneralCopywriterList.size())+"条");
+            result.setCode(0);
         } catch (IOException e) {
-            e.printStackTrace();
-            result.error500("操作失败");
+            result.error500("动态词包格式错误,请重新上传!");
         }
         return result;
     }
@@ -104,7 +138,9 @@ public class BytedanceGeneralCopywriterController {
 
     @ApiOperation(value="通用文案报表展示", notes="通用文案报表展示")
     @GetMapping(value = "/queryPageListByText")
-    public Result queryPageListByText(@RequestParam("accountId") String accountId,
+    public Result queryPageListByText(
+                                      @RequestParam(value = "userId",defaultValue = "") String userId,
+                                      @RequestParam(value = "accountId",defaultValue = "") String accountId,
                                       @RequestParam(value = "keyWord",defaultValue = "") String keyWord,
                                       @RequestParam(value = "startTime",defaultValue = "") String startTime,
                                       @RequestParam(value = "endTime",defaultValue = "") String endTime,
@@ -112,7 +148,17 @@ public class BytedanceGeneralCopywriterController {
                                       @RequestParam(value = "pageSize", defaultValue="10") Integer pageSize
     ) {
         try {
-            return byteDanceGeneralCopywriterService.getGeneralCopywriterReport(accountId,keyWord, startTime,endTime,pageNo,pageSize);
+
+            String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+            if (Check.isNull(roleCode)){
+                return Result.errorMsg("请输入正确的用户id。");
+            }
+            //角色为 管理员并且projectId是空表示:全量查询
+            if ("admin".equals(roleCode) && Check.isNull(accountId)) {
+                accountId = "admin";	//传递projectId为admin
+            }
+
+            return byteDanceGeneralCopywriterService.getGeneralCopywriterReport(userId,accountId,keyWord, startTime,endTime,pageNo,pageSize);
         }catch (Exception e){
             log.error("通用文案数据-获取文案维度创意报表数据异常",e);
             return Result.error("请求失败,请联系开发人员!");

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

@@ -135,11 +135,12 @@ public class BytedanceReportController {
 	}
 
 
-	@ApiOperation(value="投放数据-更新计划出价", notes="投放数据-更新计划出价")
+
+	@ApiOperation(value="投放数据-更新计划出价-bid", notes="投放数据-更新计划出价")
 	@GetMapping(value = "/updateADBid")
 	public Result updateADBid(@RequestParam("accountId") String accountId,
-									@RequestParam("adId") String adId,
-									@RequestParam("bid") BigDecimal bid) {
+							  @RequestParam("adId") String adId,
+							  @RequestParam("bid") BigDecimal bid) {
 		try {
 			CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
 			List<Map<String, Object>> listMap = new ArrayList<>();
@@ -156,9 +157,53 @@ public class BytedanceReportController {
 			byteDanceAdvertisePlan.setBid(bid);
 			//更新 表 定向包id
 			byteDanceAdvertisePlanService.updatePlanOrPackage(byteDanceAdvertisePlan);
-			return Result.successMsg("修改成功。",null);
+			return Result.successMsg("修改出价成功。",null);
+		}catch (Exception e){
+			log.error("投放数据-更新计划出价-bid异常",e);
+			return Result.error("请求失败,请联系开发人员!");
+		}
+	}
+
+
+	@ApiOperation(value="投放数据-更新计划出价-cpaBid", notes="投放数据-更新计划出价")
+	@GetMapping(value = "/updateADCpaBid")
+	public Result updateADCpaBid(@RequestParam("accountId") String accountId,
+									@RequestParam("adId") String adId,
+									@RequestParam("cpaBid") BigDecimal cpaBid) {
+		try {
+			CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
+			PlanSearchVo planSearchVo = new PlanSearchVo();
+			String[] ids = adId.split(",");
+			planSearchVo.setIds(ids);
+			//2 获取广告计划
+			Result result = marketingService.getPlanList(token,planSearchVo,1,1000);
+			if (!result.isSuccess()){
+				return Result.errorMsg(result.getMessage());
+			}
+			JSONObject jsonObject =JSONObject.parseObject(result.getResult().toString());
+			JSONArray array = jsonObject.getJSONArray("list");
+			List<Map<String,Object>> dataList = JSONArray.parseObject(array.toJSONString(),List.class);
+
+			for (Map<String, Object> map : dataList) {
+				String modifyTime = map.get("modify_time").toString();
+				AiBytedanceAdvertiserStrategy strategy = new AiBytedanceAdvertiserStrategy();
+				strategy.setAccountId(Long.valueOf(accountId));
+				strategy.setAdCpaBid(cpaBid);
+				//3 修改广告计划 中的 cpaBid
+				Result resultUpd = marketingService.updateAdvertiserPlan(token,adId,modifyTime,strategy);
+				if (!resultUpd.isSuccess()){
+					return Result.errorMsg(resultUpd.getMessage());
+				}
+				ByteDanceAdvertisePlan byteDanceAdvertisePlan = new ByteDanceAdvertisePlan();
+				byteDanceAdvertisePlan.setId(Long.valueOf(adId));
+				byteDanceAdvertisePlan.setCpaBid(cpaBid);
+				//更新 表 bid || 定向包id || 状态
+				byteDanceAdvertisePlanService.updatePlanOrPackage(byteDanceAdvertisePlan);
+			}
+
+			return Result.successMsg("修改出价成功。",null);
 		}catch (Exception e){
-			log.error("投放数据-更新计划出价异常",e);
+			log.error("投放数据-更新计划出价-cpaBid异常",e);
 			return Result.error("请求失败,请联系开发人员!");
 		}
 	}

+ 28 - 9
jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/BytedanceVideoSlogenInfoController.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.bytedance.advertise.controller;
 
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -14,6 +15,9 @@ import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.bytedance.advertise.entity.BytedanceVideoSlogenInfo;
 import org.jeecg.modules.bytedance.advertise.service.IBytedanceVideoSlogenInfoService;
 import org.jeecg.modules.bytedance.advertise.service.impl.BytedanceVideoSlogenInfoServiceImpl;
+import org.jeecg.modules.bytedance.common.entity.MaterialInfo;
+import org.jeecg.modules.bytedance.common.service.IMaterialInfoService;
+import org.jeecg.modules.bytedance.common.utils.Check;
 import org.jeecg.modules.system.service.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -36,7 +40,8 @@ import java.util.List;
 public class BytedanceVideoSlogenInfoController {
 	@Autowired
 	private IBytedanceVideoSlogenInfoService bytedanceVideoSlogenInfoService;
-
+	@Autowired
+	private IMaterialInfoService materialInfoService;
 	@Autowired
 	private ISysRoleService sysRoleService;
 	/**
@@ -65,7 +70,8 @@ public class BytedanceVideoSlogenInfoController {
 
 	@ApiOperation(value="指定文案报表数据展示", notes="指定文案报表数据展示")
 	@GetMapping(value = "/queryPageListByText")
-	public Result queryPageListByText(@RequestParam("accountId") String accountId,
+	public Result queryPageListByText(@RequestParam("userId") String userId,
+									  @RequestParam(value = "projectId",defaultValue = "") String projectId,
 									  @RequestParam(value = "keyWord",defaultValue = "") String keyWord,
 									  @RequestParam(value = "startTime",defaultValue = "") String startTime,
 									  @RequestParam(value = "endTime",defaultValue = "") String endTime,
@@ -73,8 +79,16 @@ public class BytedanceVideoSlogenInfoController {
 									  @RequestParam(value = "pageSize", defaultValue="10") Integer pageSize
 									) {
 		try {
-			String roleCode = sysRoleService.getRoleCodeByUserId(accountId);
-			return bytedanceVideoSlogenInfoService.getVideoSlogenReport(accountId,keyWord, startTime,endTime,pageNo,pageSize);
+			//查询用户角色
+			String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+			if (Check.isNull(roleCode)){
+				return Result.errorMsg("请输入正确的用户id。");
+			}
+			//角色为 管理员并且projectId是空表示:全量查询
+			if ("admin".equals(roleCode) && Check.isNull(projectId)) {
+				projectId = "admin";	//传递projectId为admin
+			}
+			return bytedanceVideoSlogenInfoService.getVideoSlogenReport(userId, projectId,keyWord, startTime,endTime,pageNo,pageSize);
 		}catch (Exception e){
 			log.error("指定文案-获取指定文案维度创意报表数据异常",e);
 			return Result.error("请求失败,请联系开发人员!");
@@ -110,15 +124,20 @@ public class BytedanceVideoSlogenInfoController {
 	 */
 	@ApiOperation(value="头条视频文案信息-批量添加", notes="头条视频文案信息-批量添加")
 	@PostMapping(value = "/addList")
-	public Result<BytedanceVideoSlogenInfo> addList(@RequestParam String[] videoCodeArray,
-													@RequestParam JSONArray slogenArray,
-													@RequestParam String userId) {
+	public Result<BytedanceVideoSlogenInfo> addList(@RequestBody MaterialInfo materialInfo) {
 		Result<BytedanceVideoSlogenInfo> result = new Result<>();
 		try {
-			for (String videoCode: videoCodeArray) {
-                bytedanceVideoSlogenInfoService.insertSlogans(videoCode,slogenArray,userId);
+			String userId = materialInfo.getUserId();
+			JSONArray slogenArray = materialInfo.getSlogans();
+			JSONArray materialIds = materialInfo.getMaterialIds();
+			for(int i=0;i<materialIds.size();i++){
+				MaterialInfo materialInfo2 = materialInfoService.getById(materialIds.get(i).toString());
+				String videoCode = materialInfo2.getCode();
+				Long projectId = materialInfo2.getProjectId();
+				bytedanceVideoSlogenInfoService.insertSlogans(projectId,videoCode,slogenArray,userId);
 			}
 			result.success("添加成功!");
+			result.setCode(0);
 			return result;
 		} catch (Exception e) {
 			log.error(e.getMessage(),e);