package com.njcn.system.timer.tasks;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.StrUtil;
import com.njcn.algorithm.pojo.bo.BaseParam;
import com.njcn.algorithm.pojo.liteflow.LiteFlowAlgorithmFeignClient;
import com.njcn.dataProcess.api.DataRecallFeignClient;
import com.njcn.message.message.RecallMessage;
import com.njcn.system.timer.TimerTaskRunner;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

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

    private final DataRecallFeignClient dataRecallFeignClient;

    @Override
    public void action(String date) {
        RecallMessage baseParam = new RecallMessage();

        if(StrUtil.isBlank(date)){
            baseParam.setReCallStartTime(LocalDate.now().minusDays(1));
            baseParam.setReCallEndTime(LocalDate.now().minusDays(1));
        }else {
            LocalDate localDate = LocalDateTimeUtil.parseDate(date,DatePattern.NORM_DATE_FORMATTER);
            baseParam.setReCallStartTime(localDate);
            baseParam.setReCallEndTime(localDate);
        }
        dataRecallFeignClient.recall(baseParam);
    }


}
