Forráskód Böngészése

飞书推送改版

zhaotx 4 hónapja
szülő
commit
f775911292

+ 1 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/ReportsAdPushMapper.java

@@ -23,6 +23,7 @@ public interface ReportsAdPushMapper {
     List<Map<String, String>> tmpTopMovie(@Param("date") Long date);
     //部门前后项数据排名
     List<Map<String, String>> deptRank2(@Param("date") Long date);
+    Map<String, String> deptRankTotal(@Param("date") Long date);
 
 
 

+ 35 - 22
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/ReportsAdPushMapper.xml

@@ -524,15 +524,7 @@
         where tb1.ma_appid != tb2.ma_appid
         order by tb2.user_id
     </select>
-    <select id="deptRank2" resultType="java.util.Map">
-        select tb5.dept_id, tb5.dept_name,
-        rank() over (order by sum(cost_amount) desc) as rk,
-        <include refid="costAmount"/>,
-        <include refid="sharePayAmount"/>,
-        <include refid="shareIaaAmount3"/>,
-        <include refid="iaaRoi"/>,
-        <include refid="iapRoi"/>
-        from
+    <sql id="deptRankSqlPart">
         (select cast(advertiser_id as char) advertiser_id, user_id from tidb.deepthink.advertiser_bind_info where user_id is not null and user_id != -9999 ) tb1
         left join
         (select advertiser_id, sum(iaa_cost_amount) as iaa_cost_amount, sum(iaa_real_cost_amount) as iaa_real_cost_amount,
@@ -548,30 +540,51 @@
         from application.media_ad_report_daily where stat_date=${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_line in (1,6,7,4,8,9,10) and business_method='IAP')
         group by advertiser_id)subtb2
         group by advertiser_id
-        ) tb2
+            ) tb2
         on tb1.advertiser_id = tb2.advertiser_id
-        left join (select advertiser_id,
-        round(ifnull(sum(share_iaa_amount_3), 0),2) as share_iaa_amount_3,
-        ifnull(sum(share_iaa_amount), 0) as share_iaa_amount,
-        sum(share_pay_amount) as share_pay_amount
-        from application.user_data_report_daily where stat_date=${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_line in (1,6,7,4,8,9,10))
-        group by advertiser_id) tb3
-        on tb1.advertiser_id = tb3.advertiser_id
-        left join (select user_id, nick_name, phonenumber, dept_id from tidb.deepthink.sys_user) tb4
-        on tb1.user_id=tb4.user_id
-        left join (
+            left join (select advertiser_id,
+            round(ifnull(sum(share_iaa_amount_3), 0),2) as share_iaa_amount_3,
+            ifnull(sum(share_iaa_amount), 0) as share_iaa_amount,
+            sum(share_pay_amount) as share_pay_amount
+            from application.user_data_report_daily where stat_date=${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_line in (1,6,7,4,8,9,10))
+            group by advertiser_id) tb3
+            on tb1.advertiser_id = tb3.advertiser_id
+            left join (select user_id, nick_name, phonenumber, dept_id from tidb.deepthink.sys_user) tb4
+            on tb1.user_id=tb4.user_id
+            left join (
             select dp.dept_id, dp.dept_name, ifnull(subdp.dept_id, dp.dept_id) as sub_dept_id, ifnull(subdp.dept_name, dp.dept_name) as sub_dept_name from (select * from tidb.deepthink.sys_dept where parent_id in (select dept_id from tidb.deepthink.sys_dept where parent_id=300)) dp
             right join tidb.deepthink.sys_dept subdp on dp.dept_id=subdp.parent_id
             where dp.dept_id is not null
             union all
             select dept_id, dept_name, dept_id as sub_dept_id, dept_name as sub_dept_name from tidb.deepthink.sys_dept where parent_id in (select dept_id from tidb.deepthink.sys_dept where parent_id=300)
-        ) tb5
-        on tb4.dept_id = tb5.sub_dept_id
+            ) tb5
+            on tb4.dept_id = tb5.sub_dept_id
         where tb4.user_id is not null
+    </sql>
+    <select id="deptRank2" resultType="java.util.Map">
+        select tb5.dept_id, tb5.dept_name,
+        rank() over (order by sum(cost_amount) desc) as rk,
+        <include refid="costAmount"/>,
+        <include refid="sharePayAmount"/>,
+        <include refid="shareIaaAmount3"/>,
+        <include refid="iaaRoi"/>,
+        <include refid="iapRoi"/>
+        from
+        <include refid="deptRankSqlPart"/>
         group by tb5.dept_id, tb5.dept_name
         having sum(cost_amount)>1
         order by rk
     </select>
+    <select id="deptRankTotal" resultType="java.util.Map">
+        select 0 as dept_id, '总计' as dept_name,
+        <include refid="costAmount"/>,
+        <include refid="sharePayAmount"/>,
+        <include refid="shareIaaAmount3"/>,
+        <include refid="iaaRoi"/>,
+        <include refid="iapRoi"/>
+        from
+        <include refid="deptRankSqlPart"/>
+    </select>
     <select id="cutDeptRank" resultType="java.util.Map">
         select row_number() over (order by sum(cost) desc) as ranks,
         dept_name as dept_name,

+ 3 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/ReportsByBusinessPushServiceImpl.java

@@ -190,6 +190,9 @@ public class ReportsByBusinessPushServiceImpl implements IReportsByBusinessPushS
         }
 
         List<Map<String, String>> deptData = reportsPushMapper.deptRank2(todayLong);
+        Map<String, String> deptTotalData = reportsPushMapper.deptRankTotal(todayLong);
+        deptData.add(0, deptTotalData);
+
         JSONArray deptRank = new JSONArray();
         for (Map<String, String> dept : deptData){
             JSONObject obj = new JSONObject();