package com.njcn.system.timer.tasks;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.harmonic.api.UploadGwDataFeignClient;
import com.njcn.harmonic.pojo.param.UploadParam;
import com.njcn.system.timer.TimerTaskRunner;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 类的介绍：国网数据每日上送定时任务
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2023/12/15 13:45
 */
@Component
@RequiredArgsConstructor
@Deprecated
public class UploadGwTaskMRunner implements TimerTaskRunner {

    private final UploadGwDataFeignClient uploadGwDataFeignClient;

    @Override
    public void action(String date) {
        UploadParam param = new UploadParam();
        param.setTime(DateUtil.yesterday().toString(DatePattern.NORM_MONTH_PATTERN));
        String code = uploadGwDataFeignClient.uploadPointStatisticalData(param).getCode();
        if(code.equals("A0002")){
            throw new BusinessException("失败");
        }
        //年
        param.setTime(DateUtil.yesterday().toString(DatePattern.NORM_YEAR_PATTERN));
        String code2 = uploadGwDataFeignClient.uploadPointStatisticalData(param).getCode();
        if(code2.equals("A0002")){
            throw new BusinessException("失败");
        }
    }
}
