瀏覽代碼

1.通用文案后端长度校验及动态词包功能支持,2.slogan新增是绑定项目id的修改。

huangxuechao 4 年之前
父節點
當前提交
7425c67519
共有 18 個文件被更改,包括 441 次插入62 次删除
  1. 108 0
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/ByteDanceCreativeWordPackage.java
  2. 13 0
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/ByteDanceGeneralCopywriter.java
  3. 13 1
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/BytedanceVideoSlogenInfo.java
  4. 4 1
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/ByteDanceGeneralCopywriterMapper.java
  5. 3 1
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/BytedanceVideoSlogenInfoMapper.java
  6. 14 2
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/ByteDanceGeneralCopywriterMapper.xml
  7. 95 18
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/BytedanceVideoSlogenInfoMapper.xml
  8. 4 1
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/IByteDanceGeneralCopywriterService.java
  9. 2 2
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/IBytedanceVideoSlogenInfoService.java
  10. 15 3
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/ByteDanceGeneralCopywriterServiceImpl.java
  11. 25 5
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/BytedanceVideoSlogenInfoServiceImpl.java
  12. 3 0
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/entity/MaterialInfo.java
  13. 3 0
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/service/IMaterialInfoService.java
  14. 8 2
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/service/impl/MaterialInfoServiceImpl.java
  15. 3 1
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/utils/ExcelUtil.java
  16. 37 0
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/utils/StringUtils.java
  17. 63 16
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/BytedanceGeneralCopywriterController.java
  18. 28 9
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/BytedanceVideoSlogenInfoController.java

+ 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(String userId, String accountId, 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);
 }

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

@@ -2,9 +2,14 @@
 <!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 as accountId,
             d.creative_id as creativeId,
+            e.user_id as userId,
             a.text_copywriter AS textCopywriter,
             count(*) AS creativeCount,
             sum(d.cost) AS sumCost,
@@ -13,16 +18,23 @@
             sum(d.show_num) AS sumConvertMaterial
         FROM
             ctop_bytedance_general_copywriter a
+        LEFT JOIN ctop_user_allocation e on a.account_id = e.account_id
         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="userId!=null and userId!=''">and e.user_id = #{userId}</if>
+            <if test="accountId!=null and accountId!=''">and b.account_id = #{accountId}</if>
             <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
+
         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);
 }

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

@@ -4,6 +4,7 @@ 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;
@@ -31,11 +32,11 @@ public class ByteDanceGeneralCopywriterServiceImpl extends ServiceImpl<ByteDance
 
 
     @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<Map<String, Object>> generalCopywriteReportList = byteDanceGeneralCopywriterMapper.selectGeneralCopywriterReport(userId, accountId,keyWord, startTime, endTime);
         if(Check.isNull(generalCopywriteReportList)){
-            return Result.error("还没有此文案报表数据,请将此文案投放跑量!");
+            return Result.successMsg("还没有此文案报表数据,请将此文案投放跑量!",generalCopywriteReportList);
         }
 
         for (Map<String, Object> videoSlogenReportMap: generalCopywriteReportList) {
@@ -49,6 +50,12 @@ public class ByteDanceGeneralCopywriterServiceImpl extends ServiceImpl<ByteDance
             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());
 
+
+            videoSlogenReportMap.put("cost", cost);
+            videoSlogenReportMap.put("click", click);
+            videoSlogenReportMap.put("showNum", showNum);
+            videoSlogenReportMap.put("convertNum", convertNum);
+
             //被除数不能为0
             if (StringUtils.equals("0",showNum.toString())){
                 videoSlogenReportMap.put("costPerThousandShow", 0);
@@ -79,4 +86,9 @@ public class ByteDanceGeneralCopywriterServiceImpl extends ServiceImpl<ByteDance
         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);
+    }
+
 }

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

@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -30,16 +31,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 +61,23 @@ 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);
+        System.out.println(userId+"------------"+projectId);
+        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,6 +90,11 @@ 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());
 
