renyupeng il y a 2 ans
Parent
commit
22c52c826d

+ 183 - 0
Apietl/ruixuan/report/LiveAccountDailyReport.py

@@ -0,0 +1,183 @@
+# Author renyupeng
+# coding=utf-8
+# @Time    : 2022/7/27 2:49 下午
+# @Site    : 
+# @File    : LiveAccountDailyReport.py
+# @Software: PyCharm
+# @contact: renyupeng@c-top.com.cn
+# @Tel 1501435553
+import logging
+
+from Apietl.conn.TidbConn import TidbConn
+from Apietl.utlis.Utils import Utils
+
+
+class LiveAccountDailyReport:
+    def __init__(self):
+        self.conn = TidbConn.get_connection()
+        self.parm = Utils.get_live_args()
+        self.stat_date = self.parm
+
+    def handler(self):
+        try:
+            sql = """select account_id from kuaishou_live.kuaishou_live_account_report_daily where report_date={stat_date}
+group by account_id""".format(stat_date=self.stat_date)
+            account_list = TidbConn.quary(self.conn, sql)
+            for account_id in account_list:
+                sql = """
+                replace into ruixuan.kuaishou_live_account_report_daily_dw
+select report.account_id,
+       account_name,
+       project_id,
+       project_name,
+       ks_id,
+       ks_name,
+       sale_leader_id,
+       sale_leader,
+       operator_leader_id,
+       operator_leader,
+       designer_leader_id,
+       designer_leader,
+       enterprise_name,
+       collaborator_id,
+       collaborator,
+       cost_total/100,
+       ad_show,
+       ad_show1k_cost/100,
+       impression,
+       photo_click,
+       photo_click_ratio,
+       click,
+       actionbar_click,
+       actionbar_click_cost/100,
+       esp_click_ratio,
+       action_ratio,
+       ad_item_click_count,
+       esp_live_played_seconds,
+       played_three_seconds,
+       play3s_ratio,
+       played_five_seconds,
+       play5s_ratio,
+       played_end,
+       play_end_ratio,
+       share,
+       comment,
+       likes,
+       report,
+       block,
+       item_negative,
+       live_share,
+       live_comment,
+       live_reward,
+       effective_play_count,
+       effective_play_ratio,
+       ad_live_played1m_num,
+       conversion_num,
+       conversion_cost_esp/100,
+       gmv/100,
+       t0_gmv/100,
+       t1_gmv/100,
+       t7_gmv/100,
+       t15_gmv/100,
+       t30_gmv,
+       roi,
+       t0_roi,
+       t1_roi,
+       t7_roi,
+       t15_roi,
+       t30_roi,
+       paied_order,
+       order_ratio,
+       t0_order_cnt,
+       t0_order_cnt_cost/100,
+       t0_order_cnt_ratio,
+       t1_order_cnt,
+       t7_order_cnt,
+       t15_order_cnt,
+       t30_order_cnt,
+       merchant_reco_fans,
+       t1_retention,
+       t7_retention,
+       t15_retention,
+       t30_retention,
+       t1_retention_ratio,
+       t7_retention_ratio,
+       t15_retention_ratio,
+       t30_retention_ratio,
+       reservation_success,
+       reservation_cost/100,
+       standard_live_played_started,
+       live_audience_cost/100,
+       live_event_goods_view,
+       goods_click_ratio,
+       direct_attr_plat_new_buyer_cnt,
+       t30_attr_plat_total_buyer_cnt,
+       direct_attr_seller_new_buyer_cnt,
+       t30_attr_seller_total_buyer_cnt,
+       fans_t0_gmv/100,
+       fans_t1_gmv/100,
+       fans_t7_gmv/100,
+       fans_t15_gmv/100,
+       fans_t30_gmv/100,
+       fans_t0_roi,
+       fans_t1_roi,
+       fans_t7_roi,
+       fans_t15_roi,
+       fans_t30_roi,
+       report_date
+from kuaishou_live.kuaishou_live_account_report_daily report
+         left join
+     (select acc.account_id,
+             account_name,
+             project_id,
+             project_name,
+             ks_id,
+             ks_name,
+             sale_leader_id,
+             sale.user_name     as sale_leader,
+             operator_leader_id,
+             user.user_name     as operator_leader,
+             designer_leader_id,
+             designer.user_name as designer_leader,
+             enterprise_name,
+             collaborator_id,
+             collaborator
+      from ruixuan.kuaishou_live_user_account acc
+               left join
+           ruixuan.kuaishou_live_project pro
+           on acc.project_id = pro.id
+               left join ruixuan.sys_user sale
+                         on acc.sale_leader_id = sale.user_id
+               left join ruixuan.sys_user user
+                         on acc.operator_leader_id = user.user_id
+               left join ruixuan.sys_user designer
+                         on acc.designer_leader_id = designer.user_id
+               left join(
+          select account_id,
+                 group_concat(collaborator_id) as collaborator_id,
+                 group_concat(collaborator)    as collaborator
+          from ruixuan.kuaishou_live_user_account_part
+          group by account_id
+      ) collaborator
+                        on acc.account_id = collaborator.account_id) acc_info
+     on report.account_id = acc_info.account_id
+where report.report_date={stat_date} and report.account_id={account_id};
+                """.format(stat_date=self.stat_date, account_id=account_id[0])
+                print(sql)
+                TidbConn.upsert(conn=self.conn, sql_buff=sql)
+                self.conn.commit()
+            TidbConn.conn_close(conn=self.conn)
+            return 0
+        except Exception as e:
+            logging.error(e)
+            return -1
+
+
+if __name__ == '__main__':
+    status = LiveAccountDailyReport().handler()
+    if status == 0:
+        print("作业执行成功")
+        exit(0)
+    else:
+        print("作业执行失败")
+        exit(-1)

