Parcourir la source

设计看板-分项目列表添加部分字段,并按消耗降序排序

zhaoxian il y a 2 ans
Parent
commit
deb2445c66

+ 399 - 19
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/MaterialDataMapper.xml

@@ -11,7 +11,9 @@
 
     </select>
     <select id="getCompanyIdByUserId" resultType="java.lang.String" parameterType="java.lang.String">
-        select  company_id from `jeecg-boot`.user_company where user_id = #{userId} limit 1
+        select company_id
+        from `jeecg-boot`.user_company
+        where user_id = #{userId} limit 1
     </select>
     <select id="getByteDanceTotalCharge" resultType="java.math.BigDecimal">
         select sum(cost) as 'totalCharge'
@@ -662,15 +664,23 @@
         order by media_effect_date asc
     </select>
     <select id="getByteDanceProjectData" resultType="com.alibaba.fastjson.JSONObject">
+        select * from (
         select t1.projectId,
         t1.projectName,
-        t1.totalCount,
-        t2.liveVideoCount,
-        t3.clipVideoCount,
-        t4.totalCharge,
-        t5.pushMediaCount,
-        t6.firstChargeCount,
-        t7.effectCount
+        IFNULL(t1.totalCount,0) as 'totalCount',
+        IFNULL(t2.liveVideoCount,0) as 'liveVideoCount',
+        IFNULL(t3.clipVideoCount,0) as 'clipVideoCount',
+        IFNULL(t4.totalCharge,0) as 'totalCharge',
+        IFNULL(t5.pushMediaCount,0) as 'pushMediaCount',
+        IFNULL(t6.firstChargeCount,0) as 'firstChargeCount',
+        IFNULL(t7.effectCount,0) as 'effectCount',
+        IFNULL(t8.realPersonCost,0) as 'realPersonCost',
+        IFNULL(ROUND(t8.realPersonCost / t9.realPersonCount, 2),0) AS 'realPersonAverageCost',
+        IFNULL(t10.clipCost,0) as 'clipCost',
+        IFNULL(ROUND(t10.clipCost / t11.clipCount, 2),0) AS 'clipAverageCost',
+        IFNULL(ROUND(t4.totalCharge / t12.allCount, 2),0) AS 'totalAverageCost',
+        IFNULL(t13.realInvalidCount,0) as 'realInvalidCount',
+        IFNULL(t14.clipInvalidCount,0) as 'clipInvalidCount'
         from (select project_id as 'projectId',
         project_name as 'projectName',
         count(1) as 'totalCount'
@@ -767,7 +777,8 @@
         group by project_id) t4 on t1.projectId = t4.projectId
         left join
         (select project_id as 'projectId',
-        ifnull(count(1), 0) as 'pushMediaCount'
+        ifnull(count(1), 0) as 'pushMediaCount',
+        sum(ifnull(material_ad_count, 0))as 'materialAdCount'
         from application.app_bytedance_material_info
         where 1 = 1
         <if test="companyId != null and companyId != ''">
@@ -832,20 +843,209 @@
         and media_effect_date >= #{start}
         and media_effect_date &lt;= #{end}
         group by project_id) t7 on t1.projectId = t7.projectId
+        LEFT JOIN (
+        SELECT
+        t1.project_id as 'projectId',
+        IFNULL(SUM(t2.cost),0) as 'realPersonCost'
+        FROM
+        application.app_bytedance_material_info t1
+        LEFT JOIN application.bytedance_material_video_report_daily_dw t2 ON t1.material_id = t2.signature
+        WHERE t1.tag_id = 60155
+        AND t2.stat_datetime >= #{start}
+        AND t2.stat_datetime &lt;= #{end}
+        <if test="companyId != null and companyId != ''">
+            and t1.company_id = #{companyId}
+        </if>
+        <if test="leaderId != null and leaderId != ''">
+            and t1.leader_id = #{leaderId}
+        </if>
+        <if test="clipId != null and clipId != ''">
+            and t1.clip_id = #{clipId}
+        </if>
+        <if test="planId != null and planId != ''">
+            and t1.plan_id = #{planId}
+        </if>
+        <if test="shotId != null and shotId != ''">
+            and t1.shot_id = #{shotId}
+        </if>
+        GROUP BY t1.project_id
+        ) t8 ON t1.projectId = t8.projectId
+        LEFT JOIN (
+        SELECT project_id as 'projectId',
+        ifnull(count(1), 0) as 'realPersonCount'
+        FROM application.app_bytedance_material_info
+        WHERE tag_id = 60155
+        and farst_cost_time >= #{start}
+        AND farst_cost_time &lt;= #{end}
+        <if test="companyId != null and companyId != ''">
+            and company_id = #{companyId}
+        </if>
+        <if test="leaderId != null and leaderId != ''">
+            and leader_id = #{leaderId}
+        </if>
+        <if test="clipId != null and clipId != ''">
+            and clip_id = #{clipId}
+        </if>
+        <if test="planId != null and planId != ''">
+            and plan_id = #{planId}
+        </if>
+        <if test="shotId != null and shotId != ''">
+            and shot_id = #{shotId}
+        </if>
+        GROUP BY project_id
+        ) t9 ON t1.projectId = t9.projectId
+        LEFT JOIN (
+        SELECT
+        t1.project_id as 'projectId',
+        IFNULL(SUM(t2.cost),0) as 'clipCost'
+        FROM
+        application.app_bytedance_material_info t1
+        LEFT JOIN application.bytedance_material_video_report_daily_dw t2 ON t1.material_id = t2.signature
+        WHERE t1.tag_id = 60156
+        AND t2.stat_datetime >= #{start}
+        AND t2.stat_datetime &lt;= #{end}
+        <if test="companyId != null and companyId != ''">
+            and t1.company_id = #{companyId}
+        </if>
+        <if test="leaderId != null and leaderId != ''">
+            and t1.leader_id = #{leaderId}
+        </if>
+        <if test="clipId != null and clipId != ''">
+            and t1.clip_id = #{clipId}
+        </if>
+        <if test="planId != null and planId != ''">
+            and t1.plan_id = #{planId}
+        </if>
+        <if test="shotId != null and shotId != ''">
+            and t1.shot_id = #{shotId}
+        </if>
+        GROUP BY t1.project_id
+        ) t10 ON t1.projectId = t10.projectId
+        LEFT JOIN (
+        SELECT project_id as 'projectId',
+        ifnull(count(1), 0) as 'clipCount'
+        FROM application.app_bytedance_material_info
+        WHERE tag_id = 60156
+        and farst_cost_time >= #{start}
+        AND farst_cost_time &lt;= #{end}
+        <if test="companyId != null and companyId != ''">
+            and company_id = #{companyId}
+        </if>
+        <if test="leaderId != null and leaderId != ''">
+            and leader_id = #{leaderId}
+        </if>
+        <if test="clipId != null and clipId != ''">
+            and clip_id = #{clipId}
+        </if>
+        <if test="planId != null and planId != ''">
+            and plan_id = #{planId}
+        </if>
+        <if test="shotId != null and shotId != ''">
+            and shot_id = #{shotId}
+        </if>
+        GROUP BY project_id
+        ) t11 ON t1.projectId = t11.projectId
+        LEFT JOIN (
+        SELECT project_id as 'projectId',
+        ifnull(count(1), 0) as 'allCount'
+        FROM application.app_bytedance_material_info
+        WHERE farst_cost_time >= #{start}
+        AND farst_cost_time &lt;= #{end}
+        <if test="companyId != null and companyId != ''">
+            and company_id = #{companyId}
+        </if>
+        <if test="leaderId != null and leaderId != ''">
+            and leader_id = #{leaderId}
+        </if>
+        <if test="clipId != null and clipId != ''">
+            and clip_id = #{clipId}
+        </if>
+        <if test="planId != null and planId != ''">
+            and plan_id = #{planId}
+        </if>
+        <if test="shotId != null and shotId != ''">
+            and shot_id = #{shotId}
+        </if>
+        GROUP BY project_id
+        ) t12 ON t1.projectId = t12.projectId
+        LEFT JOIN (
+        SELECT
+        project_id as 'projectId',
+        ifnull(count(1), 0) as 'realInvalidCount'
+        FROM
+        application.app_bytedance_material_info
+        WHERE tag_id = 60155
+        AND media_effect_flag = 0
+        AND farst_cost_time >= #{start}
+        AND farst_cost_time &lt;= #{end}
+        <if test="companyId != null and companyId != ''">
+            and company_id = #{companyId}
+        </if>
+        <if test="leaderId != null and leaderId != ''">
+            and leader_id = #{leaderId}
+        </if>
+        <if test="clipId != null and clipId != ''">
+            and clip_id = #{clipId}
+        </if>
+        <if test="planId != null and planId != ''">
+            and plan_id = #{planId}
+        </if>
+        <if test="shotId != null and shotId != ''">
+            and shot_id = #{shotId}
+        </if>
+        GROUP BY project_id
+        ) t13 ON t1.projectId = t13.projectId
+        LEFT JOIN (
+        SELECT
+        project_id as 'projectId',
+        ifnull(count(1), 0) as 'clipInvalidCount'
+        FROM
+        application.app_bytedance_material_info
+        WHERE tag_id = 60156
+        AND media_effect_flag = 0
+        AND farst_cost_time >= #{start}
+        AND farst_cost_time &lt;= #{end}
+        <if test="companyId != null and companyId != ''">
+            and company_id = #{companyId}
+        </if>
+        <if test="leaderId != null and leaderId != ''">
+            and leader_id = #{leaderId}
+        </if>
+        <if test="clipId != null and clipId != ''">
+            and clip_id = #{clipId}
+        </if>
+        <if test="planId != null and planId != ''">
+            and plan_id = #{planId}
+        </if>
+        <if test="shotId != null and shotId != ''">
+            and shot_id = #{shotId}
+        </if>
+        GROUP BY project_id
+        ) t14 ON t1.projectId = t14.projectId
         where t1.projectId is not null
-        order by t1.totalCount desc
+        )t
+        order by t.totalCharge desc
 
     </select>
     <select id="getKuaiShouProjectData" resultType="com.alibaba.fastjson.JSONObject">
