renyupeng 3 anni fa
parent
commit
2234e2d592

+ 8 - 0
Apietl/task/__init__.py

@@ -0,0 +1,8 @@
+# Author renyupeng
+# coding=utf-8
+# @Time    : 2021/10/25 2:07 下午
+# @Site    : 
+# @File    : __init__.py.py
+# @Software: PyCharm
+# @contact: renyupeng@c-top.com.cn
+# @Tel 1501435553

+ 8 - 0
Apietl/test/__init__.py

@@ -0,0 +1,8 @@
+# Author renyupeng
+# coding=utf-8
+# @Time    : 2021/10/12 10:29 上午
+# @Site    : 
+# @File    : __init__.py.py
+# @Software: PyCharm
+# @contact: renyupeng@c-top.com.cn
+# @Tel 1501435553

+ 19 - 20
monitor/ApplicationCDCMonitor.py

@@ -29,7 +29,7 @@ class ApplicationCDCMonitor:
         repo = requests.get(url='http://{}:{}{}?'.format(self.cdc_url, self.cdc_port, self.cdc_changefeeds_url),
                             headers=headers)
         message = repo.json()
-        print(message)
+        # print(message)
         for json in message:
             task_id = json['id']
             tso = json['checkpoint_tso']
@@ -45,25 +45,24 @@ class ApplicationCDCMonitor:
                 backResult = requests.get(
                     url='http://{}:{}{}/{}'.format(self.cdc_url, self.cdc_port, self.cdc_changefeeds_url, task_id),
                     headers=headers)
-                print(backResult, '--------1111-------')
-                # if backResult is None:
-                #     os.system(
-                #         'cd /data/tidb-deploy/cdc-8300/bin; ./cdc cli changefeed create --pd=http://192.168.0.184:2379 '
-                #         '--sink-uri="mysql://data:hcst@2021@139.186.27.96:3390" --config ../conf/{task_id}.toml '
-                #         '--changefeed-id={task_id} '.format(task_id=task_id))
-                # else:
-                #     result = backResult.json()
-                #     print(result)
-                #     if result['error'] is not None:
-                #         requests.delete(url='http://{}:{}{}/{}'.format(self.cdc_url, self.cdc_port,
-                #                                                        self.cdc_changefeeds_url, task_id))
-                #         os.system(
-                #             'cd /data/tidb-deploy/cdc-8300/bin; ./cdc cli changefeed create '
-                #             '--pd=http://192.168.0.184:2379 '
-                #             '--sink-uri="mysql://data:hcst@2021@139.186.27.96:3390" --config ../conf/{task_id}.toml '
-                #             '--changefeed-id={task_id} '.format(task_id=task_id))
-                #     else:
-                #         logging.info('新创建没有问题')
+                backResult = backResult.json
+                if backResult is None:
+                    os.system(
+                        'cd /data/tidb-deploy/cdc-8300/bin; ./cdc cli changefeed create --pd=http://192.168.0.184:2379 '
+                        '--sink-uri="mysql://data:hcst@2021@139.186.27.96:3390" --config ../conf/{task_id}.toml '
+                        '--changefeed-id={task_id} '.format(task_id=task_id))
+                else:
+                    print(backResult, '--------2-------')
+                    if backResult['error'] is not None:
+                        requests.delete(url='http://{}:{}{}/{}'.format(self.cdc_url, self.cdc_port,
+                                                                       self.cdc_changefeeds_url, task_id))
+                        os.system(
+                            'cd /data/tidb-deploy/cdc-8300/bin; ./cdc cli changefeed create '
+                            '--pd=http://192.168.0.184:2379 '
+                            '--sink-uri="mysql://data:hcst@2021@139.186.27.96:3390" --config ../conf/{task_id}.toml '
+                            '--changefeed-id={task_id} '.format(task_id=task_id))
+                    else:
+                        logging.info('新创建没有问题')
             else:
                 logging.info("无异常")
 

+ 8 - 0
monitor/__init__.py

@@ -0,0 +1,8 @@
+# Author renyupeng
+# coding=utf-8
+# @Time    : 2021/10/20 3:38 下午
+# @Site    : 
+# @File    : __init__.py.py
+# @Software: PyCharm
+# @contact: renyupeng@c-top.com.cn
+# @Tel 1501435553

+ 101 - 0
sql/1001296.sql

