package com.usky.fire.controller.web;


import com.usky.fire.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.sql.SQLOutput;

/**
 * @author JCB
 * @since 2022-08-08
 */
@EnableScheduling
@Component
public class TaskController {
    @Autowired
    private MhPostInspectService mhPostInspectService;

    @Autowired
    private BscEnterpriseScreenService bscEnterpriseScreenService;

    @Autowired
    private BscEnterpriseAutonomyService bscEnterpriseAutonomyService;

    @Autowired
    private BscEnterpriseStreetTownService bscEnterpriseStreetTownService;

    @Autowired
    private BscLawTrendService bscLawTrendService;

    @Autowired
    private DemInspectListService demInspectListService;

    @Autowired
    private DemReportDataService demReportDataService;

    @Autowired
    private PatrolInspectionPlanService patrolInspectionPlanService;

    @Autowired
    private PatrolInspectionPlanSonService patrolInspectionPlanSonService;

    //    @Scheduled(cron = "0/5 * *  * * ?") // 间隔5秒执行
    @Scheduled(cron = "0 0/5 * * * ? ") // 间隔5分钟执行
    public void task() {
        System.out.println(Thread.currentThread().getName() + "定时任务执行中");
        mhPostInspectService.postInspectAnswerRequest();
    }

    //    @Scheduled(cron = "0 0 * * * ? ")//每小时
    @Scheduled(cron = "0 0 1 * * ? ")//每天凌晨1点
    public void task1() {
        System.out.println(Thread.currentThread().getName() + "大屏定时任务执行中");
        bscEnterpriseScreenService.dataSynchro();
    }

    @Scheduled(cron = "0 0 2 * * ? ")//每天凌晨2点
    public void task2() {
        System.out.println(Thread.currentThread().getName() + "企业自主管理(全、街道)大屏定时任务执行中");
        bscEnterpriseAutonomyService.enterpriseAutonomyTask();
        bscEnterpriseStreetTownService.enterpriseStreetTownTask();
        bscLawTrendService.lawEnforcement();
    }

    @Scheduled(cron = "0 0/30 * * * ? ") // 间隔30分钟执行
    public void task3() {
        System.out.println(Thread.currentThread().getName() + "电子督察单定时任务执行中");
        demInspectListService.demInspectAutoTask();
    }

    @Scheduled(cron = "0 0 1 1 * ?")//每月1号凌晨1点
//    @Scheduled(cron = "0 0/5 * * * ? ") // 间隔5分钟执行
    public void task4() {
        System.out.println(Thread.currentThread().getName() + "消防报告生成定时任务执行中");
        demReportDataService.regularReportData();
    }

//    @Scheduled(cron = "0 0 23 * * ? ")//每天23点
//    public void task5(){
//        System.out.println(Thread.currentThread().getName() + "巡检计划分批次创建执行中");
//        patrolInspectionPlanService.addPatrolInspectionPlanSon();
//    }

//    @Scheduled(cron = "0 5 * * * ?") //每个小时第五分钟执行
//    public void task6(){
//        System.out.println(Thread.currentThread().getName() + "巡检漏检数据同步到巡检异常记录表");
//        patrolInspectionPlanSonService.addPatrolInspectionAbnormalData();
//    }

}