+ 184 - 0
Apietl/ruixuan/report/LiveAccountHourlyReport.py

@@ -0,0 +1,184 @@
+# Author renyupeng
+# coding=utf-8
+# @Time    : 2022/7/27 2:49 下午
+# @Site    : 
+# @File    : LiveAccountHourlyReport.py
+# @Software: PyCharm
+# @contact: renyupeng@c-top.com.cn
+# @Tel 1501435553
+import logging
+
+from Apietl.conn.TidbConn import TidbConn
+from Apietl.utlis.Utils import Utils
+
+
+class LiveAccountHourlyReport:
+    def __init__(self):
+        self.conn = TidbConn.get_connection()
+        self.parm = Utils.get_live_args()
+        self.stat_date = self.parm
+
+    def handler(self):
+        try:
+            sql = """select account_id from kuaishou_live.kuaishou_live_account_report_hourly where report_date={stat_date}
+group by account_id""".format(stat_date=self.stat_date)
+            account_list = TidbConn.quary(self.conn, sql)
+            for account_id in account_list:
+                sql = """
+                replace into ruixuan.kuaishou_live_account_report_hourly_dw
+select report.account_id,
+       account_name,
+       project_id,
+       project_name,
+       ks_id,
+       ks_name,
+       sale_leader_id,
+       sale_leader,
+       operator_leader_id,
+       operator_leader,
+       designer_leader_id,
+       designer_leader,
+       enterprise_name,
+       collaborator_id,
+       collaborator,
+       cost_total/100,
+       ad_show,
+       ad_show1k_cost/100,
+       impression,
+       photo_click,
+       photo_click_ratio,
+       click,
+       actionbar_click,
+       actionbar_click_cost/100,
+       esp_click_ratio,
+       action_ratio,
+       ad_item_click_count,
+       esp_live_played_seconds,
+       played_three_seconds,
+       play3s_ratio,
+       played_five_seconds,
+       play5s_ratio,
+       played_end,
+       play_end_ratio,
+       share,
+       comment,
+       likes,
+       report,
+       block,
+       item_negative,
+       live_share,
+       live_comment,
+       live_reward,
+       effective_play_count,
+       effective_play_ratio,
+       ad_live_played1m_num,
+       conversion_num,
+       conversion_cost_esp/100,
+       gmv/100,
+       t0_gmv/100,
+       t1_gmv/100,
+       t7_gmv/100,
+       t15_gmv/100,
+       t30_gmv,
+       roi,
+       t0_roi,
+       t1_roi,
+       t7_roi,
+       t15_roi,
+       t30_roi,
+       paied_order,
+       order_ratio,
+       t0_order_cnt,
+       t0_order_cnt_cost/100,
+       t0_order_cnt_ratio,
+       t1_order_cnt,
+       t7_order_cnt,
+       t15_order_cnt,
+       t30_order_cnt,
+       merchant_reco_fans,
+       t1_retention,
+       t7_retention,
+       t15_retention,
+       t30_retention,
+       t1_retention_ratio,
+       t7_retention_ratio,
+       t15_retention_ratio,
+       t30_retention_ratio,
+       reservation_success,
+       reservation_cost/100,
+       standard_live_played_started,
+       live_audience_cost/100,
+       live_event_goods_view,
+       goods_click_ratio,
+       direct_attr_plat_new_buyer_cnt,
+       t30_attr_plat_total_buyer_cnt,
+       direct_attr_seller_new_buyer_cnt,
+       t30_attr_seller_total_buyer_cnt,
+       fans_t0_gmv/100,
+       fans_t1_gmv/100,
+       fans_t7_gmv/100,
+       fans_t15_gmv/100,
+       fans_t30_gmv/100,
+       fans_t0_roi,
+       fans_t1_roi,
+       fans_t7_roi,
+       fans_t15_roi,
+       fans_t30_roi,
+       report_date,
+       `hour`
+from kuaishou_live.kuaishou_live_account_report_hourly report
+         left join
+     (select acc.account_id,
+             account_name,
+             project_id,
+             project_name,
+             ks_id,
+             ks_name,
+             sale_leader_id,
+             sale.user_name     as sale_leader,
+             operator_leader_id,
+             user.user_name     as operator_leader,
+             designer_leader_id,
+             designer.user_name as designer_leader,
+             enterprise_name,
+             collaborator_id,
+             collaborator
+      from ruixuan.kuaishou_live_user_account acc
+               left join
+           ruixuan.kuaishou_live_project pro
+           on acc.project_id = pro.id
+               left join ruixuan.sys_user sale
+                         on acc.sale_leader_id = sale.user_id
+               left join ruixuan.sys_user user
+                         on acc.operator_leader_id = user.user_id
+               left join ruixuan.sys_user designer
+                         on acc.designer_leader_id = designer.user_id
+               left join(
+          select account_id,
+                 group_concat(collaborator_id) as collaborator_id,
+                 group_concat(collaborator)    as collaborator
+          from ruixuan.kuaishou_live_user_account_part
+          group by account_id
+      ) collaborator
+                        on acc.account_id = collaborator.account_id) acc_info
+     on report.account_id = acc_info.account_id
+where report.report_date={stat_date} and report.account_id={account_id};
+                """.format(stat_date=self.stat_date, account_id=account_id[0])
+                print(sql)
+                TidbConn.upsert(conn=self.conn, sql_buff=sql)
+                self.conn.commit()
+            TidbConn.conn_close(conn=self.conn)
+            return 0
+        except Exception as e:
+            logging.error(e)
+            return -1
+
+
+if __name__ == '__main__':
+    status = LiveAccountHourlyReport().handler()
+    if status == 0:
+        print("作业执行成功")
+        exit(0)
+    else:
+        print("作业执行失败")
+        exit(-1)

