package com.usky.vpp.job;

import com.usky.vpp.config.VppUnProperties;
import com.usky.vpp.service.VppUnIntegrationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时 Poll UN 拉取事件/反馈
 */
@Component
public class VppUnPollScheduler {

    private static final Logger log = LoggerFactory.getLogger(VppUnPollScheduler.class);

    @Autowired
    private VppUnProperties properties;

    @Autowired
    private VppUnIntegrationService integrationService;

    //@Scheduled(fixedDelayString = "#{${vpp.un.poll-interval-sec:10} * 1000}")
    public void pollUn() {
        if (!properties.isPollActive()) {
            return;
        }
        try {
            integrationService.pollOnce();
        } catch (Exception ex) {
            log.warn("UN Poll 失败: {}", ex.getMessage());
        }
    }
}
