浏览代码

数据汇聚

孙永军 2 年之前
父节点
当前提交
c7e4e1f427

+ 0 - 2
src/main/java/com/sxtvs/open/api/odata/dto/Agg.java

@@ -7,8 +7,6 @@ public class Agg {
 
     private String userName;
 
-    private String depName;
-
     private Long readCount;
 
 

+ 0 - 2
src/main/java/com/sxtvs/open/api/odata/dto/NewMedia.java

@@ -10,8 +10,6 @@ public class NewMedia {
 
     private String userName;
 
-    private String depName;
-
     private String title;
 
     private Long shareCount;

+ 31 - 53
src/main/resources/com/sxtvs/OpenDataMapper.xml

@@ -12,7 +12,7 @@
         </choose>
     </sql>
     <select id="newMediaList" resultType="com.sxtvs.open.api.odata.dto.NewMedia">
-        select nick_name user_name,dep_name,title,
+        select nick_name user_name,title,
                <if test="platform != '微博' and platform != '快手'">
                    share_count,
                </if>
@@ -33,24 +33,18 @@
     </select>
 
     <select id="weiboAggList" resultType="com.sxtvs.open.api.odata.dto.Agg">
-        select a.user_name, a.dep_name, b.read_count, b.share_count, b.comment_count, b.like_count, b.followers_count fans, b.publish_count publish_count
-        from (
-                 select *
-                 from department_v2
-                 where platform = '微博') a
-                 join (select nick_name,
+        select nick_name user_name,
                               sum(read_count)                                                as read_count,
         sum(reposts)      as share_count,
         sum(comments)      as comment_count,
         sum(likes)      as like_count,
-                              max(followers_count) as followers_count,
+                              max(followers_count) as fans,
                               sum(publish_count) publish_count
                        from weibo_total
                        where dt >= #{start} and dt &lt;= #{end}
-                       group by nick_name) b
-                      on a.user_name = b.nick_name
+
         <if test="match != null and match != ''">
-            where a.user_name like concat('%', #{match},'%') or a.dep_name like concat('%', #{match},'%')
+            and nick_name like concat('%', #{match},'%')
         </if>
         <if test="nickNames.size() > 0">
             and nick_name in
@@ -58,30 +52,26 @@
                 #{item}
             </foreach>
         </if>
+        group by nick_name
         order by ${sort}
         <include refid="orderSc" />
     </select>
 
     <select id="weiboLastDt" resultType="java.lang.String">
-        select IFNULL( max(dt), REPLACE(DATE_SUB(CURDATE(), INTERVAL 1 DAY),'-','')) dt from schedule_queue where `event` = 'open_data.微博'
+        select  REPLACE(SUBSTR( IFNULL(max(publish_time), DATE_SUB(CURDATE(), INTERVAL 1 DAY)) ,1, 10) ,'-','') dt from open_data where `platform` = '微博'
     </select>
 
     <select id="weixinAggList" resultType="com.sxtvs.open.api.odata.dto.Agg">
-        select nick_name user_name, b.dep_name,  a.read_count, a.share_count, a.fav_count,cumulate_user fans, a.publish_count
-        from (select nick_name,
+        select nick_name user_name,
                      sum(int_page_read_count)                                           as read_count,
                      sum(share_count) as share_count,
                      sum(add_to_fav_count) as fav_count,
-                     max(cumulate_user)       as cumulate_user,
+                     max(cumulate_user)       as fans,
                      sum(publish_count) publish_count
               from wx_total
               where dt >= #{start} and dt &lt;= #{end}
-              group by nick_name) a,
-             department_v2 b
-        where a.nick_name = b.user_name
-          and b.platform = '微信'
         <if test="match != null and match != ''">
-            and (a.nick_name like concat('%', #{match},'%') or b.dep_name like concat('%', #{match},'%'))
+            and nick_name like concat('%', #{match},'%')
         </if>
         <if test="nickNames.size() > 0">
             and nick_name in
@@ -89,6 +79,7 @@
                 #{item}
             </foreach>
         </if>
+        group by nick_name
         order by ${sort}
         <include refid="orderSc" />
     </select>
@@ -98,20 +89,16 @@
     </select>
 
     <select id="toutiaoAggList" resultType="com.sxtvs.open.api.odata.dto.Agg">
-        select a.nick_name user_name, b.dep_name, a.read_count, a.publish_count
-        from (
-                 select nick_name,
+
+                 select nick_name user_name,
                         sum(play_count)                                                                 as read_count,
                         count(1) publish_count
                  from open_data
                  where platform = '头条'
                    and publish_time >= #{start} and publish_time &lt;= concat(#{end}, ' 23:59:59')
-                 group by nick_name) a,
-             department_v2 b
-        where a.nick_name = b.user_name
-          and b.platform = '头条'
+
         <if test="match != null and match != ''">
-            and (a.nick_name like concat('%', #{match},'%') or b.dep_name like concat('%', #{match},'%'))
+            and nick_name like concat('%', #{match},'%')
         </if>
         <if test="nickNames.size() > 0">
             and nick_name in
@@ -119,16 +106,17 @@
                 #{item}
             </foreach>
         </if>
+        group by nick_name
         order by ${sort}
         <include refid="orderSc" />
     </select>
 
     <select id="toutiaoLastDt" resultType="java.lang.String">
-        select IFNULL( max(dt), REPLACE(DATE_SUB(CURDATE(), INTERVAL 1 DAY),'-','')) dt from schedule_queue where `event` = 'open_data.头条'
+        select  REPLACE(SUBSTR( IFNULL(max(publish_time), DATE_SUB(CURDATE(), INTERVAL 1 DAY)) ,1, 10) ,'-','') dt from open_data where `platform` = '头条'
     </select>
 
     <select id="douyinAggList" resultType="com.sxtvs.open.api.odata.dto.Agg">
-        select b.nick_name user_name, c.dep_name, a.read_count, a.share_count, a.like_count, a.total_fans fans, a.publish_count
+        select b.nick_name user_name, a.read_count, a.share_count, a.like_count, a.total_fans fans, a.publish_count
         from (select open_id,
                      sum(new_play)                                             as read_count,
                      sum(new_share)   as share_count,
@@ -138,13 +126,10 @@
               from douyin_snapshot
               where dt >= #{start} and dt &lt;= #{end}
               group by open_id) a,
-             douyin_account b,
-             department_v2 c
+             douyin_account b
         where a.open_id = b.open_id
-          and b.nick_name = c.user_name
-          and c.platform = '抖音'
         <if test="match != null and match != ''">
-            and (b.nick_name like concat('%', #{match},'%') or c.dep_name like concat('%', #{match},'%'))
+            and nick_name like concat('%', #{match},'%')
         </if>
         <if test="nickNames.size() > 0">
             and nick_name in
@@ -161,9 +146,8 @@
     </select>
 
     <select id="kuaishouAggList" resultType="com.sxtvs.open.api.odata.dto.Agg">
-        select a.nick_name user_name, b.dep_name, a.read_count, a.comment_count, a.like_count, a.publish_count
-        from (
-                 select nick_name,
+
+                 select nick_name user_name,
                         sum(play_count)                                                                 as read_count,
                         sum(comment_count) as comment_count,
                         sum(like_count) as like_count,
@@ -171,12 +155,8 @@
                  from open_data
                  where platform = '快手'
                    and publish_time >= #{start} and publish_time &lt;= concat(#{end}, ' 23:59:59')
-                 group by nick_name) a,
-             department_v2 b
-        where a.nick_name = b.user_name
-          and b.platform = '快手'
         <if test="match != null and match != ''">
-            and (a.nick_name like concat('%', #{match},'%') or b.dep_name like concat('%', #{match},'%'))
+            and nick_name like concat('%', #{match},'%')
         </if>
         <if test="nickNames.size() > 0">
             and nick_name in
@@ -184,29 +164,26 @@
                 #{item}
             </foreach>
         </if>
+        group by nick_name
         order by ${sort}
         <include refid="orderSc" />
     </select>
 
     <select id="kuaishouLastDt" resultType="java.lang.String">
-        select IFNULL( max(dt), REPLACE(DATE_SUB(CURDATE(), INTERVAL 1 DAY),'-','')) dt from schedule_queue where `event` = 'open_data.快手'
+        select  REPLACE(SUBSTR( IFNULL(max(publish_time), DATE_SUB(CURDATE(), INTERVAL 1 DAY)) ,1, 10) ,'-','') dt from open_data where `platform` = '快手'
     </select>
 
     <select id="biliAggList" resultType="com.sxtvs.open.api.odata.dto.Agg">
-        select a.nick_name user_name, b.dep_name, a.read_count, a.publish_count
-        from (
-                 select nick_name,
+
+                 select nick_name user_name,
                         sum(play_count)                                                                 as read_count,
                         count(1) publish_count
                  from open_data
                  where platform = 'B站'
                 and publish_time >= #{start} and publish_time &lt;= concat(#{end}, ' 23:59:59')
-                 group by nick_name) a,
-             department_v2 b
-        where a.nick_name = b.user_name
-          and b.platform = 'B站'
+
         <if test="match != null and match != ''">
-            and (a.nick_name like concat('%', #{match},'%') or b.dep_name like concat('%', #{match},'%'))
+            and nick_name like concat('%', #{match},'%')
         </if>
         <if test="nickNames.size() > 0">
             and nick_name in
@@ -214,12 +191,13 @@
                 #{item}
             </foreach>
         </if>
+        group by nick_name
         order by ${sort}
         <include refid="orderSc" />
     </select>
 
     <select id="biliLastDt" resultType="java.lang.String">
-        select IFNULL( max(dt), REPLACE(DATE_SUB(CURDATE(), INTERVAL 1 DAY),'-','')) dt from schedule_queue where `event` = 'open_data.B站'
+        select  REPLACE(SUBSTR( IFNULL(max(publish_time), DATE_SUB(CURDATE(), INTERVAL 1 DAY)) ,1, 10) ,'-','') dt from open_data where `platform` = 'B站'
     </select>
 
     <select id="departmentGroup" resultType="java.lang.String">