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 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
 */
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();
        String[] split = code.split("-");
        if(split!=null && split.length>0){
            String stationCode = split[0];
            Station station = stationService.findByStationCode(stationCode);
            qNHLComPermisson.generateKey(station);
        }


    }
}
