| | |
| | | |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.enums.ErrorCode; |
| | | import com.iailab.framework.common.exception.ServerException; |
| | | import com.iailab.module.shasteel.job.entity.ScheduleJobEntity; |
| | | import org.quartz.*; |
| | | |
| | |
| | | try { |
| | | return (CronTrigger) scheduler.getTrigger(getTriggerKey(jobId)); |
| | | } catch (SchedulerException e) { |
| | | throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); |
| | | throw new RuntimeException("获取表达式触发器异常", e); |
| | | } |
| | | } |
| | | |
| | |
| | | pauseJob(scheduler, scheduleJob.getId()); |
| | | } |
| | | } catch (SchedulerException e) { |
| | | throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); |
| | | throw new RuntimeException("创建定时任务异常", e); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | } catch (SchedulerException e) { |
| | | throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); |
| | | throw new RuntimeException("更新定时任务异常", e); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | scheduler.triggerJob(getJobKey(scheduleJob.getId()), dataMap); |
| | | } catch (SchedulerException e) { |
| | | throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); |
| | | throw new RuntimeException("立即执行任务异常", e); |
| | | } |
| | | } |
| | | |
| | |
| | | try { |
| | | scheduler.pauseJob(getJobKey(jobId)); |
| | | } catch (SchedulerException e) { |
| | | throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); |
| | | throw new RuntimeException("暂停任务异常", e); |
| | | } |
| | | } |
| | | |
| | |
| | | try { |
| | | scheduler.resumeJob(getJobKey(jobId)); |
| | | } catch (SchedulerException e) { |
| | | throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); |
| | | throw new RuntimeException("恢复任务异常", e); |
| | | } |
| | | } |
| | | |
| | |
| | | try { |
| | | scheduler.deleteJob(getJobKey(jobId)); |
| | | } catch (SchedulerException e) { |
| | | throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); |
| | | throw new RuntimeException("删除定时任务异常", e); |
| | | } |
| | | } |
| | | } |