exportJobs.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #coding:utf8
  2. import sys
  3. import os
  4. sys.path.append(os.path.join(os.path.dirname(__file__),".."))
  5. from utils.Utils import sendEmail,getCurrent_date
  6. import datetime
  7. import time
  8. from export.exportDocument import exportDocument_medicine,list_df_columns
  9. import pandas as pd
  10. from apscheduler.schedulers.blocking import BlockingScheduler
  11. def export_medicine_friday():
  12. current_date = getCurrent_date("%Y-%m-%d")
  13. start_time = time.strftime("%Y-%m-%d",time.localtime(time.mktime(time.localtime())-6*24*60*60))
  14. if current_date<="2022-04-25":
  15. if datetime.datetime.now().weekday()==4:
  16. df_data = exportDocument_medicine(start_time,current_date)
  17. df = pd.DataFrame(df_data)
  18. filename = os.path.dirname(__file__)+"/data/%s年%s至%s医疗数据导出.xlsx"%(start_time[:-4],start_time,current_date)
  19. df.to_excel(filename,columns=['公告标题', '公告类别', '省份', '城市', '发布时间', '项目编号', '招标单位', '招标联系人', '招标联系人电话', '代理单位', '代理联系人', '代理联系人电话', '比地招标公告地址', '中标单位', '中标金额', '招标金额', '中标单位联系人', '中标单位联系电话'])
  20. host = "smtp.exmail.qq.com"
  21. username = "vip@bidizhaobiao.com"
  22. password = "Biaoxun66-"
  23. receivers = ["1985262186@qq.com","1175730271@qq.com","1265797328@qq.com","1289358902@qq.com"]
  24. attachs = [filename]
  25. sendEmail(host,username,password,receivers,attachs=attachs)
  26. def job_medicine_friday():
  27. _scheduler = BlockingScheduler()
  28. _scheduler.add_job(export_medicine_friday,"cron",day_of_week='fri',hour=18)
  29. _scheduler.start()
  30. if __name__=="__main__":
  31. job_medicine_friday()