+ 186 - 0
Apietl/ruixuan/report/LiveCampaignDailyReport.py

@@ -0,0 +1,186 @@
+# Author renyupeng
+# coding=utf-8
+# @Time    : 2022/7/27 2:49 下午
+# @Site    : 
+# @File    : LiveCampaignDailyReport.py
+# @Software: PyCharm
+# @contact: renyupeng@c-top.com.cn
+# @Tel 1501435553
+import logging
+
+from Apietl.conn.TidbConn import TidbConn
+from Apietl.utlis.Utils import Utils
+
+
+class LiveCampaignDailyReport:
+    def __init__(self):
+        self.conn = TidbConn.get_connection()
+        self.parm = Utils.get_live_args()
+        self.stat_date = self.parm
+
+    def handler(self):
+        try:
+            sql = """select account_id from kuaishou_live.kuaishou_live_campaign_report_daily where report_date={stat_date}
+group by account_id""".format(stat_date=self.stat_date)
+            account_list = TidbConn.quary(self.conn, sql)
+            for account_id in account_list:
+                sql = """
+                replace into ruixuan.kuaishou_live_campaign_report_daily_dw
+select report.account_id,
+       account_name,
+       campaign_id,
+campaign_name,
+campaign_type_str,
+       project_id,
+       project_name,
+       ks_id,
+       ks_name,
+       sale_leader_id,
+       sale_leader,
+       operator_leader_id,
+       operator_leader,
+       designer_leader_id,
+       designer_leader,
+       enterprise_name,
+       collaborator_id,
+       collaborator,
+       cost_total/100,
+       ad_show,
+       ad_show1k_cost/100,
+       impression,
+       photo_click,
+       photo_click_ratio,
+       click,
+       actionbar_click,
+       actionbar_click_cost/100,
+       esp_click_ratio,
+       action_ratio,
+       ad_item_click_count,
+       esp_live_played_seconds,
+       played_three_seconds,
+       play3s_ratio,
+       played_five_seconds,
+       play5s_ratio,
+       played_end,
+       play_end_ratio,
+       share,
+       comment,
+       likes,
+       report,
+       block,
+       item_negative,
+       live_share,
+       live_comment,
+       live_reward,
+       effective_play_count,
+       effective_play_ratio,
+       ad_live_played1m_num,
+       conversion_num,
+       conversion_cost_esp/100,
+       gmv/100,
+       t0_gmv/100,
+       t1_gmv/100,
+       t7_gmv/100,
+       t15_gmv/100,
+       t30_gmv,
+       roi,
+       t0_roi,
+       t1_roi,
+       t7_roi,
+       t15_roi,
+       t30_roi,
+       paied_order,
+       order_ratio,
+       t0_order_cnt,
+       t0_order_cnt_cost/100,
+       t0_order_cnt_ratio,
+       t1_order_cnt,
+       t7_order_cnt,
+       t15_order_cnt,
+       t30_order_cnt,
+       merchant_reco_fans,
+       t1_retention,
+       t7_retention,
+       t15_retention,
+       t30_retention,
+       t1_retention_ratio,
+       t7_retention_ratio,
+       t15_retention_ratio,
+       t30_retention_ratio,
+       reservation_success,
+       reservation_cost/100,
+       standard_live_played_started,
+       live_audience_cost/100,
+       live_event_goods_view,
+       goods_click_ratio,
+       direct_attr_plat_new_buyer_cnt,
+       t30_attr_plat_total_buyer_cnt,
+       direct_attr_seller_new_buyer_cnt,
+       t30_attr_seller_total_buyer_cnt,
+       fans_t0_gmv/100,
+       fans_t1_gmv/100,
+       fans_t7_gmv/100,
+       fans_t15_gmv/100,
+       fans_t30_gmv/100,
+       fans_t0_roi,
+       fans_t1_roi,
+       fans_t7_roi,
+       fans_t15_roi,
+       fans_t30_roi,
+       report_date
+from kuaishou_live.kuaishou_live_campaign_report_daily report
+         left join
+     (select acc.account_id,
+             account_name,
+             project_id,
+             project_name,
+             ks_id,
+             ks_name,
+             sale_leader_id,
+             sale.user_name     as sale_leader,
+             operator_leader_id,
+             user.user_name     as operator_leader,
+             designer_leader_id,
+             designer.user_name as designer_leader,
+             enterprise_name,
+             collaborator_id,
+             collaborator
+      from ruixuan.kuaishou_live_user_account acc
+               left join
+           ruixuan.kuaishou_live_project pro
+           on acc.project_id = pro.id
+               left join ruixuan.sys_user sale
+                         on acc.sale_leader_id = sale.user_id
+               left join ruixuan.sys_user user
+                         on acc.operator_leader_id = user.user_id
+               left join ruixuan.sys_user designer
+                         on acc.designer_leader_id = designer.user_id
+               left join(
+          select account_id,
+                 group_concat(collaborator_id) as collaborator_id,
+                 group_concat(collaborator)    as collaborator
+          from ruixuan.kuaishou_live_user_account_part
+          group by account_id
+      ) collaborator
+                        on acc.account_id = collaborator.account_id) acc_info
+     on report.account_id = acc_info.account_id
+where report.report_date={stat_date} and report.account_id={account_id};
+                """.format(stat_date=self.stat_date, account_id=account_id[0])
+                print(sql)
+                TidbConn.upsert(conn=self.conn, sql_buff=sql)
+                self.conn.commit()
+            TidbConn.conn_close(conn=self.conn)
+            return 0
+        except Exception as e:
+            logging.error(e)
+            return -1
+
+
+if __name__ == '__main__':
+    status = LiveCampaignDailyReport().handler()
+    if status == 0:
+        print("作业执行成功")
+        exit(0)
+    else:
+        print("作业执行失败")
+        exit(-1)

