package com.casic.missiles; import com.casic.missiles.core.service.IEtlInvokerService; import org.apache.shardingsphere.elasticjob.api.ShardingContext; import org.apache.shardingsphere.elasticjob.simple.job.SimpleJob; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** * @ClassName MyJob * @Description 环卫任务 * @Author lwh * @Date 2021/2/5 11:20 * @Version 1.0 */ @Component public class TestEtlJob implements SimpleJob { @Autowired private IEtlInvokerService etlInvokerService; @Override public void execute(ShardingContext shardingContext) { System.out.println(String.format("%s------Thread ID: %s, 任务总片数: %s, " + "当前分片项: %s,当前参数: %s," + "当前任务名称: %s,当前任务参数: %s," + "当前任务的id: %s", //获取当前线程的id shardingContext.getJobParameter(), Thread.currentThread().getId(), //获取任务总片数 shardingContext.getShardingTotalCount(), //获取当前分片项 shardingContext.getShardingItem(), //获取当前的参数 shardingContext.getShardingParameter(), //获取当前的任务名称 shardingContext.getJobName(), //获取当前任务参数 shardingContext.getJobParameter(), //获取任务的id shardingContext.getTaskId() )); // String fileName = "E:\\project\\casic-opt-monitoring-parent\\casic-web\\etl\\demo\\rest-demo.ktr"; etlInvokerService.invokeKettleTransfer(null, fileName); } }