浏览代码

Merge remote-tracking branch 'origin/master'

liyuyi@c-top.com.cn 4 年之前
父节点
当前提交
d218b21c5a
共有 20 个文件被更改,包括 899 次插入87 次删除
  1. 71 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/controller/AiKuaiShouReportAnalyzeCtrl.java
  2. 3 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaiShouStrategyListPageMapper.java
  3. 33 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/IAiKuaiShouReportAnalyzeMapper.java
  4. 465 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouReportAnalyzeMapper.xml
  5. 87 33
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyListPageMapper.xml
  6. 23 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaiShouReportAnalyzeService.java
  7. 109 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaiShouReportAnalyzeServiceImpl.java
  8. 2 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaiShouStrategyListPageServiceImpl.java
  9. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  10. 16 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  11. 28 19
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  12. 0 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  13. 18 12
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  14. 13 3
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/constant/MatchLogic.java
  15. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  16. 13 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  17. 9 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  18. 3 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouReportDailyMaterialServiceImpl.java
  19. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  20. 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;
+    }
+
+}

+ 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
 @Mapper
 public interface AiKuaiShouStrategyListPageMapper {
 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.strategy_name as strategyName,
         t1.create_time as createTime,
         t1.create_time as createTime,
         t1.account_id as accountId,
         t1.account_id as accountId,
+        (select auth_name from ctop_user_allocation where account_id=t1.account_id limit 1) as authName,
         '' as status,
         '' as status,
         t1.scenes,
         t1.scenes,
         t1.budget,
         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 ,
         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,
         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
         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_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
         where t1.account_id in
         <foreach item="item" index="index" collection="accountIds"
         <foreach item="item" index="index" collection="accountIds"
                  open="(" separator="," close=")">
                  open="(" separator="," close=")">
             #{item}
             #{item}
         </foreach>
         </foreach>
-        <if test="strategyName != null">
-            AND t1.strategy_name like '%${strategyName}%'
-        </if>
+        AND t1.strategy_name like '%${strategyName}%'
         <if test="strategyState != null">
         <if test="strategyState != null">
-            AND t1.strategy_state=#{strategyState}
+            AND t1.strategy_state= #{strategyState}
         </if>
         </if>
         <if test="id != null">
         <if test="id != null">
             AND t1.id=#{id}
             AND t1.id=#{id}
         </if>
         </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
         order by t1.create_time desc
     </select>
     </select>
 
 
@@ -60,25 +70,46 @@
         IFNULL(sum(t1.charge),0) as cost,
         IFNULL(sum(t1.charge),0) as cost,
         IFNULL(sum(t1.photo_show),0) as photoShow,
         IFNULL(sum(t1.photo_show),0) as photoShow,
         IFNULL(sum(t1.photo_click),0) as photoClick,
         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.aclick),0) as aclick,
         IFNULL(sum(t1.bclick),0) as bclick,
         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,
         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,
         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,
         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
         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">
         <if test="campaignName != null">
             and t1.campaign_name like '%${campaignName}}%'
             and t1.campaign_name like '%${campaignName}}%'
         </if>
         </if>
@@ -104,25 +135,48 @@
         IFNULL(sum(t1.charge),0) as cost,
         IFNULL(sum(t1.charge),0) as cost,
         IFNULL(sum(t1.photo_show),0) as photoShow,
         IFNULL(sum(t1.photo_show),0) as photoShow,
         IFNULL(sum(t1.photo_click),0) as photoClick,
         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.aclick),0) as aclick,
         IFNULL(sum(t1.bclick),0) as bclick,
         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,
         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,
         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,
         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
         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">
         <if test="unitName != null">
             and t1.unit_name like '%${unitName}}%'
             and t1.unit_name like '%${unitName}}%'
         </if>
         </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;
 package org.jeecg.modules.ads.service.impl;
 
 
-import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
@@ -11,7 +10,6 @@ import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.ads.mapper.AiKuaiShouStrategyListPageMapper;
 import org.jeecg.modules.ads.mapper.AiKuaiShouStrategyListPageMapper;
 import org.jeecg.modules.ads.service.IAiKuaiShouStrategyListPageService;
 import org.jeecg.modules.ads.service.IAiKuaiShouStrategyListPageService;
