|
@@ -1,14 +1,13 @@
|
|
package com.ruoyi.quartz.util;
|
|
package com.ruoyi.quartz.util;
|
|
|
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
-import java.util.concurrent.ExecutorService;
|
|
|
|
-import java.util.concurrent.Executors;
|
|
|
|
import java.util.concurrent.Future;
|
|
import java.util.concurrent.Future;
|
|
import org.quartz.DisallowConcurrentExecution;
|
|
import org.quartz.DisallowConcurrentExecution;
|
|
import org.quartz.JobExecutionContext;
|
|
import org.quartz.JobExecutionContext;
|
|
import org.quartz.JobExecutionException;
|
|
import org.quartz.JobExecutionException;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
import org.springframework.scheduling.quartz.QuartzJobBean;
|
|
import org.springframework.scheduling.quartz.QuartzJobBean;
|
|
import com.ruoyi.common.constant.Constants;
|
|
import com.ruoyi.common.constant.Constants;
|
|
import com.ruoyi.common.constant.ScheduleConstants;
|
|
import com.ruoyi.common.constant.ScheduleConstants;
|
|
@@ -29,7 +28,7 @@ public class ScheduleJob extends QuartzJobBean
|
|
{
|
|
{
|
|
private static final Logger log = LoggerFactory.getLogger(ScheduleJob.class);
|
|
private static final Logger log = LoggerFactory.getLogger(ScheduleJob.class);
|
|
|
|
|
|
- private ExecutorService service = Executors.newSingleThreadExecutor();
|
|
|
|
|
|
+ private ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) SpringContextUtil.getBean("publicThreadPool");
|
|
|
|
|
|
private final static ISysJobLogService jobLogService = (ISysJobLogService) SpringContextUtil.getBean("sysJobLogServiceImpl");
|
|
private final static ISysJobLogService jobLogService = (ISysJobLogService) SpringContextUtil.getBean("sysJobLogServiceImpl");
|
|
|
|
|
|
@@ -53,7 +52,7 @@ public class ScheduleJob extends QuartzJobBean
|
|
// 执行任务
|
|
// 执行任务
|
|
log.info("任务开始执行 - 名称:{} 方法:{}", job.getJobName(), job.getMethodName());
|
|
log.info("任务开始执行 - 名称:{} 方法:{}", job.getJobName(), job.getMethodName());
|
|
ScheduleRunnable task = new ScheduleRunnable(job.getJobName(), job.getMethodName(), job.getMethodParams());
|
|
ScheduleRunnable task = new ScheduleRunnable(job.getJobName(), job.getMethodName(), job.getMethodParams());
|
|
- Future<?> future = service.submit(task);
|
|
|
|
|
|
+ Future<?> future = executor.submit(task);
|
|
future.get();
|
|
future.get();
|
|
long times = System.currentTimeMillis() - startTime;
|
|
long times = System.currentTimeMillis() - startTime;
|
|
// 任务状态 0:成功 1:失败
|
|
// 任务状态 0:成功 1:失败
|