+            videoSlogenReportMap.put("cost", cost);
+            videoSlogenReportMap.put("click", click);
+            videoSlogenReportMap.put("showNum", showNum);
+            videoSlogenReportMap.put("convertNum", convertNum);
+
             //被除数不能为0
             if (StringUtils.equals("0",showNum.toString())){
                 videoSlogenReportMap.put("costPerThousandShow", 0);

+ 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 - 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);
+    }
 }
 
 

+ 3 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/utils/ExcelUtil.java

@@ -58,7 +58,9 @@ public class ExcelUtil {
                         Cell cell = row.getCell(cellNum);
 //            cells[cellNum] = getCellValue(cell);
                         String cellValue = getCellValue(cell);
-                        list.add(cellValue);
+                        if(!Check.isNull(cellValue)){
+                            list.add(cellValue);
+                        }
                     }
 
                 }

+ 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;
+    }
 }

+ 63 - 16
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,12 @@ 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.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 /**
  * 头条通用文案上传接口
  * @author jeecg-boot
@@ -43,6 +52,15 @@ import java.util.*;
 public class BytedanceGeneralCopywriterController {
     @Autowired
     private IByteDanceGeneralCopywriterService byteDanceGeneralCopywriterService;
+    @Autowired
+    private ISysRoleService sysRoleService;
+
+    public static void main(String[] args) {
+        String str = "测试创意反射,这么玩,你的视觉效果就是这么神奇!{地点}";
+
+        System.out.println(StringUtils.lengthAsSlogan(str));
+
+    }
 
     @ApiOperation(value="通用文案库-上传excel", notes="通用文案库-上传excel")
     @PostMapping("/loadExcel")
@@ -50,27 +68,43 @@ public class BytedanceGeneralCopywriterController {
             @RequestParam("accountId") Long accountId,
             @RequestParam("excelFile") MultipartFile excelFile){
         Result<ByteDanceGeneralCopywriter> result = new Result<>();
+        List<ByteDanceGeneralCopywriter> byteDanceGeneralCopywriterList = new ArrayList<ByteDanceGeneralCopywriter>();
         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 str: list) {
+                ByteDanceGeneralCopywriter byteDanceGeneralCopywriter = new ByteDanceGeneralCopywriter(accountId,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;
                 }
-            }
-            List<ByteDanceGeneralCopywriter> byteDanceGeneralCopywriterList = new ArrayList<ByteDanceGeneralCopywriter>();
 
-            //遍历list,查看数据
-            for (String textCopywriter : list) {
-                byteDanceGeneralCopywriterList.add(new ByteDanceGeneralCopywriter(accountId,textCopywriter));
+                //截取{}中的内容,匹配动态词包id,拼接数组存储
+                byteDanceGeneralCopywriterList.add(byteDanceGeneralCopywriter);
             }
 
-            byteDanceGeneralCopywriterService.saveBatch(byteDanceGeneralCopywriterList);
-            result.success("添加成功!");
 
+            byteDanceGeneralCopywriterService.saveBatch(byteDanceGeneralCopywriterList);
+            result.success("添加成功"+byteDanceGeneralCopywriterList.size()+"条"+",失败"+(list.size() - byteDanceGeneralCopywriterList.size())+"条");
+            result.setCode(0);
         } catch (IOException e) {
             e.printStackTrace();
             result.error500("操作失败");
@@ -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,18 @@ 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。");
+            }
+            //角色为 管理员 || 销售 || 媒介 查询全部
+            if ("admin".equals(roleCode) || roleCode.contains("sale") || "meidaManager".equals(roleCode)) {
+                userId = null;
+            }
+
+            return byteDanceGeneralCopywriterService.getGeneralCopywriterReport(userId,accountId,keyWord, startTime,endTime,pageNo,pageSize);
         }catch (Exception e){
             log.error("通用文案数据-获取文案维度创意报表数据异常",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);