-import org.jeecg.modules.system.service.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
@@ -22,18 +20,16 @@ import java.util.List;
 public class AiKuaiShouStrategyListPageServiceImpl implements IAiKuaiShouStrategyListPageService {
 public class AiKuaiShouStrategyListPageServiceImpl implements IAiKuaiShouStrategyListPageService {
 
 
     @Autowired
     @Autowired
-    AiKuaiShouStrategyListPageMapper  aiKuaiShouStrategyListPageMapper;
+    AiKuaiShouStrategyListPageMapper aiKuaiShouStrategyListPageMapper;
 
 
     @Autowired
     @Autowired
     IUserAllocationService userAllocationService;
     IUserAllocationService userAllocationService;
-    @Autowired
-    private ISysRoleService sysRoleService;
 
 
     @Override
     @Override
     public PageInfo<JSONObject> pageStrategy(JSONObject params) {
     public PageInfo<JSONObject> pageStrategy(JSONObject params) {
         JSONArray accountIds= params.getJSONArray("accountIds");
         JSONArray accountIds= params.getJSONArray("accountIds");
         if(null == accountIds||accountIds.isEmpty()){
         if(null == accountIds||accountIds.isEmpty()){
-            accountIds = null;
+            accountIds=listToJSONArray(userAllocationService.getAccountIdsByUserId(((LoginUser) SecurityUtils.getSubject().getPrincipal()).getId()));
         }
         }
         String strategyName=params.getString("strategyName");
         String strategyName=params.getString("strategyName");
         Integer strategyState=params.getInteger("strategyState");
         Integer strategyState=params.getInteger("strategyState");

+ 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;
                 url = KuaishouInterfaceConstant.HTTPS_PREFIX + url;
             }
             }
             materialInfo.setUrl(url);
             materialInfo.setUrl(url);
+            materialInfo.setCreateTime(new Date());
             MaterialCutFrame cutFrame = materialCutFrameService.getCutFrameByCode(materialInfo.getCode());
             MaterialCutFrame cutFrame = materialCutFrameService.getCutFrameByCode(materialInfo.getCode());
             if (Check.isNull(cutFrame)) {
             if (Check.isNull(cutFrame)) {
                 String videoUrl = URLDecoder.decode(url).replace("https://media-1301855440.cos.ap-chongqing.myqcloud.com/", "");
                 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.ctop.service.IProjectMemberService;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 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 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;
                 userId = null;
             }
             }
             List<JSONObject> projectList = projectMemberService.getProjectByUserIdAndMediaIds(userId, mediaIds);
             List<JSONObject> projectList = projectMemberService.getProjectByUserIdAndMediaIds(userId, mediaIds);
+            List<JSONObject> haveList = new ArrayList<>();
             if (!Check.isNull(projectList)) {
             if (!Check.isNull(projectList)) {
                 for (int i = 0; i < projectList.size(); i++) {
                 for (int i = 0; i < projectList.size(); i++) {
                     JSONObject project = projectList.get(i);
                     JSONObject project = projectList.get(i);
                     List<JSONObject> accountList = userAllocationService.getAccountListByProject(project.getLong("projectId"));
                     List<JSONObject> accountList = userAllocationService.getAccountListByProject(project.getLong("projectId"));
                     if (!Check.isNull(accountList)) {
                     if (!Check.isNull(accountList)) {
                         project.put("accountList", accountList);
                         project.put("accountList", accountList);
+                        haveList.add(project);
                     }
                     }
                 }
                 }
             }
             }
             result.setSuccess(true);
             result.setSuccess(true);
-            result.setResult(projectList);
-
+            result.setResult(haveList);
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
             result.setSuccess(false);
             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.crawler.modules.douyin.service.DouyinMusicService;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 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.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
 import cn.com.ctop.toutiao.modules.report.service.*;
 import cn.com.ctop.toutiao.modules.report.service.*;
@@ -86,6 +87,14 @@ public class TestController {
     static ExecutorService executorService = Executors.newFixedThreadPool(15);
     static ExecutorService executorService = Executors.newFixedThreadPool(15);
     static ExecutorService videoService = Executors.newFixedThreadPool(5);
     static ExecutorService videoService = Executors.newFixedThreadPool(5);
     static ExecutorService suzhaoService = Executors.newFixedThreadPool(10);
     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")
     @GetMapping(value = "/dailyReport")
@@ -100,19 +109,19 @@ public class TestController {
     }
     }
 
 
     @GetMapping("getKuaishouPlanHourlyReport")
     @GetMapping("getKuaishouPlanHourlyReport")
-    public Map<String,Object> getKuaishouPlanHourlyReport(String params){
+    public Map<String, Object> getKuaishouPlanHourlyReport(String params) {
         Long start = System.currentTimeMillis();
         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;
             return result;
         }
         }
         Long accountId = Long.parseLong(params);
         Long accountId = Long.parseLong(params);
         CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
         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;
             return result;
         }
         }
         Date getDate = new Date();
         Date getDate = new Date();
