com.ruoyi.quartz.util.ScheduleUtils Java Examples

The following examples show how to use com.ruoyi.quartz.util.ScheduleUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SysJobServiceImpl.java    From ruoyiplus with MIT License 6 votes vote down vote up
/**
 * 项目启动时,初始化定时器
 */
@PostConstruct
public void init()
{
    List<SysJob> jobList = jobMapper.selectJobAll();
    for (SysJob job : jobList)
    {
        CronTrigger cronTrigger = ScheduleUtils.getCronTrigger(scheduler, job.getJobId());
        // 如果不存在,则创建
        if (cronTrigger == null)
        {
            ScheduleUtils.createScheduleJob(scheduler, job);
        }
        else
        {
            ScheduleUtils.updateScheduleJob(scheduler, job);
        }
    }
}
 
Example #2
Source File: SysJobServiceImpl.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 恢复任务
 * 
 * @param job 调度信息
 */
@Override
@Transactional
public int resumeJob(SysJob job) throws SchedulerException
{
    Long jobId = job.getJobId();
    String jobGroup = job.getJobGroup();
    job.setStatus(ScheduleConstants.Status.NORMAL.getValue());
    int rows = jobMapper.updateJob(job);
    if (rows > 0)
    {
        scheduler.resumeJob(ScheduleUtils.getJobKey(jobId, jobGroup));
    }
    return rows;
}
 
Example #3
Source File: SysJobServiceImpl.java    From RuoYi with Apache License 2.0 5 votes vote down vote up
/**
 * 删除任务后,所对应的trigger也将被删除
 *
 * @param job 调度信息
 */
@Override
public int deleteJob(SysJob job) throws SchedulerException{
    int rows = jobMapper.deleteJobById(job.getJobId());
    if (rows > 0) {
        ScheduleUtils.deleteScheduleJob(scheduler, job.getJobId());
    }
    return rows;
}
 
Example #4
Source File: SysJobServiceImpl.java    From RuoYi with Apache License 2.0 5 votes vote down vote up
/**
 * 恢复任务
 *
 * @param job 调度信息
 */
@Override
public int resumeJob(SysJob job) throws SchedulerException{
    job.setStatus(ScheduleConstants.Status.NORMAL.getValue());
    int rows = jobMapper.updateJob(job);
    if (rows > 0) {
        ScheduleUtils.resumeJob(scheduler, job.getJobId());
    }
    return rows;
}
 
Example #5
Source File: SysJobServiceImpl.java    From RuoYi with Apache License 2.0 5 votes vote down vote up
/**
 * 暂停任务
 *
 * @param job 调度信息
 */
@Override
public int pauseJob(SysJob job) throws SchedulerException{
    job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
    int rows = jobMapper.updateJob(job);
    if (rows > 0) {
        ScheduleUtils.pauseJob(scheduler, job.getJobId());
    }
    return rows;
}
 
Example #6
Source File: SysJobServiceImpl.java    From RuoYi with Apache License 2.0 5 votes vote down vote up
/**
 * 项目启动时,初始化定时器
 */
@PostConstruct
public void init() throws SchedulerException, TaskException {
    List<SysJob> jobList = jobMapper.selectJobAll();
    for (SysJob sysJob : jobList){
        ScheduleUtils.updateScheduleJob(scheduler, sysJob);
    }
}
 
Example #7
Source File: SysJobServiceImpl.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 更新任务的时间表达式
 * 
 * @param job 调度信息
 */
@Override
public int updateJobCron(SysJob job)
{
    int rows = jobMapper.updateJob(job);
    if (rows > 0)
    {
        ScheduleUtils.updateScheduleJob(scheduler, job);
    }
    return rows;
}
 
Example #8
Source File: SysJobServiceImpl.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 新增任务
 * 
 * @param job 调度信息 调度信息
 */
@Override
public int insertJobCron(SysJob job)
{
    job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
    int rows = jobMapper.insertJob(job);
    if (rows > 0)
    {
        ScheduleUtils.createScheduleJob(scheduler, job);
    }
    return rows;
}
 
Example #9
Source File: SysJobServiceImpl.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 删除任务后,所对应的trigger也将被删除
 * 
 * @param job 调度信息
 */
