Search in sources :

Example 1 with SysJob

use of com.ruoyi.job.domain.SysJob in project RuoYi-Cloud by yangzongzhuan.

the class SysJobServiceImpl method run.

/**
 * 立即运行任务
 *
 * @param job 调度信息
 */
@Override
@Transactional(rollbackFor = Exception.class)
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);
}
Also used : SysJob(com.ruoyi.job.domain.SysJob) JobDataMap(org.quartz.JobDataMap) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with SysJob

use of com.ruoyi.job.domain.SysJob in project RuoYi-Cloud by yangzongzhuan.

the class SysJobServiceImpl method updateJob.

/**
 * 更新任务的时间表达式
 *
 * @param job 调度信息
 */
@Override
@Transactional(rollbackFor = Exception.class)
public int updateJob(SysJob job) throws SchedulerException, TaskException {
    SysJob properties = selectJobById(job.getJobId());
    int rows = jobMapper.updateJob(job);
    if (rows > 0) {
        updateSchedulerJob(job, properties.getJobGroup());
    }
    return rows;
}
Also used : SysJob(com.ruoyi.job.domain.SysJob) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with SysJob

use of com.ruoyi.job.domain.SysJob in project RuoYi-Cloud by yangzongzhuan.

the class SysJobServiceImpl method deleteJobByIds.

/**
 * 批量删除调度信息
 *
 * @param jobIds 需要删除的任务ID
 * @return 结果
 */
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteJobByIds(Long[] jobIds) throws SchedulerException {
    for (Long jobId : jobIds) {
        SysJob job = jobMapper.selectJobById(jobId);
        deleteJob(job);
    }
}
Also used : SysJob(com.ruoyi.job.domain.SysJob) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with SysJob

use of com.ruoyi.job.domain.SysJob in project RuoYi-Cloud by yangzongzhuan.

the class AbstractQuartzJob method execute.

@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    SysJob sysJob = new SysJob();
    BeanUtils.copyBeanProp(sysJob, context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES));
    try {
        before(context, sysJob);
        if (sysJob != null) {
            doExecute(context, sysJob);
        }
        after(context, sysJob, null);
    } catch (Exception e) {
        log.error("任务执行异常  - :", e);
        after(context, sysJob, e);
    }
}
Also used : SysJob(com.ruoyi.job.domain.SysJob) JobExecutionException(org.quartz.JobExecutionException)

Example 5 with SysJob

use of com.ruoyi.job.domain.SysJob in project RuoYi-Cloud-Oracle by yangzongzhuan.

the class SysJobController method changeStatus.

/**
 * 定时任务状态修改
 */
@RequiresPermissions("monitor:job:changeStatus")
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException {
    SysJob newJob = jobService.selectJobById(job.getJobId());
    newJob.setStatus(job.getStatus());
    return toAjax(jobService.changeStatus(newJob));
}
Also used : SysJob(com.ruoyi.job.domain.SysJob) RequiresPermissions(com.ruoyi.common.security.annotation.RequiresPermissions) Log(com.ruoyi.common.log.annotation.Log) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Aggregations

SysJob (com.ruoyi.job.domain.SysJob)12 Transactional (org.springframework.transaction.annotation.Transactional)6 Log (com.ruoyi.common.log.annotation.Log)2 RequiresPermissions (com.ruoyi.common.security.annotation.RequiresPermissions)2 PostConstruct (javax.annotation.PostConstruct)2 JobDataMap (org.quartz.JobDataMap)2 JobExecutionException (org.quartz.JobExecutionException)2 PutMapping (org.springframework.web.bind.annotation.PutMapping)2