package com.aiotagro.cattletrade.job;

import com.aiotagro.cattletrade.business.service.DeliveryYingyanSyncService;
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;

/**
 * 百度鹰眼轨迹同步任务
 */
@Component
public class BaiduYingyanSyncJob {

    private static final Logger logger = LoggerFactory.getLogger(BaiduYingyanSyncJob.class);

    @Autowired
    private DeliveryYingyanSyncService deliveryYingyanSyncService;

    /**
     * 每两分钟同步一次轨迹
     */
    @Scheduled(initialDelay = 30_000, fixedDelay = 120_000)
    public void syncDeliveryTrack() {
        try {
            logger.debug("开始执行运单鹰眼轨迹同步任务");
            deliveryYingyanSyncService.syncActiveDeliveries();
        } catch (Exception e) {
            logger.error("运单鹰眼轨迹同步任务执行失败", e);
        }
    }
}

