Explorar o código

Merge branch 'master' of http://git.tjyourong.com.cn/ctop/adsp-boot

zhaoxian %!s(int64=4) %!d(string=hai) anos
pai
achega
34c5d455ec
Modificáronse 24 ficheiros con 900 adicións e 98 borrados
  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. 5 5
      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. 0 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  14. 12 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java
  15. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserService.java
  16. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java
  17. 26 22
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  18. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/SysUser.java
  19. 1 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/SysUserMapper.java
  20. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  21. 6 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysUserMapper.xml
  22. 15 1
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  23. 9 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  24. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

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

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

@@ -107,7 +107,7 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
         List<KuaiShouVideoGet> fullVideos = new ArrayList<KuaiShouVideoGet>();
         fullVideos.addAll(highQualityVideos);
         fullVideos.addAll(newVideos);
-        if(null == fullVideos){
+        if(fullVideos.isEmpty()){
             log.info("素材获取失败=>accountId:{}",accountId);
             return;
         }
@@ -198,7 +198,7 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
                                 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,1,highQualityVideos.get(i*15+j));
+                                    createCreative(token,creativeParams,campaignId,unitId,strategy,null,j+1,highQualityVideos.get(i*15+j));
                                 }
                                 innerUnitCnt++;
                             }
@@ -218,7 +218,7 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
 
                             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,1,highQualityVideos.get(mod*15+j));
+                                createCreative(token,creativeParams,campaignId,unitId,strategy,null,j+1,highQualityVideos.get(mod*15+j));
                             }
                         }
                     }
@@ -242,7 +242,7 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
                                 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,1,newVideos.get(i*15+j));
+                                    createCreative(token,creativeParams,campaignId,unitId,strategy,null,j+1,newVideos.get(i*15+j));
                                 }
                                 innerUnitCnt++;
                             }
@@ -262,7 +262,7 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
 
                             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,1,newVideos.get(mod*15+j));
+                                createCreative(token,creativeParams,campaignId,unitId,strategy,null,j+1,newVideos.get(mod*15+j));
                             }
                         }
                     }

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

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

+ 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

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