package com.njcn.system.timer.tasks;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.njcn.algorithm.pojo.bo.BaseParam;
import com.njcn.algorithm.pojo.liteflow.LiteFlowAlgorithmFeignClient;

import com.njcn.system.timer.TimerTaskRunner;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 类的介绍：变电站算法执行链定时任务
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2023/12/6 9:35
 */
@Component
@RequiredArgsConstructor
public class SubstationTaskRunner implements TimerTaskRunner {

    private final LiteFlowAlgorithmFeignClient liteFlowFeignClient;
    @Override
    public void action(String date) {
        BaseParam baseParam = new BaseParam();
        baseParam.setFullChain(true);
        baseParam.setRepair(false);
        if(StrUtil.isBlank(date)){
            baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN));
        }else {
            baseParam.setDataDate(date);
        }
        liteFlowFeignClient.substationExecutor(baseParam);
    }
}
