package com.hfkj.schedule;

import com.hfkj.channel.gas.newlink.NewLinkGasService;
import com.hfkj.channel.gas.shell.CqShellPetroleumGasService;
import com.hfkj.service.gas.BsGasOilPriceWeekService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.time.LocalDate;

/**
 * 油价任务
 * @className: GasSchedule
 * @author: HuRui
 * @date: 2024/7/30
 **/
@Component
public class GasOilPriceSchedule {

    @Resource
    private BsGasOilPriceWeekService gasOilPriceWeekService;

    @Scheduled(cron = "0 0 0 * * ?")   // 每日凌晨00:00:00 执行一次
    public void newLinkGasSchedule() {
        try {
            // 更新价格
            gasOilPriceWeekService.updatePriceWeek(LocalDate.now().getDayOfWeek().getValue());

        } catch (Exception e) {
            System.out.println("更新价格失败！！！");
        }
    }
}
