|
@@ -18,7 +18,7 @@ from sqlalchemy import create_engine
|
|
|
class send_material_report_month:
|
|
|
def __init__(self):
|
|
|
self.OuterStr = "mysql+pymysql://%s:%s@%s:%d/%s" % (
|
|
|
- "hcst", parse.quote_plus("hcst@2021"), "192.168.0.184", 3390, "application")
|
|
|
+ "hcst", parse.quote_plus("hcst@2024"), "192.168.0.101", 3390, "application")
|
|
|
self.OuterConn = create_engine(self.OuterStr,
|
|
|
pool_size=10,
|
|
|
max_overflow=5,
|
|
@@ -28,49 +28,65 @@ class send_material_report_month:
|
|
|
|
|
|
def handler(self):
|
|
|
sql = """select (CASE
|
|
|
- WHEN a.clip_company_id = 'd57fecdcf7a94d009736d9c850731582' THEN '北京汇创思拓数字科技有限公司'
|
|
|
- WHEN a.clip_company_id = '6608ed13c0dd42de93c790dbdf124234' THEN
|
|
|
-'广州汇创思拓数字科技有限公司'
|
|
|
-WHEN a.clip_company_id = '4b10089775c040119e139087517aed88' THEN
|
|
|
-'上海汇创思拓数字科技有限公司'
|
|
|
-WHEN a.clip_company_id = '5e46b5dea3d740eeb8ff1a2895015a4b' THEN
|
|
|
-'北京骄阳数字科技有限公司'
|
|
|
-WHEN a.clip_company_id = '1648c7ceb4d449a9a13fbed7a8d9976c' THEN
|
|
|
-'杭州妙构思数字科技有限公司'
|
|
|
-WHEN a.clip_company_id = '3321d5893bcd430cab1238a99bc7db11' THEN
|
|
|
-'北京次元像素'
|
|
|
-else '-'
|
|
|
-END) as '公司',
|
|
|
- a.project_name AS '项目',
|
|
|
- a.account_id AS '账户',
|
|
|
- a.signature AS '素材标识',
|
|
|
- b.media_time AS '上线时间',
|
|
|
- a.channel_name '渠道',
|
|
|
- a.charge AS '消耗',
|
|
|
- a.user_name AS '运营',
|
|
|
- a.clip_name AS '剪辑',
|
|
|
- a.shot_name AS '拍摄',
|
|
|
- a.plan_name AS '编导',
|
|
|
- a.leader_name AS '负责人',
|
|
|
- a.video_name AS '素材名称',
|
|
|
- a.photo_url AS '链接'
|
|
|
-from
|
|
|
-(select clip_company_id,project_name,account_id,signature,channel_name,sum(charge)charge,clip_name,shot_name,plan_name,a.leader_name,video_name,photo_url,b.realname user_name from
|
|
|
-application.app_kuaishou_video_report_busi_m a
|
|
|
-left join `jeecg-boot`.sys_user b
|
|
|
-on a.user_id=b.id
|
|
|
-where stat_mon=202202
|
|
|
-group by account_id,signature) a
|
|
|
-left join
|
|
|
-application.app_kuaishou_material_info b
|
|
|
-on a.signature=b.material_id; """.format(stat_date=self.stat_date)
|
|
|
+ WHEN a.clip_company_id = 'd57fecdcf7a94d009736d9c850731582' THEN
|
|
|
+ '北京汇创思拓数字科技有限公司'
|
|
|
+ WHEN a.clip_company_id = '6608ed13c0dd42de93c790dbdf124234' THEN
|
|
|
+ '广州汇创思拓数字科技有限公司'
|
|
|
+ WHEN a.clip_company_id = '4b10089775c040119e139087517aed88' THEN
|
|
|
+ '上海汇创思拓数字科技有限公司'
|
|
|
+ WHEN a.clip_company_id = '5e46b5dea3d740eeb8ff1a2895015a4b' THEN
|
|
|
+ '北京骄阳数字科技有限公司'
|
|
|
+ WHEN a.clip_company_id = '1648c7ceb4d449a9a13fbed7a8d9976c' THEN
|
|
|
+ '杭州妙构思数字科技有限公司'
|
|
|
+ WHEN a.clip_company_id = '3321d5893bcd430cab1238a99bc7db11' THEN
|
|
|
+ '北京次元像素'
|
|
|
+ WHEN a.clip_company_id = 'ace886fa51a244818e918b5d6d1bcc62' then
|
|
|
+ '北京聚意创量文化传媒有限公司'
|
|
|
+ when a.clip_company_id = '3f362f527a804e8a9db6552ea12f7574'
|
|
|
+ then '石家庄汇创思拓数字科技有限公司'
|
|
|
+ else '-'
|
|
|
+ END) as '公司',
|
|
|
+ a.project_name AS '项目',
|
|
|
+ account_id as `账户ID`,
|
|
|
+ a.signature AS '素材标识',
|
|
|
+ b.frast_cost_time AS '上线时间',
|
|
|
+ '-' 渠道,
|
|
|
+ a.charge AS '消耗',
|
|
|
+ trim(a.clip_name) AS '剪辑',
|
|
|
+ trim(a.shot_name) AS '拍摄',
|
|
|
+ trim(a.plan_name) AS '编导',
|
|
|
+ trim(a.leader_name) AS '负责人',
|
|
|
+ shot_leader_name as `拍摄负责人`,
|
|
|
+ a.video_name AS '素材名称',
|
|
|
+ a.photo_url AS '链接'
|
|
|
+from (select clip_company_id,
|
|
|
+ account_id,
|
|
|
+ shot_leader_name,
|
|
|
+ company_name,
|
|
|
+ project_name,
|
|
|
+ signature,
|
|
|
+ channel_name,
|
|
|
+ sum(charge) charge,
|
|
|
+ clip_name,
|
|
|
+ shot_name,
|
|
|
+ plan_name,
|
|
|
+ a.leader_name,
|
|
|
+ video_name,
|
|
|
+ photo_url
|
|
|
+ from application.kuaishou_material_video_report_daily_dw a
|
|
|
+ where stat_date >= 20231001
|
|
|
+ and stat_date <= 20231031
|
|
|
+ group by account_id,signature) a
|
|
|
+ left join
|
|
|
+ application.material_farst_cost_time b
|
|
|
+ on a.signature = b.signature """.format(stat_date=self.stat_date)
|
|
|
print(sql)
|
|
|
path = """/data/excel/send_material_report_month.xls""".format(stat_date=self.stat_date)
|
|
|
print(path)
|
|
|
pd.read_sql(sql, self.OuterConn).to_excel(path, index=False, engine='openpyxl')
|
|
|
my_sender = 'renyupeng@c-top.com.cn' # 发件人邮箱账号
|
|
|
my_pass = 'fcyJKkHUyPo6Zztw' # 发件人邮箱授权码 / 腾讯企业邮箱请使用登陆密码
|
|
|
- recipients = ['niuxiaoyu@c-top.com.cn','dukexuan@c-top.com.cn'] # 收件人邮箱账号
|
|
|
+ recipients = ['niuxiaoyu@c-top.com.cn'] # 收件人邮箱账号
|
|
|
# content = "Please check the attachment. "
|
|
|
msg = MIMEMultipart()
|
|
|
# [发件人的邮箱昵称、发件人邮箱账号], 昵称随便
|