AppBytedanceVideoReportBusiMonth.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. # Author renyupeng
  2. # coding=utf-8
  3. # @Time : 2021/11/10 3:37 下午
  4. # @Site :
  5. # @File : AppBytedanceVideoReportBusiMonth.py
  6. # @Software: PyCharm
  7. # @contact: renyupeng@c-top.com.cn
  8. # @Tel 1501435553
  9. import logging
  10. from Apietl.conn.TidbConn import TidbConn
  11. from Apietl.utlis.Utils import Utils
  12. class AppBytedanceVideoReportBusiMonth:
  13. def __init__(self):
  14. self.conn = TidbConn.get_connection()
  15. self.parm = Utils.get_task_args()
  16. self.date_time = self.parm[0]
  17. self.day_count = Utils.get_days()
  18. def taskHandler(self):
  19. try:
  20. sql_porject = """select advertiser_id from media_api.bytedance_material_report_daily zhubiao
  21. WHERE image_mode IN (
  22. 'CREATIVE_IMAGE_MODE_VIDEO',
  23. 'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL',
  24. 'CREATIVE_IMAGE_MODE_UNION_SPLASH_VIDEO'
  25. )
  26. AND stat_datetime >= date_format(
  27. date_sub({date_time}, INTERVAL {day_count} DAY),
  28. '%Y%m%d'
  29. )
  30. group by advertiser_id """.format(date_time=self.date_time, day_count=self.day_count)
  31. account_list = TidbConn.quary(self.conn, sql_porject)
  32. for account_id in account_list:
  33. try:
  34. sql = """SET sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
  35. REPLACE INTO application.app_bytedance_video_report_busi_m
  36. SELECT date_format({date_time},'%Y%m') stat_mon,
  37. report.account_id,
  38. #'账户ID'
  39. report.material_id,
  40. #头条素材id
  41. report.image_mode,
  42. #素材类型
  43. report.inventory,
  44. #广告位
  45. cua.project_id,
  46. #项目id
  47. product.id product_id,
  48. #项目中产品id
  49. cua.advertiser_id,
  50. #广告主id
  51. uc.company_id,
  52. #运营人的公司id
  53. cua.auth_name account_name,
  54. #账户名称
  55. cp.project_name,
  56. #项目名称
  57. ca.`name` advertiser_name,
  58. #广告主名称
  59. uc.company_name,
  60. #运营人的公司名称
  61. cp.sale_id,
  62. #项目里的销售id
  63. cua.user_id,
  64. #运营id
  65. cma.clip_id,
  66. #剪辑id
  67. cma.shot_id,
  68. #拍摄id
  69. cma.plan_id,
  70. #编导id
  71. cma.leader_id,
  72. #负责人id
  73. su.org_code,
  74. #机构编码
  75. video.signature,
  76. #素材id
  77. NULL chl_type,
  78. #渠道类型
  79. clip.realname clip_name,
  80. #剪辑名称
  81. shot.realname shot_name,
  82. #拍摄名称
  83. plan.realname plan_name,
  84. #编导名称
  85. leader.realname lead_name,
  86. #负责人名称
  87. CASE
  88. WHEN cmi.material_name IS NOT NULL THEN
  89. cmi.material_name
  90. ELSE
  91. video.filename
  92. END AS video_name,
  93. ##视频名称
  94. NULL chl_name,
  95. #渠道名称
  96. up.company_id clip_company_id,
  97. #剪辑公司
  98. report.cost,
  99. report.`show`,
  100. report.avg_show_cost,
  101. report.click,
  102. report.avg_click_cost,
  103. report.ctr,
  104. report.`convert`,
  105. report.convert_cost,
  106. report.convert_rate,
  107. report.deep_convert,
  108. report.deep_convert_cost,
  109. report.deep_convert_rate,
  110. report.attribution_convert,
  111. report.attribution_convert_cost,
  112. report.attribution_deep_convert,
  113. report.attribution_deep_convert_cost,
  114. report.download_start,
  115. report.download_start_cost,
  116. report.download_start_rate,
  117. report.download_finish,
  118. report.download_finish_cost,
  119. report.download_finish_rate,
  120. report.click_install,
  121. report.install_finish,
  122. report.install_finish_cost,
  123. report.install_finish_rate,
  124. report.active,
  125. report.active_cost,
  126. report.active_rate,
  127. report.register,
  128. report.active_register_cost,
  129. report.active_register_rate,
  130. report.active_pay_amount,
  131. report.next_day_open,
  132. report.next_day_open_cost,
  133. report.next_day_open_rate,
  134. report.attribution_next_day_open_cnt,
  135. report.attribution_next_day_open_cost,
  136. report.attribution_next_day_open_rate,
  137. report.game_addiction,
  138. report.game_addiction_cost,
  139. report.game_addiction_rate,
  140. report.pay_count,
  141. report.active_pay_cost,
  142. report.active_pay_rate,
  143. report.loan_completion,
  144. report.loan_completion_cost,
  145. report.loan_completion_rate,
  146. report.pre_loan_credit,
  147. report.pre_loan_credit_cost,
  148. report.loan_credit,
  149. report.loan_credit_cost,
  150. report.loan_credit_rate,
  151. report.in_app_uv,
  152. report.in_app_detail_uv,
  153. report.in_app_cart,
  154. report.in_app_pay,
  155. report.in_app_order,
  156. report.attribution_game_pay_7d_count,
  157. report.attribution_game_pay_7d_cost,
  158. report.attribution_active_pay_7d_per_count,
  159. report.game_pay_cost,
  160. report.game_pay_count,
  161. report.phone,
  162. report.form,
  163. report.map_search,
  164. report.button,
  165. report.`view`,
  166. report.download,
  167. report.qq,
  168. report.lottery,
  169. report.vote,
  170. report.message,
  171. report.redirect,
  172. report.shopping,
  173. report.consult,
  174. report.wechat,
  175. report.phone_confirm,
  176. report.phone_connect,
  177. report.consult_effective,
  178. report.coupon,
  179. report.coupon_single_page,
  180. report.redirect_to_shop,
  181. report.poi_collect,
  182. report.poi_address_click,
  183. report.luban_order_cnt,
  184. report.luban_order_stat_amount,
  185. report.luban_order_roi,
  186. report.luban_live_enter_cnt,
  187. report.live_watch_one_minute_count,
  188. report.luban_live_follow_cnt,
  189. report.live_fans_club_join_cnt,
  190. report.luban_live_comment_cnt,
  191. report.luban_live_share_cnt,
  192. report.luban_live_gift_cnt,
  193. report.luban_live_gift_amount,
  194. report.luban_live_slidecart_click_cnt,
  195. report.luban_live_click_product_cnt,
  196. report.luban_live_pay_order_count,
  197. report.luban_live_pay_order_stat_cost,
  198. report.wechat_login_count,
  199. report.attribution_wechat_login_30d_count,
  200. report.wechat_login_cost,
  201. report.attribution_wechat_login_30d_cost,
  202. report.wechat_first_pay_count,
  203. report.attribution_wechat_first_pay_30d_count,
  204. report.wechat_first_pay_cost,
  205. report.attribution_wechat_first_pay_30d_cost,
  206. report.wechat_first_pay_rate,
  207. report.attribution_wechat_first_pay_30d_rate,
  208. report.wechat_pay_amount,
  209. report.attribution_wechat_pay_30d_amount,
  210. report.attribution_wechat_pay_30d_roi,
  211. report.phone_effective,
  212. report.total_play,
  213. report.valid_play,
  214. report.valid_play_cost,
  215. report.valid_play_rate,
  216. report.play_25_feed_break,
  217. report.play_50_feed_break,
  218. report.play_75_feed_break,
  219. report.play_100_feed_break,
  220. report.average_play_time_per_play,
  221. report.play_over_rate,
  222. report.wifi_play_rate,
  223. report.wifi_play,
  224. report.play_duration_sum,
  225. report.advanced_creative_phone_click,
  226. report.advanced_creative_counsel_click,
  227. report.advanced_creative_form_click,
  228. report.advanced_creative_coupon_addition,
  229. report.advanced_creative_form_submit,
  230. report.card_show,
  231. report.`share`,
  232. report.`comment`,
  233. report.`like`,
  234. report.follow,
  235. report.home_visited,
  236. report.ies_challenge_click,
  237. report.ies_music_click,
  238. report.location_click,
  239. report.message_action,
  240. report.click_landing_page,
  241. report.click_shopwindow,
  242. report.click_website,
  243. report.click_download,
  244. report.click_call_dy,
  245. report.`cpc`,
  246. report.`cpm`,
  247. report.`cpa`,
  248. report.`interact_per_cost`,
  249. report.`convert_show_rate`,
  250. report.`play_duration_10s_rate`,
  251. report.`play_50_feed_break_rate`,
  252. report.`play_25_feed_break_rate`,
  253. report.`play_duration_5s_rate`,
  254. report.`play_duration_2s_rate`,
  255. report.`average_play_progress`,
  256. report.`play_100_feed_break_rate`,
  257. report.`play_duration_3s_rate`,
  258. report.`play_75_feed_break_rate`,
  259. report.`play_duration`,
  260. report.`play_duration_3s`,
  261. report.`play_duration_2s`,
  262. report.`play_duration_10s`,
  263. report.`average_video_play`,
  264. report.`avg_rank`,
  265. report.submit_certification_count,
  266. report.approval_count,
  267. report.first_rental_order_count,
  268. report.first_order_count,
  269. report.commute_first_pay_count,
  270. video.`video_url`,
  271. cmi.`cover_url`
  272. FROM (
  273. SELECT advertiser_id account_id,
  274. material_id,
  275. image_mode,
  276. inventory,
  277. sum(cost) cost,
  278. sum(`show`) `show`,
  279. ifnull(round(sum(cost) / sum(`show`), 3),0) avg_show_cost,
  280. sum(click) click,
  281. ifnull(round(sum(cost) / sum(`click`), 3),0) avg_click_cost,
  282. ifnull(round(sum(click) / sum(`show`) * 100,3),0) ctr,
  283. sum(`convert`) `convert`,
  284. ifnull(round(sum(cost) / sum(`convert`), 3),0) convert_cost,
  285. ifnull(round(sum(`convert`) / sum(click) * 100,3),0) convert_rate,
  286. sum(deep_convert) deep_convert,
  287. ifnull(round(sum(cost) / sum(deep_convert),3),0) deep_convert_cost,
  288. ifnull(round(sum(deep_convert) / sum(`convert`) * 100,3),0) deep_convert_rate,
  289. sum(attribution_convert) attribution_convert,
  290. ifnull(round(sum(cost) / sum(attribution_convert),3),0) attribution_convert_cost,
  291. sum(attribution_deep_convert) attribution_deep_convert,
  292. ifnull(round(sum(cost) / sum(attribution_deep_convert),3),0) attribution_deep_convert_cost,
  293. sum(download_start) download_start,
  294. ifnull(round(sum(cost) / sum(download_start),3),0) download_start_cost,
  295. ifnull(round(sum(download_start) / sum(click),3),0) download_start_rate,
  296. sum(download_finish) download_finish,
  297. ifnull(round(sum(cost) / sum(download_finish),3),0) download_finish_cost,
  298. ifnull(round(sum(download_finish) / sum(download_start) * 100,3),0) download_finish_rate,
  299. sum(click_install) click_install,
  300. sum(install_finish) install_finish,
  301. ifnull(round(sum(cost) / sum(install_finish),3),0) install_finish_cost,
  302. ifnull(round(sum(install_finish) / sum(download_finish) * 100,3),0) install_finish_rate,
  303. sum(active) active,
  304. ifnull(round(sum(cost) / sum(active), 3),0) active_cost,
  305. ifnull(round(sum(active) / sum(click) * 100,3),0) active_rate,
  306. sum(register) register,
  307. ifnull(round(sum(cost) / sum(register), 3),0) active_register_cost,
  308. ifnull(round(sum(active_register_rate) /{day_count} * 100,3),0) active_register_rate,
  309. sum(active_pay_amount) active_pay_amount,
  310. sum(next_day_open) next_day_open,
  311. ifnull(round(sum(cost) / sum(next_day_open),3),0) next_day_open_cost,
  312. ifnull(round(sum(next_day_open) / sum(active) * 100,3),0) next_day_open_rate,
  313. sum(attribution_next_day_open_cnt) attribution_next_day_open_cnt,
  314. ifnull(round(sum(cost) / sum( attribution_next_day_open_cnt),3),0) attribution_next_day_open_cost,
  315. ifnull(round(sum( attribution_next_day_open_cnt) / sum(active) * 100,3),0) attribution_next_day_open_rate,
  316. sum(game_addiction) game_addiction,
  317. ifnull(round(sum(cost) / sum(game_addiction),3),0) game_addiction_cost,
  318. ifnull(round(sum(game_addiction_rate) /{day_count} * 100,3),0) game_addiction_rate,
  319. sum(pay_count) pay_count,
  320. ifnull(round(sum(cost) / sum(pay_count), 3),0) active_pay_cost,
  321. ifnull(round(sum(pay_count) / sum(active) * 100,3),0) active_pay_rate,
  322. sum(loan_completion) loan_completion,
  323. ifnull(round(sum(cost) / sum(loan_completion),3),0) loan_completion_cost,
  324. ifnull(round(sum(loan_completion) / sum(register) * 100,3),0) loan_completion_rate,
  325. ifnull(round(sum(pre_loan_credit), 3),0) pre_loan_credit,
  326. ifnull(round(sum(cost) / sum(pre_loan_credit),3),0) pre_loan_credit_cost,
  327. sum(loan_credit) loan_credit,
  328. ifnull(round(sum(cost) / sum(loan_credit),3),0) loan_credit_cost,
  329. ifnull(round(sum(loan_credit) / sum(loan_completion) * 100,3),0) loan_credit_rate,
  330. sum(in_app_uv) in_app_uv,
  331. sum(in_app_detail_uv) in_app_detail_uv,
  332. sum(in_app_cart) in_app_cart,
  333. sum(in_app_pay) in_app_pay,
  334. sum(in_app_order) in_app_order,
  335. ifnull(round(sum( attribution_game_pay_7d_count) /{day_count}, 3),0) attribution_game_pay_7d_count,
  336. ifnull(round(sum( attribution_game_pay_7d_cost) /{day_count}, 3),0) attribution_game_pay_7d_cost,
  337. ifnull(round(sum( attribution_active_pay_7d_per_count) /{day_count}, 3),0) attribution_active_pay_7d_per_count,
  338. sum(game_pay_cost) game_pay_cost,
  339. sum(game_pay_count) game_pay_count,
  340. sum(phone) phone,
  341. sum(form) form,
  342. sum(map_search) map_search,
  343. sum(button) button,
  344. sum(`view`) `view`,
  345. sum(download) download,
  346. sum(qq) qq,
  347. sum(lottery) lottery,
  348. sum(vote) vote,
  349. sum(message) message,
  350. sum(redirect) redirect,
  351. sum(shopping) shopping,
  352. sum(consult) consult,
  353. sum(wechat) wechat,
  354. sum(phone_confirm) phone_confirm,
  355. sum(phone_connect) phone_connect,
  356. sum(consult_effective) consult_effective,
  357. sum(coupon) coupon,
  358. sum(coupon_single_page) coupon_single_page,
  359. sum(redirect_to_shop) redirect_to_shop,
  360. sum(poi_collect) poi_collect,
  361. sum(poi_address_click) poi_address_click,
  362. sum(luban_order_cnt) luban_order_cnt,
  363. sum(luban_order_stat_amount) luban_order_stat_amount,
  364. sum(luban_order_roi) luban_order_roi,
  365. sum(luban_live_enter_cnt) luban_live_enter_cnt,
  366. sum(live_watch_one_minute_count) live_watch_one_minute_count,
  367. sum(luban_live_follow_cnt) luban_live_follow_cnt,
  368. sum(live_fans_club_join_cnt) live_fans_club_join_cnt,
  369. sum(luban_live_comment_cnt) luban_live_comment_cnt,
  370. sum(luban_live_share_cnt) luban_live_share_cnt,
  371. sum(luban_live_gift_cnt) luban_live_gift_cnt,
  372. sum(luban_live_gift_amount) luban_live_gift_amount,
  373. sum(luban_live_slidecart_click_cnt) luban_live_slidecart_click_cnt,
  374. sum(luban_live_click_product_cnt) luban_live_click_product_cnt,
  375. sum(luban_live_pay_order_count) luban_live_pay_order_count,
  376. sum(luban_live_pay_order_stat_cost) luban_live_pay_order_stat_cost,
  377. sum(wechat_login_count) wechat_login_count,
  378. sum(attribution_wechat_login_30d_count) attribution_wechat_login_30d_count,
  379. ifnull(round(sum(cost) / sum(wechat_login_count),3),0) wechat_login_cost,
  380. ifnull(round(sum(cost) / sum( attribution_wechat_login_30d_count),3),0) attribution_wechat_login_30d_cost,
  381. sum(wechat_first_pay_count) wechat_first_pay_count,
  382. sum(attribution_wechat_first_pay_30d_count) attribution_wechat_first_pay_30d_count,
  383. ifnull(round(sum(cost) / sum(wechat_first_pay_count),3),0) wechat_first_pay_cost,
  384. ifnull(round(sum(cost) / sum( attribution_wechat_first_pay_30d_count),3),0) attribution_wechat_first_pay_30d_cost,
  385. ifnull(round(sum(wechat_first_pay_count) / sum(wechat_login_count) * 100,3),0) wechat_first_pay_rate,
  386. ifnull(round(sum( attribution_wechat_first_pay_30d_count) / sum( attribution_wechat_login_30d_count) * 100,3),0) attribution_wechat_first_pay_30d_rate,
  387. sum(wechat_pay_amount) wechat_pay_amount,
  388. sum(attribution_wechat_pay_30d_amount) attribution_wechat_pay_30d_amount,
  389. sum(attribution_wechat_pay_30d_roi) attribution_wechat_pay_30d_roi,
  390. sum(phone_effective) phone_effective,
  391. sum(total_play) total_play,
  392. sum(valid_play) valid_play,
  393. ifnull(round(sum(cost) / sum(valid_play),3),0) valid_play_cost,
  394. ifnull(round(sum(valid_play) / sum(`show`) * 100,3),0) valid_play_rate,
  395. sum(play_25_feed_break) play_25_feed_break,
  396. sum(play_50_feed_break) play_50_feed_break,
  397. sum(play_75_feed_break) play_75_feed_break,
  398. sum(play_100_feed_break) play_100_feed_break,
  399. ifnull(round(sum(average_play_time_per_play) /{day_count}, 3),0) average_play_time_per_play,
  400. ifnull(round(sum(play_over_rate) /{day_count} * 100,3),0) play_over_rate,
  401. ifnull(round(sum(wifi_play) / sum(total_play) * 100,3),0) wifi_play_rate,
  402. sum(wifi_play) wifi_play,
  403. ifnull(round(sum(play_duration_sum) /{day_count}, 3),0) play_duration_sum,
  404. sum(advanced_creative_phone_click) advanced_creative_phone_click,
  405. sum(advanced_creative_counsel_click) advanced_creative_counsel_click,
  406. sum(advanced_creative_form_click) advanced_creative_form_click,
  407. sum(advanced_creative_coupon_addition) advanced_creative_coupon_addition,
  408. sum(advanced_creative_form_submit) advanced_creative_form_submit,
  409. sum(card_show) card_show,
  410. sum(`share`) `share`,
  411. sum(`comment`) `comment`,
  412. sum(`like`) `like`,
  413. sum(follow) follow,
  414. sum(home_visited) home_visited,
  415. sum(ies_challenge_click) ies_challenge_click,
  416. sum(ies_music_click) ies_music_click,
  417. sum(location_click) location_click,
  418. sum(message_action) message_action,
  419. sum(click_landing_page) click_landing_page,
  420. sum(click_shopwindow) click_shopwindow,
  421. sum(click_website) click_website,
  422. sum(click_download) click_download,
  423. sum(click_call_dy) click_call_dy,
  424. sum(cpc) cpc,
  425. sum(cpm) cpm,
  426. sum(cpa) cpa,
  427. ifnull(round(sum(interact_per_cost) /{day_count}, 3),0) interact_per_cost,
  428. ifnull(round(sum(convert_show_rate) /{day_count}, 3),0) convert_show_rate,
  429. ifnull(round(sum(play_duration_10s) / sum(total_play) * 100,3),0) play_duration_10s_rate,
  430. ifnull(round(sum(play_50_feed_break) / sum(total_play) * 100,3),0) play_50_feed_break_rate,
  431. ifnull(round(sum(play_25_feed_break) / sum(total_play) * 100,3),0) play_25_feed_break_rate,
  432. ifnull(round(sum(play_duration_5s_rate) /{day_count}, 3),0) play_duration_5s_rate,
  433. ifnull(round(sum(play_duration_2s) / sum(total_play) * 100,3),0) play_duration_2s_rate,
  434. ifnull(round(sum(average_play_progress) /{day_count}, 3),0) average_play_progress,
  435. ifnull(round(sum(play_100_feed_break) / sum(total_play) * 100,3),0) play_100_feed_break_rate,
  436. ifnull(round(sum(play_duration_3s) / sum(total_play) * 100,3),0) play_duration_3s_rate,
  437. ifnull(round(sum(play_75_feed_break) / sum(total_play) * 100,3),0) play_75_feed_break_rate,
  438. sum(play_duration) play_duration,
  439. sum(play_duration_3s) play_duration_3s,
  440. sum(play_duration_2s) play_duration_2s,
  441. sum(play_duration_10s) play_duration_10s,
  442. ifnull(round(sum(average_video_play) /{day_count}, 3),0) average_video_play,
  443. sum(avg_rank) avg_rank,
  444. sum(submit_certification_count) submit_certification_count,
  445. sum(approval_count) approval_count,
  446. sum(first_order_count) first_rental_order_count,
  447. sum(first_rental_order_count) first_order_count,
  448. sum(commute_first_pay_count) commute_first_pay_count
  449. FROM media_api.bytedance_material_report_daily zhubiao
  450. WHERE image_mode IN (
  451. 'CREATIVE_IMAGE_MODE_VIDEO',
  452. 'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL',
  453. 'CREATIVE_IMAGE_MODE_UNION_SPLASH_VIDEO'
  454. )
  455. AND stat_datetime >= date_format(
  456. date_sub({date_time}, INTERVAL {day_count} DAY),
  457. '%Y%m%d'
  458. )
  459. and advertiser_id={account_id}
  460. GROUP BY advertiser_id,
  461. material_id,
  462. image_mode,
  463. inventory
  464. ) report
  465. LEFT JOIN (select advertiser_id, signature, material_id, filename, video_url
  466. from `media_api`.bytedance_file_video_get where advertiser_id={account_id}
  467. group by advertiser_id, signature, material_id, filename, video_url) video
  468. ON report.account_id = video.advertiser_id AND report.material_id = video.material_id
  469. LEFT JOIN (select code,material_name,cover_url from `jeecg-boot`.ctop_material_info where status=1) cmi
  470. ON video.signature = cmi.code
  471. LEFT JOIN (select material_id, clip_id, shot_id, plan_id, leader_id
  472. from (
  473. select material_id,
  474. clip_id,
  475. shot_id,
  476. plan_id,
  477. leader_id,
  478. row_number() over (partition by material_id order by create_time) rn
  479. from `jeecg-boot`.ctop_material_ascription) m
  480. where rn = 1) cma
  481. ON video.signature = cma.material_id
  482. LEFT JOIN `jeecg-boot`.ctop_user_allocation cua ON report.account_id = cua.account_id
  483. LEFT JOIN `jeecg-boot`.ctop_advertiser ca ON cua.advertiser_id = ca.id
  484. LEFT JOIN `jeecg-boot`.ctop_project cp ON cua.project_id = cp.id
  485. LEFT JOIN `jeecg-boot`.user_company uc ON cua.user_id = uc.user_id
  486. LEFT JOIN `jeecg-boot`.ctop_product product ON cp.product_id = product.id
  487. LEFT JOIN `jeecg-boot`.sys_user su ON cua.user_id = su.id
  488. LEFT JOIN `jeecg-boot`.sys_user clip ON clip.id = cma.clip_id
  489. LEFT JOIN `jeecg-boot`.sys_user shot ON shot.id = cma.shot_id
  490. LEFT JOIN `jeecg-boot`.sys_user plan ON plan.id = cma.plan_id
  491. LEFT JOIN `jeecg-boot`.sys_user leader ON leader.id = cma.leader_id
  492. LEFT JOIN `jeecg-boot`.user_company up ON up.user_id = cma.clip_id
  493. where cua.account_id = {account_id};""".format(date_time=self.date_time,
  494. day_count=self.day_count,
  495. account_id=account_id[0])
  496. print(sql)
  497. TidbConn.upsert(conn=self.conn, sql_buff=sql)
  498. self.conn.commit()
  499. except Exception as e:
  500. logging.error(e)
  501. return -1
  502. TidbConn.conn_close(conn=self.conn)
  503. return 0
  504. except Exception as e:
  505. logging.error(e)
  506. return -1
  507. if __name__ == '__main__':
  508. status = AppBytedanceVideoReportBusiMonth().taskHandler()
  509. if status == 0:
  510. print("作业执行成功")
  511. exit(0)
  512. else:
  513. print("作业执行失败")
  514. exit(-1)