Browse Source

Merge branch 'master' into test

zhaoxian 4 years ago
parent
commit
f452368ac1
37 changed files with 1190 additions and 174 deletions
  1. 71 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/controller/AiKuaiShouReportAnalyzeCtrl.java
  2. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyTemplate.java
  3. 3 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaiShouStrategyListPageMapper.java
  4. 33 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/IAiKuaiShouReportAnalyzeMapper.java
  5. 465 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouReportAnalyzeMapper.xml
  6. 87 33
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyListPageMapper.xml
  7. 23 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaiShouReportAnalyzeService.java
  8. 109 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaiShouReportAnalyzeServiceImpl.java
  9. 2 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaiShouStrategyListPageServiceImpl.java
  10. 125 40
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiStrategyServiceImpl.java
  11. 10 19
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BytedanceVideoEtlInfoController.java
  12. 6 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/KuaishouVideoEtlInfoController.java
  13. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  14. 16 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  15. 28 19
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  16. 0 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  17. 12 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java
  18. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserService.java
  19. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java
  20. 26 22
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  21. 13 3
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/constant/MatchLogic.java
  22. 3 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/entity/RuleIndicator.java
  23. 2 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleTemplateServiceImpl.java
  24. 19 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataTargetKuaishou.java
  25. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/SysUser.java
  26. 1 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/SysUserMapper.java
  27. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  28. 6 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysUserMapper.xml
  29. 15 1
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  30. 9 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  31. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouVideoGetMapper.java
  32. 24 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml
  33. 10 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java
  34. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java
  35. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  36. 32 11
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouPlanServiceImpl.java
  37. 2 4
      module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/xml/WechatNoListMapper.xml

+ 71 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/controller/AiKuaiShouReportAnalyzeCtrl.java