@@ -0,0 +1,101 @@
+create table `jeecg-boot`.ctop_material_top_cost
+(
+    account_id    bigint(20),
+    md5           varchar(100),
+    photo_id      bigint(20),
+    material_name varchar(255),
+    7day_cost     decimal(19, 3),
+    primary key (account_id, md5, photo_id)
+) partition by hash ( account_id )
+    partitions 8;
+
+create table `jeecg-boot`.ctop_history_material_catch
+(
+    account_id    bigint(20),
+    md5           varchar(100),
+    photo_id      bigint(20),
+    material_name varchar(255),
+    sum_cost      decimal(19, 3),
+    creative_num int(10),
+    primary key (account_id, md5, photo_id)
+) partition by hash ( account_id )
+    partitions 8;
+
+
+truncate table `jeecg-boot`.ctop_material_top_cost;
+insert into `jeecg-boot`.ctop_material_top_cost(account_id, md5, photo_id, material_name,7day_cost )
+select a.account_id,signature,a.photo_id,c.photo_name,a.charge from
+(select a.* from
+(select account_id,signature,photo_id,sum(charge) as charge
+from `application`.kuaishou_material_video_report_daily_dw where
+stat_date >=date_format(date_sub(${stat_date}, INTERVAL 60 Day), '%Y%m%d')
+group by account_id, signature, photo_id)a
+inner join(
+select account_id from `jeecg-boot`.ctop_ai_kuaishou_advertiser_strategy
+)b
+on a.account_id=b.account_id)a
+left join
+(select account_id,photo_id,photo_name,channel_type,material_type from `jeecg-boot`.ctop_kuaishou_video_get )c
+on a.account_id=c.account_id and a.photo_id=c.photo_id;
+
+
+truncate table `jeecg-boot`.ctop_history_material_catch;
+insert into `jeecg-boot`.ctop_history_material_catch(account_id, md5, photo_id, material_name, sum_cost,creative_num)
+select account_id,signature,photo_id,photo_name,charge,c from (
+select account_id, photo_id, signature,photo_name, charge, count(1) as c
+from (
+         select q.account_id, q.photo_id, q.signature, q.charge, creative_id,q.photo_name
+         from (select m.account_id,
+                      m.photo_id,
+                      m.signature,
+                      m.charge,
+                      m.photo_name
+               from (select t.*, s.charge
+                     from (
+                              select account_id, signature, photo_name, photo_id
+                              from `jeecg-boot`.ctop_kuaishou_video_get
+                              where stat_date >= date_sub(date_format(${stat_date},'%Y-%m-%d'), INTERVAL 60 Day)
+                          ) t
+                              inner join
+                          (
+                              select account_id, photo_id, signature, sum(charge) as charge
+                              from `application`.kuaishou_material_video_report_daily_dw
+                              where stat_date >=
+                                    date_format(date_sub(${stat_date}, INTERVAL 60 Day), '%Y%m%d')
+                              group by account_id, photo_id, signature) s
+                          on t.account_id = s.account_id and t.photo_id = s.photo_id) m
+               where
+                 m.charge < 500
+               limit 100) q
+                  left join
+              (
+                  select account_id, creative_id, photo_id
+                  from `jeecg-boot`.ctop_kuaishou_creative
+                  where
+                     creative_create_time >= date_sub(date_format(${stat_date},'%Y-%m-%d'), INTERVAL 60 Day)
+                    and photo_id != 0
+              ) w
+              on q.account_id = w.account_id and q.photo_id = w.photo_id
+     ) t
+group by account_id, photo_id, signature, charge,photo_name
+order by  c desc )t
+where t.c<20 ;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 175 - 0
sql/郭浩临时需求.sql