+ 187 - 0
Apietl/ruixuan/report/LiveCampaignHourlyReport.py

@@ -0,0 +1,187 @@
+# Author renyupeng
+# coding=utf-8
+# @Time    : 2022/7/27 2:49 下午
+# @Site    :
+# @File    : LiveCampaignHourlyReport.py
+# @Software: PyCharm
+# @contact: renyupeng@c-top.com.cn
+# @Tel 1501435553
+import logging
+
+from Apietl.conn.TidbConn import TidbConn
+from Apietl.utlis.Utils import Utils
+
+
+class LiveCampaignHourlyReport:
+    def __init__(self):
+        self.conn = TidbConn.get_connection()
+        self.parm = Utils.get_live_args()
+        self.stat_date = self.parm
+
+    def handler(self):
+        try:
+            sql = """select account_id from kuaishou_live.kuaishou_live_campaign_report_hourly where report_date={stat_date}
+group by account_id""".format(stat_date=self.stat_date)
+            account_list = TidbConn.quary(self.conn, sql)
+            for account_id in account_list:
+                sql = """
+                replace into ruixuan.kuaishou_live_campaign_report_hourly_dw
+select report.account_id,
+       account_name,
+       campaign_id,
+campaign_name,
+campaign_type_str,
+       project_id,
+       project_name,
+       ks_id,
+       ks_name,
+       sale_leader_id,
+       sale_leader,
+       operator_leader_id,
+       operator_leader,
+       designer_leader_id,
+       designer_leader,
+       enterprise_name,
+       collaborator_id,
+       collaborator,
+       cost_total/100,
+       ad_show,
+       ad_show1k_cost/100,
+       impression,
+       photo_click,
+       photo_click_ratio,
+       click,
+       actionbar_click,
+       actionbar_click_cost/100,
+       esp_click_ratio,
+       action_ratio,
+       ad_item_click_count,
+       esp_live_played_seconds,
+       played_three_seconds,
+       play3s_ratio,
+       played_five_seconds,
+       play5s_ratio,
+       played_end,
+       play_end_ratio,
+       share,
+       comment,
+       likes,
+       report,
+       block,
+       item_negative,
+       live_share,
+       live_comment,
+       live_reward,
+       effective_play_count,
+       effective_play_ratio,
+       ad_live_played1m_num,
+       conversion_num,
+       conversion_cost_esp/100,
+       gmv/100,
+       t0_gmv/100,
+       t1_gmv/100,
+       t7_gmv/100,
+       t15_gmv/100,
+       t30_gmv,
+       roi,
+       t0_roi,
+       t1_roi,
+       t7_roi,
+       t15_roi,
+       t30_roi,
+       paied_order,
+       order_ratio,
+       t0_order_cnt,
+       t0_order_cnt_cost/100,
+       t0_order_cnt_ratio,
+       t1_order_cnt,
+       t7_order_cnt,
+       t15_order_cnt,
+       t30_order_cnt,
+       merchant_reco_fans,
+       t1_retention,
+       t7_retention,
+       t15_retention,
+       t30_retention,
+       t1_retention_ratio,
+       t7_retention_ratio,
+       t15_retention_ratio,
+       t30_retention_ratio,
+       reservation_success,
+       reservation_cost/100,
+       standard_live_played_started,
+       live_audience_cost/100,
+       live_event_goods_view,
+       goods_click_ratio,
+       direct_attr_plat_new_buyer_cnt,
+       t30_attr_plat_total_buyer_cnt,
+       direct_attr_seller_new_buyer_cnt,
+       t30_attr_seller_total_buyer_cnt,
+       fans_t0_gmv/100,
+       fans_t1_gmv/100,
+       fans_t7_gmv/100,
+       fans_t15_gmv/100,
+       fans_t30_gmv/100,
+       fans_t0_roi,
+       fans_t1_roi,
+       fans_t7_roi,
+       fans_t15_roi,
+       fans_t30_roi,
+       report_date,
+       `hour`
+from kuaishou_live.kuaishou_live_campaign_report_hourly report
+         left join
+     (select acc.account_id,
+             account_name,
+             project_id,
+             project_name,
+             ks_id,
+             ks_name,
+             sale_leader_id,
+             sale.user_name     as sale_leader,
+             operator_leader_id,
+             user.user_name     as operator_leader,
+             designer_leader_id,
+             designer.user_name as designer_leader,
+             enterprise_name,
+             collaborator_id,
+             collaborator
+      from ruixuan.kuaishou_live_user_account acc
+               left join
+           ruixuan.kuaishou_live_project pro
+           on acc.project_id = pro.id
+               left join ruixuan.sys_user sale
+                         on acc.sale_leader_id = sale.user_id
+               left join ruixuan.sys_user user
+                         on acc.operator_leader_id = user.user_id
+               left join ruixuan.sys_user designer
+                         on acc.designer_leader_id = designer.user_id
+               left join(
+          select account_id,
+                 group_concat(collaborator_id) as collaborator_id,
+                 group_concat(collaborator)    as collaborator
+          from ruixuan.kuaishou_live_user_account_part
+          group by account_id
+      ) collaborator
+                        on acc.account_id = collaborator.account_id) acc_info
+     on report.account_id = acc_info.account_id
+where report.report_date={stat_date} and report.account_id={account_id};
+                """.format(stat_date=self.stat_date, account_id=account_id[0])
+                print(sql)
+                TidbConn.upsert(conn=self.conn, sql_buff=sql)
+                self.conn.commit()
+            TidbConn.conn_close(conn=self.conn)
+            return 0
+        except Exception as e:
+            logging.error(e)
+            return -1
+
+
+if __name__ == '__main__':
+    status = LiveCampaignHourlyReport().handler()
+    if status == 0:
+        print("作业执行成功")
+        exit(0)
+    else:
+        print("作业执行失败")
+        exit(-1)

