瀏覽代碼

素材大盘 - top素材排行榜、top设计排行榜

huangxuechao 3 年之前
父節點
當前提交
759d0863c6

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

@@ -10,6 +10,7 @@ import org.jeecg.modules.ctop.service.IMaterialReportOverViewService;
 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.*;
 
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 import java.util.HashMap;
 import java.util.HashMap;
@@ -28,7 +29,7 @@ public class MaterialReportOverViewController {
     @Autowired
     @Autowired
     private IMaterialReportOverViewService materialReportOverViewService;
     private IMaterialReportOverViewService materialReportOverViewService;
 
 
-    @Autowired
+    @Resource
     private MaterialReportOverViewMapper materialReportOverViewMapper;
     private MaterialReportOverViewMapper materialReportOverViewMapper;
 
 
     /**
     /**
@@ -88,7 +89,9 @@ public class MaterialReportOverViewController {
         List<JSONObject> topMaterialList = materialReportOverViewService.getTopMaterialList(params.getInteger("mediaId"),
         List<JSONObject> topMaterialList = materialReportOverViewService.getTopMaterialList(params.getInteger("mediaId"),
                 params.getString("startDate"),
                 params.getString("startDate"),
                 params.getString("endDate"),
                 params.getString("endDate"),
-                params.getJSONArray("projects"));
+                params.getJSONArray("projects"),
+                params.getInteger("channelType")
+        );
         result.setResult(topMaterialList);
         result.setResult(topMaterialList);
         result.setSuccess(true);
         result.setSuccess(true);
         return result;
         return result;
@@ -135,16 +138,14 @@ public class MaterialReportOverViewController {
      *  Top设计排行榜
      *  Top设计排行榜
      */
      */
     @PostMapping("/designTop")
     @PostMapping("/designTop")
-    public Result<PageInfo<JSONObject>> designTop(@RequestBody JSONObject params){
-        Result<PageInfo<JSONObject>> result = new Result<>();
-        PageInfo<JSONObject> topMaterialList = materialReportOverViewService.getTopDesignList(
+    public Result<List<JSONObject>> designTop(@RequestBody JSONObject params){
+        Result<List<JSONObject>> result = new Result<>();
+        List<JSONObject> topMaterialList = materialReportOverViewService.getTopDesignList(
+                params.getInteger("mediaId"),
                 params.getString("startDate"),
                 params.getString("startDate"),
                 params.getString("endDate"),
                 params.getString("endDate"),
-                params.getString("userId"),
-                params.getString("target"),
-                params.getString("order"),
-                params.getInteger("pageSize"),
-                params.getInteger("pageNo"));
+                params.getJSONArray("projects"),
+                params.getString("type"));
         result.setResult(topMaterialList);
         result.setResult(topMaterialList);
         result.setSuccess(true);
         result.setSuccess(true);
         return result;
         return result;

+ 11 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/MaterialReportOverViewMapper.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.ctop.mapper;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.orderplatform.util.JsonArrayUtil;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.List;
 import java.util.List;
@@ -46,6 +47,9 @@ public interface MaterialReportOverViewMapper {
     //头条素材排行榜
     //头条素材排行榜
     List<JSONObject> queryBytedanceTopMaterial(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projects") JSONArray projects);
     List<JSONObject> queryBytedanceTopMaterial(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projects") JSONArray projects);
 
 
+    //头条素材排行榜New
+    List<JSONObject> queryBytedanceTopMaterialNew(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projects") JSONArray projects, @Param("channelType")Integer channelType);
+
     //查看更多
     //查看更多
     List<JSONObject> queryBytedanceMaterialReport(@Param("filed") String filed, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projects") JSONArray projects,
     List<JSONObject> queryBytedanceMaterialReport(@Param("filed") String filed, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projects") JSONArray projects,
                                                   @Param("md5") String md5, @Param("target") String target, @Param("order") String order);
                                                   @Param("md5") String md5, @Param("target") String target, @Param("order") String order);
@@ -54,7 +58,8 @@ public interface MaterialReportOverViewMapper {
                                            @Param("md5") String md5);
                                            @Param("md5") String md5);
 
 
     //快手素材排行榜
     //快手素材排行榜
-    List<JSONObject> queryKuaishouTopMaterial(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projects") JSONArray projects);
+    List<JSONObject> queryKuaishouTopMaterial(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projects") JSONArray projects, @Param("channelType")Integer channelType);
+
 
 
     //查看更多
     //查看更多
     List<JSONObject> queryKuaishouMaterialReport(@Param("filed") String filed, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projects") JSONArray projects,
     List<JSONObject> queryKuaishouMaterialReport(@Param("filed") String filed, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projects") JSONArray projects,
@@ -64,9 +69,12 @@ public interface MaterialReportOverViewMapper {
                                           @Param("channelType") String channelType, @Param("md5") String md5);
                                           @Param("channelType") String channelType, @Param("md5") String md5);
 
 
     //设计排行榜
     //设计排行榜
-    List<JSONObject> queryTopDesign(String startDate, String endDate, Set<String> userIds, String target, String order);
-
+    List<JSONObject> queryTopDesign(String startDate, String endDate, Set<String> userIds, String target, String order, String roleName);
     Long queryTopDesignCount(String startDate, String endDate, Set<String> userIds);
     Long queryTopDesignCount(String startDate, String endDate, Set<String> userIds);
+    //设计排行榜新版本
+    List<JSONObject> queryKuaishouTopDesign(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projects") JSONArray  projects, @Param("type")  String type);
+    List<JSONObject> queryBytedanceTopDesign(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projects") JSONArray  projects, @Param("type")  String type);
+
 
 
     //素材详情页
     //素材详情页
 
 

+ 131 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MaterialReportOverViewMapper.xml

@@ -230,7 +230,7 @@
         IFNULL((SELECT GROUP_CONCAT(tag_name) from ctop_material_tag_info where code=signature and status=1),"塑造") as  tag
         IFNULL((SELECT GROUP_CONCAT(tag_name) from ctop_material_tag_info where code=signature and status=1),"塑造") as  tag
         FROM
         FROM
         (SELECT md5 signature,
         (SELECT md5 signature,
-        IFNULL(toutiao_url, '') AS url,
+        case when toutiao_url = '' or toutiao_url is null then url end url,
         cover_url AS coverUrl,
         cover_url AS coverUrl,
         material_name AS materialName,
         material_name AS materialName,
         sum(cost) AS cost from etl_report_bytedance_video
         sum(cost) AS cost from etl_report_bytedance_video
@@ -251,6 +251,93 @@
         ORDER BY cost DESC
         ORDER BY cost DESC
     </select>
     </select>
 
 
+    <select id="queryKuaishouTopDesign" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.charge as cost
+        <if test="type == 1"> ,t1.shot_name as userName, "摄像" as roleName </if>
+        <if test="type == 2"> ,t1.clip_name as userName, "剪辑" as roleName </if>
+        <if test="type == 3"> ,t1.plan_name as userName, "编导" as roleName </if>
+        FROM
+        (select sum(charge) as charge,t2.*
+        from ctop_etl_kuaishou_account_material_report_daily t1 LEFT JOIN ctop_etl_kuaishou_video_info t2 ON t1.signature = t2.video_code
+        where
+        1=1
+        AND t1.stat_date &gt;= #{startDate}
+        AND t1.stat_date &lt;= #{endDate}
+        <if test="projects !=null">
+            AND project_id IN
+            <foreach collection="projects" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="type == 1"> AND t2.shot_id is not null and t2.shot_id != '' GROUP BY t2.shot_id</if>
+        <if test="type == 2"> AND t2.clip_id is not null and t2.clip_id != '' GROUP BY t2.clip_id</if>
+        <if test="type == 3"> AND t2.plan_id is not null and t2.plan_id != '' GROUP BY t2.plan_id</if>
+        ORDER BY charge desc  LIMIT 10
+        ) t1
+
+
+
+    </select>
+
+    <select id="queryBytedanceTopDesign" resultType="com.alibaba.fastjson.JSONObject">
+
+        SELECT
+        t1.cost
+        <if test="type == 1"> ,t1.shot_name as userName, "摄像" as roleName </if>
+        <if test="type == 2"> ,t1.clip_name as userName, "剪辑" as roleName </if>
+        <if test="type == 3"> ,t1.plan_name as userName, "编导" as roleName </if>
+        FROM
+        (select sum(cost) as cost,clip_name,plan_name,shot_name
+        from etl_report_bytedance_video t1
+        where
+        1=1
+        AND t1.stat_datetime &gt;= #{startDate}
+        AND t1.stat_datetime &lt;=  #{endDate}
+        <if test="projects !=null">
+            AND project_id IN
+            <foreach collection="projects" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="type == 1"> AND t1.shot_id is not null and t1.shot_id != '' GROUP BY t1.shot_id</if>
+        <if test="type == 2"> AND t1.clip_id is not null and t1.clip_id != '' GROUP BY t1.clip_id</if>
+        <if test="type == 3"> AND t1.plan_id is not null and t1.plan_id != '' GROUP BY t1.plan_id</if>
+        ORDER BY cost desc  LIMIT 10
+        ) t1
+
+    </select>
+
+    <select id="queryBytedanceTopMaterialNew" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.*,
+        IFNULL((SELECT GROUP_CONCAT(tag_name) from ctop_material_tag_info where code=signature and status=1),"塑造") as  tag
+        FROM
+        (SELECT md5 signature,
+        case when toutiao_url = '' or toutiao_url is null then url end url,
+        cover_url AS coverUrl,
+        material_name AS materialName,
+        sum(cost) AS cost from etl_report_bytedance_video
+        where 1=1
+        <if test="projects !=null">
+            AND project_id IN
+            <foreach collection="projects" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        AND stat_datetime &gt;= #{startDate}
+        AND stat_datetime &lt;= #{endDate}
+        AND md5!=''
+        GROUP BY md5
+        ORDER BY cost DESC
+        LIMIT 5) t1
+        ORDER BY cost DESC
+    </select>
+
+
     <select id="queryBytedanceMaterialReport" resultType="com.alibaba.fastjson.JSONObject">
     <select id="queryBytedanceMaterialReport" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
         SELECT
         t1.md5 signature,
         t1.md5 signature,
@@ -303,14 +390,16 @@
         GROUP BY t1.md5) t
         GROUP BY t1.md5) t
     </select>
     </select>
 
 
+
+
     <select id="queryKuaishouTopMaterial" resultType="com.alibaba.fastjson.JSONObject">
     <select id="queryKuaishouTopMaterial" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
         SELECT
         t1.*,
         t1.*,
         t2.video_name as materialName,
         t2.video_name as materialName,
         t2.cover_url as coverUrl,
         t2.cover_url as coverUrl,
         t2.url as url ,
         t2.url as url ,
-        IFNULL((SELECT GROUP_CONCAT(tag_name) from ctop_material_tag_info where code=t1.signature and status=1),"塑造") as
-        tag
+        t2.channel_type,
+        (SELECT GROUP_CONCAT(tag_name) from ctop_material_tag_info where code=t1.signature and status=1)as tag
         FROM
         FROM
         (select sum(charge) as charge,signature
         (select sum(charge) as charge,signature
         from ctop_etl_kuaishou_account_material_report_daily t1
         from ctop_etl_kuaishou_account_material_report_daily t1
@@ -323,15 +412,48 @@
                 #{item}
                 #{item}
             </foreach>
             </foreach>
         </if>
         </if>
+
         AND t1.stat_date &gt;= #{startDate}
         AND t1.stat_date &gt;= #{startDate}
         AND t1.stat_date &lt;= #{endDate}
         AND t1.stat_date &lt;= #{endDate}
         GROUP BY t1.signature
         GROUP BY t1.signature
         ORDER BY charge desc
         ORDER BY charge desc
-        limit 5
         ) t1
         ) t1
         LEFT JOIN ctop_etl_kuaishou_video_info t2
         LEFT JOIN ctop_etl_kuaishou_video_info t2
         ON t1.signature = t2.video_code
         ON t1.signature = t2.video_code
-        ORDER BY charge desc
+        where 1=1
+        <if test="channelType !=null">
+            AND t2.channel_type = #{channelType}
+        </if>
+        ORDER BY charge desc LIMIT 5
+
+<!--        SELECT-->
+<!--        t1.*,-->
+<!--        t2.video_name as materialName,-->
+<!--        t2.cover_url as coverUrl,-->
+<!--        t2.url as url ,-->
+<!--        IFNULL((SELECT GROUP_CONCAT(tag_name) from ctop_material_tag_info where code=t1.signature and status=1),"塑造") as-->
+<!--        tag-->
+<!--        FROM-->
+<!--        (select sum(charge) as charge,signature-->
+<!--        from ctop_etl_kuaishou_account_material_report_daily t1-->
+<!--        where-->
+<!--        1=1-->
+<!--        <if test="projects !=null">-->
+<!--            AND project_id IN-->
+<!--            <foreach collection="projects" item="item" separator=","-->
+<!--                     open="(" close=")">-->
+<!--                #{item}-->
+<!--            </foreach>-->
+<!--        </if>-->
+<!--        AND t1.stat_date &gt;= #{startDate}-->
+<!--        AND t1.stat_date &lt;= #{endDate}-->
+<!--        GROUP BY t1.signature-->
+<!--        ORDER BY charge desc-->
+<!--        limit 5-->
+<!--        ) t1-->
+<!--        LEFT JOIN ctop_etl_kuaishou_video_info t2-->
+<!--        ON t1.signature = t2.video_code-->
+<!--        ORDER BY charge desc-->
     </select>
     </select>
 
 
     <select id="queryKuaishouMaterialReport" resultType="com.alibaba.fastjson.JSONObject">
     <select id="queryKuaishouMaterialReport" resultType="com.alibaba.fastjson.JSONObject">
@@ -429,6 +551,10 @@
         user_id
         user_id
         ORDER BY
         ORDER BY
         ${target} ${order}) t) t1
         ${target} ${order}) t) t1
+        where 1=1
+        <if test="roleName != null">
+            and t1.roleName = #{roleName}
+        </if>
     </select>
     </select>
 
 
     <select id="queryTopDesignCount" resultType="java.lang.Long">
     <select id="queryTopDesignCount" resultType="java.lang.Long">

+ 8 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IMaterialReportOverViewService.java

@@ -30,7 +30,7 @@ public interface IMaterialReportOverViewService {
     JSONObject getTagProportion(int mediaId, String startDate, String endDate, int tagId);
     JSONObject getTagProportion(int mediaId, String startDate, String endDate, int tagId);
 
 
     //查询Top素材排行榜
     //查询Top素材排行榜
-    List<JSONObject> getTopMaterialList(int mediaId, String startDate, String endDate, JSONArray projects);
+    List<JSONObject> getTopMaterialList(int mediaId, String startDate, String endDate, JSONArray projects, Integer channelType);
 
 
     //素材查看更多
     //素材查看更多
     PageInfo<JSONObject> getTopMaterialList(int mediaId, String startDate, String endDate, JSONArray projects, String channelType, String md5, String target, String order, int pageNo, int pageSize);
     PageInfo<JSONObject> getTopMaterialList(int mediaId, String startDate, String endDate, JSONArray projects, String channelType, String md5, String target, String order, int pageNo, int pageSize);
@@ -40,8 +40,14 @@ public interface IMaterialReportOverViewService {
 
 
     void exportKuaishouExcel(JSONObject requestBody, HttpServletRequest request, HttpServletResponse response);
     void exportKuaishouExcel(JSONObject requestBody, HttpServletRequest request, HttpServletResponse response);
 
 
+//    params.getInteger("mediaId"),
+//            params.getString("startDate"),
+//            params.getString("endDate"),
+//            params.getJSONArray("projects"),
+//            params.getString("roleName"));
+
     //查询设计人员排行榜
     //查询设计人员排行榜
-    PageInfo<JSONObject> getTopDesignList(String startDate, String endDate, String userId, String target, String order, int pageSize, int pageNo);
+    List<JSONObject> getTopDesignList(Integer mediaId, String startDate, String endDate, JSONArray projects, String roleName);
 
 
     // 视频详情页
     // 视频详情页
     JSONObject getMaterialDetailInfo(int mediaId, String md5);
     JSONObject getMaterialDetailInfo(int mediaId, String md5);

+ 14 - 13
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/MaterialReportOverViewServiceImpl.java

@@ -21,6 +21,7 @@ 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;
 
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.IOException;
@@ -34,7 +35,7 @@ import java.util.*;
 @Service
 @Service
 public class MaterialReportOverViewServiceImpl implements IMaterialReportOverViewService {
 public class MaterialReportOverViewServiceImpl implements IMaterialReportOverViewService {
 
 
-    @Autowired
+    @Resource
     private MaterialReportOverViewMapper materialReportOverViewMapper;
     private MaterialReportOverViewMapper materialReportOverViewMapper;
 
 
     @Autowired
     @Autowired
@@ -141,7 +142,7 @@ public class MaterialReportOverViewServiceImpl implements IMaterialReportOverVie
     }
     }
 
 
     @Override
     @Override
-    public List<JSONObject> getTopMaterialList(int mediaId, String startDate, String endDate, JSONArray projects) {
+    public List<JSONObject> getTopMaterialList(int mediaId, String startDate, String endDate, JSONArray projects, Integer channelType) {
         List<JSONObject> result = new ArrayList<>();
         List<JSONObject> result = new ArrayList<>();
         if (projects.isEmpty()) {
         if (projects.isEmpty()) {
             projects = getProjectsByCurrentUser(mediaId);
             projects = getProjectsByCurrentUser(mediaId);
@@ -150,7 +151,7 @@ public class MaterialReportOverViewServiceImpl implements IMaterialReportOverVie
             result = materialReportOverViewMapper.queryBytedanceTopMaterial(startDate, endDate, projects);
             result = materialReportOverViewMapper.queryBytedanceTopMaterial(startDate, endDate, projects);
 
 
         } else if (mediaId == CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT) {
         } else if (mediaId == CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT) {
-            result = materialReportOverViewMapper.queryKuaishouTopMaterial(startDate, endDate, projects);
+            result = materialReportOverViewMapper.queryKuaishouTopMaterial(startDate, endDate, projects, channelType);
         }
         }
         return result;
         return result;
     }
     }
@@ -284,17 +285,17 @@ public class MaterialReportOverViewServiceImpl implements IMaterialReportOverVie
     }
     }
 
 
     @Override
     @Override
-    public PageInfo<JSONObject> getTopDesignList(String startDate, String endDate, String userId, String target, String order, int pageSize, int pageNo) {
-        PageInfo<JSONObject> result = new PageInfo<>();
-        Set<String> subordinate = this.recursiveQuerySubordinate(userId);
-        if (subordinate.size()==1) {
-            subordinate = materialReportOverViewMapper.recursiveQuerySubordinateByUserId(userId);
+    public List<JSONObject> getTopDesignList(Integer mediaId, String startDate, String endDate, JSONArray projects, String type) {
+        List<JSONObject> result = new ArrayList<>();
+        if (projects.isEmpty()) {
+            projects = getProjectsByCurrentUser(mediaId);
+        }
+        if (mediaId == CtopAdConstant.PLATFORM_TYPE_BYTEDANCE_INT) {
+            result = materialReportOverViewMapper.queryBytedanceTopDesign(startDate, endDate, projects, type);
+
+        } else if (mediaId == CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT) {
+            result = materialReportOverViewMapper.queryKuaishouTopDesign(startDate, endDate, projects, type);
         }
         }
-        PageHelper.startPage(pageNo, pageSize, false);
-        List<JSONObject> topDesign = materialReportOverViewMapper.queryTopDesign(startDate, endDate, subordinate, target, order);
-        Long count = materialReportOverViewMapper.queryTopDesignCount(startDate, endDate, subordinate);
-        result.setList(topDesign);
-        result.setTotal(count);
         return result;
         return result;
     }
     }