package com.njzscloud.supervisory.dispose.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.njzscloud.common.sichen.support.Task;
import com.njzscloud.supervisory.dispose.contant.TimeOutStatus;
import com.njzscloud.supervisory.dispose.pojo.DisposeRecordEntity;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class TaskService {

    private final DisposeRecordService disposeRecordService;

    @Task(period = 60)
    public void earlyWarning() {
        log.info("超时警告任务执行开始");
        boolean update = disposeRecordService.update(Wrappers.<DisposeRecordEntity>update()
                .set("time_out_status", TimeOutStatus.YiChaoShi)
                .leSql("create_time", "DATE_SUB(NOW(), INTERVAL 12 HOUR)")
                .eq("time_out_status", TimeOutStatus.WeiChaoShi)
                .eq("deleted", 0)
        );
        log.info("超时警告任务执行结束：{}", update);
    }
}
