package com.njcn.system.timer.tasks.hbPushGw;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.njcn.harmonic.api.UploadGwDataFeignClient;
import com.njcn.harmonic.pojo.param.UploadDataParam;
import com.njcn.system.timer.TimerTaskRunner;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 用于pms往国网推送公共连接点数据定时任务
 */
@Component
@RequiredArgsConstructor
public class UploadGwCommPointRunner implements TimerTaskRunner {

    private final UploadGwDataFeignClient uploadGwDataFeignClient;

    @Override
    public void action(String date) {
        UploadDataParam uploadDataParam = new UploadDataParam();
        if(StrUtil.isBlank(date)){
            String dateDeal = DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN);
            uploadDataParam.setSearchBeginTime(dateDeal);
        }else {
            uploadDataParam.setSearchBeginTime(date);
        }
        uploadGwDataFeignClient.upGwCommPoint(uploadDataParam);
    }
}