@@ -125,22 +134,20 @@ public class TestController {
         Date finalGetDate = getDate;
         Date finalGetDate = getDate;
         try {
         try {
             kuaishouInterfaceService.getAdvertiserCampaignReportHourly(token, finalGetDate, finalGetDate);
             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();
             long end = System.currentTimeMillis();
-            log.info("执行时长:{}毫秒",end-start);
+            log.info("执行时长:{}毫秒", end - start);
             return result;
             return result;
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
             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;
             return result;
         }
         }
     }
     }
 
 
 
 
-
-
     @GetMapping(value = "/getMd5")
     @GetMapping(value = "/getMd5")
     public void getMd5() {
     public void getMd5() {
         kuaiShouHistoryReportTaskService.getMd5(null, null);
         kuaiShouHistoryReportTaskService.getMd5(null, null);
@@ -1199,13 +1206,15 @@ public class TestController {
 
 
         return result;
         return result;
     }
     }
+
     @Autowired
     @Autowired
     private IKuaiShouCommentService kuaiShouCommentService;
     private IKuaiShouCommentService kuaiShouCommentService;
+
     @GetMapping("deleteComment")
     @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);
         kuaiShouCommentService.shieldComment(accountId);
-        ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
         return result;
         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.common.module.utils.StringUtils;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;

+ 18 - 12
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -1,6 +1,5 @@
 package org.jeecg;
 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.BindAccountLogin;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.UserAllocation;
 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.IKuaiShouHistoryReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 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.IKuaishouReportDailyAgentService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouVideoEtlInfoService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouVideoEtlInfoService;
 import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
 import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
 import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
 import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
 import cn.com.ctop.oa.modules.service.IWechatNoListService;
 import cn.com.ctop.oa.modules.service.IWechatNoListService;
 import cn.com.ctop.oa.modules.service.IWechatUserListService;
 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.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.report.service.*;
 import cn.com.ctop.toutiao.modules.report.service.*;
-import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.DateUtils;
 import org.junit.Test;
 import org.junit.Test;
@@ -350,14 +346,6 @@ public class SampleTest {
     }
     }
 
 
     @Autowired
     @Autowired
-    IRuleKuaiShouPlanService kuaiShouPlanService;
-
-    @Test
-    public void kuaishouRuleData() {
-        kuaiShouPlanService.cleanRuleDataUnit(3429620L, "2020-12-07", "2020-12-07", 1);
-    }
-
-    @Autowired
     private IKuaiShouCommentService kuaiShouCommentService;
     private IKuaiShouCommentService kuaiShouCommentService;
 
 
     @Test
     @Test
@@ -376,6 +364,13 @@ public class SampleTest {
             videoReportDailyService.videoInfoList(date, date);
             videoReportDailyService.videoInfoList(date, date);
         }
         }
     }
     }
+    @Autowired
+    private org.jeecg.modules.ads.service.Test test;
+
+    @Test
+    public void test(){
+        test.f();
+    }
 
 
     @Autowired
     @Autowired
     private IRuleKuaiShouPlanService ruleKuaiShouPlanService;
     private IRuleKuaiShouPlanService ruleKuaiShouPlanService;
