renyupeng 3 years ago
parent
commit
f12b71df2b
1 changed files with 8 additions and 7 deletions
  1. 8 7
      Apietl/bytedance_etl/Q4Task/AppBytedanceAdReportBusi.py

+ 8 - 7
Apietl/bytedance_etl/Q4Task/AppBytedanceAdReportBusi.py

@@ -21,10 +21,10 @@ class AppBytedanceAdReportBusi:
 
     def taskHandler(self):
         try:
-            sql_porject = """select project_id from `jeecg-boot`.ctop_user_allocation where media_id=1
-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=1
+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_bytedance_ad_report_busi_{day_count}d 
@@ -538,7 +538,7 @@ group by project_id """
                        stat_datetime >= 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,
@@ -570,9 +570,10 @@ group by project_id """
                      LEFT JOIN `jeecg-boot`.ctop_product product ON product.id = cp.product_id
                      WHERE
                       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()