+ 191 - 0
Apietl/ruixuan/report/LiveUnitDailyReport.py

@@ -0,0 +1,191 @@
+# Author renyupeng
+# coding=utf-8
+# @Time    : 2022/7/27 2:49 下午
+# @Site    :
+# @File    : LiveUnitDailyReport.py
+# @Software: PyCharm
+# @contact: renyupeng@c-top.com.cn
+# @Tel 1501435553
+import logging
+
+from Apietl.conn.TidbConn import TidbConn
+from Apietl.utlis.Utils import Utils
+
+
+class LiveUnitDailyReport:
+    def __init__(self):
+        self.conn = TidbConn.get_connection()
+        self.parm = Utils.get_live_args()
+        self.stat_date = self.parm
+
+    def handler(self):
+        try:
+            sql = """select account_id from kuaishou_live.kuaishou_live_unit_report_daily where report_date={stat_date}
+group by account_id""".format(stat_date=self.stat_date)
+            account_list = TidbConn.quary(self.conn, sql)
+            for account_id in account_list:
+                sql = """
+                replace into ruixuan.kuaishou_live_unit_report_daily_dw
+select report.account_id,
+       account_name,
+campaign_id,
+campaign_name,
+unit_id,
+unit_name,
+ocpc_action_type_str,
+speed_type_str,
+creative_build_type_str,
+campaign_type_str,
+       project_id,
+       project_name,
+       ks_id,
+       ks_name,
+       sale_leader_id,
+       sale_leader,
+       operator_leader_id,
+       operator_leader,
+       designer_leader_id,
+       designer_leader,
+       enterprise_name,
+       collaborator_id,
+       collaborator,
+       cost_total/100,
+       ad_show,
+       ad_show1k_cost/100,
+       impression,
+       photo_click,
+       photo_click_ratio,
+       click,
+       actionbar_click,
+       actionbar_click_cost/100,
+       esp_click_ratio,
+       action_ratio,
+       ad_item_click_count,
+       esp_live_played_seconds,
+       played_three_seconds,
+       play3s_ratio,
+       played_five_seconds,
+       play5s_ratio,
+       played_end,
+       play_end_ratio,
+       share,
+       comment,
+       likes,
+       report,
+       block,
+       item_negative,
+       live_share,
+       live_comment,
+       live_reward,
+       effective_play_count,
+       effective_play_ratio,
+       ad_live_played1m_num,
+       conversion_num,
+       conversion_cost_esp/100,
+       gmv/100,
+       t0_gmv/100,
+       t1_gmv/100,
+       t7_gmv/100,
+       t15_gmv/100,
+       t30_gmv,
+       roi,
+       t0_roi,
+       t1_roi,
+       t7_roi,
+       t15_roi,
+       t30_roi,
+       paied_order,
+       order_ratio,
+       t0_order_cnt,
+       t0_order_cnt_cost/100,
+       t0_order_cnt_ratio,
+       t1_order_cnt,
+       t7_order_cnt,
+       t15_order_cnt,
+       t30_order_cnt,
+       merchant_reco_fans,
+       t1_retention,
+       t7_retention,
+       t15_retention,
+       t30_retention,
+       t1_retention_ratio,
+       t7_retention_ratio,
+       t15_retention_ratio,
+       t30_retention_ratio,
+       reservation_success,
+       reservation_cost/100,
+       standard_live_played_started,
+       live_audience_cost/100,
+       live_event_goods_view,
+       goods_click_ratio,
+       direct_attr_plat_new_buyer_cnt,
+       t30_attr_plat_total_buyer_cnt,
+       direct_attr_seller_new_buyer_cnt,
+       t30_attr_seller_total_buyer_cnt,
+       fans_t0_gmv/100,
+       fans_t1_gmv/100,
+       fans_t7_gmv/100,
+       fans_t15_gmv/100,
+       fans_t30_gmv/100,
+       fans_t0_roi,
+       fans_t1_roi,
+       fans_t7_roi,
+       fans_t15_roi,
+       fans_t30_roi,
+       report_date
+from kuaishou_live.kuaishou_live_unit_report_daily report
+         left join
+     (select acc.account_id,
+             account_name,
+             project_id,
+             project_name,
+             ks_id,
+             ks_name,
+             sale_leader_id,
+             sale.user_name     as sale_leader,
+             operator_leader_id,
+             user.user_name     as operator_leader,
+             designer_leader_id,
+             designer.user_name as designer_leader,
+             enterprise_name,
+             collaborator_id,
+             collaborator
+      from ruixuan.kuaishou_live_user_account acc
+               left join
+           ruixuan.kuaishou_live_project pro
+           on acc.project_id = pro.id
+               left join ruixuan.sys_user sale
+                         on acc.sale_leader_id = sale.user_id
+               left join ruixuan.sys_user user
+                         on acc.operator_leader_id = user.user_id
+               left join ruixuan.sys_user designer
+                         on acc.designer_leader_id = designer.user_id
+               left join(
+          select account_id,
+                 group_concat(collaborator_id) as collaborator_id,
+                 group_concat(collaborator)    as collaborator
+          from ruixuan.kuaishou_live_user_account_part
+          group by account_id
+      ) collaborator
+                        on acc.account_id = collaborator.account_id) acc_info
+     on report.account_id = acc_info.account_id
+where report.report_date={stat_date} and report.account_id={account_id};
+                """.format(stat_date=self.stat_date, account_id=account_id[0])
+                print(sql)
+                TidbConn.upsert(conn=self.conn, sql_buff=sql)
+                self.conn.commit()
+            TidbConn.conn_close(conn=self.conn)
+            return 0
+        except Exception as e:
+            logging.error(e)
+            return -1
+
+
+if __name__ == '__main__':
+    status = LiveUnitDailyReport().handler()
+    if status == 0:
+        print("作业执行成功")
+        exit(0)
+    else:
+        print("作业执行失败")
+        exit(-1)

