renyupeng пре 3 година
родитељ
комит
4b39599fc0

+ 10 - 8
Apietl/kwai_etl/Q4Task/AppKuaishouUnitReportBusi.py

@@ -21,10 +21,10 @@ class AppKuaishouUnitReportBusi:
 
     def taskHandler(self):
         try:
-            sql_porject = """select project_id from `jeecg-boot`.ctop_user_allocation where media_id=2
-group by project_id """
-            project_list = TidbConn.quary(self.conn, sql_porject)
-            for project_id in project_list:
+            sql_porject = """select account_id from `jeecg-boot`.ctop_user_allocation where media_id=2
+group by account_id """
+            account_list = TidbConn.quary(self.conn, sql_porject)
+            for account_id in account_list:
                 try:
                     sql = """SET sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
 REPLACE INTO application.app_kuaishou_unit_report_busi_{day_count}d 
@@ -305,7 +305,9 @@ round(sum(ad_photo_played_2s_ratio)/{day_count}*100,3) ad_photo_played_2s_ratio,
 round(sum(event_outbound_call_ratio)/sum(activation)*100,3) event_outbound_call_ratio,
 sum(event_ad_watch_times) event_ad_watch_times
 from 
- media_api.kuaishou_unit_report_daily  a  where stat_date >= date_format(date_sub({date_time}, INTERVAL ({day_count} -1 )  DAY),'%Y%m%d')
+ media_api.kuaishou_unit_report_daily  a 
+where stat_date >= date_format(date_sub({date_time}, INTERVAL ({day_count} -1 )  DAY),'%Y%m%d')
+and advertiser_id={account_id}
  group by advertiser_id,campaign_id,campaign_name,unit_id,unit_name) report
 LEFT JOIN (
 SELECT
@@ -331,10 +333,10 @@ LEFT JOIN `jeecg-boot`.sys_user su ON su.id = cua.user_id
 LEFT JOIN `jeecg-boot`.user_company uc ON uc.user_id = cua.user_id
 LEFT JOIN `jeecg-boot`.ctop_product product ON product.id = cp.product_id
 WHERE
-cua.account_id IS NOT NULL) bei 
+cua.account_id IS NOT NULL
+and cua.account_id ={account_id}) bei 
 ON report.account_id = bei.account_id
-where bei.project_id={project_id}
-;""".format(date_time=self.date_time, day_count=self.day_count, project_id=project_id[0])
+;""".format(date_time=self.date_time, day_count=self.day_count, account_id=account_id[0])
                     print(sql)
                     TidbConn.upsert(conn=self.conn, sql_buff=sql)
                     self.conn.commit()

+ 8 - 7
Apietl/kwai_etl/Q4Task/AppKuaishouUnitReportBusiMonth.py

@@ -21,10 +21,10 @@ class AppKuaishouUnitReportBusiMonth:
 
     def taskHandler(self):
         try:
-            sql_porject = """select project_id from `jeecg-boot`.ctop_user_allocation where media_id=2
-group by project_id """
-            project_list = TidbConn.quary(self.conn, sql_porject)
-            for project_id in project_list:
+            sql_porject = """select account_id from `jeecg-boot`.ctop_user_allocation where media_id=2
+group by account_id """
+            account_list = TidbConn.quary(self.conn, sql_porject)
+            for account_id in account_list:
                 try:
                     sql = """SET sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
 REPLACE INTO application.app_kuaishou_unit_report_busi_m
@@ -307,6 +307,7 @@ sum(event_ad_watch_times) event_ad_watch_times
 from 
  media_api.kuaishou_unit_report_daily  a 
 where stat_date >= date_format(date_sub({date_time}, INTERVAL {day_count}  DAY),'%Y%m%d')
+and advertiser_id={account_id}
  group by advertiser_id,campaign_id,campaign_name,unit_id,unit_name) report
 LEFT JOIN (
 SELECT
@@ -332,10 +333,10 @@ LEFT JOIN `jeecg-boot`.sys_user su ON su.id = cua.user_id
 LEFT JOIN `jeecg-boot`.user_company uc ON uc.user_id = cua.user_id
 LEFT JOIN `jeecg-boot`.ctop_product product ON product.id = cp.product_id
 WHERE
-cua.account_id IS NOT NULL) bei 
+cua.account_id IS NOT NULL
+and cua.account_id ={account_id}) bei 
 ON report.account_id = bei.account_id
-where bei.project_id={project_id}
-;""".format(date_time=self.date_time, day_count=self.day_count, project_id=project_id[0])
+;""".format(date_time=self.date_time, day_count=self.day_count, account_id=account_id[0])
                     print(sql)
                     TidbConn.upsert(conn=self.conn, sql_buff=sql)
                     self.conn.commit()

