apscheduler_elab.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # -*- coding: utf-8 -*-
  2. from panda_util import PandaUtil
  3. import time
  4. from report_push import ReportPush
  5. class Config(object):
  6. """
  7. 任务id对应的key
  8. day_push:1
  9. week_push_one:2
  10. week_push_two: 3
  11. """
  12. JOBS = [
  13. {
  14. 'id': 'day_push',
  15. 'func': 'apscheduler_elab:Funcs.day_push',
  16. 'args': '',
  17. 'trigger': 'cron',
  18. 'day_of_week': '*',
  19. 'hour': 8,
  20. 'minute': 45
  21. },
  22. {
  23. 'id': 'week_push_one',
  24. 'func': 'apscheduler_elab:Funcs.week_push_one',
  25. 'args': '',
  26. 'trigger': 'cron',
  27. 'day_of_week': '1',
  28. 'hour': 8,
  29. 'minute': 45
  30. },
  31. {
  32. 'id': 'week_push_two',
  33. 'func': 'apscheduler_elab:Funcs.week_push_two',
  34. 'args': '',
  35. 'trigger': 'cron',
  36. 'day_of_week': '1',
  37. 'hour': 10,
  38. 'minute': 45
  39. }
  40. ]
  41. # 线程池配置
  42. SCHEDULER_EXECUTORS = {
  43. 'default': {'type': 'threadpool', 'max_workers': 20}
  44. }
  45. SCHEDULER_JOB_DEFAULTS = {
  46. 'coalesce': False,
  47. 'max_instances': 3
  48. }
  49. # 调度器开关
  50. SCHEDULER_API_ENABLED = True
  51. pass
  52. class Funcs(object):
  53. @staticmethod
  54. def day_push():
  55. rp = ReportPush('bi_report')
  56. rp.report_push(1)
  57. @staticmethod
  58. def week_push_one():
  59. rp = ReportPush('bi_report')
  60. rp.report_push(2)
  61. @staticmethod
  62. def week_push_two():
  63. rp = ReportPush('bi_report')
  64. rp.report_push(2)
  65. @staticmethod
  66. def minute_push_elab():
  67. pdu = PandaUtil('linshi')
  68. sql = 'select house_id, COUNT(house_id) as number from t_house_image group by house_id limit 5'
  69. file_name = 'pandas_chart_columns2{}.xlsx'.format(time.time())
  70. df_data = pdu.query_data(sql)
  71. print(df_data.size)
  72. pdu.panda_chart([df_data], 1, 'title x', 'title y', file_name)
  73. if __name__ == '__main__':
  74. pass