|
@@ -18,43 +18,42 @@ from sqlalchemy import create_engine
|
|
|
class send_material_report_weekly:
|
|
|
def __init__(self):
|
|
|
self.OuterStr = "mysql+pymysql://%s:%s@%s:%d/%s" % (
|
|
|
- "data", parse.quote_plus("hcst@2021"), "139.186.27.96", 3390, "jeecg-boot")
|
|
|
+ "hcst", parse.quote_plus("hcst@2021"), "192.168.0.184", 3390, "application")
|
|
|
self.OuterConn = create_engine(self.OuterStr,
|
|
|
pool_size=10,
|
|
|
max_overflow=5,
|
|
|
pool_timeout=10,
|
|
|
pool_recycle=3600)
|
|
|
- self.stat_date = (datetime.date.today() + datetime.timedelta(-1)).strftime("%Y-%m-%d")
|
|
|
+ self.stat_date = (datetime.date.today() + datetime.timedelta(-1)).strftime("%Y%m%d")
|
|
|
|
|
|
def handler(self):
|
|
|
- sql = """SELECT
|
|
|
- ifnull(t2.company_name,'0') AS '公司',
|
|
|
- ifnull(t3.project_name,'-') AS '项目',
|
|
|
- ifnull(t2.video_code,'-') AS '素材标识',
|
|
|
- ifnull(t2.state_date,'-') AS '上线时间',
|
|
|
- ifnull(t2.channel_name,'-') AS '渠道',
|
|
|
+ sql = """select ifnull(t3.company_name,'-') AS '公司',
|
|
|
+ ifnull(t1.project_name,'-') AS '项目',
|
|
|
+ ifnull(t1.signature,'-') AS '素材标识',
|
|
|
+ ifnull(t3.media_time,'-') AS '上线时间',
|
|
|
+ ifnull(t1.channel_name,'-') AS '渠道',
|
|
|
round(sum(t1.charge),3) AS '消耗',
|
|
|
- ifnull(t2.clip_name,'-') AS '剪辑',
|
|
|
- ifnull(t2.shot_name,'-') AS '拍摄',
|
|
|
- ifnull(t2.plan_name,'-') AS '编导',
|
|
|
- ifnull(t2.design_team_leader_name,'-') AS '负责人',
|
|
|
- ifnull(t2.video_name,'-') AS '素材名称',
|
|
|
- ifnull(t2.url,'-') AS '链接'
|
|
|
-FROM
|
|
|
-`jeecg-boot`.ctop_etl_kuaishou_account_material_report_daily t1
|
|
|
-LEFT JOIN `jeecg-boot`.ctop_etl_kuaishou_video_info t2 ON t1.signature = t2.video_code
|
|
|
-LEFT JOIN `jeecg-boot`.ctop_project t3
|
|
|
-on t1.project_id=t3.id
|
|
|
+ ifnull(t1.clip_name,'-') AS '剪辑',
|
|
|
+ ifnull(t1.shot_name,'-') AS '拍摄',
|
|
|
+ ifnull(t1.plan_name,'-') AS '编导',
|
|
|
+ ifnull(t1.leader_name,'-') AS '负责人',
|
|
|
+ case when t3.material_innovate=1 then '非创新素材'
|
|
|
+ when t3.material_innovate=2 then '创新素材'
|
|
|
+ else '其它' end AS '是否创新素材',
|
|
|
+ ifnull(t1.video_name,'-') AS '素材名称',
|
|
|
+ ifnull(t1.photo_url,'-') AS '链接'
|
|
|
+from application.kuaishou_material_video_report_daily_dw t1
|
|
|
+left join (select material_id,media_time,company_name,material_innovate from application.app_kuaishou_material_info) t3
|
|
|
+on t1.signature=t3.material_id
|
|
|
where t1.stat_date between date_sub('{stat_date}', INTERVAL 6 DAY) and '{stat_date}'
|
|
|
-GROUP BY
|
|
|
-t1.signature; """.format(stat_date=self.stat_date)
|
|
|
+group by t1.signature; """.format(stat_date=self.stat_date)
|
|
|
print(sql)
|
|
|
path = """/data/excel/material_week_{stat_date}.xls""".format(stat_date=self.stat_date)
|
|
|
print(path)
|
|
|
pd.read_sql(sql, self.OuterConn).to_excel(path, index=False, engine='openpyxl')
|
|
|
my_sender = 'zhaohailiang@c-top.com.cn' # 发件人邮箱账号
|
|
|
my_pass = 'h27UwLdJcD797THk' # 发件人邮箱授权码 / 腾讯企业邮箱请使用登陆密码
|
|
|
- recipients = ['wanglei@c-top.com.cn','niuxiaoyu@c-top.com.cn','dukexuan@c-top.com.cn','yangyan@c-top.com.cn',''] # 收件人邮箱账号
|
|
|
+ recipients = ['renyupeng@c-top.com.cn'] # 收件人邮箱账号
|
|
|
# content = "Please check the attachment. "
|
|
|
msg = MIMEMultipart()
|
|
|
# [发件人的邮箱昵称、发件人邮箱账号], 昵称随便
|