package com.jiayue.insu.incloud.job.data.push;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.jiayue.insu.incloud.constants.CommonStant;
import com.jiayue.insu.incloud.constants.enums.QNHLEnum;
import com.jiayue.insu.incloud.entity.Record;
import com.jiayue.insu.incloud.entity.Station;
import com.jiayue.insu.incloud.pushdata.PushDataForQNHL;
import com.jiayue.insu.incloud.service.RecordService;
import com.jiayue.insu.incloud.service.StationService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDateTime;

/**
 * 清能推送原始短期数据定时任务
 *
 * @author yh
 * @version 1.0
 * @since 2022/5/22 11:29
 */
@Slf4j
public class QNHLPushInitDqDataJob implements Job {

    @Autowired
    private PushDataForQNHL pushDataForQNHL;
    @Autowired
    private StationService stationService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        String code = jobExecutionContext.getTrigger().getJobKey().getName();
        // 校验并获取场站信息
        Station station = stationService.checkAndFindStation(code,CommonStant.RECORD_TYPE_PUSH_INIT);
        //没有成功记录进行业务
        if (station != null) {
            pushDataForQNHL.pushDQAndNWPData(station);
        }else{
            log.error("========== 一体化定时任务异常:  场站信息为空  {}==========",code);
        }
    }
}
