AppBytedanceCompanyDesignReportBusiMonth.py 28 KB

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