AppBytedanceImageReportBusiMonth.py 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  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. 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.`image_url`
  234. FROM (
  235. SELECT advertiser_id account_id,
  236. material_id,
  237. image_mode,
  238. inventory,
  239. sum(cost) cost,
  240. sum(`show`) `show`,
  241. round(sum(cost) / sum(`show`), 3) avg_show_cost,
  242. sum(click) click,
  243. round(sum(cost) / sum(`click`), 3) avg_click_cost,
  244. round(
  245. sum(click) / sum(`show`) * 100,
  246. 3
  247. ) ctr,
  248. sum(`convert`) `convert`,
  249. round(sum(cost) / sum(`convert`), 3) convert_cost,
  250. round(
  251. sum(`convert`) / sum(click) * 100,
  252. 3
  253. ) convert_rate,
  254. sum(deep_convert) deep_convert,
  255. round(
  256. sum(cost) / sum(deep_convert),
  257. 3
  258. ) deep_convert_cost,
  259. round(
  260. sum(deep_convert) / sum(`convert`) * 100,
  261. 3
  262. ) deep_convert_rate,
  263. sum(attribution_convert) attribution_convert,
  264. round(
  265. sum(cost) / sum(attribution_convert),
  266. 3
  267. ) attribution_convert_cost,
  268. sum(attribution_deep_convert) attribution_deep_convert,
  269. round(
  270. sum(cost) / sum(attribution_deep_convert),
  271. 3
  272. ) attribution_deep_convert_cost,
  273. sum(download_start) download_start,
  274. round(
  275. sum(cost) / sum(download_start),
  276. 3
  277. ) download_start_cost,
  278. round(
  279. sum(download_start) / sum(click),
  280. 3
  281. ) download_start_rate,
  282. sum(download_finish) download_finish,
  283. round(
  284. sum(cost) / sum(download_finish),
  285. 3
  286. ) download_finish_cost,
  287. round(
  288. sum(download_finish) / sum(download_start) * 100,
  289. 3
  290. ) download_finish_rate,
  291. sum(click_install) click_install,
  292. sum(install_finish) install_finish,
  293. round(
  294. sum(cost) / sum(install_finish),
  295. 3
  296. ) install_finish_cost,
  297. round(
  298. sum(install_finish) / sum(download_finish) * 100,
  299. 3
  300. ) install_finish_rate,
  301. sum(active) active,
  302. round(sum(cost) / sum(active), 3) active_cost,
  303. round(
  304. sum(active) / sum(click) * 100,
  305. 3
  306. ) active_rate,
  307. sum(register) register,
  308. round(sum(cost) / sum(register), 3) active_register_cost,
  309. round(
  310. sum(active_register_rate) / {day_count} * 100,
  311. 3
  312. ) active_register_rate,
  313. sum(active_pay_amount) active_pay_amount,
  314. sum(next_day_open) next_day_open,
  315. round(
  316. sum(cost) / sum(next_day_open),
  317. 3
  318. ) next_day_open_cost,
  319. round(
  320. sum(next_day_open) / sum(active) * 100,
  321. 3
  322. ) next_day_open_rate,
  323. sum(
  324. attribution_next_day_open_cnt
  325. ) attribution_next_day_open_cnt,
  326. round(
  327. sum(cost) / sum(
  328. attribution_next_day_open_cnt
  329. ),
  330. 3
  331. ) attribution_next_day_open_cost,
  332. round(
  333. sum(
  334. attribution_next_day_open_cnt
  335. ) / sum(active) * 100,
  336. 3
  337. ) attribution_next_day_open_rate,
  338. sum(game_addiction) game_addiction,
  339. round(
  340. sum(cost) / sum(game_addiction),
  341. 3
  342. ) game_addiction_cost,
  343. round(
  344. sum(game_addiction_rate) / {day_count} * 100,
  345. 3
  346. ) game_addiction_rate,
  347. sum(pay_count) pay_count,
  348. round(sum(cost) / sum(pay_count), 3) active_pay_cost,
  349. round(
  350. sum(pay_count) / sum(active) * 100,
  351. 3
  352. ) active_pay_rate,
  353. sum(loan_completion) loan_completion,
  354. round(
  355. sum(cost) / sum(loan_completion),
  356. 3
  357. ) loan_completion_cost,
  358. round(
  359. sum(loan_completion) / sum(register) * 100,
  360. 3
  361. ) loan_completion_rate,
  362. round(sum(pre_loan_credit), 3) pre_loan_credit,
  363. round(
  364. sum(cost) / sum(pre_loan_credit),
  365. 3
  366. ) pre_loan_credit_cost,
  367. sum(loan_credit) loan_credit,
  368. round(
  369. sum(cost) / sum(loan_credit),
  370. 3
  371. ) loan_credit_cost,
  372. round(
  373. sum(loan_credit) / sum(loan_completion) * 100,
  374. 3
  375. ) loan_credit_rate,
  376. sum(in_app_uv) in_app_uv,
  377. sum(in_app_detail_uv) in_app_detail_uv,
  378. sum(in_app_cart) in_app_cart,
  379. sum(in_app_pay) in_app_pay,
  380. sum(in_app_order) in_app_order,
  381. round(
  382. sum(
  383. attribution_game_pay_7d_count
  384. ) / {day_count},
  385. 3
  386. ) attribution_game_pay_7d_count,
  387. round(
  388. sum(
  389. attribution_game_pay_7d_cost
  390. ) / {day_count},
  391. 3
  392. ) attribution_game_pay_7d_cost,
  393. round(
  394. sum(
  395. attribution_active_pay_7d_per_count
  396. ) / {day_count},
  397. 3
  398. ) attribution_active_pay_7d_per_count,
  399. sum(game_pay_cost) game_pay_cost,
  400. sum(game_pay_count) game_pay_count,
  401. sum(phone) phone,
  402. sum(form) form,
  403. sum(map_search) map_search,
  404. sum(button) button,
  405. sum(`view`) `view`,
  406. sum(download) download,
  407. sum(qq) qq,
  408. sum(lottery) lottery,
  409. sum(vote) vote,
  410. sum(message) message,
  411. sum(redirect) redirect,
  412. sum(shopping) shopping,
  413. sum(consult) consult,
  414. sum(wechat) wechat,
  415. sum(phone_confirm) phone_confirm,
  416. sum(phone_connect) phone_connect,
  417. sum(consult_effective) consult_effective,
  418. sum(coupon) coupon,
  419. sum(coupon_single_page) coupon_single_page,
  420. sum(redirect_to_shop) redirect_to_shop,
  421. sum(poi_collect) poi_collect,
  422. sum(poi_address_click) poi_address_click,
  423. sum(luban_order_cnt) luban_order_cnt,
  424. sum(luban_order_stat_amount) luban_order_stat_amount,
  425. sum(luban_order_roi) luban_order_roi,
  426. sum(luban_live_enter_cnt) luban_live_enter_cnt,
  427. sum(
  428. live_watch_one_minute_count
  429. ) live_watch_one_minute_count,
  430. sum(luban_live_follow_cnt) luban_live_follow_cnt,
  431. sum(live_fans_club_join_cnt) live_fans_club_join_cnt,
  432. sum(luban_live_comment_cnt) luban_live_comment_cnt,
  433. sum(luban_live_share_cnt) luban_live_share_cnt,
  434. sum(luban_live_gift_cnt) luban_live_gift_cnt,
  435. sum(luban_live_gift_amount) luban_live_gift_amount,
  436. sum(
  437. luban_live_slidecart_click_cnt
  438. ) luban_live_slidecart_click_cnt,
  439. sum(
  440. luban_live_click_product_cnt
  441. ) luban_live_click_product_cnt,
  442. sum(luban_live_pay_order_count) luban_live_pay_order_count,
  443. sum(
  444. luban_live_pay_order_stat_cost
  445. ) luban_live_pay_order_stat_cost,
  446. sum(wechat_login_count) wechat_login_count,
  447. sum(
  448. attribution_wechat_login_30d_count
  449. ) attribution_wechat_login_30d_count,
  450. round(
  451. sum(cost) / sum(wechat_login_count),
  452. 3
  453. ) wechat_login_cost,
  454. round(
  455. sum(cost) / sum(
  456. attribution_wechat_login_30d_count
  457. ),
  458. 3
  459. ) attribution_wechat_login_30d_cost,
  460. sum(wechat_first_pay_count) wechat_first_pay_count,
  461. sum(
  462. attribution_wechat_first_pay_30d_count
  463. ) attribution_wechat_first_pay_30d_count,
  464. round(
  465. sum(cost) / sum(wechat_first_pay_count),
  466. 3
  467. ) wechat_first_pay_cost,
  468. round(
  469. sum(cost) / sum(
  470. attribution_wechat_first_pay_30d_count
  471. ),
  472. 3
  473. ) attribution_wechat_first_pay_30d_cost,
  474. round(
  475. sum(wechat_first_pay_count) / sum(wechat_login_count) * 100,
  476. 3
  477. ) wechat_first_pay_rate,
  478. round(
  479. sum(
  480. attribution_wechat_first_pay_30d_count
  481. ) / sum(
  482. attribution_wechat_login_30d_count
  483. ) * 100,
  484. 3
  485. ) attribution_wechat_first_pay_30d_rate,
  486. sum(wechat_pay_amount) wechat_pay_amount,
  487. sum(
  488. attribution_wechat_pay_30d_amount
  489. ) attribution_wechat_pay_30d_amount,
  490. sum(
  491. attribution_wechat_pay_30d_roi
  492. ) attribution_wechat_pay_30d_roi,
  493. sum(phone_effective) phone_effective,
  494. sum(total_play) total_play,
  495. sum(valid_play) valid_play,
  496. round(
  497. sum(cost) / sum(valid_play),
  498. 3
  499. ) valid_play_cost,
  500. round(
  501. sum(valid_play) / sum(`show`) * 100,
  502. 3
  503. ) valid_play_rate,
  504. sum(play_25_feed_break) play_25_feed_break,
  505. sum(play_50_feed_break) play_50_feed_break,
  506. sum(play_75_feed_break) play_75_feed_break,
  507. sum(play_100_feed_break) play_100_feed_break,
  508. round(
  509. sum(average_play_time_per_play) / {day_count},
  510. 3
  511. ) average_play_time_per_play,
  512. round(
  513. sum(play_over_rate) / {day_count} * 100,
  514. 3
  515. ) play_over_rate,
  516. round(
  517. sum(wifi_play) / sum(total_play) * 100,
  518. 3
  519. ) wifi_play_rate,
  520. sum(wifi_play) wifi_play,
  521. round(sum(play_duration_sum) / {day_count}, 3) play_duration_sum,
  522. sum(
  523. advanced_creative_phone_click
  524. ) advanced_creative_phone_click,
  525. sum(
  526. advanced_creative_counsel_click
  527. ) advanced_creative_counsel_click,
  528. sum(
  529. advanced_creative_form_click
  530. ) advanced_creative_form_click,
  531. sum(
  532. advanced_creative_coupon_addition
  533. ) advanced_creative_coupon_addition,
  534. sum(
  535. advanced_creative_form_submit
  536. ) advanced_creative_form_submit,
  537. sum(card_show) card_show,
  538. sum(`share`) `share`,
  539. sum(`comment`) `comment`,
  540. sum(`like`) `like`,
  541. sum(follow) follow,
  542. sum(home_visited) home_visited,
  543. sum(ies_challenge_click) ies_challenge_click,
  544. sum(ies_music_click) ies_music_click,
  545. sum(location_click) location_click,
  546. sum(message_action) message_action,
  547. sum(click_landing_page) click_landing_page,
  548. sum(click_shopwindow) click_shopwindow,
  549. sum(click_website) click_website,
  550. sum(click_download) click_download,
  551. sum(click_call_dy) click_call_dy,
  552. sum(cpc) cpc,
  553. sum(cpm) cpm,
  554. sum(cpa) cpa,
  555. round(sum(interact_per_cost) / {day_count}, 3) interact_per_cost,
  556. round(sum(convert_show_rate) / {day_count}, 3) convert_show_rate,
  557. round(
  558. sum(round(play_duration_10s)) / sum(total_play) * 100,
  559. 3
  560. ) play_duration_10s_rate,
  561. round(
  562. sum(play_50_feed_break) / sum(total_play) * 100,
  563. 3
  564. ) play_50_feed_break_rate,
  565. round(
  566. sum(play_25_feed_break) / sum(total_play) * 100,
  567. 3
  568. ) play_25_feed_break_rate,
  569. round(
  570. sum(play_duration_5s_rate) / {day_count},
  571. 3
  572. ) play_duration_5s_rate,
  573. round(
  574. sum(play_duration_2s) / sum(total_play) * 100,
  575. 3
  576. ) play_duration_2s_rate,
  577. round(
  578. sum(average_play_progress) / {day_count},
  579. 3
  580. ) average_play_progress,
  581. round(
  582. sum(play_100_feed_break) / sum(total_play) * 100,
  583. 3
  584. ) play_100_feed_break_rate,
  585. round(
  586. sum(play_duration_3s) / sum(total_play) * 100,
  587. 3
  588. ) play_duration_3s_rate,
  589. round(
  590. sum(play_75_feed_break) / sum(total_play) * 100,
  591. 3
  592. ) play_75_feed_break_rate,
  593. sum(play_duration) play_duration,
  594. sum(play_duration_3s) play_duration_3s,
  595. sum(play_duration_2s) play_duration_2s,
  596. sum(play_duration_10s) play_duration_10s,
  597. round(
  598. sum(average_video_play) / {day_count},
  599. 3
  600. ) average_video_play,
  601. sum(avg_rank) avg_rank,
  602. sum(submit_certification_count) submit_certification_count,
  603. sum(approval_count) approval_count,
  604. sum(first_order_count) first_rental_order_count,
  605. sum(first_rental_order_count) first_order_count,
  606. sum(commute_first_pay_count) commute_first_pay_count
  607. FROM media_api.bytedance_material_report_daily zhubiao
  608. WHERE image_mode IN (
  609. 'CREATIVE_IMAGE_MODE_SMALL',
  610. 'CREATIVE_IMAGE_MODE_LARGE',
  611. 'CREATIVE_IMAGE_MODE_LARGE_VERTICAL',
  612. 'CREATIVE_IMAGE_MODE_GROUP',
  613. 'CREATIVE_IMAGE_MODE_GIF',
  614. 'TOUTIAO_SEARCH_AD_IMAGE',
  615. 'SEARCH_AD_SMALL_IMAGE',
  616. 'CREATIVE_IMAGE_MODE_UNION_SPLASH'
  617. )
  618. AND stat_datetime >= date_format(
  619. date_sub({date_time}, INTERVAL {day_count} DAY),
  620. '%Y%m%d'
  621. )
  622. GROUP BY advertiser_id,
  623. material_id,
  624. image_mode,
  625. inventory
  626. ) report
  627. LEFT JOIN (select advertiser_id,signature,material_id,filename,image_url
  628. from `media_api`.bytedance_file_image_get group by advertiser_id,signature,material_id,filename,image_url)
  629. video
  630. ON report.account_id = video.advertiser_id AND report.material_id = video.material_id
  631. LEFT JOIN `jeecg-boot`.ctop_user_allocation cua
  632. ON report.account_id = cua.account_id
  633. LEFT JOIN `jeecg-boot`.ctop_advertiser ca
  634. ON cua.advertiser_id = ca.id
  635. LEFT JOIN `jeecg-boot`.ctop_project cp
  636. ON cua.project_id = cp.id
  637. LEFT JOIN `jeecg-boot`.user_company uc
  638. ON cua.user_id = uc.user_id
  639. LEFT JOIN `jeecg-boot`.ctop_product product
  640. ON cp.product_id = product.id
  641. LEFT JOIN `jeecg-boot`.sys_user su
  642. ON cua.user_id = su.id
  643. """.format(date_time=self.date_time, day_count=self.day_count, project_id=project_id[0])
  644. TidbConn.upsert(conn=self.conn, sql_buff=sql)
  645. self.conn.commit()
  646. except Exception as e:
  647. logging.error(e)
  648. return -1
  649. TidbConn.conn_close(conn=self.conn)
  650. return 0
  651. except Exception as e:
  652. logging.error(e)
  653. return -1
  654. if __name__ == '__main__':
  655. status = AppBytedanceImageReportBusiMonth().taskHandler()
  656. if status == 0:
  657. print("作业执行成功")
  658. exit(0)
  659. else:
  660. print("作业执行失败")
  661. exit(-1)