package com.mosty.qwzx.task;

import com.mosty.base.model.entity.qwzx.TbQwZbbb;
import com.mosty.qwzx.service.TbQwXfbbService;
import com.mosty.qwzx.service.TbQwXfpbService;
import com.mosty.qwzx.service.TbQwZbbbService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author dw
 * @since 2022/9/28
 * 每5分钟查询报备(包含巡防报备和值班报备)信息，
 * 如果时间到了，结束报备
 **/
@Slf4j
@Component
@AllArgsConstructor
public class TbQwJsbbTask {

    private final TbQwXfbbService tbQwXfbbService;
    private final TbQwZbbbService tbQwZbbbService;

    @Scheduled(cron = "0 */10 * * * ?")
    public void run() {
        // 结束巡防报备
        this.tbQwXfbbService.authJsbb();
        // 结束值班报备
        this.tbQwZbbbService.authJsbb();
        // 删除报备
        this.tbQwXfbbService.delRedisXfwz();
    }

    @Scheduled(cron = " 0 0 0 ? * 1 ")
    public void authJsbbTs() {
        // 结束特殊巡防报备
        this.tbQwXfbbService.authJsbbTs();
    }
}