+ 9 - 7
Apietl/kwai_etl/Q4Task/AppKuaishouVideoReportBusi.py

@@ -21,10 +21,10 @@ class AppKuaishouVideoReportBusi:
 
     def taskHandler(self):
         try:
-            sql_porject = """select project_id from `jeecg-boot`.ctop_user_allocation where media_id=2
-group by project_id """
-            project_list = TidbConn.quary(self.conn, sql_porject)
-            for project_id in project_list:
+            sql_porject = """select account_id from `jeecg-boot`.ctop_user_allocation where media_id=2
+group by account_id """
+            account_list = TidbConn.quary(self.conn, sql_porject)
+            for account_id in account_list:
                 try:
                     sql = """SET sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
 REPLACE INTO application.app_kuaishou_video_report_busi_{day_count}d 
@@ -319,7 +319,9 @@ sum(event_measurement_house) event_measurement_house,
 round(sum(ad_photo_played_2s_ratio)/{day_count}*100,3) ad_photo_played_2s_ratio,
 round(sum(event_outbound_call_ratio)/sum(activation)*100,3) event_outbound_call_ratio,
 sum(event_ad_watch_times) event_ad_watch_times
-from  media_api.kuaishou_material_video_report_daily where stat_date >= date_format(date_sub({date_time}, INTERVAL ({day_count} -1 )  DAY),'%Y%m%d')
+from  media_api.kuaishou_material_video_report_daily 
+where stat_date >= date_format(date_sub({date_time}, INTERVAL ({day_count} -1 )  DAY),'%Y%m%d')
+and advertiser_id={account_id}
 group by 
 advertiser_id,
 photo_id,
@@ -345,8 +347,8 @@ LEFT JOIN `jeecg-boot`.sys_user shot ON shot.id = cma.shot_id
 LEFT JOIN `jeecg-boot`.sys_user plan ON plan.id = cma.plan_id
 LEFT JOIN `jeecg-boot`.sys_user leader ON leader.id = cma.leader_id
 LEFT JOIN `jeecg-boot`.user_company up ON up.user_id = cma.clip_id
-where cua.project_id={project_id}
-;""".format(date_time=self.date_time, day_count=self.day_count, project_id=project_id[0])
+where cua.account_id={account_id}
+;""".format(date_time=self.date_time, day_count=self.day_count, account_id=account_id[0])
                     print(sql)
                     TidbConn.upsert(conn=self.conn, sql_buff=sql)
                     self.conn.commit()

+ 7 - 6
Apietl/kwai_etl/Q4Task/AppKuaishouVideoReportBusiMonth.py

@@ -21,10 +21,10 @@ class AppKuaishouVideoReportBusiMonth:
 
     def taskHandler(self):
         try:
-            sql_porject = """select project_id from `jeecg-boot`.ctop_user_allocation where media_id=2
-group by project_id """
-            project_list = TidbConn.quary(self.conn, sql_porject)
-            for project_id in project_list:
+            sql_porject = """select account_id from `jeecg-boot`.ctop_user_allocation where media_id=2
+group by account_id """
+            account_list = TidbConn.quary(self.conn, sql_porject)
+            for account_id in account_list:
                 try:
                     sql = """SET sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
 REPLACE INTO application.app_kuaishou_video_report_busi_m
@@ -321,6 +321,7 @@ round(sum(event_outbound_call_ratio)/sum(activation)*100,3) event_outbound_call_
 sum(event_ad_watch_times) event_ad_watch_times
 from  media_api.kuaishou_material_video_report_daily 
 where stat_date >= date_format(date_sub({date_time}, INTERVAL {day_count} DAY),'%Y%m%d')
+and advertiser_id={account_id}
 group by 
 advertiser_id,
 photo_id,
@@ -346,8 +347,8 @@ LEFT JOIN `jeecg-boot`.sys_user shot ON shot.id = cma.shot_id
 LEFT JOIN `jeecg-boot`.sys_user plan ON plan.id = cma.plan_id
 LEFT JOIN `jeecg-boot`.sys_user leader ON leader.id = cma.leader_id
 LEFT JOIN `jeecg-boot`.user_company up ON up.user_id = cma.clip_id
-where cua.project_id={project_id}
-;""".format(date_time=self.date_time, day_count=self.day_count, project_id=project_id[0])
+where cua.account_id={account_id}
+;""".format(date_time=self.date_time, day_count=self.day_count, account_id=account_id[0])
                     print(sql)
                     TidbConn.upsert(conn=self.conn, sql_buff=sql)
                     self.conn.commit()