-        select t1.projectId,
+        select * from (
+        select
+        t1.projectId,
         t1.projectName,
-        t1.totalCount,
-        t2.liveVideoCount,
-        t3.clipVideoCount,
-        t4.totalCharge,
-        t5.pushMediaCount,
-        t6.firstChargeCount,
-        t7.effectCount
+        IFNULL(t1.totalCount,0) as 'totalCount',
+        IFNULL(t2.liveVideoCount,0) as 'liveVideoCount',
+        IFNULL(t3.clipVideoCount,0) as 'clipVideoCount',
+        IFNULL(t4.totalCharge,0) as 'totalCharge',
+        IFNULL(t5.pushMediaCount,0) as 'pushMediaCount',
+        IFNULL(t6.firstChargeCount,0) as 'firstChargeCount',
+        IFNULL(t7.effectCount,0) as 'effectCount',
+        IFNULL(t8.realPersonCost,0) as 'realPersonCost',
+        IFNULL(ROUND(t8.realPersonCost / t9.realPersonCount, 2),0) AS 'realPersonAverageCost',
+        IFNULL(t10.clipCost,0) as 'clipCost',
+        IFNULL(ROUND(t10.clipCost / t11.clipCount, 2),0) AS 'clipAverageCost',
+        IFNULL(ROUND(t4.totalCharge / t12.allCount, 2),0) AS 'totalAverageCost',
+        IFNULL(t13.realInvalidCount,0) as 'realInvalidCount',
+        IFNULL(t14.clipInvalidCount,0) as 'clipInvalidCount'
         from (select project_id as 'projectId',
         project_name as 'projectName',
         count(1) as 'totalCount'
@@ -1007,8 +1207,188 @@
         and media_effect_date >= #{start}
         and media_effect_date &lt;= #{end}
         group by project_id) t7 on t1.projectId = t7.projectId
+        LEFT JOIN (
+        SELECT
+        t1.project_id as 'projectId',
+        IFNULL(SUM(t2.charge),0) as 'realPersonCost'
+        FROM
+        application.app_kuaishou_material_info t1
+        LEFT JOIN application.kuaishou_material_video_report_daily_dw t2 ON t1.material_id = t2.signature
+        WHERE t1.tag_id = 60155
+        AND t2.stat_date >= #{start}
+        AND t2.stat_date &lt;= #{end}
+        <if test="companyId != null and companyId != ''">
+            and t1.company_id = #{companyId}
+        </if>
+        <if test="leaderId != null and leaderId != ''">
+            and t1.leader_id = #{leaderId}
+        </if>
+        <if test="clipId != null and clipId != ''">
+            and t1.clip_id = #{clipId}
+        </if>
+        <if test="planId != null and planId != ''">
+            and t1.plan_id = #{planId}
+        </if>
+        <if test="shotId != null and shotId != ''">
+            and t1.shot_id = #{shotId}
+        </if>
+        GROUP BY t1.project_id
+        ) t8 ON t1.projectId = t8.projectId
+        LEFT JOIN (
+        SELECT project_id as 'projectId',
+        ifnull(count(1), 0) as 'realPersonCount'
+        FROM application.app_kuaishou_material_info
+        WHERE tag_id = 60155
+        and farst_cost_time >= #{start}
+        AND farst_cost_time &lt;= #{end}
+        <if test="companyId != null and companyId != ''">
+            and company_id = #{companyId}
+        </if>
+        <if test="leaderId != null and leaderId != ''">
+            and leader_id = #{leaderId}
+        </if>
+        <if test="clipId != null and clipId != ''">
+            and clip_id = #{clipId}
+        </if>
+        <if test="planId != null and planId != ''">
+            and plan_id = #{planId}
+        </if>
+        <if test="shotId != null and shotId != ''">
+            and shot_id = #{shotId}
+        </if>
+        GROUP BY project_id
+        ) t9 ON t1.projectId = t9.projectId
+        LEFT JOIN (
+        SELECT
+        t1.project_id as 'projectId',
+        IFNULL(SUM(t2.charge),0) as 'clipCost'
+        FROM
+        application.app_kuaishou_material_info t1
+        LEFT JOIN application.kuaishou_material_video_report_daily_dw t2 ON t1.material_id = t2.signature
+        WHERE t1.tag_id = 60156
+        AND t2.stat_date >= #{start}
+        AND t2.stat_date &lt;= #{end}
+        <if test="companyId != null and companyId != ''">
+            and t1.company_id = #{companyId}
+        </if>
+        <if test="leaderId != null and leaderId != ''">
+            and t1.leader_id = #{leaderId}
+        </if>
+        <if test="clipId != null and clipId != ''">
+            and t1.clip_id = #{clipId}
+        </if>
+        <if test="planId != null and planId != ''">
+            and t1.plan_id = #{planId}
+        </if>
+        <if test="shotId != null and shotId != ''">
+            and t1.shot_id = #{shotId}
+        </if>
+        GROUP BY t1.project_id
+        ) t10 ON t1.projectId = t10.projectId
+        LEFT JOIN (
+        SELECT project_id as 'projectId',
+        ifnull(count(1), 0) as 'clipCount'
+        FROM application.app_kuaishou_material_info
+        WHERE tag_id = 60156
+        and farst_cost_time >= #{start}
+        AND farst_cost_time &lt;= #{end}
+        <if test="companyId != null and companyId != ''">
+            and company_id = #{companyId}
+        </if>
+        <if test="leaderId != null and leaderId != ''">
+            and leader_id = #{leaderId}
+        </if>
+        <if test="clipId != null and clipId != ''">
+            and clip_id = #{clipId}
+        </if>
+        <if test="planId != null and planId != ''">
+            and plan_id = #{planId}
+        </if>
+        <if test="shotId != null and shotId != ''">
+            and shot_id = #{shotId}
+        </if>
+        GROUP BY project_id
+        ) t11 ON t1.projectId = t11.projectId
+        LEFT JOIN (
+        SELECT project_id as 'projectId',
+        ifnull(count(1), 0) as 'allCount'
+        FROM application.app_kuaishou_material_info
+        WHERE farst_cost_time >= #{start}
+        AND farst_cost_time &lt;= #{end}
+        <if test="companyId != null and companyId != ''">
+            and company_id = #{companyId}
+        </if>
+        <if test="leaderId != null and leaderId != ''">
+            and leader_id = #{leaderId}
+        </if>
+        <if test="clipId != null and clipId != ''">
+            and clip_id = #{clipId}
+        </if>
+        <if test="planId != null and planId != ''">
+            and plan_id = #{planId}
+        </if>
+        <if test="shotId != null and shotId != ''">
+            and shot_id = #{shotId}
+        </if>
+        GROUP BY project_id
+        ) t12 ON t1.projectId = t12.projectId
+        LEFT JOIN (
+        SELECT
+        project_id as 'projectId',
+        ifnull(count(1), 0) as 'realInvalidCount'
+        FROM
+        application.app_kuaishou_material_info
+        WHERE tag_id = 60155
+        AND media_effect_flag = 0
+        AND farst_cost_time >= #{start}
+        AND farst_cost_time &lt;= #{end}
+        <if test="companyId != null and companyId != ''">
+            and company_id = #{companyId}
+        </if>
+        <if test="leaderId != null and leaderId != ''">
+            and leader_id = #{leaderId}
+        </if>
+        <if test="clipId != null and clipId != ''">
+            and clip_id = #{clipId}
+        </if>
+        <if test="planId != null and planId != ''">
+            and plan_id = #{planId}
+        </if>
+        <if test="shotId != null and shotId != ''">
+            and shot_id = #{shotId}
+        </if>
+        GROUP BY project_id
+        ) t13 ON t1.projectId = t13.projectId
+        LEFT JOIN (
+        SELECT
+        project_id as 'projectId',
+        ifnull(count(1), 0) as 'clipInvalidCount'
+        FROM
+        application.app_kuaishou_material_info
+        WHERE tag_id = 60156
+        AND media_effect_flag = 0
+        AND farst_cost_time >= #{start}
+        AND farst_cost_time &lt;= #{end}
+        <if test="companyId != null and companyId != ''">
+            and company_id = #{companyId}
+        </if>
+        <if test="leaderId != null and leaderId != ''">
+            and leader_id = #{leaderId}
+        </if>
+        <if test="clipId != null and clipId != ''">
+            and clip_id = #{clipId}
+        </if>
+        <if test="planId != null and planId != ''">
+            and plan_id = #{planId}
+        </if>
+        <if test="shotId != null and shotId != ''">
+            and shot_id = #{shotId}
+        </if>
+        GROUP BY project_id
+        ) t14 ON t1.projectId = t14.projectId
         where t1.projectId is not null
-        order by t1.totalCount desc
+        ) t
+        order by t.totalCharge desc
     </select>
     <select id="getByteDanceTeamData" resultType="com.alibaba.fastjson.JSONObject">
         select

+ 2 - 2
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/MaterialDataServiceImpl.java

@@ -107,7 +107,7 @@ public class MaterialDataServiceImpl implements IMaterialDataService {
     // 头条分项目
     @Override
     public Result<Object> getByteDanceProjectData(Map<String, Object> requestMap, Integer pageNo, Integer pageSize) {
-        PageHelper.startPage(pageNo, pageSize);
+//        PageHelper.startPage(pageNo, pageSize);
         List<JSONObject> data = materialDataMapper.getByteDanceProjectData(requestMap);
         return Result.ok(new PageInfo<>(data));
     }
@@ -115,7 +115,7 @@ public class MaterialDataServiceImpl implements IMaterialDataService {
     // 快手分项目
     @Override
     public Result<Object> getKuaiShouProjectData(Map<String, Object> requestMap, Integer pageNo, Integer pageSize) {
-        PageHelper.startPage(pageNo, pageSize);
+//        PageHelper.startPage(pageNo, pageSize);
         List<JSONObject> data = materialDataMapper.getKuaiShouProjectData(requestMap);
         return Result.ok(new PageInfo<>(data));
     }