@@ -432,4 +427,15 @@ public class SampleTest {
 
 
 
 
 
 
+    @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 {
             } else {
+                /**
+                 不包含逻辑根据指标分两种:
+                 1、大部分数组型指标阈值逻辑:所设的阈值中,存在任一目标则不报警,都不存在时则报警,出现阈值之外的亦报警
+                 2、排除人群包、排除流量包逻辑:所选必须都存在,否则报警
+
+                 包含逻辑通用: 任一存在则报警
+                 */
                 if (value.contains("[") && threshold.contains("[")) {
                 if (value.contains("[") && threshold.contains("[")) {
                     List<String> values = strToList(value);
                     List<String> values = strToList(value);
                     List<String> thresholds = strToList(threshold);
                     List<String> thresholds = strToList(threshold);
@@ -120,13 +127,16 @@ public class MatchLogic {
                                 }
                                 }
                             }
                             }
                         } else {
                         } else {
-                            //不包含,任一存在不报警,都不存在则报警
+                            boolean flag = true;
+                            //不包含,阈值中,存在任一目标则不报警,都不存在时则报警,出现阈值之外的亦报警
                             for (String v : values) {
                             for (String v : values) {
                                 if (threshold.contains(v)) {
                                 if (threshold.contains(v)) {
-                                    return false;
+                                    flag = false;
+                                } else {
+                                    return true;
                                 }
                                 }
                             }
                             }
-                            return true;
+                            return flag;
                         }
                         }
                     }
                     }
                 } else {
                 } else {

+ 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> getAccountIdsByUserId(@Param("userId") String userId);
 
 
+    List<JSONObject> getAllAccountIdsByMediaId(@Param("mediaId") String mediaId);
+
     Long getProjectIdByAccountId(@Param("accountId") Long accountId);
     Long getProjectIdByAccountId(@Param("accountId") Long accountId);
 
 
     UserAllocation getUserAllocation(@Param("accountId") Long accountId);
     UserAllocation getUserAllocation(@Param("accountId") Long accountId);

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

@@ -76,6 +76,19 @@
           and allocation.account_status=0
           and allocation.account_status=0
     </select>
     </select>
 
 
+
+    <select id="getAllAccountIdsByMediaId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            account_id,
+            auth_name,
+            project_name
+        FROM
+            ctop_user_allocation
+        WHERE
+            media_id=#{mediaId}
+          and account_status=0
+    </select>
+
     <select id="getProjectIdByAccountId" resultType="java.lang.Long">
     <select id="getProjectIdByAccountId" resultType="java.lang.Long">
     select  project_id  from  ctop_user_allocation
     select  project_id  from  ctop_user_allocation
     where account_id = #{accountId}
     where account_id = #{accountId}

+ 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.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
@@ -123,7 +124,14 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
 
 
     @Override
     @Override
     public List<JSONObject> getAccountIdsByUserId(String userId) {
     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
     @Override

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

@@ -62,6 +62,7 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
 
 
         String result = HttpUtils.httpPostRequest(url, param, headers);
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
         JSONObject resultJson = JSONObject.parseObject(result);
+    //    log.info("快手返回数据:{}",resultJson);
         if (Check.isNull(resultJson)) {
         if (Check.isNull(resultJson)) {
             return;
             return;
         }
         }
@@ -89,8 +90,10 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
                 material.setSignature(videoGetvo.getSignature());
                 material.setSignature(videoGetvo.getSignature());
             }
             }
             material.setAccountId(accountId);
             material.setAccountId(accountId);
+
             addList.add(material);
             addList.add(material);
         }
         }
+  //      log.info("addList:{}",addList);
         dailyMaterialMapper.batchReplace(addList);
         dailyMaterialMapper.batchReplace(addList);
         getMaterialReportByAccountIdAndStatDate(accountId, token, startDate, endDate, page + 1);
         getMaterialReportByAccountIdAndStatDate(accountId, token, startDate, endDate, page + 1);
     }
     }

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

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

@@ -19,11 +19,9 @@
         end AS type,
         end AS type,
         case when nl.type!=''and nl.type !='补卡' then CONCAT(nl.new_duration,' h')
         case when nl.type!=''and nl.type !='补卡' then CONCAT(nl.new_duration,' h')
         when ck.checkin_type ='上班打卡'and ck.exception_type ='时间异常' then
         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
         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
         end AS stateDuration
         FROM ctop_wechat_user_list AS us
         FROM ctop_wechat_user_list AS us
         LEFT JOIN ctop_wechat_department AS dpt ON us.depart_id = dpt.depart_id
         LEFT JOIN ctop_wechat_department AS dpt ON us.depart_id = dpt.depart_id