AppBytedanceCompanyDesignReportBusi.py 28 KB

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