package com.jiayue.insu.incloud.job.permission;

import com.jiayue.insu.incloud.compermisson.QNHLComPermisson;
import com.jiayue.insu.incloud.entity.Station;
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;

/**
 * 清能互联 通讯token Job
 *
 * @author yh
 * @version 1.0
 * @since 2022/5/22 11:29
 */
@Slf4j
public class QNHLPermissonJob implements Job {
    @Autowired
    private QNHLComPermisson qNHLComPermisson;
    @Autowired
    private StationService stationService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        String code = jobExecutionContext.getTrigger().getJobKey().getName();
        // 校验并获取场站信息
        Station station = stationService.checkAndFindStation(code,null);
        if (station == null) {
            log.error("========== 一体化定时任务异常:  场站不存在  {}==========",code);
        }
        qNHLComPermisson.generateKey(station);
    }
}
