|
@@ -0,0 +1,925 @@
|
|
|
|
+<?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.ctop.mapper.MaterialReportOverViewMapper">
|
|
|
|
+
|
|
|
|
+ <select id="recursiveQuerySubordinateByLeader" resultType="java.lang.String">
|
|
|
|
+ SELECT distinct id
|
|
|
|
+ FROM sys_user
|
|
|
|
+ WHERE leader_id = #{leaderId}
|
|
|
|
+ and status = 1
|
|
|
|
+ and del_flag = 0
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="recursiveQuerySubordinateByLeaders" resultType="java.lang.String">
|
|
|
|
+ SELECT distinct id
|
|
|
|
+ FROM sys_user
|
|
|
|
+ WHERE
|
|
|
|
+ status = 1
|
|
|
|
+ and del_flag = 0
|
|
|
|
+ and leader_id in
|
|
|
|
+ <foreach collection="leaderIds" item="item" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="recursiveQuerySubordinateByUserId" resultType="java.lang.String">
|
|
|
|
+ SELECT distinct id
|
|
|
|
+ FROM sys_user
|
|
|
|
+ WHERE leader_id = (select leader_id from sys_user where id = #{userId})
|
|
|
|
+ and status = 1
|
|
|
|
+ and del_flag = 0
|
|
|
|
+
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryProjectBy" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT DISTINCT
|
|
|
|
+ t1.project_id as projectId,
|
|
|
|
+ t1.project_name as projectName
|
|
|
|
+ FROM
|
|
|
|
+ ctop_project_member t1
|
|
|
|
+ LEFT JOIN ctop_project t2 on t1.project_id=t2.id
|
|
|
|
+ WHERE
|
|
|
|
+ t2.media_id IN
|
|
|
|
+ <foreach collection="mediaIds" item="item" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ and t1.user_id IN
|
|
|
|
+ <foreach collection="userIds" item="item" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ and t1.project_name is not null and t1.project_name!=''
|
|
|
|
+ ORDER BY t2.create_time desc
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryProjectIdBy" resultType="long">
|
|
|
|
+ SELECT DISTINCT
|
|
|
|
+ t1.project_id as projectId
|
|
|
|
+ FROM
|
|
|
|
+ ctop_project_member t1
|
|
|
|
+ LEFT JOIN ctop_project t2 on t1.project_id=t2.id
|
|
|
|
+ WHERE
|
|
|
|
+ t2.media_id IN
|
|
|
|
+ <foreach collection="mediaIds" item="item" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ and t1.user_id IN
|
|
|
|
+ <foreach collection="userIds" item="item" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedanceCost" resultType="java.math.BigDecimal">
|
|
|
|
+ SELECT
|
|
|
|
+ sum(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 >= #{startDate}
|
|
|
|
+ AND stat_datetime <= #{endDate}
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryKuaishouCost" resultType="java.math.BigDecimal">
|
|
|
|
+ SELECT
|
|
|
|
+ sum(charge)
|
|
|
|
+ FROM
|
|
|
|
+ ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE
|
|
|
|
+ 1=1
|
|
|
|
+ <if test="projects !=null">
|
|
|
|
+ AND project_id IN
|
|
|
|
+ <foreach collection="projects" item="item" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ AND stat_date >= #{startDate}
|
|
|
|
+ AND stat_date <= #{endDate}
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryMaterialCount" resultType="long">
|
|
|
|
+ SELECT
|
|
|
|
+ count(id) from ctop_material_info
|
|
|
|
+ WHERE
|
|
|
|
+ 1=1
|
|
|
|
+ <if test="projects !=null">
|
|
|
|
+ AND project_id IN
|
|
|
|
+ <foreach collection="projects" item="item" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ AND DATE_FORMAT(create_time, '%Y-%m-%d')>= #{startDate}
|
|
|
|
+ AND DATE_FORMAT(create_time, '%Y-%m-%d')<= #{endDate}
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryNewMaterialCount" resultType="long">
|
|
|
|
+ SELECT
|
|
|
|
+ count(id) from ctop_material_info
|
|
|
|
+ WHERE
|
|
|
|
+ DATE_FORMAT(create_time, '%Y-%m-%d')= #{statDate}
|
|
|
|
+ <if test="projects !=null">
|
|
|
|
+ AND project_id IN
|
|
|
|
+ <foreach collection="projects" item="item" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedanceChat" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT
|
|
|
|
+ sum(cost) as cost,
|
|
|
|
+ stat_datetime as statDate
|
|
|
|
+ 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 >= #{startDate}
|
|
|
|
+ AND stat_datetime <= #{endDate}
|
|
|
|
+ group by stat_datetime
|
|
|
|
+ order by stat_datetime
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedanceChatGroupMonth" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT
|
|
|
|
+ sum(cost) as cost,
|
|
|
|
+ DATE_FORMAT(stat_datetime, '%Y-%m') as statDate
|
|
|
|
+ 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 >= #{startDate}
|
|
|
|
+ AND stat_datetime <= #{endDate}
|
|
|
|
+ group by DATE_FORMAT(stat_datetime, '%Y-%m')
|
|
|
|
+ order by stat_datetime asc
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryKuaishouChat" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT
|
|
|
|
+ sum(charge) as cost,
|
|
|
|
+ stat_date as statDate
|
|
|
|
+ FROM
|
|
|
|
+ ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE
|
|
|
|
+ 1=1
|
|
|
|
+ <if test="projects !=null">
|
|
|
|
+ AND project_id IN
|
|
|
|
+ <foreach collection="projects" item="item" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ AND stat_date >= #{startDate}
|
|
|
|
+ AND stat_date <= #{endDate}
|
|
|
|
+ group by stat_date
|
|
|
|
+ order by stat_date
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryKuaishouChatGroupMonth" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT
|
|
|
|
+ sum(charge) as cost,
|
|
|
|
+ DATE_FORMAT(stat_date, '%Y-%m') as statDate
|
|
|
|
+ FROM
|
|
|
|
+ ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE
|
|
|
|
+ 1=1
|
|
|
|
+ <if test="projects !=null">
|
|
|
|
+ AND project_id IN
|
|
|
|
+ <foreach collection="projects" item="item" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ AND stat_date >= #{startDate}
|
|
|
|
+ AND stat_date <= #{endDate}
|
|
|
|
+ group by DATE_FORMAT(stat_date, '%Y-%m')
|
|
|
|
+ order by stat_date
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedanceTopMaterial" 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,
|
|
|
|
+ IFNULL(toutiao_url, '') AS 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 >= #{startDate}
|
|
|
|
+ AND stat_datetime <= #{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
|
|
|
|
+ t1.md5 signature,
|
|
|
|
+ IFNULL(t1.toutiao_url, '') AS url,
|
|
|
|
+ t1.cover_url AS coverUrl,
|
|
|
|
+ t1.material_name AS materialName,
|
|
|
|
+ t1.project_name AS projectName,
|
|
|
|
+ t1.material_create_time AS createTime,
|
|
|
|
+ ${filed}
|
|
|
|
+ FROM
|
|
|
|
+ etl_report_bytedance_video t1
|
|
|
|
+ WHERE
|
|
|
|
+ 1=1
|
|
|
|
+ <if test="md5 !=null and md5 != ''">
|
|
|
|
+ AND t1.md5= #{md5}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="projects !=null">
|
|
|
|
+ AND project_id IN
|
|
|
|
+ <foreach collection="projects" item="item" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ AND stat_datetime >= #{startDate}
|
|
|
|
+ AND stat_datetime <= #{endDate}
|
|
|
|
+ GROUP BY t1.md5
|
|
|
|
+ ORDER BY ${target} ${order}
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedanceMaterialReportCount" resultType="java.lang.Long">
|
|
|
|
+ select count(1) from(
|
|
|
|
+ SELECT
|
|
|
|
+ count(1)
|
|
|
|
+ FROM
|
|
|
|
+ etl_report_bytedance_video t1
|
|
|
|
+ WHERE
|
|
|
|
+ 1=1
|
|
|
|
+ <if test="md5 !=null and md5 != ''">
|
|
|
|
+ AND t1.md5= #{md5}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="projects !=null">
|
|
|
|
+ AND project_id IN
|
|
|
|
+ <foreach collection="projects" item="item" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ AND stat_datetime >= #{startDate}
|
|
|
|
+ AND stat_datetime <= #{endDate}
|
|
|
|
+ GROUP BY t1.md5) t
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryKuaishouTopMaterial" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ 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 >= #{startDate}
|
|
|
|
+ AND t1.stat_date <= #{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 id="queryKuaishouMaterialReport" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT
|
|
|
|
+ t1.*,
|
|
|
|
+ t2.video_name as materialName,
|
|
|
|
+ t2.cover_url as coverUrl,
|
|
|
|
+ t2.url as url ,
|
|
|
|
+ t2.channel_name AS channel,
|
|
|
|
+ t2.state_date as createTime
|
|
|
|
+ FROM
|
|
|
|
+ (select ${filed}
|
|
|
|
+ from ctop_etl_kuaishou_account_material_report_daily t1
|
|
|
|
+ where
|
|
|
|
+ 1=1
|
|
|
|
+ <if test="md5 !=null and md5 != ''">
|
|
|
|
+ AND t1.signature= #{md5}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="projects !=null">
|
|
|
|
+ AND project_id IN
|
|
|
|
+ <foreach collection="projects" item="item" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ AND t1.stat_date >= #{startDate}
|
|
|
|
+ AND t1.stat_date <= #{endDate}
|
|
|
|
+ GROUP BY t1.signature
|
|
|
|
+ ) t1
|
|
|
|
+ LEFT JOIN ctop_etl_kuaishou_video_info t2
|
|
|
|
+ ON t1.signature = t2.video_code
|
|
|
|
+ where 1=1
|
|
|
|
+ <if test="channelType !=null and channelType != ''">
|
|
|
|
+ AND t2.channel_type= #{channelType}
|
|
|
|
+ </if>
|
|
|
|
+ ORDER BY ${target} ${order}
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryKuaishouMaterialReportCount" resultType="java.lang.Long">
|
|
|
|
+ SELECT
|
|
|
|
+ count(1)
|
|
|
|
+ FROM
|
|
|
|
+ (select t1.signature
|
|
|
|
+ from ctop_etl_kuaishou_account_material_report_daily t1
|
|
|
|
+ where
|
|
|
|
+ 1=1
|
|
|
|
+ <if test="md5 !=null and md5 != ''">
|
|
|
|
+ AND t1.signature= #{md5}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="projects !=null">
|
|
|
|
+ AND project_id IN
|
|
|
|
+ <foreach collection="projects" item="item" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ AND t1.stat_date >= #{startDate}
|
|
|
|
+ AND t1.stat_date <= #{endDate}
|
|
|
|
+ GROUP BY t1.signature
|
|
|
|
+ ) t1
|
|
|
|
+ LEFT JOIN ctop_etl_kuaishou_video_info t2
|
|
|
|
+ ON t1.signature = t2.video_code
|
|
|
|
+ where 1=1
|
|
|
|
+ <if test="channelType !=null and channelType != ''">
|
|
|
|
+ AND t2.channel_type= #{channelType}
|
|
|
|
+ </if>
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryTopDesign" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT rowNumber,
|
|
|
|
+ userName,
|
|
|
|
+ roleName,
|
|
|
|
+ cost
|
|
|
|
+ from(
|
|
|
|
+ SELECT (@i:=@i+1) AS rowNumber,
|
|
|
|
+ userName,
|
|
|
|
+ roleName,
|
|
|
|
+ cost
|
|
|
|
+ from(
|
|
|
|
+ SELECT
|
|
|
|
+ user_name AS userName,
|
|
|
|
+ role_name AS roleName,
|
|
|
|
+ sum(cost) cost
|
|
|
|
+ FROM
|
|
|
|
+ etl_design_daily_report,(SELECT @i:=0) i
|
|
|
|
+ where
|
|
|
|
+ stat_date >= #{startDate}
|
|
|
|
+ AND stat_date <= #{endDate}
|
|
|
|
+ AND user_id IN
|
|
|
|
+ <foreach collection="userIds" item="item" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ GROUP BY
|
|
|
|
+ user_id
|
|
|
|
+ ORDER BY
|
|
|
|
+ ${target} ${order}) t) t1
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryTopDesignCount" resultType="java.lang.Long">
|
|
|
|
+ SELECT
|
|
|
|
+ count(1)
|
|
|
|
+ FROM
|
|
|
|
+ (
|
|
|
|
+ SELECT
|
|
|
|
+ count(1)
|
|
|
|
+ FROM
|
|
|
|
+ etl_design_daily_report
|
|
|
|
+ where
|
|
|
|
+ stat_date >= #{startDate}
|
|
|
|
+ AND stat_date <= #{endDate}
|
|
|
|
+ AND user_id IN
|
|
|
|
+ <foreach collection="userIds" item="item" separator=","
|
|
|
|
+ open="(" close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ GROUP BY
|
|
|
|
+ user_id ) t
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedanceVideoDetail" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT t.url,
|
|
|
|
+ t.cover_url as coverUrl,
|
|
|
|
+ t.id as materialId,
|
|
|
|
+ t.material_name as materialName,
|
|
|
|
+ t2.`second`,
|
|
|
|
+ '头条' as madia,
|
|
|
|
+ GROUP_CONCAT((SELECT project_name from ctop_project where id = t.project_id limit 1)) as projectName,
|
|
|
|
+ t.create_time as createTime,
|
|
|
|
+ t2.size,
|
|
|
|
+ '内部' as channelType,
|
|
|
|
+ t.`code`,
|
|
|
|
+ '' as materialType,
|
|
|
|
+ t2.height,
|
|
|
|
+ t2.width,
|
|
|
|
+ '北京汇创思拓数字科技有限公司' as supplier,
|
|
|
|
+ IFNULL((SELECT leader_name from sys_user where id = t1.clip_id), '') as leaderName,
|
|
|
|
+ IFNULL(t1.clip_name, '') clipName,
|
|
|
|
+ IFNULL(t1.shot_name, '') shotName,
|
|
|
|
+ IFNULL(t1.plan_name, '') planName
|
|
|
|
+ FROM ctop_material_info t
|
|
|
|
+ LEFT JOIN ctop_material_ascription t1 on t.`code` = t1.material_id
|
|
|
|
+ LEFT JOIN ctop_material_parameter t2 on t.`code` = t2.material_id
|
|
|
|
+ where t.code = #{md5}
|
|
|
|
+ GROUP BY t.code
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryKuaishouVideoDetail" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT t1.url,
|
|
|
|
+ t1.cover_url as coverUrl,
|
|
|
|
+ t.id as materialId,
|
|
|
|
+ t.material_name as materialName,
|
|
|
|
+ t2.`second`,
|
|
|
|
+ '快手' as madia,
|
|
|
|
+ GROUP_CONCAT((SELECT project_name from ctop_project where id = t.project_id limit 1)) as projectName,
|
|
|
|
+ t.create_time as createTime,
|
|
|
|
+ t2.size,
|
|
|
|
+ t1.channel_name as channelType,
|
|
|
|
+ t1.`video_code` as 'code',
|
|
|
|
+ '' as materialType,
|
|
|
|
+ t2.height,
|
|
|
|
+ t2.width,
|
|
|
|
+ '北京汇创思拓数字科技有限公司' as supplier,
|
|
|
|
+ IFNULL(t1.design_team_leader_name, '') as leaderName,
|
|
|
|
+ IFNULL(t1.clip_name, '') clipName,
|
|
|
|
+ IFNULL(t1.shot_name, '') shotName,
|
|
|
|
+ IFNULL(t1.plan_name, '') planName
|
|
|
|
+ FROM ctop_etl_kuaishou_video_info t1
|
|
|
|
+ LEFT JOIN ctop_material_info t ON t.`code` = t1.video_code
|
|
|
|
+ LEFT JOIN ctop_material_parameter t2 on t.`code` = t2.material_id
|
|
|
|
+ where t1.video_code = #{md5}
|
|
|
|
+ GROUP BY t1.video_code
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedanceVideoChat" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT sum(cost) AS cost,
|
|
|
|
+ DATE_FORMAT(stat_datetime, '%Y-%m') AS statDate
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE md5 = #{md5}
|
|
|
|
+ GROUP BY DATE_FORMAT(stat_datetime, '%Y-%m')
|
|
|
|
+ ORDER BY stat_datetime ASC
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryKuaishouVideoChat" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT sum(charge) AS cost,
|
|
|
|
+ DATE_FORMAT(stat_date, '%Y-%m') AS statDate
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE signature = #{md5}
|
|
|
|
+ GROUP BY DATE_FORMAT(stat_date, '%Y-%m')
|
|
|
|
+ ORDER BY stat_date
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedanceProjectIdByMd5" resultType="java.lang.Long">
|
|
|
|
+ SELECT
|
|
|
|
+ project_id
|
|
|
|
+ FROM
|
|
|
|
+ etl_report_bytedance_video
|
|
|
|
+ WHERE
|
|
|
|
+ md5 = #{md5}
|
|
|
|
+ AND project_id IS NOT NULL
|
|
|
|
+ LIMIT 1
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryKuaishouProjectIdByMd5" resultType="java.lang.Long">
|
|
|
|
+ SELECT
|
|
|
|
+ project_id
|
|
|
|
+ FROM
|
|
|
|
+ ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE
|
|
|
|
+ signature = #{md5}
|
|
|
|
+ AND project_id IS NOT NULL
|
|
|
|
+ LIMIT 1
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedanceCostByMd5" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ select cost
|
|
|
|
+ from (
|
|
|
|
+ SELECT ROUND(sum(cost), 2) cost,
|
|
|
|
+ 1 as num
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE md5 = #{md5}
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(MAX(cost), 2) top,
|
|
|
|
+ 2 as num
|
|
|
|
+ FROM (
|
|
|
|
+ SELECT sum(cost) cost
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ GROUP BY md5
|
|
|
|
+ ) t
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(AVG(cost), 2) average,
|
|
|
|
+ 3 as num
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ ) t
|
|
|
|
+ order by num
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedanceClickByMd5" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ select click
|
|
|
|
+ from (
|
|
|
|
+ SELECT sum(click) click,
|
|
|
|
+ 1 as num
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE md5 = #{md5}
|
|
|
|
+ union all
|
|
|
|
+ SELECT MAX(click) top,
|
|
|
|
+ 2 as num
|
|
|
|
+ FROM (
|
|
|
|
+ SELECT sum(click) click
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ GROUP BY md5
|
|
|
|
+ ) t
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(AVG(click), 0) average,
|
|
|
|
+ 3 as num
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ ) t
|
|
|
|
+ order by num
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedanceMaterialShowByMd5" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ select materialShow
|
|
|
|
+ from (
|
|
|
|
+ SELECT sum(material_show) materialShow,
|
|
|
|
+ 1 as num
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE md5 = #{md5}
|
|
|
|
+ union all
|
|
|
|
+ SELECT MAX(materialShow) top,
|
|
|
|
+ 2 as num
|
|
|
|
+ FROM (
|
|
|
|
+ SELECT sum(material_show) materialShow
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ GROUP BY md5
|
|
|
|
+ ) t
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(AVG(material_show), 0) average,
|
|
|
|
+ 3 as num
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ ) t
|
|
|
|
+ order by num
|
|
|
|
+
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedancePlay100RateByMd5" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ select play100Rate
|
|
|
|
+ from (
|
|
|
|
+ SELECT ifnull(round(sum(play100_feed_break) / sum(material_show), 2),0) play100Rate,
|
|
|
|
+ 1 as num
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE md5 = #{md5}
|
|
|
|
+ union all
|
|
|
|
+ SELECT ifnull(MAX(play100Rate),0) top,
|
|
|
|
+ 2 as num
|
|
|
|
+ FROM (
|
|
|
|
+ SELECT round(sum(play100_feed_break) / sum(material_show), 2) play100Rate
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ GROUP BY md5
|
|
|
|
+ ) t
|
|
|
|
+ union all
|
|
|
|
+ SELECT ifnull(ROUND(sum(play100_feed_break) / sum(material_show), 2),0) average,
|
|
|
|
+ 3 as num
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ ) t
|
|
|
|
+ order by num
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedanceLikeMaterialByMd5" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ select likeMaterial
|
|
|
|
+ from (
|
|
|
|
+ SELECT sum(like_material) likeMaterial,
|
|
|
|
+ 1 as num
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE md5 = #{md5}
|
|
|
|
+ union all
|
|
|
|
+ SELECT MAX(likeMaterial) top,
|
|
|
|
+ 2 as num
|
|
|
|
+ FROM (
|
|
|
|
+ SELECT sum(like_material) likeMaterial
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ GROUP BY md5
|
|
|
|
+ ) t
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(AVG(like_material), 0) average,
|
|
|
|
+ 3 as num
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ ) t
|
|
|
|
+ order by num
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedanceCommentMaterialByMd5" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ select commentMaterial
|
|
|
|
+ from (
|
|
|
|
+ SELECT sum(comment_material) commentMaterial,
|
|
|
|
+ 1 as num
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE md5 = #{md5}
|
|
|
|
+ union all
|
|
|
|
+ SELECT MAX(commentMaterial) top,
|
|
|
|
+ 2 as num
|
|
|
|
+ FROM (
|
|
|
|
+ SELECT sum(comment_material) commentMaterial
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ GROUP BY md5
|
|
|
|
+ ) t
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(AVG(comment_material), 0) average,
|
|
|
|
+ 3 as num
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ ) t
|
|
|
|
+ order by num
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedanceShareMaterialByMd5" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ select shareMaterial
|
|
|
|
+ from (
|
|
|
|
+ SELECT sum(share_material) shareMaterial,
|
|
|
|
+ 1 as num
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE md5 = #{md5}
|
|
|
|
+ union all
|
|
|
|
+ SELECT MAX(shareMaterial) top,
|
|
|
|
+ 2 as num
|
|
|
|
+ FROM (
|
|
|
|
+ SELECT sum(share_material) shareMaterial
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ GROUP BY md5
|
|
|
|
+ ) t
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(AVG(share_material), 0) average,
|
|
|
|
+ 3 as num
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ ) t
|
|
|
|
+ order by num
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedanceFollowByMd5" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ select follow
|
|
|
|
+ from (
|
|
|
|
+ SELECT sum(follow) follow,
|
|
|
|
+ 1 as num
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE md5 = #{md5}
|
|
|
|
+ union all
|
|
|
|
+ SELECT MAX(follow) top,
|
|
|
|
+ 2 as num
|
|
|
|
+ FROM (
|
|
|
|
+ SELECT sum(follow) follow
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ GROUP BY md5
|
|
|
|
+ ) t
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(AVG(follow), 0) average,
|
|
|
|
+ 3 as num
|
|
|
|
+ FROM etl_report_bytedance_video
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ ) t
|
|
|
|
+ order by num
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryKuaishouChargeByMd5" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ select charge
|
|
|
|
+ from (
|
|
|
|
+ SELECT ROUND(sum(charge), 2) charge,
|
|
|
|
+ 1 as num
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE signature = #{md5}
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(MAX(charge), 2) top,
|
|
|
|
+ 2 as num
|
|
|
|
+ FROM (
|
|
|
|
+ SELECT sum(charge) charge
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ GROUP BY signature
|
|
|
|
+ ) t
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(AVG(charge), 2) average,
|
|
|
|
+ 3 as num
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ ) t
|
|
|
|
+ order by num
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryKuaishouPhotoShowByMd5" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ select photoShow
|
|
|
|
+ from (
|
|
|
|
+ SELECT sum(photo_show) photoShow,
|
|
|
|
+ 1 as num
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE signature = #{md5}
|
|
|
|
+ union all
|
|
|
|
+ SELECT MAX(photoShow) top,
|
|
|
|
+ 2 as num
|
|
|
|
+ FROM (
|
|
|
|
+ SELECT sum(photo_show) photoShow
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ GROUP BY signature
|
|
|
|
+ ) t
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(AVG(photo_show), 0) average,
|
|
|
|
+ 3 as num
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ ) t
|
|
|
|
+ order by num
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryKuaishouPhotoClickByMd5" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ select photoClick
|
|
|
|
+ from (
|
|
|
|
+ SELECT sum(photo_click) photoClick,
|
|
|
|
+ 1 as num
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE signature = #{md5}
|
|
|
|
+ union all
|
|
|
|
+ SELECT MAX(photoClick) top,
|
|
|
|
+ 2 as num
|
|
|
|
+ FROM (
|
|
|
|
+ SELECT sum(photo_click) photoClick
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ GROUP BY signature
|
|
|
|
+ ) t
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(AVG(photo_click), 0) average,
|
|
|
|
+ 3 as num
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ ) t
|
|
|
|
+ order by num
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryKuaishouAClickByMd5" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ select aclick
|
|
|
|
+ from (
|
|
|
|
+ SELECT sum(aclick) aclick,
|
|
|
|
+ 1 as num
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE signature = #{md5}
|
|
|
|
+ union all
|
|
|
|
+ SELECT MAX(aclick) top,
|
|
|
|
+ 2 as num
|
|
|
|
+ FROM (
|
|
|
|
+ SELECT sum(aclick) aclick
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ GROUP BY signature
|
|
|
|
+ ) t
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(AVG(aclick), 0) average,
|
|
|
|
+ 3 as num
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ ) t
|
|
|
|
+ order by num
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryKuaishouBClickByMd5" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ select bclick
|
|
|
|
+ from (
|
|
|
|
+ SELECT sum(bclick) bclick,
|
|
|
|
+ 1 as num
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE signature = #{md5}
|
|
|
|
+ union all
|
|
|
|
+ SELECT MAX(bclick) top,
|
|
|
|
+ 2 as num
|
|
|
|
+ FROM (
|
|
|
|
+ SELECT sum(bclick) bclick
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ GROUP BY signature
|
|
|
|
+ ) t
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(AVG(bclick), 0) average,
|
|
|
|
+ 3 as num
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ ) t
|
|
|
|
+ order by num
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryKuaishouActivationByMd5" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ select activation
|
|
|
|
+ from (
|
|
|
|
+ SELECT sum(activation) activation,
|
|
|
|
+ 1 as num
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE signature = #{md5}
|
|
|
|
+ union all
|
|
|
|
+ SELECT MAX(activation) top,
|
|
|
|
+ 2 as num
|
|
|
|
+ FROM (
|
|
|
|
+ SELECT sum(activation) activation
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ GROUP BY signature
|
|
|
|
+ ) t
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(AVG(activation), 0) average,
|
|
|
|
+ 3 as num
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ ) t
|
|
|
|
+ order by num
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryKuaishouPlay3sRateByMd5" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ select play3sRate
|
|
|
|
+ from (
|
|
|
|
+ SELECT round(sum(play_3s_count) / sum(aclick), 2) play3sRate,
|
|
|
|
+ 1 as num
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE signature = #{md5}
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(MAX(play3sRate), 2) top,
|
|
|
|
+ 2 as num
|
|
|
|
+ FROM (
|
|
|
|
+ SELECT sum(play_3s_count) / sum(aclick) play3sRate
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ GROUP BY signature
|
|
|
|
+ ) t
|
|
|
|
+ union all
|
|
|
|
+ SELECT ROUND(sum(play_3s_count) / sum(aclick), 2) average,
|
|
|
|
+ 3 as num
|
|
|
|
+ FROM ctop_etl_kuaishou_account_material_report_daily
|
|
|
|
+ WHERE project_id = #{project}
|
|
|
|
+ ) t
|
|
|
|
+ order by num
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+</mapper>
|