+ 192 - 0
Apietl/ruixuan/report/LiveUnitHourlyReport.py

@@ -0,0 +1,192 @@
+# Author renyupeng
+# coding=utf-8
+# @Time    : 2022/7/27 2:49 下午
+# @Site    :
+# @File    : LiveUnitHourlyReport.py
+# @Software: PyCharm
+# @contact: renyupeng@c-top.com.cn
+# @Tel 1501435553
+import logging
+
+from Apietl.conn.TidbConn import TidbConn
+from Apietl.utlis.Utils import Utils
+
+
+class LiveUnitHourlyReport:
+    def __init__(self):
+        self.conn = TidbConn.get_connection()
+        self.parm = Utils.get_live_args()
+        self.stat_date = self.parm
+
+    def handler(self):
+        try:
+            sql = """select account_id from kuaishou_live.kuaishou_live_unit_report_hourly where report_date={stat_date}
+group by account_id""".format(stat_date=self.stat_date)
+            account_list = TidbConn.quary(self.conn, sql)
+            for account_id in account_list:
+                sql = """
+                replace into ruixuan.kuaishou_live_unit_report_hourly_dw
+select report.account_id,
+       account_name,
+campaign_id,
+campaign_name,
+unit_id,
+unit_name,
+ocpc_action_type_str,
+speed_type_str,
+creative_build_type_str,
+campaign_type_str,
+       project_id,
+       project_name,
+       ks_id,
+       ks_name,
+       sale_leader_id,
+       sale_leader,
+       operator_leader_id,
+       operator_leader,
+       designer_leader_id,
+       designer_leader,
+       enterprise_name,
+       collaborator_id,
+       collaborator,
+       cost_total/100,
+       ad_show,
+       ad_show1k_cost/100,
+       impression,
+       photo_click,
+       photo_click_ratio,
+       click,
+       actionbar_click,
+       actionbar_click_cost/100,
+       esp_click_ratio,
+       action_ratio,
+       ad_item_click_count,
+       esp_live_played_seconds,
+       played_three_seconds,
+       play3s_ratio,
+       played_five_seconds,
+       play5s_ratio,
+       played_end,
+       play_end_ratio,
+       share,
+       comment,
+       likes,
+       report,
+       block,
+       item_negative,
+       live_share,
+       live_comment,
+       live_reward,
+       effective_play_count,
+       effective_play_ratio,
+       ad_live_played1m_num,
+       conversion_num,
+       conversion_cost_esp/100,
+       gmv/100,
+       t0_gmv/100,
+       t1_gmv/100,
+       t7_gmv/100,
+       t15_gmv/100,
+       t30_gmv,
+       roi,
+       t0_roi,
+       t1_roi,
+       t7_roi,
+       t15_roi,
+       t30_roi,
+       paied_order,
+       order_ratio,
+       t0_order_cnt,
+       t0_order_cnt_cost/100,
+       t0_order_cnt_ratio,
+       t1_order_cnt,
+       t7_order_cnt,
+       t15_order_cnt,
+       t30_order_cnt,
+       merchant_reco_fans,
+       t1_retention,
+       t7_retention,
+       t15_retention,
+       t30_retention,
+       t1_retention_ratio,
+       t7_retention_ratio,
+       t15_retention_ratio,
+       t30_retention_ratio,
+       reservation_success,
+       reservation_cost/100,
+       standard_live_played_started,
+       live_audience_cost/100,
+       live_event_goods_view,
+       goods_click_ratio,
+       direct_attr_plat_new_buyer_cnt,
+       t30_attr_plat_total_buyer_cnt,
+       direct_attr_seller_new_buyer_cnt,
+       t30_attr_seller_total_buyer_cnt,
+       fans_t0_gmv/100,
+       fans_t1_gmv/100,
+       fans_t7_gmv/100,
+       fans_t15_gmv/100,
+       fans_t30_gmv/100,
+       fans_t0_roi,
+       fans_t1_roi,
+       fans_t7_roi,
+       fans_t15_roi,
+       fans_t30_roi,
+       report_date,
+       `hour`
+from kuaishou_live.kuaishou_live_unit_report_hourly report
+         left join
+     (select acc.account_id,
+             account_name,
+             project_id,
+             project_name,
+             ks_id,
+             ks_name,
+             sale_leader_id,
+             sale.user_name     as sale_leader,
+             operator_leader_id,
+             user.user_name     as operator_leader,
+             designer_leader_id,
+             designer.user_name as designer_leader,
+             enterprise_name,
+             collaborator_id,
+             collaborator
+      from ruixuan.kuaishou_live_user_account acc
+               left join
+           ruixuan.kuaishou_live_project pro
+           on acc.project_id = pro.id
+               left join ruixuan.sys_user sale
+                         on acc.sale_leader_id = sale.user_id
+               left join ruixuan.sys_user user
+                         on acc.operator_leader_id = user.user_id
+               left join ruixuan.sys_user designer
+                         on acc.designer_leader_id = designer.user_id
+               left join(
+          select account_id,
+                 group_concat(collaborator_id) as collaborator_id,
+                 group_concat(collaborator)    as collaborator
+          from ruixuan.kuaishou_live_user_account_part
+          group by account_id
+      ) collaborator
+                        on acc.account_id = collaborator.account_id) acc_info
+     on report.account_id = acc_info.account_id
+where report.report_date={stat_date} and report.account_id={account_id};
+                """.format(stat_date=self.stat_date, account_id=account_id[0])
+                print(sql)
+                TidbConn.upsert(conn=self.conn, sql_buff=sql)
+                self.conn.commit()
+            TidbConn.conn_close(conn=self.conn)
+            return 0
+        except Exception as e:
+            logging.error(e)
+            return -1
+
+
+if __name__ == '__main__':
+    status = LiveUnitHourlyReport().handler()
+    if status == 0:
+        print("作业执行成功")
+        exit(0)
+    else:
+        print("作业执行失败")
+        exit(-1)

