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.process.api.ThsSuperviseFeignClient;
import com.njcn.process.enums.AlarmTypeEnum;
import com.njcn.process.enums.InitTypeEnum;
import com.njcn.process.pojo.param.SuperviseParam;
import com.njcn.system.timer.TimerTaskRunner;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * pqs
 * 技术监督每日任务
 * @author cdf
 * @date 2024/3/18
 */
@Component
@RequiredArgsConstructor
public class ThsSuperviseTask  implements TimerTaskRunner {

    private final ThsSuperviseFeignClient thsSuperviseFeignClient;

    @Override
    public void action(String date) {


        if(StrUtil.isBlank(date)){
            date = DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN);
        }

        SuperviseParam superviseParam = new SuperviseParam();
        superviseParam.setReDate(date);
        superviseParam.setInitType(InitTypeEnum.AUTO.getCode());
        superviseParam.setType(AlarmTypeEnum.EARLY_WARN.getCode());
        thsSuperviseFeignClient.initSupervise(superviseParam);


        superviseParam.setInitType(InitTypeEnum.MANUAL.getCode());
        superviseParam.setType(AlarmTypeEnum.REPORT_WARN.getCode());
        thsSuperviseFeignClient.initSupervise(superviseParam);

    }
}