@@ -0,0 +1,71 @@
+package org.jeecg.modules.ads.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.ads.service.IAiKuaiShouReportAnalyzeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
+@RequestMapping("/ai/analyze")
+@RestController
+public class AiKuaiShouReportAnalyzeCtrl {
+
+    @Autowired
+    IAiKuaiShouReportAnalyzeService aiKuaiShouReportAnalyzeService;
+
+    @GetMapping("/getStrategyAndTarget")
+    public Result<List<JSONObject>> getStrategyAndTarget(@RequestParam("accountId") Long accountId){
+        Result<List<JSONObject>> result=new Result<>();
+        result.setResult(aiKuaiShouReportAnalyzeService.getStrategyAndTarget(accountId));
+        result.setSuccess(true);
+        return result;
+    }
+
+    @GetMapping("/getStrategyAndMaterial")
+    public Result<List<JSONObject>> getStrategyAndMaterial(@RequestParam("accountId") Long accountId){
+        Result<List<JSONObject>> result=new Result<>();
+        result.setResult(aiKuaiShouReportAnalyzeService.getStrategyAndMaterial(accountId));
+        result.setSuccess(true);
+        return result;
+    }
+
+    @PostMapping("/report/targetOrMaterial")
+    public Result<PageInfo<JSONObject>> targetOrMaterialReport(@RequestBody JSONObject params){
+        Result<PageInfo<JSONObject>> result=new Result<>();
+        if(params.isEmpty()){
+            result.error500("参数为空");
+        }else {
+            if(params.getString("type").equals("target")){
+                result.setResult(aiKuaiShouReportAnalyzeService.getTargetReportBy(params));
+            }
+            else if(params.getString("type").equals("material")){
+                result.setResult(aiKuaiShouReportAnalyzeService.getMaterialReportBy(params));
+            }
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    //TODO 先不加时间维度,现在是t-2
+    @PostMapping("/chart/targetOrMaterial")
+    public Result<Map<String,Object>> targetOrMaterialChart(@RequestBody JSONObject params){
+        Result<Map<String,Object>> result=new Result<>();
+        if(params.isEmpty()){
+            result.error500("参数为空");
+        }else {
+            if(params.getString("type").equals("target")){
+                result.setResult(aiKuaiShouReportAnalyzeService.getTargetChartBy(params));
+            }
+            else if(params.getString("type").equals("material")){
+                result.setResult(aiKuaiShouReportAnalyzeService.getMaterialChartBy(params));
+            }
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+}

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyTemplate.java

@@ -28,6 +28,7 @@ public class AiKuaishouStrategyTemplate {
 	private String testDirection;
 	/**素材选择方式*/
 	private String materialSelectMethod;
+
 	/**
 	 * 组内素材组合模式
 	 * single 单视频+不同封面

+ 3 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaiShouStrategyListPageMapper.java

@@ -14,10 +14,10 @@ import java.util.List;
 @Mapper
 public interface AiKuaiShouStrategyListPageMapper {
 
-    List<JSONObject> queryStrategyBy(@Param("accountIds") JSONArray accountIds,@Param("strategyName") String strategyName,@Param("strategyState") Integer strategyState,@Param("id") Long id);
+    List<JSONObject> queryStrategyBy(@Param("accountIds") JSONArray accountIds, @Param("strategyName") String strategyName, @Param("strategyState") Integer strategyState, @Param("id") Long id);
 
-    List<JSONObject> queryCampaignByStrategyId(@Param("strategyId") Long strategyId,@Param("campaignName") String campaignName,@Param("campaignId") Long campaignId,@Param("status") Integer status);
+    List<JSONObject> queryCampaignByStrategyId(@Param("strategyId") Long strategyId, @Param("campaignName") String campaignName, @Param("campaignId") Long campaignId, @Param("status") Integer status);
 
-    List<JSONObject> queryUnitByCampaignId(@Param("campaignId") Long campaignId,@Param("unitName") String unitName,@Param("unitId") Long unitId,@Param("status") Integer status);
+    List<JSONObject> queryUnitByCampaignId(@Param("campaignId") Long campaignId, @Param("unitName") String unitName, @Param("unitId") Long unitId, @Param("status") Integer status);
 
 }

+ 33 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/IAiKuaiShouReportAnalyzeMapper.java

@@ -0,0 +1,33 @@
+package org.jeecg.modules.ads.mapper;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface IAiKuaiShouReportAnalyzeMapper {
+
+    List<JSONObject> queryStrategyByAccountId(@Param("accountId") Long accountId);
+
+    List<JSONObject> queryTargetByStrategyId(@Param("strategyId") Long StrategyId);
+
+    List<JSONObject> queryMaterialByStrategyId(@Param("strategyId") Long strategyId);
+
+    List<JSONObject> queryTargetReportBy(@Param("accountId") Long accountId, @Param("strategyId") Long strategyId, @Param("codes") JSONArray codes, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> queryMaterialReportBy(@Param("accountId") Long accountId, @Param("strategyId") Long strategyId, @Param("targetIds") JSONArray targetIds, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> queryAgeChartByTarget(@Param("strategyId") Long strategyId, @Param("targetIds") JSONArray targetIds, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> queryAgeChartByMaterial(@Param("strategyId") Long strategyId, @Param("codes") JSONArray codes, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> queryGenderChartByTarget(@Param("strategyId") Long strategyId, @Param("targetIds") JSONArray targetIds, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> queryGenderChartByMaterial(@Param("strategyId") Long strategyId, @Param("codes") JSONArray codes, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> queryRegionChartByTarget(@Param("strategyId") Long strategyId, @Param("targetIds") JSONArray targetIds, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> queryRegionChartByMaterial(@Param("strategyId") Long strategyId, @Param("codes") JSONArray codes, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+}

+ 465 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouReportAnalyzeMapper.xml

@@ -0,0 +1,465 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.ads.mapper.IAiKuaiShouReportAnalyzeMapper">
+
+    <select id="queryStrategyByAccountId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT id,
+               strategy_name
+        FROM ctop_kuaishou_strategy
+        WHERE account_id = #{accountId}
+    </select>
+
+    <select id="queryTargetByStrategyId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t4.id,
+               t4.target_type,
+               t4.target_content
+        FROM ctop_kuaishou_strategy t1
+                 LEFT JOIN ctop_ai_kuaishou_strategy_middle t2 on t1.id = t2.strategy_id
+                 LEFT JOIN ctop_ai_kuaishou_strategy_target_union t3 on t2.id = t3.strategy_middle_id
+                 LEFT JOIN ctop_ai_kuaishou_strategy_target_base t4 on t3.strategy_target_id = t4.id
+        where t1.id = #{strategyId}
+    </select>
+
+    <select id="queryMaterialByStrategyId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT DISTINCT t2.code,
+                        t2.material_name,
+                        t2.cover_url
+        FROM ctop_ai_kuaishou_strategy_map_creative t1
+                 LEFT JOIN ctop_material_info t2 ON t1.video_signature = t2.CODE
+        WHERE t1.strategy_id = #{strategyId}
+            and t2.code is not null
+        GROUP BY t2.code
+    </select>
+
+    <select id="queryTargetReportBy" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        r.target_type as targetType,
+        r.target_content as targetContent,
+        IFNULL(sum(t.charge),0) as cost,
+        IFNULL(sum(t.photo_show),0) as photoShow,
+        IFNULL(sum(t.photo_click),0) as photoClick,
+        CASE WHEN sum(t.photo_click) / sum(t.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.photo_click) /
+        sum(t.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t.aclick),0) as aclick,
+        IFNULL(sum(t.bclick),0) as bclick,
+        CASE WHEN sum(t.bclick) / sum(t.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.bclick) / sum(t.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t.charge) / sum(t.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t.charge) / sum(t.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_click)), 2)
+        END AS cpc ,
+        IFNULL(sum(t.activation),0) as active,
+        CASE WHEN sum(t.charge) / sum(t.activation) IS NULL THEN 0 ELSE sum(t.charge) / sum(t.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t.activation) / sum(t.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t.activation) /
+        sum(t.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t.event_register),0) as register,
+        CASE WHEN sum(t.charge) / sum(t.event_register) IS NULL THEN 0 ELSE round(sum(t.charge)/sum(t.event_register),3)
+        end as activeRegisterCost ,
+        CASE WHEN sum(t.event_register) / sum(t.activation) IS NULL THEN 0 ELSE concat(round(sum(t.event_register) /
+        sum(t.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t.event_next_day_stay) / sum(t.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t.event_next_day_stay) / sum(t.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+        ctop_kuaishou_report_daily_group t LEFT JOIN (SELECT
+        unit_id,
+        t3.target_type,
+        t3.target_content
+        FROM
+        ctop_ai_kuaishou_strategy_map_creative t1
+        LEFT JOIN ctop_ai_kuaishou_strategy_target_union t2 on t1.strategy_target_union_id=t2.id
+        LEFT JOIN ctop_ai_kuaishou_strategy_target_base t3 on t2.strategy_target_id=t3.id
+        WHERE
+        t1.strategy_id= #{strategyId}
+        and t1.video_signature in
+        <foreach item="item" index="index" collection="codes"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        GROUP BY t1.unit_id,t3.id) r on t.unit_id=r.unit_id
+        where account_id=#{accountId}
+        <if test="startDate != null">
+            AND t.stat_date >=#{startDate}
+        </if>
+        <if test="endDate != null">
+            AND t.stat_date &lt;=#{endDate}
+        </if>
+        GROUP BY t.unit_id
+    </select>
+
+    <select id="queryMaterialReportBy" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT r.creativeCount,
+        r.scenes,
+        t.signature as code,
+        t.cover_url as coverUrl,
+        IFNULL(sum(t.charge),0) as cost,
+        IFNULL(sum(t.photo_show),0) as photoShow,
+        IFNULL(sum(t.photo_click),0) as photoClick,
+        CASE WHEN sum(t.photo_click) / sum(t.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.photo_click) /
+        sum(t.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t.aclick),0) as aclick,
+        IFNULL(sum(t.bclick),0) as bclick,
+        CASE WHEN sum(t.bclick) / sum(t.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.bclick) / sum(t.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t.charge) / sum(t.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t.charge) / sum(t.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_click)), 2)
+        END AS cpc ,
+        IFNULL(sum(t.activation),0) as active,
+        CASE WHEN sum(t.charge) / sum(t.activation) IS NULL THEN 0 ELSE sum(t.charge) / sum(t.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t.activation) / sum(t.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t.activation) /
+        sum(t.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t.event_register),0) as register,
+        CASE WHEN sum(t.charge) / sum(t.event_register) IS NULL THEN 0 ELSE round(sum(t.charge)/sum(t.event_register),3)
+        end as activeRegisterCost ,
+        CASE WHEN sum(t.event_register) / sum(t.activation) IS NULL THEN 0 ELSE concat(round(sum(t.event_register) /
+        sum(t.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t.event_next_day_stay) / sum(t.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t.event_next_day_stay) / sum(t.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+        ctop_kuaishou_report_daily_material t LEFT JOIN (SELECT
+        t1.video_signature as code,
+        COUNT(t1.video_signature) as creativeCount,
+        t4.scenes
+        FROM
+        ctop_ai_kuaishou_strategy_map_creative t1
+        LEFT JOIN ctop_ai_kuaishou_strategy_target_union t2 on t1.strategy_target_union_id=t2.id
+        LEFT JOIN ctop_ai_kuaishou_strategy_target_base t3 on t2.strategy_target_id=t3.id
+        LEFT JOIN ctop_kuaishou_strategy t4 on t1.strategy_id=t4.id
+        WHERE
+        t1.strategy_id= #{strategyId}
+        and t3.id in
+        <foreach item="item" index="index" collection="targetIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        GROUP BY t1.video_signature) r on t.signature=r.`code`
+        where account_id=#{accountId}
+        <if test="startDate != null">
+            AND t.stat_date >=#{startDate}
+        </if>
+        <if test="endDate != null">
+            AND t.stat_date &lt;=#{endDate}
+        </if>
+        GROUP BY t.signature
+    </select>
+
+    <select id="queryAgeChartByTarget" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            t.age_segment as ageSegment,
+        IFNULL(sum(t.charge),0) as cost,
+        IFNULL(sum(t.photo_show),0) as photoShow,
+        IFNULL(sum(t.photo_click),0) as photoClick,
+        CASE WHEN sum(t.photo_click) / sum(t.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.photo_click) /
+        sum(t.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t.aclick),0) as aclick,
+        IFNULL(sum(t.bclick),0) as bclick,
+        CASE WHEN sum(t.bclick) / sum(t.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.bclick) / sum(t.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t.charge) / sum(t.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t.charge) / sum(t.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_click)), 2)
+        END AS cpc ,
+        IFNULL(sum(t.activation),0) as active,
+        CASE WHEN sum(t.charge) / sum(t.activation) IS NULL THEN 0 ELSE sum(t.charge) / sum(t.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t.activation) / sum(t.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t.activation) /
+        sum(t.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t.event_register),0) as register,
+        CASE WHEN sum(t.charge) / sum(t.event_register) IS NULL THEN 0 ELSE round(sum(t.charge)/sum(t.event_register),3)
+        end as activeRegisterCost ,
+        CASE WHEN sum(t.event_register) / sum(t.activation) IS NULL THEN 0 ELSE concat(round(sum(t.event_register) /
+        sum(t.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t.event_next_day_stay) / sum(t.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t.event_next_day_stay) / sum(t.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+            ctop_kuaishou_audience_report_daily_age t
+        WHERE
+                unit_id IN (
+                SELECT
+                    t1.unit_id
+                FROM
+                    ctop_ai_kuaishou_strategy_map_creative t1
+                        LEFT JOIN ctop_ai_kuaishou_strategy_target_union t2 ON t1.strategy_target_union_id = t2.id
+                        LEFT JOIN ctop_ai_kuaishou_strategy_target_base t3 ON t2.strategy_target_id = t3.id
+                        LEFT JOIN ctop_kuaishou_strategy t4 ON t1.strategy_id = t4.id
+                WHERE
+                    t1.strategy_id = #{strategyId}
+                  AND t3.id in
+        <foreach item="item" index="index" collection="targetIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+                GROUP BY
+                    t1.unit_id
+            )
+        GROUP BY
+            t.age_segment
+    </select>
+
+    <select id="queryAgeChartByMaterial" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            t.age_segment as ageSegment,
+        IFNULL(sum(t.charge),0) as cost,
+        IFNULL(sum(t.photo_show),0) as photoShow,
+        IFNULL(sum(t.photo_click),0) as photoClick,
+        CASE WHEN sum(t.photo_click) / sum(t.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.photo_click) /
+        sum(t.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t.aclick),0) as aclick,
+        IFNULL(sum(t.bclick),0) as bclick,
+        CASE WHEN sum(t.bclick) / sum(t.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.bclick) / sum(t.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t.charge) / sum(t.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t.charge) / sum(t.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_click)), 2)
+        END AS cpc ,
+        IFNULL(sum(t.activation),0) as active,
+        CASE WHEN sum(t.charge) / sum(t.activation) IS NULL THEN 0 ELSE sum(t.charge) / sum(t.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t.activation) / sum(t.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t.activation) /
+        sum(t.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t.event_register),0) as register,
+        CASE WHEN sum(t.charge) / sum(t.event_register) IS NULL THEN 0 ELSE round(sum(t.charge)/sum(t.event_register),3)
+        end as activeRegisterCost ,
+        CASE WHEN sum(t.event_register) / sum(t.activation) IS NULL THEN 0 ELSE concat(round(sum(t.event_register) /
+        sum(t.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t.event_next_day_stay) / sum(t.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t.event_next_day_stay) / sum(t.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+            ctop_kuaishou_audience_report_daily_age t
+        WHERE
+                unit_id IN (
+                SELECT
+                    unit_id
+                FROM
+                    ctop_ai_kuaishou_strategy_map_creative
+                WHERE
+                    strategy_id = #{strategyId}
+                  AND video_signature in
+        <foreach item="item" index="index" collection="codes"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+                GROUP BY
+                    unit_id
+            )
+        GROUP BY
+            t.age_segment
+    </select>
+
+    <select id="queryGenderChartByTarget" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t.gender,
+        IFNULL(sum(t.charge),0) as cost,
+        IFNULL(sum(t.photo_show),0) as photoShow,
+        IFNULL(sum(t.photo_click),0) as photoClick,
+        CASE WHEN sum(t.photo_click) / sum(t.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.photo_click) /
+        sum(t.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t.aclick),0) as aclick,
+        IFNULL(sum(t.bclick),0) as bclick,
+        CASE WHEN sum(t.bclick) / sum(t.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.bclick) / sum(t.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t.charge) / sum(t.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t.charge) / sum(t.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_click)), 2)
+        END AS cpc ,
+        IFNULL(sum(t.activation),0) as active,
+        CASE WHEN sum(t.charge) / sum(t.activation) IS NULL THEN 0 ELSE sum(t.charge) / sum(t.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t.activation) / sum(t.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t.activation) /
+        sum(t.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t.event_register),0) as register,
+        CASE WHEN sum(t.charge) / sum(t.event_register) IS NULL THEN 0 ELSE round(sum(t.charge)/sum(t.event_register),3)
+        end as activeRegisterCost ,
+        CASE WHEN sum(t.event_register) / sum(t.activation) IS NULL THEN 0 ELSE concat(round(sum(t.event_register) /
+        sum(t.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t.event_next_day_stay) / sum(t.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t.event_next_day_stay) / sum(t.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+        ctop_kuaishou_audience_report_daily_gender t
+        WHERE
+        unit_id IN (
+        SELECT
+        t1.unit_id
+        FROM
+        ctop_ai_kuaishou_strategy_map_creative t1
+        LEFT JOIN ctop_ai_kuaishou_strategy_target_union t2 ON t1.strategy_target_union_id = t2.id
+        LEFT JOIN ctop_ai_kuaishou_strategy_target_base t3 ON t2.strategy_target_id = t3.id
+        LEFT JOIN ctop_kuaishou_strategy t4 ON t1.strategy_id = t4.id
+        WHERE
+        t1.strategy_id = #{strategyId}
+        AND t3.id in
+        <foreach item="item" index="index" collection="targetIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        GROUP BY
+        t1.unit_id
+        )
+        GROUP BY
+        t.gender
+    </select>
+
+    <select id="queryGenderChartByMaterial" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t.gender,
+        IFNULL(sum(t.charge),0) as cost,
+        IFNULL(sum(t.photo_show),0) as photoShow,
+        IFNULL(sum(t.photo_click),0) as photoClick,
+        CASE WHEN sum(t.photo_click) / sum(t.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.photo_click) /
+        sum(t.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t.aclick),0) as aclick,
+        IFNULL(sum(t.bclick),0) as bclick,
+        CASE WHEN sum(t.bclick) / sum(t.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.bclick) / sum(t.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t.charge) / sum(t.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t.charge) / sum(t.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_click)), 2)
+        END AS cpc ,
+        IFNULL(sum(t.activation),0) as active,
+        CASE WHEN sum(t.charge) / sum(t.activation) IS NULL THEN 0 ELSE sum(t.charge) / sum(t.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t.activation) / sum(t.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t.activation) /
+        sum(t.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t.event_register),0) as register,
+        CASE WHEN sum(t.charge) / sum(t.event_register) IS NULL THEN 0 ELSE round(sum(t.charge)/sum(t.event_register),3)
+        end as activeRegisterCost ,
+        CASE WHEN sum(t.event_register) / sum(t.activation) IS NULL THEN 0 ELSE concat(round(sum(t.event_register) /
+        sum(t.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t.event_next_day_stay) / sum(t.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t.event_next_day_stay) / sum(t.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+        ctop_kuaishou_audience_report_daily_gender t
+        WHERE
+        unit_id IN (
+        SELECT
+        unit_id
+        FROM
+        ctop_ai_kuaishou_strategy_map_creative
+        WHERE
+        strategy_id = #{strategyId}
+        AND video_signature in
+        <foreach item="item" index="index" collection="codes"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        GROUP BY
+        unit_id
+        )
+        GROUP BY
+        t.gender
+    </select>
+
+    <select id="queryRegionChartByTarget" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t.province,
+        IFNULL(sum(t.charge),0) as cost,
+        IFNULL(sum(t.photo_show),0) as photoShow,
+        IFNULL(sum(t.photo_click),0) as photoClick,
+        CASE WHEN sum(t.photo_click) / sum(t.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.photo_click) /
+        sum(t.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t.aclick),0) as aclick,
+        IFNULL(sum(t.bclick),0) as bclick,
+        CASE WHEN sum(t.bclick) / sum(t.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.bclick) / sum(t.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t.charge) / sum(t.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t.charge) / sum(t.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_click)), 2)
+        END AS cpc ,
+        IFNULL(sum(t.activation),0) as active,
+        CASE WHEN sum(t.charge) / sum(t.activation) IS NULL THEN 0 ELSE sum(t.charge) / sum(t.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t.activation) / sum(t.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t.activation) /
+        sum(t.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t.event_register),0) as register,
+        CASE WHEN sum(t.charge) / sum(t.event_register) IS NULL THEN 0 ELSE round(sum(t.charge)/sum(t.event_register),3)
+        end as activeRegisterCost ,
+        CASE WHEN sum(t.event_register) / sum(t.activation) IS NULL THEN 0 ELSE concat(round(sum(t.event_register) /
+        sum(t.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t.event_next_day_stay) / sum(t.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t.event_next_day_stay) / sum(t.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+        ctop_kuaishou_audience_report_daily_province t
+        WHERE
+        unit_id IN (
+        SELECT
+        t1.unit_id
+        FROM
+        ctop_ai_kuaishou_strategy_map_creative t1
+        LEFT JOIN ctop_ai_kuaishou_strategy_target_union t2 ON t1.strategy_target_union_id = t2.id
+        LEFT JOIN ctop_ai_kuaishou_strategy_target_base t3 ON t2.strategy_target_id = t3.id
+        LEFT JOIN ctop_kuaishou_strategy t4 ON t1.strategy_id = t4.id
+        WHERE
+        t1.strategy_id = #{strategyId}
+        AND t3.id in
+        <foreach item="item" index="index" collection="targetIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        GROUP BY
+        t1.unit_id
+        )
+        GROUP BY
+        t.province
+    </select>
+
+    <select id="queryRegionChartByMaterial" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t.province,
+        IFNULL(sum(t.charge),0) as cost,
+        IFNULL(sum(t.photo_show),0) as photoShow,
+        IFNULL(sum(t.photo_click),0) as photoClick,
+        CASE WHEN sum(t.photo_click) / sum(t.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.photo_click) /
+        sum(t.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t.aclick),0) as aclick,
+        IFNULL(sum(t.bclick),0) as bclick,
+        CASE WHEN sum(t.bclick) / sum(t.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.bclick) / sum(t.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t.charge) / sum(t.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t.charge) / sum(t.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_click)), 2)
+        END AS cpc ,
+        IFNULL(sum(t.activation),0) as active,
+        CASE WHEN sum(t.charge) / sum(t.activation) IS NULL THEN 0 ELSE sum(t.charge) / sum(t.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t.activation) / sum(t.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t.activation) /
+        sum(t.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t.event_register),0) as register,
+        CASE WHEN sum(t.charge) / sum(t.event_register) IS NULL THEN 0 ELSE round(sum(t.charge)/sum(t.event_register),3)
+        end as activeRegisterCost ,
+        CASE WHEN sum(t.event_register) / sum(t.activation) IS NULL THEN 0 ELSE concat(round(sum(t.event_register) /
+        sum(t.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t.event_next_day_stay) / sum(t.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t.event_next_day_stay) / sum(t.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+        ctop_kuaishou_audience_report_daily_province t
+        WHERE
+        unit_id IN (
+        SELECT
+        unit_id
+        FROM
+        ctop_ai_kuaishou_strategy_map_creative
+        WHERE
+        strategy_id = #{strategyId}
+        AND video_signature in
+        <foreach item="item" index="index" collection="codes"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        GROUP BY
+        unit_id
+        )
+        GROUP BY
+        t.province
+    </select>
+
+</mapper>

+ 87 - 33
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyListPageMapper.xml

@@ -9,6 +9,7 @@
         t1.strategy_name as strategyName,
         t1.create_time as createTime,
         t1.account_id as accountId,
+        (select auth_name from ctop_user_allocation where account_id=t1.account_id limit 1) as authName,
         '' as status,
         t1.scenes,
         t1.budget,
@@ -29,24 +30,33 @@
         CASE WHEN sum(t3.event_register) / sum(t3.activation) IS NULL THEN 0 ELSE concat(round(sum(t3.event_register) / sum(t3.activation)*100,2),'%') end as activeRegisterRate ,
         IFNULL(sum(t3.event_next_day_stay),0) as nextDayOpen,
         CASE WHEN sum(t3.event_next_day_stay) / sum(t3.activation) IS NULL THEN 0 ELSE concat(round(sum(t3.event_next_day_stay) / sum(t3.activation)*100,2),'%') end as nextDayOpenRate
-        FROM
-        ctop_kuaishou_strategy t1
+        FROM (
+        SELECT
+        DISTINCT t2.campaign_id,
+        t1.id,
+        t1.strategy_state,
+        t1.strategy_name,
+        t1.create_time,
+        t1.account_id,
+        '' as status,
+        t1.scenes,
+        t1.budget
+        from ctop_kuaishou_strategy t1
         LEFT JOIN ctop_ai_kuaishou_strategy_map_creative t2 on t1.id=t2.strategy_id
-        left join ctop_kuaishou_report_daily_campaign t3 on t2.campaign_id=t3.campaign_id
         where t1.account_id in
         <foreach item="item" index="index" collection="accountIds"
                  open="(" separator="," close=")">
             #{item}
         </foreach>
-        <if test="strategyName != null">
-            AND t1.strategy_name like '%${strategyName}%'
-        </if>
+        AND t1.strategy_name like '%${strategyName}%'
         <if test="strategyState != null">
-            AND t1.strategy_state=#{strategyState}
+            AND t1.strategy_state= #{strategyState}
         </if>
         <if test="id != null">
             AND t1.id=#{id}
         </if>
+        ) t1 left join ctop_kuaishou_report_daily_campaign t3 on t1.campaign_id=t3.campaign_id
+        group by t1.campaign_id
         order by t1.create_time desc
     </select>
 
@@ -60,25 +70,46 @@
         IFNULL(sum(t1.charge),0) as cost,
         IFNULL(sum(t1.photo_show),0) as photoShow,
         IFNULL(sum(t1.photo_click),0) as photoClick,
-        CASE WHEN sum(t1.photo_click) / sum(t1.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.photo_click) / sum(t1.photo_show)) * 100,2),'%') END AS clickRate,
+        CASE WHEN sum(t1.photo_click) / sum(t1.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.photo_click) /
+        sum(t1.photo_show)) * 100,2),'%') END AS clickRate,
         IFNULL(sum(t1.aclick),0) as aclick,
         IFNULL(sum(t1.bclick),0) as bclick,
-        CASE WHEN sum(t1.bclick) / sum(t1.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.bclick) / sum(t1.aclick)) * 100,2),'%') END AS bClickRate,
-        CASE WHEN sum(t1.charge) / sum(t1.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_show)) * 1000, 2 ) END AS cpm ,
-        CASE WHEN sum(t1.charge) / sum(t1.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_click)), 2) END AS cpc ,
+        CASE WHEN sum(t1.bclick) / sum(t1.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.bclick) / sum(t1.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t1.charge) / sum(t1.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t1.charge) / sum(t1.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_click)),
+        2) END AS cpc ,
         IFNULL(sum(t1.activation),0) as active,
-        CASE WHEN sum(t1.charge) / sum(t1.activation) IS NULL THEN 0 ELSE sum(t1.charge) / sum(t1.activation) end AS activeCost ,
-        CASE WHEN sum(t1.activation) / sum(t1.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t1.activation) / sum(t1.download_completed)*100,2),'%') end as activeRate ,
+        CASE WHEN sum(t1.charge) / sum(t1.activation) IS NULL THEN 0 ELSE sum(t1.charge) / sum(t1.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t1.activation) / sum(t1.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t1.activation) /
+        sum(t1.download_completed)*100,2),'%') end as activeRate ,
         IFNULL(sum(t1.event_register),0) as register,
-        CASE WHEN sum(t1.charge) / sum(t1.event_register) IS NULL THEN 0 ELSE round(sum(t1.charge)/sum(t1.event_register),3) end as activeRegisterCost ,
-        CASE WHEN sum(t1.event_register) / sum(t1.activation) IS NULL THEN 0 ELSE concat(round(sum(t1.event_register) / sum(t1.activation)*100,2),'%') end as activeRegisterRate ,
+        CASE WHEN sum(t1.charge) / sum(t1.event_register) IS NULL THEN 0 ELSE
+        round(sum(t1.charge)/sum(t1.event_register),3) end as activeRegisterCost ,
+        CASE WHEN sum(t1.event_register) / sum(t1.activation) IS NULL THEN 0 ELSE concat(round(sum(t1.event_register) /
+        sum(t1.activation)*100,2),'%') end as activeRegisterRate ,
         IFNULL(sum(t1.event_next_day_stay),0) as nextDayOpen,
-        CASE WHEN sum(t1.event_next_day_stay) / sum(t1.activation) IS NULL THEN 0 ELSE concat(round(sum(t1.event_next_day_stay) / sum(t1.activation)*100,2),'%') end as nextDayOpenRate
+        CASE WHEN sum(t1.event_next_day_stay) / sum(t1.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t1.event_next_day_stay) / sum(t1.activation)*100,2),'%') end as nextDayOpenRate
         FROM
-        ctop_kuaishou_report_daily_campaign t1
-        LEFT JOIN ctop_ai_kuaishou_strategy_map_creative t2 on t1.campaign_id=t2.campaign_id
-        left join ctop_kuaishou_strategy t3 on t2.strategy_id=t3.id
-        where t3.id= #{strategyId}
+        (
+        SELECT
+        DISTINCT t2.campaign_id,
+        t1.id,
+        t1.strategy_state,
+        t1.strategy_name,
+        t1.create_time,
+        t1.account_id,
+        '' as status,
+        t1.scenes,
+        t1.budget from ctop_kuaishou_strategy t1
+        LEFT JOIN ctop_ai_kuaishou_strategy_map_creative t2 on t1.id=t2.strategy_id
+        where t1.id=#{strategyId}
+        ) t3 left join ctop_kuaishou_report_daily_campaign t1 on t3.campaign_id=t1.campaign_id
+        WHERE
+        1=1
         <if test="campaignName != null">
             and t1.campaign_name like '%${campaignName}}%'
         </if>
@@ -104,25 +135,48 @@
         IFNULL(sum(t1.charge),0) as cost,
         IFNULL(sum(t1.photo_show),0) as photoShow,
         IFNULL(sum(t1.photo_click),0) as photoClick,
-        CASE WHEN sum(t1.photo_click) / sum(t1.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.photo_click) / sum(t1.photo_show)) * 100,2),'%') END AS clickRate,
+        CASE WHEN sum(t1.photo_click) / sum(t1.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.photo_click) /
+        sum(t1.photo_show)) * 100,2),'%') END AS clickRate,
         IFNULL(sum(t1.aclick),0) as aclick,
         IFNULL(sum(t1.bclick),0) as bclick,
-        CASE WHEN sum(t1.bclick) / sum(t1.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.bclick) / sum(t1.aclick)) * 100,2),'%') END AS bClickRate,
-        CASE WHEN sum(t1.charge) / sum(t1.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_show)) * 1000, 2 ) END AS cpm ,
-        CASE WHEN sum(t1.charge) / sum(t1.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_click)), 2) END AS cpc ,
+        CASE WHEN sum(t1.bclick) / sum(t1.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.bclick) / sum(t1.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t1.charge) / sum(t1.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t1.charge) / sum(t1.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_click)),
+        2) END AS cpc ,
         IFNULL(sum(t1.activation),0) as active,
-        CASE WHEN sum(t1.charge) / sum(t1.activation) IS NULL THEN 0 ELSE sum(t1.charge) / sum(t1.activation) end AS activeCost ,
-        CASE WHEN sum(t1.activation) / sum(t1.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t1.activation) / sum(t1.download_completed)*100,2),'%') end as activeRate ,
+        CASE WHEN sum(t1.charge) / sum(t1.activation) IS NULL THEN 0 ELSE sum(t1.charge) / sum(t1.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t1.activation) / sum(t1.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t1.activation) /
+        sum(t1.download_completed)*100,2),'%') end as activeRate ,
         IFNULL(sum(t1.event_register),0) as register,
-        CASE WHEN sum(t1.charge) / sum(t1.event_register) IS NULL THEN 0 ELSE round(sum(t1.charge)/sum(t1.event_register),3) end as activeRegisterCost ,
-        CASE WHEN sum(t1.event_register) / sum(t1.activation) IS NULL THEN 0 ELSE concat(round(sum(t1.event_register) / sum(t1.activation)*100,2),'%') end as activeRegisterRate ,
+        CASE WHEN sum(t1.charge) / sum(t1.event_register) IS NULL THEN 0 ELSE
+        round(sum(t1.charge)/sum(t1.event_register),3) end as activeRegisterCost ,
+        CASE WHEN sum(t1.event_register) / sum(t1.activation) IS NULL THEN 0 ELSE concat(round(sum(t1.event_register) /
+        sum(t1.activation)*100,2),'%') end as activeRegisterRate ,
         IFNULL(sum(t1.event_next_day_stay),0) as nextDayOpen,
-        CASE WHEN sum(t1.event_next_day_stay) / sum(t1.activation) IS NULL THEN 0 ELSE concat(round(sum(t1.event_next_day_stay) / sum(t1.activation)*100,2),'%') end as nextDayOpenRate
+        CASE WHEN sum(t1.event_next_day_stay) / sum(t1.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t1.event_next_day_stay) / sum(t1.activation)*100,2),'%') end as nextDayOpenRate
         FROM
-        ctop_kuaishou_report_daily_group t1
-        LEFT JOIN ctop_ai_kuaishou_strategy_map_creative t2 on t1.unit_id=t2.unit_id
-        left join ctop_kuaishou_strategy t3 on t2.strategy_id=t3.id
-        where t1.campaign_id= #{campaignId}
+        (
+        SELECT
+        DISTINCT
+        t2.unit_id,
+        t2.campaign_id,
+        t1.id,
+        t1.strategy_state ,
+        t1.strategy_name ,
+        t1.create_time ,
+        t1.account_id,
+        '' as status,
+        t1.scenes,
+        t1.budget from ctop_kuaishou_strategy t1
+        LEFT JOIN ctop_ai_kuaishou_strategy_map_creative t2 on t1.id=t2.strategy_id
+        where t2.campaign_id=#{campaignId}
+        ) t3 left join ctop_kuaishou_report_daily_group t1 on t3.unit_id=t1.unit_id
+        where
+        1=1
         <if test="unitName != null">
             and t1.unit_name like '%${unitName}}%'
         </if>

+ 23 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaiShouReportAnalyzeService.java

@@ -0,0 +1,23 @@
+package org.jeecg.modules.ads.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+
+import java.util.List;
+import java.util.Map;
+
+public interface IAiKuaiShouReportAnalyzeService {
+
+    List<JSONObject> getStrategyAndTarget(Long accountId);
+
+    List<JSONObject> getStrategyAndMaterial(Long accountId);
+
+    PageInfo<JSONObject> getTargetReportBy(JSONObject params);
+
+    PageInfo<JSONObject> getMaterialReportBy(JSONObject params);
+
+    Map<String,Object> getTargetChartBy(JSONObject params);
+
+    Map<String,Object> getMaterialChartBy(JSONObject params);
+
+}

+ 109 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaiShouReportAnalyzeServiceImpl.java

@@ -0,0 +1,109 @@
+package org.jeecg.modules.ads.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.modules.ads.mapper.IAiKuaiShouReportAnalyzeMapper;
+import org.jeecg.modules.ads.service.IAiKuaiShouReportAnalyzeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class AiKuaiShouReportAnalyzeServiceImpl implements IAiKuaiShouReportAnalyzeService {
+
+    @Autowired
+    private IAiKuaiShouReportAnalyzeMapper aiKuaiShouReportAnalyzeMapper;
+
+    @Override
+    public List<JSONObject> getStrategyAndTarget(Long accountId) {
+        List<JSONObject> strategies = aiKuaiShouReportAnalyzeMapper.queryStrategyByAccountId(accountId);
+        if (!strategies.isEmpty()) {
+            List<JSONObject> deletes = new ArrayList<>();
+            strategies.forEach(strategy -> {
+                List<JSONObject> targets = aiKuaiShouReportAnalyzeMapper.queryTargetByStrategyId(strategy.getLong("id"));
+                if (targets.isEmpty() || targets.get(0) == null) {
+                    deletes.add(strategy);
+                } else {
+                    strategy.put("targets", targets);
+                }
+            });
+            strategies.removeAll(deletes);
+        }
+        return strategies;
+    }
+
+    @Override
+    public List<JSONObject> getStrategyAndMaterial(Long accountId) {
+        List<JSONObject> strategies = aiKuaiShouReportAnalyzeMapper.queryStrategyByAccountId(accountId);
+        if (!strategies.isEmpty()) {
+            List<JSONObject> deletes = new ArrayList<>();
+            strategies.forEach(strategy -> {
+                List<JSONObject> materials = aiKuaiShouReportAnalyzeMapper.queryMaterialByStrategyId(strategy.getLong("id"));
+                if (materials.isEmpty() || materials.get(0) == null) {
+                    deletes.add(strategy);
+                } else {
+                    strategy.put("materials", materials);
+                }
+            });
+            strategies.removeAll(deletes);
+        }
+        return strategies;
+    }
+
+    @Override
+    public PageInfo<JSONObject> getTargetReportBy(JSONObject params) {
+        Long accountId = params.getLong("accountId");
+        Long strategyId = params.getLong("strategyId");
+        JSONArray targetIds = params.getJSONArray("targetIds");
+        String startDate = params.getString("startDate");
+        String endDate = params.getString("endDate");
+        int pageNo = params.getInteger("pageNo");
+        int pageSize = params.getInteger("pageSize");
+        PageHelper.startPage(pageNo, pageSize);
+        return new PageInfo<>(aiKuaiShouReportAnalyzeMapper.queryMaterialReportBy(accountId, strategyId, targetIds, startDate, endDate));
+    }
+
+    @Override
+    public PageInfo<JSONObject> getMaterialReportBy(JSONObject params) {
+        Long accountId = params.getLong("accountId");
+        Long strategyId = params.getLong("strategyId");
+        JSONArray codes = params.getJSONArray("codes");
+        String startDate = params.getString("startDate");
+        String endDate = params.getString("endDate");
+        int pageNo = params.getInteger("pageNo");
+        int pageSize = params.getInteger("pageSize");
+        PageHelper.startPage(pageNo, pageSize);
+        return new PageInfo<>(aiKuaiShouReportAnalyzeMapper.queryTargetReportBy(accountId, strategyId, codes, startDate, endDate));
+    }
+
+    @Override
+    public Map<String, Object> getTargetChartBy(JSONObject params) {
+        Map<String,Object> result =new HashMap<>();
+        Long strategyId = params.getLong("strategyId");
+        JSONArray targetIds = params.getJSONArray("targetIds");
+        String startDate = params.getString("startDate");
+        String endDate = params.getString("endDate");
+        result.put("age",aiKuaiShouReportAnalyzeMapper.queryAgeChartByTarget(strategyId,targetIds,startDate,endDate));
+        result.put("gender",aiKuaiShouReportAnalyzeMapper.queryGenderChartByTarget(strategyId,targetIds,startDate,endDate));
+        result.put("region",aiKuaiShouReportAnalyzeMapper.queryRegionChartByTarget(strategyId,targetIds,startDate,endDate));
+        return result;
+    }
+
+    @Override
+    public Map<String, Object> getMaterialChartBy(JSONObject params) {
+        Map<String,Object> result =new HashMap<>();
+        Long strategyId = params.getLong("strategyId");
+        JSONArray codes = params.getJSONArray("codes");
+        String startDate = params.getString("startDate");
+        String endDate = params.getString("endDate");
+        result.put("age",aiKuaiShouReportAnalyzeMapper.queryAgeChartByMaterial(strategyId,codes,startDate,endDate));
+        result.put("gender",aiKuaiShouReportAnalyzeMapper.queryGenderChartByMaterial(strategyId,codes,startDate,endDate));
+        result.put("region",aiKuaiShouReportAnalyzeMapper.queryRegionChartByMaterial(strategyId,codes,startDate,endDate));
+        return result;    }
+}

+ 2 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaiShouStrategyListPageServiceImpl.java

@@ -1,6 +1,5 @@
 package org.jeecg.modules.ads.service.impl;
 
-import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -11,7 +10,6 @@ import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.ads.mapper.AiKuaiShouStrategyListPageMapper;
 import org.jeecg.modules.ads.service.IAiKuaiShouStrategyListPageService;
-import org.jeecg.modules.system.service.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -22,18 +20,16 @@ import java.util.List;
 public class AiKuaiShouStrategyListPageServiceImpl implements IAiKuaiShouStrategyListPageService {
 
     @Autowired
-    AiKuaiShouStrategyListPageMapper  aiKuaiShouStrategyListPageMapper;
+    AiKuaiShouStrategyListPageMapper aiKuaiShouStrategyListPageMapper;
 
     @Autowired
     IUserAllocationService userAllocationService;
-    @Autowired
-    private ISysRoleService sysRoleService;
 
     @Override
     public PageInfo<JSONObject> pageStrategy(JSONObject params) {
         JSONArray accountIds= params.getJSONArray("accountIds");
         if(null == accountIds||accountIds.isEmpty()){
-            accountIds = null;
+            accountIds=listToJSONArray(userAllocationService.getAccountIdsByUserId(((LoginUser) SecurityUtils.getSubject().getPrincipal()).getId()));
         }
         String strategyName=params.getString("strategyName");
         Integer strategyState=params.getInteger("strategyState");

+ 125 - 40
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiStrategyServiceImpl.java

@@ -9,6 +9,7 @@ import cn.com.ctop.common.module.service.IMaterialImageInfoService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouVideoGetMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
@@ -56,6 +57,9 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
     private IKuaiShouImageGetService imageGetService;
     @Autowired
     private IKuaiShouMaterialUploadService materialUploadService;
+    @Autowired
+    private KuaiShouVideoGetMapper videoGetMapper;
+
     /**
      *
      * @param strategy
@@ -69,12 +73,7 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
             log.info("token获取失败=>accountId:{}",strategy.getAccountId());
             return;
         }
-        //1:获取相应账户下的最新的5条素材信息
-        List<KuaiShouVideoGet> videoGets = videoGetService.getNewVideoByAccountId(accountId,1);
-        if(null == videoGets){
-            log.info("素材获取失败=>accountId:{}",accountId);
-            return;
-        }
+
         //策略类型
         String scenes = strategy.getScenes();
         //根据策略类型获取策略模板信息
@@ -83,6 +82,36 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
             log.info("策略模板信息获取失败=>testDirection:{}",scenes);
             return;
         }
+
+        // 1: 根据模板信息表里的 material_select_method (素材选择方式),得到"跑量视频"和"上新视频"获取方式
+        // {'highQualityMaterial':{'days':7, 'num':5},'newMaterialNum':5}
+        // TODO 更新该账户下的 ctop_kuaishou_video_get 数据
+
+        kuaishouInterfaceService.getVideoList(token,DateUtils.date2Str(),DateUtils.date2Str());
+
+        JSONObject MaterialSelectMethod = JSONObject.parseObject(strategyTemplate.getMaterialSelectMethod());
+        List<KuaiShouVideoGet> newVideos = new ArrayList<KuaiShouVideoGet>();
+        List<KuaiShouVideoGet> highQualityVideos = new ArrayList<KuaiShouVideoGet>();
+
+        if (MaterialSelectMethod.containsKey("newMaterialNum")){
+            int newVideoCnt = (int) MaterialSelectMethod.get("newMaterialNum");
+            newVideos = videoGetService.getNewVideoDescDate(accountId,newVideoCnt);
+        }
+        if(MaterialSelectMethod.containsKey("highQualityMaterial")){
+            int days = MaterialSelectMethod.getJSONObject("highQualityMaterial").getInteger("days");
+            int highQualityVideoCnt = MaterialSelectMethod.getJSONObject("highQualityMaterial").getInteger("num");
+            highQualityVideos = videoGetMapper.getHighQualityVideo(accountId,days,highQualityVideoCnt);
+        }
+
+        // 跑量视频 + 上新视频 合并到一个list, 为单素材搭配组做准备 TODO
+        List<KuaiShouVideoGet> fullVideos = new ArrayList<KuaiShouVideoGet>();
+        fullVideos.addAll(highQualityVideos);
+        fullVideos.addAll(newVideos);
+        if(fullVideos.isEmpty()){
+            log.info("素材获取失败=>accountId:{}",accountId);
+            return;
+        }
+
         String materialFixType = strategyTemplate.getMaterialFixType();
         Date campaignDate = new Date();
         String timestamp = DateUtils.formatDate(campaignDate,"yyyyMMddHHmmss");
@@ -96,7 +125,7 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
             //7、一个计划,拼装创建计划的入参json
             JSONObject campaignParams = new JSONObject();
             campaignParams.put("advertiser_id",token.getAccountId());
-            String campaignName = "户14-上下滑&信息流" + "-自定义001"+ "剪辑-低价-低价包邮-活动-年龄18岁以上-单出价-"+ timestamp;
+            String campaignName = "户14-上下滑&信息流" + "-自定义001-"+ "剪辑-低价-低价包邮-活动-年龄18岁以上-单出价-"+ timestamp;
             campaignParams.put("campaign_name",campaignName);
             campaignParams.put("type",Integer.parseInt(strategy.getMarketingGoal()));
             campaignParams.put("day_budget",0L);
@@ -109,12 +138,12 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
             }
             Long campaignId = (Long) campaignCreateResult.get("campaignId");
             int unitCnt = 1;
-            // 8、根据定向和素材,两层循环 创建组和创意
+            // 8、根据素材和出价,两层循环 创建组和创意
             for (Long item:getCapbids) {
                 //判定素材搭配方式
                 if(null!=materialFixType&&materialFixType.trim().equals("single")){
                     // 选择素材,创建创意
-                    for(KuaiShouVideoGet videoItem: videoGets){
+                    for(KuaiShouVideoGet videoItem: fullVideos){
                         //拼装广告组参数
                         unitCnt ++;
                         String unitName = campaignName + "-" + unitCnt;
@@ -146,41 +175,97 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
                             createCreativeByImage(cutFrameList,orgFrameList,token,creativeParams,campaignId,unitId,strategy,videoItem,15,null);
                         }
                     }
-                }else{
+                }
+                else{
                     //混搭素材逻辑
-                    String unitName = campaignName + "-" + unitCnt;
-                    JSONObject unitParams = createUnitParams(token, campaignId, strategy, item, unitName);
-                    Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
-                    Integer unitCode = (Integer) unitCreateResult.get("code");
-                    String unitMessage = (String) unitCreateResult.get("message");
-                    if(unitCode != 0 ){
-                        log.info("组创建失败=>accountId:{};message:{}",accountId,unitMessage);
-                        continue;
+                    //跑量素材
+                    if(highQualityVideos.size() > 0){
+                        // 取模和余数:
+                        int mod = highQualityVideos.size() / 15;
+                        int rem = highQualityVideos.size() % 15;
+                        int innerUnitCnt = 0;
+                        if(mod!=0){
+                            for(int i=0;i<mod;i++){
+                                String unitName = campaignName + "-跑量-" + item + "-" + innerUnitCnt;
+                                JSONObject unitParams = createUnitParams(token, campaignId, strategy, item, unitName);
+                                Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
+                                Integer unitCode = (Integer) unitCreateResult.get("code");
+                                String unitMessage = (String) unitCreateResult.get("message");
+                                if(unitCode != 0 ){
+                                    log.info("组创建失败=>accountId:{};message:{}",accountId,unitMessage);
+                                    continue;
+                                }
+                                Long unitId = (Long) unitCreateResult.get("unitId");
+                                for(int j=0;j<15;j++){
+                                    JSONObject creativeParams = creativeParams(token,unitId,highQualityVideos.get(i*15+j),unitCnt,strategy);
+                                    createCreative(token,creativeParams,campaignId,unitId,strategy,null,j+1,highQualityVideos.get(i*15+j));
+                                }
+                                innerUnitCnt++;
+                            }
+
+                        }
+                        if(rem!=0){
+                            String unitName = campaignName + "-跑量-" + item + "-" + innerUnitCnt;
+                            JSONObject unitParams = createUnitParams(token, campaignId, strategy, item, unitName);
+                            Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
+                            Integer unitCode = (Integer) unitCreateResult.get("code");
+                            String unitMessage = (String) unitCreateResult.get("message");
+                            if(unitCode != 0 ){
+                                log.info("组创建失败=>accountId:{};message:{}",accountId,unitMessage);
+                                continue;
+                            }
+                            Long unitId = (Long) unitCreateResult.get("unitId");
+
+                            for(int j=0;j<rem;j++){
+                                JSONObject creativeParams = creativeParams(token,unitId,highQualityVideos.get(mod*15+j),unitCnt,strategy);
+                                createCreative(token,creativeParams,campaignId,unitId,strategy,null,j+1,highQualityVideos.get(mod*15+j));
+                            }
+                        }
                     }
-                    Long unitId = (Long) unitCreateResult.get("unitId");
-                    // 选择素材,创建创意
-                    for(KuaiShouVideoGet videoItem: videoGets){
-                        //拼装广告组参数
-                        JSONObject creativeParams = creativeParams(token,unitId,videoItem,unitCnt,strategy);
-                        JSONArray sceneIdJsonArray = JSONArray.parseArray(strategy.getSceneId());
-                        // 如果广告位只包含 上下滑大屏广告(6),则一个素材搭配1张封面,生成1个创意
-                        if (sceneIdJsonArray.contains(6) && sceneIdJsonArray.size() == 1){
-                            //直接创建创意
-                            createCreative(token,creativeParams,campaignId,unitId,strategy,null,1,videoItem);
-                        } else {
-                            // 素材自带的封面 ctop_material_image_info 内部素材的自带封面,素造的没有
-                            // 素材的智能抽帧封面 ctop_material_cut_frame 其中素造的为8张封面,内部的为15张封面
-                            List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
-                            List<MaterialImageInfo> orgFrameList = materialImageInfoService.getListByVideoSignature(videoItem.getSignature());
-                            // 其他情况下,一个素材搭配15张封面,生成15个创意
-                            if ((null == cutFrameList||cutFrameList.isEmpty())&&(null == orgFrameList|| orgFrameList.isEmpty())){
-                                log.info("未获取到视频封面=>videoSignature:{}",videoItem.getSignature());
+                    // 新上素材混搭
+                    if(newVideos.size() > 0){
+                        // 取模和余数:
+                        int mod = newVideos.size() / 15;
+                        int rem = newVideos.size() % 15;
+                        int innerUnitCnt = 0;
+                        if(mod!=0){
+                            for(int i=0;i<mod;i++){
+                                String unitName = campaignName + "-上新-" + item + "-" + innerUnitCnt;
+                                JSONObject unitParams = createUnitParams(token, campaignId, strategy, item, unitName);
+                                Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
+                                Integer unitCode = (Integer) unitCreateResult.get("code");
+                                String unitMessage = (String) unitCreateResult.get("message");
+                                if(unitCode != 0 ){
+                                    log.info("组创建失败=>accountId:{};message:{}",accountId,unitMessage);
+                                    continue;
+                                }
+                                Long unitId = (Long) unitCreateResult.get("unitId");
+                                for(int j=0;j<15;j++){
+                                    JSONObject creativeParams = creativeParams(token,unitId,newVideos.get(i*15+j),unitCnt,strategy);
+                                    createCreative(token,creativeParams,campaignId,unitId,strategy,null,j+1,newVideos.get(i*15+j));
+                                }
+                                innerUnitCnt++;
+                            }
+
+                        }
+                        if(rem!=0){
+                            String unitName = campaignName + "-上新-" + item + "-" + innerUnitCnt;
+                            JSONObject unitParams = createUnitParams(token, campaignId, strategy, item, unitName);
+                            Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
+                            Integer unitCode = (Integer) unitCreateResult.get("code");
+                            String unitMessage = (String) unitCreateResult.get("message");
+                            if(unitCode != 0 ){
+                                log.info("组创建失败=>accountId:{};message:{}",accountId,unitMessage);
                                 continue;
                             }
-                            createCreativeByImage(cutFrameList,orgFrameList,token,creativeParams,campaignId,unitId,strategy,videoItem,1,null);
+                            Long unitId = (Long) unitCreateResult.get("unitId");
+
+                            for(int j=0;j<rem;j++){
+                                JSONObject creativeParams = creativeParams(token,unitId,newVideos.get(mod*15+j),unitCnt,strategy);
+                                createCreative(token,creativeParams,campaignId,unitId,strategy,null,j+1,newVideos.get(mod*15+j));
+                            }
                         }
                     }
-                    unitCnt ++;
                 }
             }
         }else if(scenes.equals(2)){
@@ -225,7 +310,7 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
                     AiKuaishouStrategyTargetUnion targetUnion = new AiKuaishouStrategyTargetUnion(strategyMiddle.getId(),item.getId(),item.getTargetContent());
                     targetUnionService.save(targetUnion);
                     // 选择素材,创建创意
-                    for(KuaiShouVideoGet videoItem: videoGets){
+                    for(KuaiShouVideoGet videoItem: fullVideos){
                         //拼装广告组参数
                         unitCnt++;
                         String unitName = campaignName + "-" + unitCnt;
@@ -262,7 +347,7 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
                     AiKuaishouStrategyTargetUnion targetUnion = new AiKuaishouStrategyTargetUnion(strategyMiddle.getId(),item.getId(),item.getTargetContent());
                     targetUnionService.save(targetUnion);
                     // 选择素材,创建创意
-                    for(KuaiShouVideoGet videoItem: videoGets){
+                    for(KuaiShouVideoGet videoItem: fullVideos){
                         unitCnt++;
                         String unitName = campaignName + "-" + unitCnt;
                         JSONObject unitParams = createUnitParams(token,campaignId,strategy,strategyTemplate, item,timestamp,unitName);

+ 10 - 19
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BytedanceVideoEtlInfoController.java

@@ -1,6 +1,5 @@
 package org.jeecg.modules.ctop.controller;
 
-import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.vo.SheetInfoVo;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
@@ -8,37 +7,29 @@ import cn.com.ctop.toutiao.modules.report.service.IBytedanceVideoEtlInfoService;
 import com.alibaba.excel.EasyExcelFactory;
 import com.alibaba.excel.ExcelWriter;
 import com.alibaba.excel.metadata.Sheet;
-import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.util.DateUtils;
-import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.excelutil.entity.BytedanceVideoEtlInfoEntity;
-import org.jeecg.modules.excelutil.entity.KuaishouXxlEntity;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
-import org.jeecgframework.poi.excel.def.NormalExcelConstants;
-import org.jeecgframework.poi.excel.entity.ExportParams;
 import org.jeecgframework.poi.excel.entity.ImportParams;
-import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
-import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 头条视频信息清洗
@@ -81,7 +72,7 @@ public class BytedanceVideoEtlInfoController {
 					queryWrapper.gt("effect_date",startDate);
 				}
 				if(null!=endDate&&!"".equals(endDate.trim())){
-					queryWrapper.lt("effect_date",startDate);
+					queryWrapper.lt("effect_date",endDate);
 				}
 				queryWrapper.lt("effect_day_num",7);
 			}else if(type.trim().equals("hot")){
@@ -90,7 +81,7 @@ public class BytedanceVideoEtlInfoController {
 					queryWrapper.gt("",startDate);
 				}
 				if(null!=endDate&&!"".equals(endDate.trim())){
-					queryWrapper.lt("faddish_date",startDate);
+					queryWrapper.lt("faddish_date",endDate);
 				}
 				queryWrapper.lt("faddish_day_num",30);
 			}else {
@@ -99,7 +90,7 @@ public class BytedanceVideoEtlInfoController {
 					queryWrapper.gt("state_date",startDate);
 				}
 				if(null!=endDate&&!"".equals(endDate.trim())){
-					queryWrapper.lt("state_date",startDate);
+					queryWrapper.lt("state_date",endDate);
 				}
 			}
 		}
@@ -193,7 +184,7 @@ public class BytedanceVideoEtlInfoController {
 				  queryWrapper.gt("effect_date",startDate);
 			  }
 			  if(null!=endDate&&!"".equals(endDate.trim())){
-				  queryWrapper.lt("effect_date",startDate);
+				  queryWrapper.lt("effect_date",endDate);
 			  }
 			  queryWrapper.lt("effect_day_num",7);
 		  }else if(type.trim().equals("hot")){
@@ -202,7 +193,7 @@ public class BytedanceVideoEtlInfoController {
 				  queryWrapper.gt("",startDate);
 			  }
 			  if(null!=endDate&&!"".equals(endDate.trim())){
-				  queryWrapper.lt("faddish_date",startDate);
+				  queryWrapper.lt("faddish_date",endDate);
 			  }
 			  queryWrapper.lt("faddish_day_num",30);
 		  }else {
@@ -211,7 +202,7 @@ public class BytedanceVideoEtlInfoController {
 				  queryWrapper.gt("state_date",startDate);
 			  }
 			  if(null!=endDate&&!"".equals(endDate.trim())){
-				  queryWrapper.lt("state_date",startDate);
+				  queryWrapper.lt("state_date",endDate);
 			  }
 		  }
 	  }

+ 6 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/KuaishouVideoEtlInfoController.java

@@ -69,7 +69,7 @@ public class KuaishouVideoEtlInfoController {
 					queryWrapper.gt("effect_date",startDate);
 				}
 				if(null!=endDate&&!"".equals(endDate.trim())){
-					queryWrapper.lt("effect_date",startDate);
+					queryWrapper.lt("effect_date",endDate);
 				}
 				queryWrapper.lt("effect_day_num",7);
 			}else if(type.trim().equals("hot")){
@@ -78,7 +78,7 @@ public class KuaishouVideoEtlInfoController {
 					queryWrapper.gt("",startDate);
 				}
 				if(null!=endDate&&!"".equals(endDate.trim())){
-					queryWrapper.lt("faddish_date",startDate);
+					queryWrapper.lt("faddish_date",endDate);
 				}
 				queryWrapper.lt("faddish_day_num",30);
 			}else {
@@ -87,7 +87,7 @@ public class KuaishouVideoEtlInfoController {
 					queryWrapper.gt("state_date",startDate);
 				}
 				if(null!=endDate&&!"".equals(endDate.trim())){
-					queryWrapper.lt("state_date",startDate);
+					queryWrapper.lt("state_date",endDate);
 				}
 			}
 		}
@@ -181,7 +181,7 @@ public class KuaishouVideoEtlInfoController {
 				  queryWrapper.gt("effect_date",startDate);
 			  }
 			  if(null!=endDate&&!"".equals(endDate.trim())){
-				  queryWrapper.lt("effect_date",startDate);
+				  queryWrapper.lt("effect_date",endDate);
 			  }
 			  queryWrapper.lt("effect_day_num",7);
 		  }else if(type.trim().equals("hot")){
@@ -190,7 +190,7 @@ public class KuaishouVideoEtlInfoController {
 				  queryWrapper.gt("",startDate);
 			  }
 			  if(null!=endDate&&!"".equals(endDate.trim())){
-				  queryWrapper.lt("faddish_date",startDate);
+				  queryWrapper.lt("faddish_date",endDate);
 			  }
 			  queryWrapper.lt("faddish_day_num",30);
 		  }else {
@@ -199,7 +199,7 @@ public class KuaishouVideoEtlInfoController {
 				  queryWrapper.gt("state_date",startDate);
 			  }
 			  if(null!=endDate&&!"".equals(endDate.trim())){
-				  queryWrapper.lt("state_date",startDate);
+				  queryWrapper.lt("state_date",endDate);
 			  }
 		  }
 	  }

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java

@@ -499,6 +499,7 @@ public class MaterialInfoController {
                 url = KuaishouInterfaceConstant.HTTPS_PREFIX + url;
             }
             materialInfo.setUrl(url);
+            materialInfo.setCreateTime(new Date());
             MaterialCutFrame cutFrame = materialCutFrameService.getCutFrameByCode(materialInfo.getCode());
             if (Check.isNull(cutFrame)) {
                 String videoUrl = URLDecoder.decode(url).replace("https://media-1301855440.cos.ap-chongqing.myqcloud.com/", "");

+ 16 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java

@@ -28,10 +28,21 @@ import org.jeecg.modules.ctop.service.IAdvertiserService;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 项目成员
@@ -178,18 +189,19 @@ public class ProjectMemberController {
                 userId = null;
             }
             List<JSONObject> projectList = projectMemberService.getProjectByUserIdAndMediaIds(userId, mediaIds);
+            List<JSONObject> haveList = new ArrayList<>();
             if (!Check.isNull(projectList)) {
                 for (int i = 0; i < projectList.size(); i++) {
                     JSONObject project = projectList.get(i);
                     List<JSONObject> accountList = userAllocationService.getAccountListByProject(project.getLong("projectId"));
                     if (!Check.isNull(accountList)) {
                         project.put("accountList", accountList);
+                        haveList.add(project);
                     }
                 }
             }
             result.setSuccess(true);
-            result.setResult(projectList);
-
+            result.setResult(haveList);
         } catch (Exception e) {
             e.printStackTrace();
             result.setSuccess(false);

+ 28 - 19
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -10,6 +10,7 @@ import cn.com.ctop.crawler.modules.core.service.CrawlerDouyinMusicTaskService;
 import cn.com.ctop.crawler.modules.douyin.service.DouyinMusicService;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
 import cn.com.ctop.toutiao.modules.report.service.*;
@@ -86,6 +87,14 @@ public class TestController {
     static ExecutorService executorService = Executors.newFixedThreadPool(15);
     static ExecutorService videoService = Executors.newFixedThreadPool(5);
     static ExecutorService suzhaoService = Executors.newFixedThreadPool(10);
+    @Autowired
+    private IKuaiShouDailyAgentService dailyAgentService;
+
+
+    @GetMapping(value = "/agentReport")
+    public void agentReport(String startDate, String endDate) {
+        dailyAgentService.getAgentReportByPage(startDate, endDate);
+    }
 
 
     @GetMapping(value = "/dailyReport")
@@ -100,19 +109,19 @@ public class TestController {
     }
 
     @GetMapping("getKuaishouPlanHourlyReport")
-    public Map<String,Object> getKuaishouPlanHourlyReport(String params){
+    public Map<String, Object> getKuaishouPlanHourlyReport(String params) {
         Long start = System.currentTimeMillis();
-        Map<String,Object>result = new HashMap<>();
-        if(null == params||params.trim().equals("")){
-            ResultMapUtils.setResultMap(result,StatusCode.COMMON_PARAM_ERROR);
-            result.put("message","COMMON_PARAM_ERROR");
+        Map<String, Object> result = new HashMap<>();
+        if (null == params || params.trim().equals("")) {
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
+            result.put("message", "COMMON_PARAM_ERROR");
             return result;
         }
         Long accountId = Long.parseLong(params);
         CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
-        if(null == token){
-            ResultMapUtils.setResultMap(result,StatusCode.COMMON_PARAM_ERROR);
-            result.put("message","TOKEN_IS_NULL");
+        if (null == token) {
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
+            result.put("message", "TOKEN_IS_NULL");
             return result;
         }
         Date getDate = new Date();
@@ -125,22 +134,20 @@ public class TestController {
         Date finalGetDate = getDate;
         try {
             kuaishouInterfaceService.getAdvertiserCampaignReportHourly(token, finalGetDate, finalGetDate);
-            ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
-            result.put("message","SUCCESS");
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+            result.put("message", "SUCCESS");
             long end = System.currentTimeMillis();
-            log.info("执行时长:{}毫秒",end-start);
+            log.info("执行时长:{}毫秒", end - start);
             return result;
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
-            ResultMapUtils.setResultMap(result,StatusCode.COMMON_SERVER_ERROR);
-            result.put("message","COMMON_SERVER_ERROR");
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_SERVER_ERROR);
+            result.put("message", "COMMON_SERVER_ERROR");
             return result;
         }
     }
 
 
-
-
     @GetMapping(value = "/getMd5")
     public void getMd5() {
         kuaiShouHistoryReportTaskService.getMd5(null, null);
@@ -1199,13 +1206,15 @@ public class TestController {
 
         return result;
     }
+
     @Autowired
     private IKuaiShouCommentService kuaiShouCommentService;
+
     @GetMapping("deleteComment")
-    public Map<String,Object>deleteComment(Long accountId){
-        Map<String,Object>result = new HashMap<>();
+    public Map<String, Object> deleteComment(Long accountId) {
+        Map<String, Object> result = new HashMap<>();
         kuaiShouCommentService.shieldComment(accountId);
-        ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
         return result;
     }
 }

+ 0 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java

@@ -16,7 +16,6 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.StringUtils;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;

+ 12 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java

@@ -6,6 +6,8 @@ import cn.com.ctop.common.module.entity.SysRole;
 import cn.com.ctop.common.module.entity.SysUser;
 import cn.com.ctop.common.module.model.SysUserSysDepartModel;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.common.module.vo.SysDepartUsersVO;
 import cn.com.ctop.common.module.vo.SysUserRoleVO;
 import cn.com.ctop.common.module.vo.SysUserVo;
@@ -111,6 +113,16 @@ public class SysUserController {
         return map;
     }
 
+    @RequestMapping(value = "/getAllDesigner", method = RequestMethod.GET)
+    public Map<String, Object> getAllDesigner() {
+        Map<String, Object> map = new HashMap<>();
+        List<SysUser> userList = sysUserService.getAllDesigner();
+        map.put("data",userList);
+        ResultMapUtils.setResultMap(map, StatusCode.COMMON_SUCCESS);
+        return map;
+    }
+
+
     @Autowired
     private UserCompanyMapper userCompanyMapper;
 

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserService.java

@@ -260,4 +260,7 @@ public interface ISysUserService extends IService<SysUser> {
     List<SysUser> queryByDepIds(List<String> departIds, String username);
 
     List<SysUserVo> getAllUser(String userName);
+
+    List<SysUser> getAllDesigner();
+
 }

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java

@@ -275,6 +275,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     }
 
     @Override
+    public List<SysUser> getAllDesigner() {
+        return userMapper.selectAllDesigner();
+    }
+
+    @Override
     public Map<String, String> getDepNamesByUserIds(List<String> userIds) {
         List<SysUserDepVo> list = this.baseMapper.getDepNamesByUserIds(userIds);
         Map<String, String> res = new HashMap<String, String>();

+ 26 - 22
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -1,6 +1,5 @@
 package org.jeecg;
 
-import cn.com.ctop.alarm.modules.service.IAlarmEventSendService;
 import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.UserAllocation;
@@ -13,17 +12,14 @@ import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyReportTaskServic
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
-import cn.com.ctop.kuaishou.modules.report.service.IKuaishouCostGroupService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouVideoEtlInfoService;
 import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
 import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
 import cn.com.ctop.oa.modules.service.IWechatNoListService;
 import cn.com.ctop.oa.modules.service.IWechatUserListService;
-import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.report.service.*;
-import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.junit.Test;
@@ -350,14 +346,6 @@ public class SampleTest {
     }
 
     @Autowired
-    IRuleKuaiShouPlanService kuaiShouPlanService;
-
-    @Test
-    public void kuaishouRuleData() {
-        kuaiShouPlanService.cleanRuleDataUnit(3429620L, "2020-12-07", "2020-12-07", 1);
-    }
-
-    @Autowired
     private IKuaiShouCommentService kuaiShouCommentService;
 
     @Test
@@ -396,12 +384,12 @@ public class SampleTest {
     private IKuaishouVideoEtlInfoService kuaishouVideoEtlInfoService;
     @Test
     public void etlKuaishouData(){
-        String dateString = "2020-08-29";
+        String dateString = "2020-12-25";
         Date startDate = DateUtils.parseDate(dateString,"yyyy-MM-dd");
-        for(int i=0;i<=185;i++){
+        for(int i=0;i<=10;i++){
             Date getDate = DateUtils.addDay(startDate,i);
             kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
-//            bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
+            bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
         }
     }
 
@@ -409,12 +397,12 @@ public class SampleTest {
     private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
     @Test
     public void etlBytedanceData(){
-        String dateString = "2020-07-01";
+        String dateString = "2020-12-23";
         Date startDate = DateUtils.parseDate(dateString,"yyyy-MM-dd");
-        for(int i=0;i<=310;i++){
+        for(int i=0;i<=10;i++){
             Date getDate = DateUtils.addDay(startDate,i);
             bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
-//            kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
+            kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
         }
     }
 
@@ -428,10 +416,26 @@ public class SampleTest {
 
     @Test
     public void loadKuaishouVideo(){
-        String endDate = DateUtils.getNowDate("yyyy-MM-dd");
-        CtopOauthToken token = tokenService.getTokenByAccountId(9718688L);
-//        kuaishouInterfaceService.getVideoList(token, endDate, endDate);
-        kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, new Date(), new Date(), null, null);
+        Date date = new Date();
+        CtopOauthToken token = tokenService.getTokenByAccountId(9556344L);
+//        kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, new Date(), new Date(), null, null);
+        kuaishouInterfaceService.getVideoList(token, DateUtils.formatDate(DateUtils.addDay(date,-5)), DateUtils.formatDate(date));
+        // 获取图片信息数据
+//        kuaishouInterfaceService.getImageList(token, DateUtils.getNowDate("yyyy-MM-dd"));
+    }
+
+
+
+
+    @Autowired
+    IRuleByteDanceAccountService ruleByteDanceAccountService;
+
+    @Test
+    public void cleanRuleDataAccount(){
+        List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
+        for(CtopOauthToken oauthToken:tokens){
+            ruleKuaiShouPlanService.cleanRuleDataTarget(oauthToken.getAccountId(),1);
+        }
     }
 
 }

+ 13 - 3
module-alarm/src/main/java/cn/com/ctop/alarm/modules/constant/MatchLogic.java

@@ -96,6 +96,13 @@ public class MatchLogic {
                     }
                 }
             } else {
+                /**
+                 不包含逻辑根据指标分两种:
+                 1、大部分数组型指标阈值逻辑:所设的阈值中,存在任一目标则不报警,都不存在时则报警,出现阈值之外的亦报警
+                 2、排除人群包、排除流量包逻辑:所选必须都存在,否则报警
+
+                 包含逻辑通用: 任一存在则报警
+                 */
                 if (value.contains("[") && threshold.contains("[")) {
                     List<String> values = strToList(value);
                     List<String> thresholds = strToList(threshold);
@@ -120,13 +127,16 @@ public class MatchLogic {
                                 }
                             }
                         } else {
-                            //不包含,任一存在不报警,都不存在则报警
+                            boolean flag = true;
+                            //不包含,阈值中,存在任一目标则不报警,都不存在时则报警,出现阈值之外的亦报警
                             for (String v : values) {
                                 if (threshold.contains(v)) {
-                                    return false;
+                                    flag = false;
+                                } else {
+                                    return true;
                                 }
                             }
-                            return true;
+                            return flag;
                         }
                     }
                 } else {

+ 3 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/entity/RuleIndicator.java

@@ -75,6 +75,9 @@ public class RuleIndicator {
     @Excel(name = "对应数据字典id", width = 15)
     @ApiModelProperty(value = "对应数据字典id")
     private String dictId;
+
+    private String requestUrl;
+
     /**
      * 对应数据表名称
      */

+ 2 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleTemplateServiceImpl.java

@@ -344,6 +344,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                         ruleJson.put("dataUnit", ruleIndicator.getDataUnit());
                         ruleJson.put("name", ruleIndicator.getName());
                         ruleJson.put("modelType", ruleIndicator.getModelType());
+                        ruleJson.put("requestUrl", ruleIndicator.getRequestUrl());
                     }
 
                     ruleDetail.add(ruleJson);
@@ -490,6 +491,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                         ruleJson.put("dataUnit", ruleIndicator.getDataUnit());
                         ruleJson.put("name", ruleIndicator.getName());
                         ruleJson.put("modelType", ruleIndicator.getModelType());
+                        ruleJson.put("requestUrl", ruleIndicator.getRequestUrl());
                     }
 
                     ruleDetail.add(ruleJson);

+ 19 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataTargetKuaishou.java

@@ -39,4 +39,23 @@ public class RuleDataTargetKuaishou {
 	private String scheduleTime;
 
 	private Integer status;
+
+	/**应用商店*/
+	private String appStore;
+
+	/**定向人群包*/
+	private String population;
+
+	/**排除人群包*/
+	private String excludePopulation;
+
+	/**年龄范围*/
+	private String agesRange;
+
+	/**商业兴趣*/
+	private String businessInterest;
+
+	/**网络环境*/
+	private Integer network;
+
 }

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/SysUser.java

@@ -198,4 +198,9 @@ public class SysUser implements Serializable {
     @TableField(exist = false)
     private String depart;
 
+    /**
+     * 部门
+     */
+    @TableField(exist = false)
+    private String roleName;
 }

+ 1 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/SysUserMapper.java

@@ -25,6 +25,7 @@ import java.util.Map;
  */
 public interface SysUserMapper extends BaseMapper<SysUser> {
     List<SysUser> selectAllUser();
+    List<SysUser> selectAllDesigner();
 
     /**
      * 通过用户账号查询用户信息

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java

@@ -29,6 +29,8 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
 
     List<JSONObject> getAccountIdsByUserId(@Param("userId") String userId);
 
+    List<JSONObject> getAllAccountIdsByMediaId(@Param("mediaId") String mediaId);
+
     Long getProjectIdByAccountId(@Param("accountId") Long accountId);
 
     UserAllocation getUserAllocation(@Param("accountId") Long accountId);

+ 6 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysUserMapper.xml

@@ -254,4 +254,10 @@ SELECT
         INNER JOIN  ctop_user_allocation t2 ON t1.id = t2.user_id
         WHERE t2.account_id = #{accountId}
     </select>
+    <select id="selectAllDesigner" resultType="cn.com.ctop.common.module.entity.SysUser">
+        select user.realname,user.id,role.role_name from sys_user_role userRole left join sys_user user on userRole.user_id = user.id
+        left join sys_role role on userRole.role_id = role.id
+            where role.role_code in ('plane','plan','shot','clip')
+            and user.status = 1
+    </select>
 </mapper>

+ 15 - 1
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -65,13 +65,27 @@
 
     <select id="getAccountIdsByUserId" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
+            allocation.account_id,
+            allocation.auth_name,
+            project.project_name as project_name
+        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
+    </select>
+
+
+    <select id="getAllAccountIdsByMediaId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
             account_id,
             auth_name,
             project_name
         FROM
             ctop_user_allocation
         WHERE
-            user_id = #{userId}
+            media_id=#{mediaId}
           and account_status=0
     </select>
 

+ 9 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -123,7 +124,14 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
 
     @Override
     public List<JSONObject> getAccountIdsByUserId(String userId) {
-        return userAllocationMapper.getAccountIdsByUserId(userId);
+        List<JSONObject> result= new ArrayList<>();
+        if(userId.equals("e9ca23d68d884d4ebb19d07889727dae")){
+            result=userAllocationMapper.getAllAccountIdsByMediaId("2");
+        }else {
+            result=userAllocationMapper.getAccountIdsByUserId(userId);
+
+        }
+        return result;
     }
 
     @Override

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouVideoGetMapper.java

@@ -19,4 +19,9 @@ public interface KuaiShouVideoGetMapper extends BaseMapper<KuaiShouVideoGet> {
     void replaceBatch(@Param(value = "videos") List<KuaiShouVideoGet> videoGets);
 
     List<KuaiShouVideoGetVo> getVideoList(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGet> getHighQualityVideo(long accountId,int days,int num);
+
+
+
 }

+ 24 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml

@@ -59,4 +59,28 @@
 
 
 
+    <select id="getHighQualityVideo" parameterType="java.util.Map"
+            resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
+        select * from ctop_kuaishou_video_get
+        where account_id = #{accountId}
+        and signature in
+        (
+        select
+            daily_material.signature
+        from
+        ctop_kuaishou_report_daily_material daily_material
+        inner join
+        ctop_user_allocation allocation
+        on daily_material.account_id = allocation.account_id
+        where  allocation.project_id in (select project_id from ctop_user_allocation where account_id = #{accountId})
+        and  to_days(now()) - to_days(daily_material.stat_date) &lt;= #{days}
+        and daily_material.signature is not null
+        GROUP BY daily_material.signature
+        order by sum(daily_material.charge) desc
+        limit #{num}
+        )
+    </select>
+
+
+
 </mapper>

+ 10 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouVideoGetMapper;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
@@ -13,6 +14,9 @@ import java.util.Map;
  * @Date: 2019-07-25
  * @Version: V1.0
  */
+
+
+
 public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
     void replaceBatch(List<KuaiShouVideoGet> videoGets);
 
@@ -21,4 +25,10 @@ public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
     List<KuaiShouVideoGetVo> getVideoList(Map<String, Object> stringObjectMap);
 
     List<KuaiShouVideoGet> getNewVideoByAccountId(Long accountId,Integer videoAiStatus);
+
+    List<KuaiShouVideoGet> getNewVideoDescDate(Long accountId,Integer newVideoCnt);
+
+
+
+
 }

+ 15 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java

@@ -133,4 +133,19 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
         queryWrapper.orderByDesc("stat_date");
         return this.list(queryWrapper);
     }
+
+
+    @Override
+    public List<KuaiShouVideoGet>getNewVideoDescDate(Long accountId,Integer newVideoCnt){
+        QueryWrapper<KuaiShouVideoGet>queryWrapper = new QueryWrapper<>();
+        if(null!=accountId&&accountId!=0){
+            queryWrapper.eq("account_id",accountId);
+        }
+        if(null!=newVideoCnt && newVideoCnt>0){
+            queryWrapper.orderByDesc("stat_date");
+            queryWrapper.last("limit " + newVideoCnt);
+        }
+        return this.list(queryWrapper);
+    }
+
 }

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -226,7 +226,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 }
                 var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
                 kuaiShouVideoGet.setId(token.getAccountId() + kuaiShouVideoGet.getPhotoId());
