|
@@ -1,7 +1,12 @@
|
|
|
package com.ruoyi.quartz.service.impl;
|
|
package com.ruoyi.quartz.service.impl;
|
|
|
|
|
|
|
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
+
|
|
|
|
|
+import com.ruoyi.common.annotation.DataSource;
|
|
|
|
|
+import com.ruoyi.common.enums.DataSourceType;
|
|
|
|
|
+import com.ruoyi.common.utils.spring.SpringUtils;
|
|
|
import org.quartz.JobDataMap;
|
|
import org.quartz.JobDataMap;
|
|
|
import org.quartz.JobKey;
|
|
import org.quartz.JobKey;
|
|
|
import org.quartz.Scheduler;
|
|
import org.quartz.Scheduler;
|
|
@@ -23,6 +28,7 @@ import com.ruoyi.quartz.util.ScheduleUtils;
|
|
|
* @author ruoyi
|
|
* @author ruoyi
|
|
|
*/
|
|
*/
|
|
|
@Service
|
|
@Service
|
|
|
|
|
+@DataSource(DataSourceType.SYSTEM)
|
|
|
public class SysJobServiceImpl implements ISysJobService
|
|
public class SysJobServiceImpl implements ISysJobService
|
|
|
{
|
|
{
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -38,13 +44,18 @@ public class SysJobServiceImpl implements ISysJobService
|
|
|
public void init() throws SchedulerException, TaskException
|
|
public void init() throws SchedulerException, TaskException
|
|
|
{
|
|
{
|
|
|
scheduler.clear();
|
|
scheduler.clear();
|
|
|
- List<SysJob> jobList = jobMapper.selectJobAll();
|
|
|
|
|
|
|
+ List<SysJob> jobList = SpringUtils.getBean(ISysJobService.class).selectJobAll();
|
|
|
for (SysJob job : jobList)
|
|
for (SysJob job : jobList)
|
|
|
{
|
|
{
|
|
|
ScheduleUtils.createScheduleJob(scheduler, job);
|
|
ScheduleUtils.createScheduleJob(scheduler, job);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<SysJob> selectJobAll() {
|
|
|
|
|
+ return jobMapper.selectJobAll();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取quartz调度器的计划任务列表
|
|
* 获取quartz调度器的计划任务列表
|
|
|
*
|
|
*
|