exportJobs.py 1.7 KB

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