-
                 kuaiShouVideoGet.setAccountId(token.getAccountId());
                 kuaiShouVideoGet.setStatDate(detailJson.getDate("upload_time"));
                 kuaiShouVideoGet.setUpdateTime(new Date());
@@ -2151,6 +2150,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                 videoGet.setUrl(dataJson.getString("url"));
                                 videoGet.setPhotoId(dataJson.getString("photo_id"));
                                 videoGet.setCoverUrl(dataJson.getString("cover_url"));
+                                videoGet.setStatus(dataJson.getInteger("new_status"));
                                 Integer type = MaterialEnum.getTypeBySize(dataJson.getInteger("width"), dataJson.getInteger("height"));
                                 if (!Check.isNull(type)) {
                                     videoGet.setMaterialType(type);

+ 32 - 11
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouPlanServiceImpl.java

@@ -201,28 +201,49 @@ public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaisho
                 target.setPlanId(unitDetail.getLong("campaign_id"));
                 target.setUnitId(unitDetail.getLong("unit_id"));
                 target.setSceneId(unitDetail.getJSONArray("scene_id")==null?"":unitDetail.getJSONArray("scene_id").toString());
-
-                JSONArray region = unitDetail.getJSONObject("target").getJSONArray("region");
+                //获取组定向信息
+                JSONObject unitTarget = unitDetail.getJSONObject("target");
+                //地域
+                JSONArray region = unitTarget.getJSONArray("region");
                 target.setRegion(region==null?"":region.toJSONString());
-
+                //性别
                 Integer gender = unitDetail.getJSONObject("target").getInteger("gender");
                 target.setGender(gender==null?0:gender);
-
-                Integer platformOs = unitDetail.getJSONObject("target").getInteger("platform_os");
+                //年龄
+                JSONArray agesRange = unitTarget.getJSONArray("ages_range");
+                target.setAgesRange(agesRange==null?"":agesRange.toJSONString());
+                //操作系统
+                Integer platformOs = unitTarget.getInteger("platform_os");
                 target.setPlatformOs(platformOs==null?0:platformOs);
-
-                JSONArray deviceBrand = unitDetail.getJSONObject("target").getJSONArray("device_brand");
+                //设类类型
+                JSONArray deviceBrand = unitTarget.getJSONArray("device_brand");
                 target.setDeviceBrand(deviceBrand==null?"":deviceBrand.toJSONString());
-
-                JSONArray devicePrice = unitDetail.getJSONObject("target").getJSONArray("device_price");
+                //设备价格
+                JSONArray devicePrice = unitTarget.getJSONArray("device_price");
                 target.setDevicePrice(devicePrice==null?"":devicePrice.toJSONString());
-
-                Integer filterConvertedLevel = unitDetail.getJSONObject("target").getInteger("filter_converted_level");
+                //过滤已转化人群
+                Integer filterConvertedLevel = unitTarget.getInteger("filter_converted_level");
                 target.setFilterConvertedLevel(filterConvertedLevel);
+                //人群包定向
+                JSONArray population = unitTarget.getJSONArray("population");
+                target.setPopulation(population==null?"":population.toJSONString());
+                //人群包排除
+                JSONArray excludePopulation = unitTarget.getJSONArray("exclude_population");
+                target.setExcludePopulation(excludePopulation==null?"":excludePopulation.toJSONString());
+                //应用商店
+                JSONArray appStore = unitDetail.getJSONArray("app_store");
+                target.setAppStore(appStore==null?"":appStore.toJSONString());
+                //商业兴趣
+                JSONArray businessInterest = unitTarget.getJSONArray("business_interest");
+                target.setBusinessInterest(businessInterest==null?"":businessInterest.toJSONString());
+                //网络环境
+                Integer network = unitTarget.getInteger("network");
+                target.setNetwork(network==null?0:network);
 
                 Integer isOpen = unitDetail.getJSONObject("target").getJSONObject("intelli_extend").getInteger("is_open");
                 target.setIsOpen(isOpen==null?0:isOpen);
                 target.setScheduleTime(unitDetail.getString("schedule_time")==null?"":unitDetail.getString("schedule_time"));
+
                 batch.add(target);
             }
         });

