package com.usky.cdi.service.util;

import com.usky.cdi.service.impl.AlarmDataSyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 设备数据同步组件（包含定时任务）
 */
@Slf4j
@Component
public class DeviceAlarmDataSyncService {

    private final AlarmDataSyncService alarmDataSyncService;

    @Autowired
    public DeviceAlarmDataSyncService(AlarmDataSyncService alarmDataSyncService) {
        this.alarmDataSyncService = alarmDataSyncService;
    }

    /**
     * 定时任务：定期执行设备数据同步上报
     * fixedDelay：任务执行完成后固定延迟29分钟执行下一次
     * initialDelay：初始化后立即执行第一次任务
     */
    // @Scheduled(fixedDelay = 1 * 60 * 1000, initialDelay = 0)
    // public void scheduledDeviceDataSync() {
    //     Integer tenantId = 1205;
    //     Long engineeringId = 3101070011L;
    //     String username = "3101070011";
    //     String password = "5RqhJ7VG";
    //     log.info("开始执行桃浦象屿人防设备数据同步定时任务，租户ID：{}，工程ID：{}", tenantId, engineeringId);
    //
    //     try {
    //         alarmDataSyncService.synchronizeAlarmData(tenantId, engineeringId, username, password, "peacetime");
    //     } catch (Exception e) {
    //         log.error("定时任务执行设备数据同步失败：{}", e.getMessage(), e);
    //     }
    // }
}