package com.njcn.executor.handler;

import com.njcn.common.pojo.constant.BizParamConstant;
import com.njcn.executor.utils.CommonExecutorUtils;
import com.njcn.prepare.harmonic.api.newalgorithm.ROperatingIndexFeignClient;
import com.njcn.prepare.harmonic.pojo.param.PrimaryGridParam;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @Description: 单位监测指标数据质量
 * @return: null
 * @Author: wr
 * @Date: 2023/9/26 13:41
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class ROperatingIndexJob {

    private final ROperatingIndexFeignClient rOperatingIndexFeignClient;

    @XxlJob("rOperatingIndexDay")
    public void rOperatingMonitorDay(){
        log.info(LocalDateTime.now()+"单位监测指标数据质量_日表(主网，数据中心)------------------------");
        PrimaryGridParam primaryGridParam=new PrimaryGridParam();
        primaryGridParam.setDataSource(1);
        primaryGridParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_DAY));
        primaryGridParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_DAY));
        CommonExecutorUtils.commDefineDateObj(BizParamConstant.STAT_BIZ_DAY,primaryGridParam);
        rOperatingIndexFeignClient.primaryGridDataHanlder(primaryGridParam);
    }

    @XxlJob("rOperatingIndexMonth")
    public void rOperatingIndexMonth(){
        log.info(LocalDateTime.now()+"单位监测指标数据质量_月表(主网，数据中心)------------------------");
        PrimaryGridParam primaryGridParam=new PrimaryGridParam();
        primaryGridParam.setDataSource(1);
        primaryGridParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_MONTH));
        primaryGridParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_MONTH));
        CommonExecutorUtils.commDefineDateObj(BizParamConstant.STAT_BIZ_MONTH,primaryGridParam);
        rOperatingIndexFeignClient.primaryGridDataHanlder(primaryGridParam);
    }

    @XxlJob("rOperatingIndexQuarter")
    public void rOperatingIndexQuarter(){
        log.info(LocalDateTime.now()+"单位监测指标数据质量_季表(主网，数据中心)------------------------");
        PrimaryGridParam primaryGridParam=new PrimaryGridParam();
        primaryGridParam.setDataSource(1);
        primaryGridParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_QUARTER));
        primaryGridParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_QUARTER));
        CommonExecutorUtils.commDefineDateObj(BizParamConstant.STAT_BIZ_QUARTER,primaryGridParam);
        rOperatingIndexFeignClient.primaryGridDataHanlder(primaryGridParam);
    }

    @XxlJob("rOperatingIndexYear")
    public void rOperatingIndexYear(){
        log.info(LocalDateTime.now()+"单位监测指标数据质量_月表(主网，数据中心)------------------------");
        PrimaryGridParam primaryGridParam=new PrimaryGridParam();
        primaryGridParam.setDataSource(1);
        primaryGridParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_YEAR));
        primaryGridParam.setDataDate(CommonExecutorUtils.prepareTimeDeal(BizParamConstant.STAT_BIZ_YEAR));
        CommonExecutorUtils.commDefineDateObj(BizParamConstant.STAT_BIZ_YEAR,primaryGridParam);
        rOperatingIndexFeignClient.primaryGridDataHanlder(primaryGridParam);
    }

}
