Search in sources :

Example 6 with SysJob

use of com.ruoyi.project.monitor.domain.SysJob in project RuoYi-Vue-fast by yangzongzhuan.

the class SysJobController method changeStatus.

/**
 * 定时任务状态修改
 */
@PreAuthorize("@ss.hasPermi('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.project.monitor.domain.SysJob) Log(com.ruoyi.framework.aspectj.lang.annotation.Log) PutMapping(org.springframework.web.bind.annotation.PutMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 7 with SysJob

use of com.ruoyi.project.monitor.domain.SysJob in project RuoYi-Vue-fast 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.project.monitor.domain.SysJob) JobExecutionException(org.quartz.JobExecutionException)

Example 8 with SysJob

use of com.ruoyi.project.monitor.domain.SysJob in project RuoYi-Vue-fast 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.project.monitor.domain.SysJob) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with SysJob

use of com.ruoyi.project.monitor.domain.SysJob in project RuoYi-Vue-fast by yangzongzhuan.

the class SysJobServiceImpl method init.

/**
 * 项目启动时,初始化定时器 主要是防止手动修改数据库导致未同步到定时任务处理(注:不能手动修改数据库ID和任务组名,否则会导致脏数据)
 */
@PostConstruct
public void init() throws SchedulerException, TaskException {
    scheduler.clear();
    List<SysJob> jobList = jobMapper.selectJobAll();
    for (SysJob job : jobList) {
        ScheduleUtils.createScheduleJob(scheduler, job);
    }
}
Also used : SysJob(com.ruoyi.project.monitor.domain.SysJob) PostConstruct(javax.annotation.PostConstruct)

Example 10 with SysJob

use of com.ruoyi.project.monitor.domain.SysJob in project RuoYi-Vue-Oracle by yangzongzhuan.

the class SysJobServiceImpl method init.

/**
 * 项目启动时,初始化定时器 主要是防止手动修改数据库导致未同步到定时任务处理(注:不能手动修改数据库ID和任务组名,否则会导致脏数据)
 */
@PostConstruct
public void init() throws SchedulerException, TaskException {
    scheduler.clear();
    List<SysJob> jobList = jobMapper.selectJobAll();
    for (SysJob job : jobList) {
        ScheduleUtils.createScheduleJob(scheduler, job);
    }
}
Also used : SysJob(com.ruoyi.project.monitor.domain.SysJob) PostConstruct(javax.annotation.PostConstruct)

Aggregations

SysJob (com.ruoyi.project.monitor.domain.SysJob)12 Transactional (org.springframework.transaction.annotation.Transactional)6 Log (com.ruoyi.framework.aspectj.lang.annotation.Log)2 PostConstruct (javax.annotation.PostConstruct)2 JobDataMap (org.quartz.JobDataMap)2 JobExecutionException (org.quartz.JobExecutionException)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 PutMapping (org.springframework.web.bind.annotation.PutMapping)2