+ 59 - 0
Apietl/task/AppBytedanceMaterialProjectRalation.py

@@ -0,0 +1,59 @@
+# Author renyupeng
+# coding=utf-8
+# @Time    : 2022/8/4 2:35 下午
+# @Site    : 
+# @File    : AppBytedanceMaterialProjectRalation.py
+# @Software: PyCharm
+# @contact: renyupeng@c-top.com.cn
+# @Tel 1501435553
+import logging
+
+from Apietl.conn.TidbConn import TidbConn
+
+
+class AppBytedanceMaterialProjectRalation:
+    def __init__(self):
+        self.conn = TidbConn.get_connection()
+
+    def handler(self):
+        try:
+            sql = """select advertiser_id from media_api.bytedance_file_video_get 
+            where create_time>=date_format(date_sub(now(),interval 3 day),'%Y-%m-%d')
+            group by advertiser_id"""
+            account_list = TidbConn.quary(self.conn, sql)
+            for account_id in account_list:
+                try:
+                    sql = """
+replace into application.bytedance_project_material_relation
+select project_id, signature
+from (select advertiser_id, signature
+      from media_api.bytedance_file_video_get where  advertiser_id ={account_id} 
+      and create_time>=date_format(date_sub(now(),interval 3 day),'%Y-%m-%d')
+      and signature is not null
+      group by advertiser_id, signature) a
+         left join
+     (select account_id, project_id from `jeecg-boot`.ctop_user_allocation where media_id != 2) b
+     on a.advertiser_id = b.account_id
+group by project_id, signature
+
+                    """.format(account_id=account_id[0])
+                    print(sql)
+                    TidbConn.upsert(conn=self.conn, sql_buff=sql)
+                    self.conn.commit()
+                except Exception as e:
+                    logging.error(e)
+                    return -1
+        except Exception as e:
+            logging.error(e)
+            return -1
+
+
+if __name__ == '__main__':
+    status = AppBytedanceMaterialProjectRalation().handler()
+
+    if status == 0:
+        print("作业执行成功")
+        exit(0)
+    else:
+        print("作业执行失败")
+        exit(-1)

+ 59 - 0
Apietl/task/AppKuaishouMaterialProjectRelation.py

@@ -0,0 +1,59 @@
+# Author renyupeng
+# coding=utf-8
+# @Time    : 2022/8/4 2:35 下午
+# @Site    : 
+# @File    : AppKuaishouMaterialProjectRelation.py
+# @Software: PyCharm
+# @contact: renyupeng@c-top.com.cn
+# @Tel 1501435553
+import logging
+
+from Apietl.conn.TidbConn import TidbConn
+
+
+class AppKuaishouMaterialProjectRelation:
+    def __init__(self):
+        self.conn = TidbConn.get_connection()
+
+    def handler(self):
+        try:
+            sql = """select account_id from media_api.kuaishou_video_list 
+                  and stat_date>=date_format(date_sub(now(),interval 3 day),'%Y-%m-%d')
+            group by account_id"""
+            account_list = TidbConn.quary(self.conn, sql)
+            for account_id in account_list:
+                try:
+                    sql = """
+                    replace into application.kuaishou_project_material_relation
+select project_id, signature
+from (select account_id, signature
+      from media_api.kuaishou_video_list where  account_id ={account_id} 
+      and stat_date>=date_format(date_sub(now(),interval 3 day),'%Y-%m-%d')
+      and signature is not null
+      group by account_id, signature) a
+         left join
+     (select account_id, project_id from `jeecg-boot`.ctop_user_allocation where media_id = 2) b
+     on a.account_id = b.account_id
+group by project_id, signature
+
+                    """.format(account_id=account_id[0])
+                    print(sql)
+                    TidbConn.upsert(conn=self.conn, sql_buff=sql)
+                    self.conn.commit()
+                except Exception as e:
+                    logging.error(e)
+                    return -1
+        except Exception as e:
+            logging.error(e)
+            return -1
+
+
+if __name__ == '__main__':
+    status = AppKuaishouMaterialProjectRelation().handler()
+
+    if status == 0:
+        print("作业执行成功")
+        exit(0)
+    else:
+        print("作业执行失败")
+        exit(-1)

