apscheduler_elab.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # -*- coding: utf-8 -*-
  2. from panda_util import PandaUtil
  3. import time
  4. from email_util import EmailUtil
  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': 9
  20. },
  21. {
  22. 'id': 'week_push_one',
  23. 'func': 'apscheduler_elab:Funcs.week_push_one',
  24. 'args': '',
  25. 'trigger': 'cron',
  26. 'day_of_week': '1',
  27. 'hour': 8,
  28. 'minute': 50
  29. },
  30. {
  31. 'id': 'week_push_two',
  32. 'func': 'apscheduler_elab:Funcs.week_push_two',
  33. 'args': '',
  34. 'trigger': 'cron',
  35. 'day_of_week': '1',
  36. 'hour': 10,
  37. 'minute': 50
  38. }
  39. ]
  40. # 线程池配置
  41. SCHEDULER_EXECUTORS = {
  42. 'default': {'type': 'threadpool', 'max_workers': 20}
  43. }
  44. SCHEDULER_JOB_DEFAULTS = {
  45. 'coalesce': False,
  46. 'max_instances': 3
  47. }
  48. # 调度器开关
  49. SCHEDULER_API_ENABLED = True
  50. pass
  51. class Funcs(object):
  52. @staticmethod
  53. def day_push():
  54. print(time.time())
  55. @staticmethod
  56. def week_push_one():
  57. print(time.time())
  58. @staticmethod
  59. def week_push_two():
  60. print(time.time())
  61. @staticmethod
  62. def minute_push_elab():
  63. pdu = PandaUtil('linshi')
  64. sql = 'select house_id, COUNT(house_id) as number from t_house_image group by house_id limit 5'
  65. file_name = 'pandas_chart_columns2{}.xlsx'.format(time.time())
  66. df_data = pdu.query_data(sql)
  67. print(df_data.size)
  68. pdu.panda_chart([df_data], 1, 'title x', 'title y', file_name)
  69. send_email = EmailUtil()
  70. send_email.send_mail(mail_excel=file_name, content='elab数据报表推送服务')
  71. if __name__ == '__main__':
  72. pass