# -*- coding: utf-8 -*-
from report_push import ReportPush
from jianye_report import JianYeReport


class Config(object):
    """
        任务id对应的key
        day_push：1
        week_push_one：2
        week_push_two： 3
        day_work_two: 4
        day_work_three: 4
        day_work_four: 5
    """
    jianye__house_hour = 6
    jianye_house_minute = 30
    jianye_brand_hour = 6
    jianye_brand_minute = 30

    # SECRET_KEY = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'

    JSON_AS_ASCII = False

    JOBS = [
        {
            'id': 'day_push',
            'func': 'apscheduler_elab:Funcs.day_push',
            'args': '',
            'trigger': 'cron',
            'day_of_week': '*',
            'hour': 8,
            'minute': 45
        },
        {
            'id': 'week_push_one',
            'func': 'apscheduler_elab:Funcs.week_push_one',
            'args': '',
            'trigger': 'cron',
            'day_of_week': 'mon',
            'hour': 9,
            'minute': 50
        },
        {
               'id': 'week_push_am_9',
               'func': 'apscheduler_elab:Funcs.week_push_am_9',
               'args': '',
               'trigger': 'cron',
               'day_of_week': 'mon',
               'hour': 8,
               'minute': 50
        },
        {
            'id': 'week_push_two',
            'func': 'apscheduler_elab:Funcs.week_push_two',
            'args': '',
            'trigger': 'cron',
            'day_of_week': 'mon',
            'hour': 10,
            'minute': 50
        },
        {
            'id': 'day_work_two',
            'func': 'apscheduler_elab:Funcs.day_work_two',
            'args': '',
            'trigger': 'cron',
            'day_of_week': '*',
            'hour': 8,
            'minute': 30
        },
        {
            'id': 'day_work_three',
            'func': 'apscheduler_elab:Funcs.day_work_three',
            'args': '',
            'trigger': 'cron',
            'day_of_week': '*',
            'hour': 8,
            'minute': 30
        }
        ,
        {
            'id': 'day_work_5',
            'func': 'apscheduler_elab:Funcs.day_work_5',
            'args': '',
            'trigger': 'cron',
            'day_of_week': '*',
            'hour': jianye__house_hour,
            'minute': jianye_house_minute
        },
        {
            'id': 'day_work_6',
            'func': 'apscheduler_elab:Funcs.day_work_6',
            'args': '',
            'trigger': 'cron',
            'day_of_week': '*',
            'hour': jianye__house_hour,
            'minute': jianye_house_minute
        },
        {
            'id': 'day_work_7',
            'func': 'apscheduler_elab:Funcs.day_work_7',
            'args': '',
            'trigger': 'cron',
            'day_of_week': '*',
            'hour': jianye__house_hour,
            'minute': jianye_house_minute
        },
        {
            'id': 'day_work_8',
            'func': 'apscheduler_elab:Funcs.day_work_8',
            'args': '',
            'trigger': 'cron',
            'day_of_week': '*',
            'hour': jianye__house_hour,
            'minute': jianye_house_minute
        },
        {
            'id': 'day_work_9',
            'func': 'apscheduler_elab:Funcs.day_work_9',
            'args': '',
            'trigger': 'cron',
            'day_of_week': '*',
            'hour': jianye__house_hour,
            'minute': jianye_house_minute
        },
        {
            'id': 'day_work_10',
            'func': 'apscheduler_elab:Funcs.day_work_10',
            'args': '',
            'trigger': 'cron',
            'day_of_week': '*',
            'hour': jianye__house_hour,
            'minute': jianye_house_minute
        },
        {
            'id': 'day_work_11',
            'func': 'apscheduler_elab:Funcs.day_work_11',
            'args': '',
            'trigger': 'cron',
            'day_of_week': '*',
            'hour': jianye__house_hour,
            'minute': jianye_house_minute
        },
        {
            'id': 'day_work_12',
            'func': 'apscheduler_elab:Funcs.day_work_12',
            'args': '',
            'trigger': 'cron',
            'day_of_week': '*',
            'hour': jianye_brand_hour,
            'minute': jianye_brand_minute
        }
    ]

    # 线程池配置
    SCHEDULER_EXECUTORS = {
        'default': {'type': 'threadpool', 'max_workers': 20}
    }

    SCHEDULER_JOB_DEFAULTS = {
        'coalesce': False,
        'max_instances': 5
    }

    # 调度器开关
    SCHEDULER_API_ENABLED = True
    pass


class Funcs(object):
    @staticmethod
    def day_push():
        rp = ReportPush('bi_report')
        rp.report_push(1)

    @staticmethod
    def week_push_one():
        rp = ReportPush('bi_report')
        rp.report_push(2)

    @staticmethod
    def week_push_am_9():
        rp = ReportPush('bi_report')
        rp.report_push(21)

    @staticmethod
    def week_push_two():
        rp = ReportPush('bi_report')
        rp.report_push(3)

    @staticmethod
    def day_work_two():
        # rp = ReportPush('bi_report')
        # rp.report_push(4)
        print("run。。。")

    @staticmethod
    def day_work_three():
        # rp = ReportPush('bi_report')
        # rp.report_push_test(4)
        pass

    @staticmethod
    def day_work_5():
        jianye = JianYeReport()
        jianye.send_mail_to_customer(5)

    @staticmethod
    def day_work_6():
        jianye = JianYeReport()
        jianye.send_mail_to_customer(6)

    @staticmethod
    def day_work_7():
        jianye = JianYeReport()
        jianye.send_mail_to_customer(7)

    @staticmethod
    def day_work_8():
        jianye = JianYeReport()
        jianye.send_mail_to_customer(8)

    @staticmethod
    def day_work_9():
        jianye = JianYeReport()
        jianye.send_mail_to_customer(9)

    @staticmethod
    def day_work_10():
        jianye = JianYeReport()
        jianye.send_mail_to_customer(10)

    @staticmethod
    def day_work_11():
        jianye = JianYeReport()
        jianye.send_mail_to_customer(11)

    @staticmethod
    def day_work_12():
        jianye = JianYeReport()
        jianye.send_mail_to_customer(12)

    @staticmethod
    def minute_push_elab():
        # pdu = PandaUtil('linshi')
        # sql = 'select house_id, COUNT(house_id) as number from t_house_image group by house_id limit 5'
        # file_name = 'pandas_chart_columns2{}.xlsx'.format(time.time())
        # df_data = pdu.query_data(sql)
        # print(df_data.size)
        # pdu.panda_chart([df_data], 1, 'title x', 'title y', file_name)
        print('wwwww')


if __name__ == '__main__':
    pass
