AppBytedanceImageReportBusiMonth.py 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. # Author renyupeng
  2. # coding=utf-8
  3. # @Time : 2021/11/10 3:37 下午
  4. # @Site :
  5. # @File : AppBytedanceImageReportBusiMonth.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 AppBytedanceImageReportBusiMonth:
  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 project_id from `jeecg-boot`.ctop_user_allocation where media_id=1
  21. group by project_id """
  22. project_list = TidbConn.quary(self.conn,sql_porject)
  23. for project_id in project_list:
  24. try:
  25. sql = """SET sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
  26. REPLACE INTO application.app_bytedance_image_report_busi_m
  27. SELECT date_format({date_time},'%Y%m') stat_non,
  28. report.account_id,
  29. #'账户ID'
  30. report.material_id,
  31. #头条素材id
  32. report.image_mode,
  33. #素材类型
  34. report.inventory,
  35. #广告位
  36. cua.project_id,
  37. #项目id
  38. product.id product_id,
  39. #项目中产品id
  40. cua.advertiser_id,
  41. #广告主id
  42. uc.company_id,
  43. #运营人的公司id
  44. cua.auth_name account_name,
  45. #账户名称
  46. cp.project_name,
  47. #项目名称
  48. ca.`name` advertiser_name,
  49. #广告主名称
  50. uc.company_name,
  51. #运营人的公司名称
  52. cp.sale_id,
  53. #项目里的销售id
  54. cua.user_id,
  55. #运营id
  56. su.org_code,
  57. #机构编码
  58. video.signature signature,
  59. #素材id
  60. CASE
  61. WHEN cmi.material_name IS NOT NULL THEN
  62. cmi.material_name
  63. ELSE
  64. video.filename
  65. END AS video_name,
  66. report.cost,
  67. report.`show`,
  68. report.avg_show_cost,
  69. report.click,
  70. report.avg_click_cost,
  71. report.ctr,
  72. report.`convert`,
  73. report.convert_cost,
  74. report.convert_rate,
  75. report.deep_convert,
  76. report.deep_convert_cost,
  77. report.deep_convert_rate,
  78. report.attribution_convert,
  79. report.attribution_convert_cost,
  80. report.attribution_deep_convert,
  81. report.attribution_deep_convert_cost,
  82. report.download_start,
  83. report.download_start_cost,
  84. report.download_start_rate,
  85. report.download_finish,
  86. report.download_finish_cost,
  87. report.download_finish_rate,
  88. report.click_install,
  89. report.install_finish,
  90. report.install_finish_cost,
  91. report.install_finish_rate,
  92. report.active,
  93. report.active_cost,
  94. report.active_rate,
  95. report.register,
  96. report.active_register_cost,
  97. report.active_register_rate,
  98. report.active_pay_amount,
  99. report.next_day_open,
  100. report.next_day_open_cost,
  101. report.next_day_open_rate,
  102. report.attribution_next_day_open_cnt,
  103. report.attribution_next_day_open_cost,
  104. report.attribution_next_day_open_rate,
  105. report.game_addiction,
  106. report.game_addiction_cost,
  107. report.game_addiction_rate,
  108. report.pay_count,
  109. report.active_pay_cost,
  110. report.active_pay_rate,
  111. report.loan_completion,
  112. report.loan_completion_cost,
  113. report.loan_completion_rate,
  114. report.pre_loan_credit,
  115. report.pre_loan_credit_cost,
  116. report.loan_credit,
  117. report.loan_credit_cost,
  118. report.loan_credit_rate,
  119. report.in_app_uv,
  120. report.in_app_detail_uv,
  121. report.in_app_cart,
  122. report.in_app_pay,
  123. report.in_app_order,
  124. report.attribution_game_pay_7d_count,
  125. report.attribution_game_pay_7d_cost,
  126. report.attribution_active_pay_7d_per_count,
  127. report.game_pay_cost,
  128. report.game_pay_count,
  129. report.phone,
  130. report.form,
  131. report.map_search,
  132. report.button,
  133. report.`view`,
  134. report.download,
  135. report.qq,
  136. report.lottery,
  137. report.vote,
  138. report.message,
  139. report.redirect,
  140. report.shopping,
  141. report.consult,
  142. report.wechat,
  143. report.phone_confirm,
  144. report.phone_connect,
  145. report.consult_effective,
  146. report.coupon,
  147. report.coupon_single_page,
  148. report.redirect_to_shop,
  149. report.poi_collect,
  150. report.poi_address_click,
  151. report.luban_order_cnt,
  152. report.luban_order_stat_amount,
  153. report.luban_order_roi,
  154. report.luban_live_enter_cnt,
  155. report.live_watch_one_minute_count,
  156. report.luban_live_follow_cnt,
  157. report.live_fans_club_join_cnt,
  158. report.luban_live_comment_cnt,
  159. report.luban_live_share_cnt,
  160. report.luban_live_gift_cnt,
  161. report.luban_live_gift_amount,
  162. report.luban_live_slidecart_click_cnt,
  163. report.luban_live_click_product_cnt,
  164. report.luban_live_pay_order_count,
  165. report.luban_live_pay_order_stat_cost,
  166. report.wechat_login_count,
  167. report.attribution_wechat_login_30d_count,
  168. report.wechat_login_cost,
  169. report.attribution_wechat_login_30d_cost,
  170. report.wechat_first_pay_count,
  171. report.attribution_wechat_first_pay_30d_count,
  172. report.wechat_first_pay_cost,
  173. report.attribution_wechat_first_pay_30d_cost,
  174. report.wechat_first_pay_rate,
  175. report.attribution_wechat_first_pay_30d_rate,
  176. report.wechat_pay_amount,
  177. report.attribution_wechat_pay_30d_amount,
  178. report.attribution_wechat_pay_30d_roi,
  179. report.phone_effective,
  180. report.total_play,
  181. report.valid_play,
  182. report.valid_play_cost,
  183. report.valid_play_rate,
  184. report.play_25_feed_break,
  185. report.play_50_feed_break,
  186. report.play_75_feed_break,
  187. report.play_100_feed_break,
  188. report.average_play_time_per_play,
  189. report.play_over_rate,
  190. report.wifi_play_rate,
  191. report.wifi_play,
  192. report.play_duration_sum,
  193. report.advanced_creative_phone_click,
  194. report.advanced_creative_counsel_click,
  195. report.advanced_creative_form_click,
  196. report.advanced_creative_coupon_addition,
  197. report.advanced_creative_form_submit,
  198. report.card_show,
  199. report.`share`,
  200. report.`comment`,
  201. report.`like`,
  202. report.follow,
  203. report.home_visited,
  204. report.ies_challenge_click,
  205. report.ies_music_click,
  206. report.location_click,
  207. report.message_action,
  208. report.click_landing_page,
  209. report.click_shopwindow,
  210. report.click_website,
  211. report.click_download,
  212. report.click_call_dy,
  213. report.`cpc`,
  214. report.`cpm`,
  215. report.`cpa`,
  216. report.`interact_per_cost`,
  217. report.`convert_show_rate`,
  218. report.`play_duration_10s_rate`,
  219. report.`play_50_feed_break_rate`,
  220. report.`play_25_feed_break_rate`,
  221. report.`play_duration_5s_rate`,
  222. report.`play_duration_2s_rate`,
  223. report.`average_play_progress`,
  224. report.`play_100_feed_break_rate`,
  225. report.`play_duration_3s_rate`,
  226. report.`play_75_feed_break_rate`,
  227. report.`play_duration`,
  228. report.`play_duration_3s`,
  229. report.`play_duration_2s`,
  230. report.`play_duration_10s`,
  231. report.`average_video_play`,
  232. report.`avg_rank`,
  233. report.submit_certification_count,
  234. report.approval_count,
  235. report.first_rental_order_count,
  236. report.first_order_count,
  237. report.commute_first_pay_count,
  238. video.`video_url`,
  239. cmi.`cover_url`
  240. FROM (
  241. SELECT advertiser_id account_id,
  242. material_id,
  243. image_mode,
  244. inventory,
  245. sum(cost) cost,
  246. sum(`show`) `show`,
  247. round(sum(cost) / sum(`show`), 3) avg_show_cost,
  248. sum(click) click,
  249. round(sum(cost) / sum(`click`), 3) avg_click_cost,
  250. round(
  251. sum(click) / sum(`show`) * 100,
  252. 3
  253. ) ctr,
  254. sum(`convert`) `convert`,
  255. round(sum(cost) / sum(`convert`), 3) convert_cost,
  256. round(
  257. sum(`convert`) / sum(click) * 100,
  258. 3
  259. ) convert_rate,
  260. sum(deep_convert) deep_convert,
  261. round(
  262. sum(cost) / sum(deep_convert),
  263. 3
  264. ) deep_convert_cost,
  265. round(
  266. sum(deep_convert) / sum(`convert`) * 100,
  267. 3
  268. ) deep_convert_rate,
  269. sum(attribution_convert) attribution_convert,
  270. round(
  271. sum(cost) / sum(attribution_convert),
  272. 3
  273. ) attribution_convert_cost,
  274. sum(attribution_deep_convert) attribution_deep_convert,
  275. round(
  276. sum(cost) / sum(attribution_deep_convert),
  277. 3
  278. ) attribution_deep_convert_cost,
  279. sum(download_start) download_start,
  280. round(
  281. sum(cost) / sum(download_start),
  282. 3
  283. ) download_start_cost,
  284. round(
  285. sum(download_start) / sum(click),
  286. 3
  287. ) download_start_rate,
  288. sum(download_finish) download_finish,
  289. round(
  290. sum(cost) / sum(download_finish),
  291. 3
  292. ) download_finish_cost,
  293. round(
  294. sum(download_finish) / sum(download_start) * 100,
  295. 3
  296. ) download_finish_rate,
  297. sum(click_install) click_install,
  298. sum(install_finish) install_finish,
  299. round(
  300. sum(cost) / sum(install_finish),
  301. 3
  302. ) install_finish_cost,
  303. round(
  304. sum(install_finish) / sum(download_finish) * 100,
  305. 3
  306. ) install_finish_rate,
  307. sum(active) active,
  308. round(sum(cost) / sum(active), 3) active_cost,
  309. round(
  310. sum(active) / sum(click) * 100,
  311. 3
  312. ) active_rate,
  313. sum(register) register,
  314. round(sum(cost) / sum(register), 3) active_register_cost,
  315. round(
  316. sum(active_register_rate) / {day_count} * 100,
  317. 3
  318. ) active_register_rate,
  319. sum(active_pay_amount) active_pay_amount,
  320. sum(next_day_open) next_day_open,
  321. round(
  322. sum(cost) / sum(next_day_open),
  323. 3
  324. ) next_day_open_cost,
  325. round(
  326. sum(next_day_open) / sum(active) * 100,
  327. 3
  328. ) next_day_open_rate,
  329. sum(
  330. attribution_next_day_open_cnt
  331. ) attribution_next_day_open_cnt,
  332. round(
  333. sum(cost) / sum(
  334. attribution_next_day_open_cnt
  335. ),
  336. 3
  337. ) attribution_next_day_open_cost,
  338. round(
  339. sum(
  340. attribution_next_day_open_cnt
  341. ) / sum(active) * 100,
  342. 3
  343. ) attribution_next_day_open_rate,
  344. sum(game_addiction) game_addiction,
  345. round(
  346. sum(cost) / sum(game_addiction),
  347. 3
  348. ) game_addiction_cost,
  349. round(
  350. sum(game_addiction_rate) / {day_count} * 100,
  351. 3
  352. ) game_addiction_rate,
  353. sum(pay_count) pay_count,
  354. round(sum(cost) / sum(pay_count), 3) active_pay_cost,
  355. round(
  356. sum(pay_count) / sum(active) * 100,
  357. 3
  358. ) active_pay_rate,
  359. sum(loan_completion) loan_completion,
  360. round(
  361. sum(cost) / sum(loan_completion),
  362. 3
  363. ) loan_completion_cost,
  364. round(
  365. sum(loan_completion) / sum(register) * 100,
  366. 3
  367. ) loan_completion_rate,
  368. round(sum(pre_loan_credit), 3) pre_loan_credit,
  369. round(
  370. sum(cost) / sum(pre_loan_credit),
  371. 3
  372. ) pre_loan_credit_cost,
  373. sum(loan_credit) loan_credit,
  374. round(
  375. sum(cost) / sum(loan_credit),
  376. 3
  377. ) loan_credit_cost,
  378. round(
  379. sum(loan_credit) / sum(loan_completion) * 100,
  380. 3
  381. ) loan_credit_rate,
  382. sum(in_app_uv) in_app_uv,
  383. sum(in_app_detail_uv) in_app_detail_uv,
  384. sum(in_app_cart) in_app_cart,
  385. sum(in_app_pay) in_app_pay,
  386. sum(in_app_order) in_app_order,
  387. round(
  388. sum(
  389. attribution_game_pay_7d_count
  390. ) / {day_count},
  391. 3
  392. ) attribution_game_pay_7d_count,
  393. round(
  394. sum(
  395. attribution_game_pay_7d_cost
  396. ) / {day_count},
  397. 3
  398. ) attribution_game_pay_7d_cost,
  399. round(
  400. sum(
  401. attribution_active_pay_7d_per_count
  402. ) / {day_count},
  403. 3
  404. ) attribution_active_pay_7d_per_count,
  405. sum(game_pay_cost) game_pay_cost,
  406. sum(game_pay_count) game_pay_count,
  407. sum(phone) phone,
  408. sum(form) form,
  409. sum(map_search) map_search,
  410. sum(button) button,
  411. sum(`view`) `view`,
  412. sum(download) download,
  413. sum(qq) qq,
  414. sum(lottery) lottery,
  415. sum(vote) vote,
  416. sum(message) message,
  417. sum(redirect) redirect,
  418. sum(shopping) shopping,
  419. sum(consult) consult,
  420. sum(wechat) wechat,
  421. sum(phone_confirm) phone_confirm,
  422. sum(phone_connect) phone_connect,
  423. sum(consult_effective) consult_effective,
  424. sum(coupon) coupon,
  425. sum(coupon_single_page) coupon_single_page,
  426. sum(redirect_to_shop) redirect_to_shop,
  427. sum(poi_collect) poi_collect,
  428. sum(poi_address_click) poi_address_click,
  429. sum(luban_order_cnt) luban_order_cnt,
  430. sum(luban_order_stat_amount) luban_order_stat_amount,
  431. sum(luban_order_roi) luban_order_roi,
  432. sum(luban_live_enter_cnt) luban_live_enter_cnt,
  433. sum(
  434. live_watch_one_minute_count
  435. ) live_watch_one_minute_count,
  436. sum(luban_live_follow_cnt) luban_live_follow_cnt,
  437. sum(live_fans_club_join_cnt) live_fans_club_join_cnt,
  438. sum(luban_live_comment_cnt) luban_live_comment_cnt,
  439. sum(luban_live_share_cnt) luban_live_share_cnt,
  440. sum(luban_live_gift_cnt) luban_live_gift_cnt,
  441. sum(luban_live_gift_amount) luban_live_gift_amount,
  442. sum(
  443. luban_live_slidecart_click_cnt
  444. ) luban_live_slidecart_click_cnt,
  445. sum(
  446. luban_live_click_product_cnt
  447. ) luban_live_click_product_cnt,
  448. sum(luban_live_pay_order_count) luban_live_pay_order_count,
  449. sum(
  450. luban_live_pay_order_stat_cost
  451. ) luban_live_pay_order_stat_cost,
  452. sum(wechat_login_count) wechat_login_count,
  453. sum(
  454. attribution_wechat_login_30d_count
  455. ) attribution_wechat_login_30d_count,
  456. round(
  457. sum(cost) / sum(wechat_login_count),
  458. 3
  459. ) wechat_login_cost,
  460. round(
  461. sum(cost) / sum(
  462. attribution_wechat_login_30d_count
  463. ),
  464. 3
  465. ) attribution_wechat_login_30d_cost,
  466. sum(wechat_first_pay_count) wechat_first_pay_count,
  467. sum(
  468. attribution_wechat_first_pay_30d_count
  469. ) attribution_wechat_first_pay_30d_count,
  470. round(
  471. sum(cost) / sum(wechat_first_pay_count),
  472. 3
  473. ) wechat_first_pay_cost,
  474. round(
  475. sum(cost) / sum(
  476. attribution_wechat_first_pay_30d_count
  477. ),
  478. 3
  479. ) attribution_wechat_first_pay_30d_cost,
  480. round(
  481. sum(wechat_first_pay_count) / sum(wechat_login_count) * 100,
  482. 3
  483. ) wechat_first_pay_rate,
  484. round(
  485. sum(
  486. attribution_wechat_first_pay_30d_count
  487. ) / sum(
  488. attribution_wechat_login_30d_count
  489. ) * 100,
  490. 3
  491. ) attribution_wechat_first_pay_30d_rate,
  492. sum(wechat_pay_amount) wechat_pay_amount,
  493. sum(
  494. attribution_wechat_pay_30d_amount
  495. ) attribution_wechat_pay_30d_amount,
  496. sum(
  497. attribution_wechat_pay_30d_roi
  498. ) attribution_wechat_pay_30d_roi,
  499. sum(phone_effective) phone_effective,
  500. sum(total_play) total_play,
  501. sum(valid_play) valid_play,
  502. round(
  503. sum(cost) / sum(valid_play),
  504. 3
  505. ) valid_play_cost,
  506. round(
  507. sum(valid_play) / sum(`show`) * 100,
  508. 3
  509. ) valid_play_rate,
  510. sum(play_25_feed_break) play_25_feed_break,
  511. sum(play_50_feed_break) play_50_feed_break,
  512. sum(play_75_feed_break) play_75_feed_break,
  513. sum(play_100_feed_break) play_100_feed_break,
  514. round(
  515. sum(average_play_time_per_play) / {day_count},
  516. 3
  517. ) average_play_time_per_play,
  518. round(
  519. sum(play_over_rate) / {day_count} * 100,
  520. 3
  521. ) play_over_rate,
  522. round(
  523. sum(wifi_play) / sum(total_play) * 100,
  524. 3
  525. ) wifi_play_rate,
  526. sum(wifi_play) wifi_play,
  527. round(sum(play_duration_sum) / {day_count}, 3) play_duration_sum,
  528. sum(
  529. advanced_creative_phone_click
  530. ) advanced_creative_phone_click,
  531. sum(
  532. advanced_creative_counsel_click
  533. ) advanced_creative_counsel_click,
  534. sum(
  535. advanced_creative_form_click
  536. ) advanced_creative_form_click,
  537. sum(
  538. advanced_creative_coupon_addition
  539. ) advanced_creative_coupon_addition,
  540. sum(
  541. advanced_creative_form_submit
  542. ) advanced_creative_form_submit,
  543. sum(card_show) card_show,
  544. sum(`share`) `share`,
  545. sum(`comment`) `comment`,
  546. sum(`like`) `like`,
  547. sum(follow) follow,
  548. sum(home_visited) home_visited,
  549. sum(ies_challenge_click) ies_challenge_click,
  550. sum(ies_music_click) ies_music_click,
  551. sum(location_click) location_click,
  552. sum(message_action) message_action,
  553. sum(click_landing_page) click_landing_page,
  554. sum(click_shopwindow) click_shopwindow,
  555. sum(click_website) click_website,
  556. sum(click_download) click_download,
  557. sum(click_call_dy) click_call_dy,
  558. sum(cpc) cpc,
  559. sum(cpm) cpm,
  560. sum(cpa) cpa,
  561. round(sum(interact_per_cost) / {day_count}, 3) interact_per_cost,
  562. round(sum(convert_show_rate) / {day_count}, 3) convert_show_rate,
  563. round(
  564. sum(round(play_duration_10s)) / sum(total_play) * 100,
  565. 3
  566. ) play_duration_10s_rate,
  567. round(
  568. sum(play_50_feed_break) / sum(total_play) * 100,
  569. 3
  570. ) play_50_feed_break_rate,
  571. round(
  572. sum(play_25_feed_break) / sum(total_play) * 100,
  573. 3
  574. ) play_25_feed_break_rate,
  575. round(
  576. sum(play_duration_5s_rate) / {day_count},
  577. 3
  578. ) play_duration_5s_rate,
  579. round(
  580. sum(play_duration_2s) / sum(total_play) * 100,
  581. 3
  582. ) play_duration_2s_rate,
  583. round(
  584. sum(average_play_progress) / {day_count},
  585. 3
  586. ) average_play_progress,
  587. round(
  588. sum(play_100_feed_break) / sum(total_play) * 100,
  589. 3
  590. ) play_100_feed_break_rate,
  591. round(
  592. sum(play_duration_3s) / sum(total_play) * 100,
  593. 3
  594. ) play_duration_3s_rate,
  595. round(
  596. sum(play_75_feed_break) / sum(total_play) * 100,
  597. 3
  598. ) play_75_feed_break_rate,
  599. sum(play_duration) play_duration,
  600. sum(play_duration_3s) play_duration_3s,
  601. sum(play_duration_2s) play_duration_2s,
  602. sum(play_duration_10s) play_duration_10s,
  603. round(
  604. sum(average_video_play) / {day_count},
  605. 3
  606. ) average_video_play,
  607. sum(avg_rank) avg_rank,
  608. sum(submit_certification_count) submit_certification_count,
  609. sum(approval_count) approval_count,
  610. sum(first_order_count) first_rental_order_count,
  611. sum(first_rental_order_count) first_order_count,
  612. sum(commute_first_pay_count) commute_first_pay_count
  613. FROM media_api.bytedance_material_report_daily zhubiao
  614. WHERE image_mode IN (
  615. 'CREATIVE_IMAGE_MODE_SMALL',
  616. 'CREATIVE_IMAGE_MODE_LARGE',
  617. 'CREATIVE_IMAGE_MODE_LARGE_VERTICAL',
  618. 'CREATIVE_IMAGE_MODE_GROUP',
  619. 'CREATIVE_IMAGE_MODE_GIF',
  620. 'TOUTIAO_SEARCH_AD_IMAGE',
  621. 'SEARCH_AD_SMALL_IMAGE',
  622. 'CREATIVE_IMAGE_MODE_UNION_SPLASH'
  623. )
  624. AND stat_datetime >= date_format(
  625. date_sub({date_time}, INTERVAL {day_count} DAY),
  626. '%Y%m%d'
  627. )
  628. GROUP BY advertiser_id,
  629. material_id,
  630. image_mode,
  631. inventory
  632. ) report
  633. LEFT JOIN (select advertiser_id,signature,material_id,filename,image_url from `media_api`.bytedance_file_image_get group by advertiser_id,signature,material_id,filename,image_url) video
  634. ON report.account_id = video.advertiser_id AND report.material_id = video.material_id
  635. LEFT JOIN `jeecg-boot`.ctop_user_allocation cua
  636. ON report.advertiser_id = cua.account_id
  637. LEFT JOIN `jeecg-boot`.ctop_advertiser ca
  638. ON cua.advertiser_id = ca.id
  639. LEFT JOIN `jeecg-boot`.ctop_project cp
  640. ON cua.project_id = cp.id
  641. LEFT JOIN `jeecg-boot`.user_company uc
  642. ON cua.user_id = uc.user_id
  643. LEFT JOIN `jeecg-boot`.ctop_product product
  644. ON cp.product_id = product.id
  645. LEFT JOIN `jeecg-boot`.sys_user su
  646. ON cua.user_id = su.id
  647. """.format(date_time=self.date_time, day_count=self.day_count, project_id=project_id[0])
  648. TidbConn.upsert(conn=self.conn, sql_buff=sql)
  649. self.conn.commit()
  650. except Exception as e:
  651. logging.error(e)
  652. return -1
  653. TidbConn.conn_close(conn=self.conn)
  654. return 0
  655. except Exception as e:
  656. logging.error(e)
  657. return -1
  658. if __name__ == '__main__':
  659. status = AppBytedanceImageReportBusiMonth().taskHandler()
  660. if status == 0:
  661. print("作业执行成功")
  662. exit(0)
  663. else:
  664. print("作业执行失败")
  665. exit(-1)