package com.fs.framework.manager;

import com.fs.doctor.service.IFsDoctorOnlineService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
@Slf4j
@Component
public class DoctorOnlineStatusScheduler {

//    @Autowired
//    private IFsDoctorOnlineService doctorOnlineService;
//
//    // 每 60 秒执行一次
//    @Scheduled(fixedRate = 60_000)
//    public void updateOfflineDoctors() {
//        //log.warn("医生在线状态兜底任务执行中...");
//        //如果某个医生最后心跳时间早于当前时间 90 秒前，就认为他已离线。
//        LocalDateTime timeout = LocalDateTime.now().minusSeconds(90);
//
//        int updated = doctorOnlineService.setOfflineByTimeout(timeout);
//
//        if (updated > 0) {
//            log.info("自动下线 {} 名医生", updated);
//        }
//    }
}