AppBytedanceImageReportBusi.py 29 KB

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