@@ -0,0 +1,175 @@
+select date_format(current_date, '%Y-%m-%d')                                             `日期`,
+       company_name                                                                      `公司名称`,
+       project_name                                                                      `项目名称`,
+       ks_id                                                                             `快手id`,
+       cr.account_id                                                                     `账户id`,
+       material_name                                                                     `素材名称`,
+       code                                                                              `素材唯一编码`,
+       realname                                                                          `运营人员`,
+       clip_name                                                                         `设计人员`,
+       case when hc_status = 0 then '待审核' when hc_status = 1 then '审核通过' else '审核拒绝' end `汇创后台素材审核状态`,
+       case when photo_id is null then '未推送' else '推送' end                               `素材推送状态`,
+       concat('`', photo_id, '`')                                                        `视频id`,
+       creative_create_time                                                              `素材首次关联创意时间`,
+       creative_num                                                                      `素材关联创意数`,
+       error_num                                                                         `审核拒绝创意数`
+from (select q.*,
+             case when q.creative_create_time is null then 0 else s.creative_count end as creative_num,
+             case when q.creative_create_time is null then 0 else w.creative_count end as error_num
+      from (
+               select code,
+                      material_name,
+                      a.status                    as hc_status,
+                      a.create_time               as hc_create_time,
+                      clip_id,
+                      a.account_id,
+                      a.photo_id,
+                      min(b.creative_create_time) as creative_create_time
+               from (select a.*, b.clip_id, c.account_id, photo_id, c.stat_date as media_video_time
+                     from (select code, material_name, status, create_time
+                           from `jeecg-boot`.ctop_material_info
+                           where create_time > date_sub('2021-10-12', INTERVAL 6 Day)) a
+                              left join(
+                         select material_id, clip_id
+                         from `jeecg-boot`.ctop_material_ascription
+                     ) b
+                                       on a.code = b.material_id
+                              left join(
+                         select account_id, signature, photo_id, stat_date
+                         from ctop_kuaishou_video_get
+                         where stat_date >= date_sub('2021-10-12', INTERVAL 6 Day)
+                     ) c
+                                       on a.code = c.signature) a
+                        left join
+                    (select account_id, creative_id, photo_id, status, creative_create_time
+                     from `jeecg-boot`.ctop_kuaishou_creative
+                     where creative_create_time >= date_sub('2021-10-12', INTERVAL 6 Day)) b
+                    on a.account_id = b.account_id and a.photo_id = b.photo_id
+               group by a.status, material_name, code, a.create_time, clip_id, a.account_id, a.photo_id) q
+               left join
+           (
+               select code,
+                      account_id,
+                      case when account_id is null then 0 else c end as creative_count
+               from (
+                        select code,
+                               account_id,
+                               count(1) as c
+                        from (
+                                 select code,
+                                        material_name,
+                                        a.status               as hc_status,
+                                        a.create_time          as hc_create_time,
+                                        clip_id,
+                                        a.account_id,
+                                        a.photo_id,
+                                        b.creative_id,
+                                        b.status               as creative_status,
+                                        b.creative_create_time as creative_create_time
+                                 from (select a.*, b.clip_id, c.account_id, photo_id, c.stat_date as media_video_time
+                                       from (select code, material_name, status, create_time
+                                             from `jeecg-boot`.ctop_material_info
+                                             where create_time >
+                                                   date_sub('2021-10-12', INTERVAL 6 Day)) a
+                                                left join(
+                                           select material_id, clip_id
+                                           from `jeecg-boot`.ctop_material_ascription
+                                       ) b
+                                                         on a.code = b.material_id
+                                                left join(
+                                           select account_id, signature, photo_id, stat_date
+                                           from ctop_kuaishou_video_get
+                                           where stat_date >= date_sub('2021-10-12', INTERVAL 6 Day)
+                                       ) c
+                                                         on a.code = c.signature) a
+                                          left join
+                                      (select account_id, creative_id, photo_id, status, creative_create_time
+                                       from `jeecg-boot`.ctop_kuaishou_creative
+                                       where creative_create_time >= date_sub('2021-10-12', INTERVAL 6 Day)) b
+                                      on a.account_id = b.account_id and a.photo_id = b.photo_id) t
+                        group by account_id, material_name, hc_status, hc_create_time, clip_id, code, photo_id) t
+           ) s
+           on q.account_id = s.account_id and q.code = s.code
+               left join(
+          select code,
+                 account_id,
+                 case when account_id is null then 0 else c end as creative_count
+          from (
+                   select code,
+                          account_id,
+                          material_name,
+                          hc_status,
+                          hc_create_time,
+                          clip_id,
+                          photo_id,
+                          case when creative_id is null then 0 else  count(1) end as c
+                   from (
+                            select code,
+                                   material_name,
+                                   a.status               as hc_status,
+                                   a.create_time          as hc_create_time,
+                                   clip_id,
+                                   a.account_id,
+                                   a.photo_id,
+                                   b.creative_id,
+                                   b.status               as creative_status,
+                                   b.creative_create_time as creative_create_time
+                            from (select a.*, b.clip_id, c.account_id, photo_id, c.stat_date as media_video_time
+                                  from (select code, material_name, status, create_time
+                                        from `jeecg-boot`.ctop_material_info
+                                        where create_time > date_sub('2021-10-12', INTERVAL 6 Day)) a
+                                           left join(
+                                      select material_id, clip_id
+                                      from `jeecg-boot`.ctop_material_ascription
+                                  ) b
+                                                    on a.code = b.material_id
+                                           left join(
+                                      select account_id, signature, photo_id, stat_date
+                                      from ctop_kuaishou_video_get
+                                      where stat_date >= date_sub('2021-10-12', INTERVAL 6 Day)
+                                  ) c
+                                                    on a.code = c.signature) a
+                                     left join
+                                 (select account_id, creative_id, photo_id, status, creative_create_time
+                                  from `jeecg-boot`.ctop_kuaishou_creative
+                                  where status = 42
+                                    and creative_create_time >= date_sub('2021-10-12', INTERVAL 6 Day)) b
+                                 on a.account_id = b.account_id and a.photo_id = b.photo_id) t
+                   group by account_id, code, material_name,
+                            hc_status,
+                            hc_create_time,
+                            clip_id,
+                            photo_id) t
+      ) w
+                        on q.account_id = w.account_id and q.code = w.code) cr
+         left join
+     (
+         select a.account_id, a.project_name, su.realname, c.user_id as ks_id
+         from (select account_id, user_id, user_name, project_name from ctop_user_allocation) a
+                  left join
+                  (select account_id, user_id from ctop_kuaishou_advertiser_base_info) c
+                  on a.account_id = c.account_id
+                  left join sys_user su on su.id = a.user_id
+     ) user
+     on cr.account_id = user.account_id
+         left join (
+    select id, realname as clip_name
+    from sys_user
+) clip
+                   on cr.clip_id = clip.id
+         left join
+         (select user_id, company_name from user_company) com
+         on cr.clip_id = com.user_id
+
+
+
+
+
+
+
+
+
+
+
+
+