+ 8 - 0
Apietl/utlis/Utils.py

@@ -38,6 +38,14 @@ class Utils:
         return date_time, day_count
 
     @staticmethod
+    def get_live_args():
+        parser = argparse.ArgumentParser(description='')
+        parser.add_argument('-date_time', type=str, default=None, help="TX_DT")
+        args = parser.parse_args()
+        date_time = args.date_time
+        return date_time
+
+    @staticmethod
     def get_month_range(start_date=None):
         if start_date is None:
             start_date = date.today().replace(day=1)

+ 77 - 0
OuterDataCompareInnerData/MonitorRuixian/MonitorAppTask.py

@@ -0,0 +1,77 @@
+# Author renyupeng
+# coding=utf-8
+# @Time    : 2021/11/17 6:48 下午
+# @Site    : 
+# @File    : MonitorRuixuanTask.py
+# @Software: PyCharm
+# @contact: renyupeng@c-top.com.cn
+# @Tel 1501435553
+import datetime
+import logging
+import os
+from Apietl.conn.TidbConn import TidbConn
+from Apietl.conn.TidbProConn import TidbProConn
+from OuterDataCompareInnerData.Utils.SchedulerList import SchedulerList
+from OuterDataCompareInnerData.Utils.sendMessage import feishuMsg
+
+
+class MonitorRuixuanTask:
+    def __init__(self):
+        self.InnerConn = TidbConn.get_connection()
+        self.OuterConn = TidbProConn.get_connection()
+        self.table_list = [
+            'kuaishou_live_account_report_daily_dw'
+            , 'kuaishou_live_campaign_report_daily_dw'
+            , 'kuaishou_live_unit_report_daily_dw'
+        ]
+        self.stat_date = (datetime.date.today() + datetime.timedelta(-1)).strftime("%Y%m%d")
+
+    def CheckTask(self):
+        try:
+            for table in self.table_list:
+                try:
+                        sql = """select count(1) from `application`.{table} where stat_date={stat_date}""".format(
+                            table=table, stat_date=self.stat_date)
+                        InnertotalNum = TidbConn.quary(self.InnerConn, sql)[0][0]
+                        OutertotalNum = TidbConn.quary(self.OuterConn, sql)[0][0]
+                        print("""{stat_date}日 {table} 内网数量为{InnertotalNum},外网数量为{OutertotalNum}""".format(
+                            stat_date=self.stat_date,
+                            table=table,
+                            InnertotalNum=InnertotalNum,
+                            OutertotalNum=OutertotalNum))
+                        if InnertotalNum == 0:
+                            feishuMsg.send_robot_msg(
+                                """{stat_date}日 {table} 数据为0""".format(stat_date=self.stat_date, table=table))
+                        elif InnertotalNum != OutertotalNum:
+                            feishuMsg.send_robot_msg(
+                                """{stat_date}日 {table} 内网数量为{InnertotalNum},外网数量为{OutertotalNum} 数据不相等 datax
+                                 数据同步启动""".format(
+                                    stat_date=self.stat_date,
+                                    table=table,
+                                    InnertotalNum=InnertotalNum,
+                                    OutertotalNum=OutertotalNum))
+
+                            datax_json = SchedulerList.LiveSchedulerList(table)
+                            os.system('sh /data/datax/application/push_live_pro.sh {stat_date} {table} {datax_json}'.format(
+                                stat_date=self.stat_date, table=table, datax_json=datax_json))
+                        else:
+                            feishuMsg.send_robot_msg(
+                                """{stat_date}日 {table} 内网数量为{InnertotalNum},外网数量为{OutertotalNum} 数据相等 """.format(
+                                    stat_date=self.stat_date,
+                                    table=table,
+                                    InnertotalNum=InnertotalNum,
+                                    OutertotalNum=OutertotalNum))
+
+                except Exception as e:
+                    logging.error(e)
+                    return -1
+            TidbConn.conn_close(conn=self.InnerConn)
+            TidbProConn.conn_close(conn=self.OuterConn)
+
+        except Exception as e:
+            logging.error(e)
+            return -1
+
+
+if __name__ == '__main__':
+    MonitorRuixuanTask().CheckTask()

+ 16 - 0
OuterDataCompareInnerData/Utils/SchedulerList.py

@@ -21,6 +21,12 @@ class SchedulerList:
                                "kuaishou_campaign_report_daily_dw": "campaign",
                                "kuaishou_material_video_report_daily_dw": "video",
                                "kuaishou_unit_report_daily_dw": "unit"}
+
+        self.Live_Scheduler_List = {
+
+                               "kuaishou_live_account_report_daily_dw": "ruixuan",
+                               "kuaishou_live_campaign_report_daily_dw": "ruixuan",
+                               "kuaishou_live_unit_report_daily_dw": "ruixuan"}
     @classmethod
     def SchedulerList(cls, table):
         try:
@@ -28,3 +34,13 @@ class SchedulerList:
         except KeyError:
             return None
 
+
+    @classmethod
+    def LiveSchedulerList(cls, table):
+        try:
+            return SchedulerList().Live_Scheduler_List[table]
+        except KeyError:
+            return None
+
+
+