+ 2 - 4
module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/xml/WechatNoListMapper.xml

@@ -19,11 +19,9 @@
         end AS type,
         case when nl.type!=''and nl.type !='补卡' then CONCAT(nl.new_duration,' h')
         when ck.checkin_type ='上班打卡'and ck.exception_type ='时间异常' then
-        CONCAT(TIMESTAMPDIFF(MINUTE,DATE_FORMAT(CONCAT(DATE_FORMAT(ck.checkin_time,'%Y-%m-%d '),'09:35:00'),'%Y-%m-%d
-        %H:%i:%s'),ck.checkin_time),' min')
+        CONCAT(TIMESTAMPDIFF(MINUTE,DATE_FORMAT(CONCAT(DATE_FORMAT(ck.checkin_time,'%Y-%m-%d '),'09:35:00'),'%Y-%m-%d %H:%i:%s'),ck.checkin_time),' min')
         when ck.checkin_type ='下班打卡'and ck.exception_type ='时间异常' then
-        CONCAT(TIMESTAMPDIFF(MINUTE,ck.checkin_time,DATE_FORMAT(CONCAT(DATE_FORMAT(ck.checkin_time,'%Y-%m-%d
-        '),'19:00:00'),'%Y-%m-%d %H:%i:%s')),' min')
+        CONCAT(TIMESTAMPDIFF(MINUTE,ck.checkin_time,DATE_FORMAT(CONCAT(DATE_FORMAT(ck.checkin_time,'%Y-%m-%d '),'19:00:00'),'%Y-%m-%d %H:%i:%s')),' min')
         end AS stateDuration
         FROM ctop_wechat_user_list AS us
         LEFT JOIN ctop_wechat_department AS dpt ON us.depart_id = dpt.depart_id