@Override
public int deleteJob(SysJob job)
{
    int rows = jobMapper.deleteJobById(job.getJobId());
    if (rows > 0)
    {
        ScheduleUtils.deleteScheduleJob(scheduler, job.getJobId());
    }
    return rows;
}
 
Example #10
Source File: SysJobServiceImpl.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 恢复任务
 * 
 * @param job 调度信息
 */
@Override
public int resumeJob(SysJob job)
{
    job.setStatus(ScheduleConstants.Status.NORMAL.getValue());
    int rows = jobMapper.updateJob(job);
    if (rows > 0)
    {
        ScheduleUtils.resumeJob(scheduler, job.getJobId());
    }
    return rows;
}
 
Example #11
Source File: SysJobServiceImpl.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 暂停任务
 * 
 * @param job 调度信息
 */
@Override
public int pauseJob(SysJob job)
{
    job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
    int rows = jobMapper.updateJob(job);
    if (rows > 0)
    {
        ScheduleUtils.pauseJob(scheduler, job.getJobId());
    }
    return rows;
}
 
Example #12
Source File: SysJobServiceImpl.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 更新任务
 * 
 * @param job 任务对象
 * @param jobGroup 任务组名
 */
public void updateSchedulerJob(SysJob job, String jobGroup) throws SchedulerException, TaskException
{
    Long jobId = job.getJobId();
    // 判断是否存在
    JobKey jobKey = ScheduleUtils.getJobKey(jobId, jobGroup);
    if (scheduler.checkExists(jobKey))
    {
        // 防止创建时存在数据问题 先移除,然后在执行创建操作
        scheduler.deleteJob(jobKey);
    }
    ScheduleUtils.createScheduleJob(scheduler, job);
}
 
Example #13
Source File: SysJobServiceImpl.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 新增任务
 * 
 * @param job 调度信息 调度信息
 */
@Override
@Transactional
public int insertJob(SysJob job) throws SchedulerException, TaskException
{
    job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
    int rows = jobMapper.insertJob(job);
    if (rows > 0)
    {
        ScheduleUtils.createScheduleJob(scheduler, job);
    }
    return rows;
}
 
Example #14
Source File: SysJobServiceImpl.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 立即运行任务
 * 
 * @param job 调度信息
 */
@Override
@Transactional
public void run(SysJob job) throws SchedulerException
{
    Long jobId = job.getJobId();
    String jobGroup = job.getJobGroup();
    SysJob properties = selectJobById(job.getJobId());
    // 参数
    JobDataMap dataMap = new JobDataMap();
    dataMap.put(ScheduleConstants.TASK_PROPERTIES, properties);
    scheduler.triggerJob(ScheduleUtils.getJobKey(jobId, jobGroup), dataMap);
}
 
Example #15
Source File: SysJobServiceImpl.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 删除任务后,所对应的trigger也将被删除
 * 
 * @param job 调度信息
 */
@Override
@Transactional
public int deleteJob(SysJob job) throws SchedulerException
{
    Long jobId = job.getJobId();
    String jobGroup = job.getJobGroup();
    int rows = jobMapper.deleteJobById(jobId);
    if (rows > 0)
    {
        scheduler.deleteJob(ScheduleUtils.getJobKey(jobId, jobGroup));
    }
    return rows;
}
 
Example #16
Source File: SysJobServiceImpl.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 暂停任务
 * 
 * @param job 调度信息
 */
@Override
@Transactional
public int pauseJob(SysJob job) throws SchedulerException
{
    Long jobId = job.getJobId();
    String jobGroup = job.getJobGroup();
    job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
    int rows = jobMapper.updateJob(job);
    if (rows > 0)
    {
        scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup));
    }
    return rows;
}
 
Example #17
Source File: SysJobServiceImpl.java    From ruoyiplus with MIT License 4 votes vote down vote up
/**
 * 立即运行任务
 * 
 * @param job 调度信息
 */
@Override
public int run(SysJob job)
{
    return ScheduleUtils.run(scheduler, selectJobById(job.getJobId()));
}
 
Example #18
Source File: SysJobServiceImpl.java    From RuoYi with Apache License 2.0 2 votes vote down vote up
/**
 * 立即运行任务
 *
 * @param job 调度信息
 */
@Override
public void run(SysJob job) throws SchedulerException{
    ScheduleUtils.run(scheduler, selectJobById(job.getJobId()));
}