import requests
from pprint import pprint
import peizhi
def test():

    from datetime import date
    from datetime import timedelta
    today = date.today()
    format_today = today.strftime("%Y%m%d")
    tomorrow = today + timedelta(days=1)
    format_tomorrow = tomorrow.strftime("%Y%m%d")
    print(format_today)
    print(format_tomorrow)

    days = []
    url = "https://api.apihubs.cn/holiday/get"
    params = {
        "year":2021,
        "size":1000
    }
    result = requests.get(url=url,params=params)
    res = result.json()
    pprint(res)
    list = res.get("data").get("list")
    for i in range(len(list)):
        workday = list[i].get("workday")
        if workday == 2:
            date = list[i].get("date")
            days.append(date)
    message = ""
    if int(format_tomorrow) in days and int(format_today) not in days:
        worker = peizhi.Personnel_list.get(int(format_tomorrow))
        message = worker
        if worker == None:
            message = "还没有分配具体的值班人员请尽快分配"



        # # 钉钉报警
        # dd_url = "https://oapi.dingtalk.com/robot/send?access_token=062ab7f98f47c85e6c200efd21ae5d532e4f1bbfd6782ae1268b9a1f4d3dc7b9"
        # text = "明日开始休息：本次值班人员为：%s  值班人员记得带 电脑，手机， vpn环境" % {message}
        # json_text = {
        #     "msgtype": "text",
        #     "at": {
        #         "atMobiles": [
        #
        #             "all"
        #         ],
        #         # 变为true 就会@所有人
        #         "isAtAll": True
        #     },
        #     "text": {
        #         "content": text
        #     }
        # }
        #
        # requests.post(url=dd_url, json=json_text, verify=False)








if __name__ == '__main__':
    test()