AppBytedanceCompanyDesignReportBusi.py 28 KB

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