package com.rongwei.savecheck.controller;

import com.rongwei.rwcommon.base.R;
import com.rongwei.sfcommon.sys.service.impl.ScheduledTasksService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ScheduledTasksController class
 *
 * @author XH
 * @date 2024/08/27
 */
@RestController
@RequestMapping("/scheduled/task")
public class ScheduledTasksController {
    private final Logger log = LoggerFactory.getLogger(this.getClass().getName());

    @Autowired
    private ScheduledTasksService scheduledTasksService;

    /**
     * 隐患任务整改提醒 系统
     * 定时任务 每天8点
     *
     * @param
     * @return
     * @date 2023/12/20 9:55
     * @author shangmi
     */

    @Scheduled(cron = "0 0 8 ? * *")
    @PostMapping("/rectification/system")
    public R rectificationSystem() {
        log.info("隐患跟踪任务整改提现定时任务！");
        scheduledTasksService.rectificationSystem();
        return R.ok();
    }

    /**
     * 隐患任务验证提醒 系统
     * 定时任务 每天8点
     *
     * @param
     * @return
     * @date 2023/12/20 9:55
     * @author shangmi
     */

    @Scheduled(cron = "0 0 8 ? * *")
    @PostMapping("/verify/system")
    public R verifySystem() {
        log.info("隐患跟踪任务整改提醒定时任务！");
        scheduledTasksService.verifySystem();
        return R.ok();
    }

    /**
     * 隐患任务确认提醒 系统
     * 定时任务 每天8点
     *
     * @param
     * @return
     * @date 2023/12/20 9:55
     * @author shangmi
     */

    @Scheduled(cron = "0 0 8 ? * *")
    @PostMapping("/affirm/system")
    public R affirmSystem() {
        log.info("隐患跟踪任务整改提醒定时任务！");
        scheduledTasksService.affirmSystem();
        return R.ok();
    }


    @Scheduled(cron = "0 0 7 ? * WED,FRI")
    @PostMapping("/hidden/danger")
    public R hiddenDangerTak() {
        log.info("点巡检隐患任务提醒");
        scheduledTasksService.hiddenDangerTask();
        return R.ok();
    }

    @Scheduled(cron = "0 0 8 ? * *")
    @PostMapping("/save/check/plan")
    public R createCheckPlanByTemp() {
        log.info("点巡检隐患任务定时生成");
        scheduledTasksService.createCheckPlanByTemp();
        return R.ok();
    }

    @Scheduled(cron = "0 0 0/1 * * ? ")
    @PostMapping("/hazard-investigation")
    public R creatHazardInvestigationTask(){
        log.info("隐患排查任务定时生成");
       return scheduledTasksService.creatHazardInvestigationTask();
    }


    @Scheduled(cron = "0 0 1 ? * *")
    @PostMapping("/qualification-certificate")
    public R qualificationCertificateRemind(){
        log.info("资质证照复审定时提醒");
        return scheduledTasksService.qualificationCertificateRemind();
    }

    @Scheduled(cron = "0 0 1 ? * *")
    @PostMapping("/hidden-danger/warning-status")
    public R updateHiddenDangerWarningStatus(){
        log.info("更新隐患任务预警状态");
        return scheduledTasksService.updateHiddenDangerWarningStatus();
    }
}
