com.ruoyi.common.constant.ScheduleConstants Java Examples
The following examples show how to use
com.ruoyi.common.constant.ScheduleConstants.
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: AbstractQuartzJob.java From RuoYi-Vue with MIT License | 6 votes |
@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); } }
Example #2
Source File: SysJobServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 任务调度状态修改 * * @param job 调度信息 */ @Override @Transactional public int changeStatus(SysJob job) throws SchedulerException { int rows = 0; String status = job.getStatus(); if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) { rows = resumeJob(job); } else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) { rows = pauseJob(job); } return rows; }
Example #3
Source File: ScheduleUtils.java From RuoYi-Vue with MIT License | 6 votes |
/** * 设置定时任务策略 */ public static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb) throws TaskException { switch (job.getMisfirePolicy()) { case ScheduleConstants.MISFIRE_DEFAULT: return cb; case ScheduleConstants.MISFIRE_IGNORE_MISFIRES: return cb.withMisfireHandlingInstructionIgnoreMisfires(); case ScheduleConstants.MISFIRE_FIRE_AND_PROCEED: return cb.withMisfireHandlingInstructionFireAndProceed(); case ScheduleConstants.MISFIRE_DO_NOTHING: return cb.withMisfireHandlingInstructionDoNothing(); default: throw new TaskException("The task misfire policy '" + job.getMisfirePolicy() + "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR); } }
Example #4
Source File: SysJobServiceImpl.java From ruoyiplus with MIT License | 6 votes |
/** * 任务调度状态修改 * * @param job 调度信息 */ @Override public int changeStatus(SysJob job) { int rows = 0; String status = job.getStatus(); if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) { rows = resumeJob(job); } else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) { rows = pauseJob(job); } return rows; }
Example #5
Source File: ScheduleUtils.java From ruoyiplus with MIT License | 6 votes |
/** * 立即执行任务 */ public static int run(Scheduler scheduler, SysJob job) { int rows = 0; try { // 参数 JobDataMap dataMap = new JobDataMap(); dataMap.put(ScheduleConstants.TASK_PROPERTIES, job); scheduler.triggerJob(getJobKey(job.getJobId()), dataMap); rows = 1; } catch (SchedulerException e) { log.error("run 异常:", e); } return rows; }
Example #6
Source File: ScheduleUtils.java From supplierShop with MIT License | 6 votes |
/** * 设置定时任务策略 */ public static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb) throws TaskException { switch (job.getMisfirePolicy()) { case ScheduleConstants.MISFIRE_DEFAULT: return cb; case ScheduleConstants.MISFIRE_IGNORE_MISFIRES: return cb.withMisfireHandlingInstructionIgnoreMisfires(); case ScheduleConstants.MISFIRE_FIRE_AND_PROCEED: return cb.withMisfireHandlingInstructionFireAndProceed(); case ScheduleConstants.MISFIRE_DO_NOTHING: return cb.withMisfireHandlingInstructionDoNothing(); default: throw new TaskException("The task misfire policy '" + job.getMisfirePolicy() + "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR); } }
Example #7
Source File: AbstractQuartzJob.java From supplierShop with MIT License | 6 votes |
@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); } }
Example #8
Source File: ScheduleUtils.java From ruoyiplus with MIT License | 6 votes |
public static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb) throws TaskException { switch (job.getMisfirePolicy()) { case ScheduleConstants.MISFIRE_DEFAULT: return cb; case ScheduleConstants.MISFIRE_IGNORE_MISFIRES: return cb.withMisfireHandlingInstructionIgnoreMisfires(); case ScheduleConstants.MISFIRE_FIRE_AND_PROCEED: return cb.withMisfireHandlingInstructionFireAndProceed(); case ScheduleConstants.MISFIRE_DO_NOTHING: return cb.withMisfireHandlingInstructionDoNothing(); default: throw new TaskException("The task misfire policy '" + job.getMisfirePolicy() + "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR); } }
Example #9
Source File: SysJobServiceImpl.java From RuoYi-Vue with MIT License | 6 votes |
/** * 任务调度状态修改 * * @param job 调度信息 */ @Override @Transactional public int changeStatus(SysJob job) throws SchedulerException { int rows = 0; String status = job.getStatus(); if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) { rows = resumeJob(job); } else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) { rows = pauseJob(job); } return rows; }
Example #10
Source File: SysJobServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 恢复任务 * * @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 #11
Source File: SysJobServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 恢复任务 * * @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 #12
Source File: SysJobServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 新增任务 * * @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 #13
Source File: SysJobServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 暂停任务 * * @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 #14
Source File: AbstractQuartzJob.java From RuoYi with Apache License 2.0 | 5 votes |
@Override public void execute(JobExecutionContext context){ SysJob sysJob = new SysJob(); BeanUtil.copyProperties(context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES), sysJob); try { before(context, sysJob); if (ObjectUtil.isNotNull(sysJob)) { doExecute(context, sysJob); } after(context, sysJob, null); } catch (Exception e) { log.error("任务执行异常 - :", e); after(context, sysJob, e); } }
Example #15
Source File: SysJobServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 任务调度状态修改 * * @param job 调度信息 */ @Override public int changeStatus(SysJob job) throws SchedulerException{ int rows = 0; String status = job.getStatus(); if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) { rows = resumeJob(job); } else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) { rows = pauseJob(job); } return rows; }
Example #16
Source File: SysJobServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 新增任务 * * @param job 调度信息 调度信息 */ @Override public int insertJobCron(SysJob job) throws SchedulerException, TaskException{ job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); int rows = jobMapper.insertJob(job); if (rows > 0) { createScheduleJob(scheduler, job); } return rows; }
Example #17
Source File: ScheduleUtils.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 创建定时任务 */ public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException { Class<? extends Job> jobClass = getQuartzJobClass(job); // 构建job信息 JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(job.getJobId())).build(); // 表达式调度构建器 CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression()); cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder); // 按新的cronExpression表达式构建一个新的trigger CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(job.getJobId())) .withSchedule(cronScheduleBuilder).build(); // 放入参数,运行时的方法可以获取 jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job); // 判断是否存在 if (scheduler.checkExists(getJobKey(job.getJobId()))){ // 防止创建时存在数据问题 先移除,然后在执行创建操作 scheduler.deleteJob(getJobKey(job.getJobId())); } scheduler.scheduleJob(jobDetail, trigger); // 暂停任务 if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue())) { pauseJob(scheduler, job.getJobId()); } }
Example #18
Source File: ScheduleUtils.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 立即执行任务 */ public static void run(Scheduler scheduler, SysJob job) throws SchedulerException { // 参数 JobDataMap dataMap = new JobDataMap(); dataMap.put(ScheduleConstants.TASK_PROPERTIES, job); scheduler.triggerJob(getJobKey(job.getJobId()), dataMap); }
Example #19
Source File: ScheduleUtils.java From RuoYi with Apache License 2.0 | 5 votes |
private static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb) throws TaskException { switch (job.getMisfirePolicy()) { case ScheduleConstants.MISFIRE_DEFAULT: return cb; case ScheduleConstants.MISFIRE_IGNORE_MISFIRES: return cb.withMisfireHandlingInstructionIgnoreMisfires(); case ScheduleConstants.MISFIRE_FIRE_AND_PROCEED: return cb.withMisfireHandlingInstructionFireAndProceed(); case ScheduleConstants.MISFIRE_DO_NOTHING: return cb.withMisfireHandlingInstructionDoNothing(); default: throw new TaskException("The task misfire policy '" + job.getMisfirePolicy() + "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR); } }
Example #20
Source File: SysJobServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 暂停任务 * * @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 #21
Source File: SysJobServiceImpl.java From RuoYi-Vue with MIT License | 5 votes |
/** * 暂停任务 * * @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 #22
Source File: SysJobServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 恢复任务 * * @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 #23
Source File: SysJobServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 立即运行任务 * * @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 #24
Source File: SysJobServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 新增任务 * * @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 #25
Source File: ScheduleUtils.java From supplierShop with MIT License | 5 votes |
/** * 创建定时任务 */ public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException { Class<? extends Job> jobClass = getQuartzJobClass(job); // 构建job信息 Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build(); // 表达式调度构建器 CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression()); cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder); // 按新的cronExpression表达式构建一个新的trigger CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(jobId, jobGroup)) .withSchedule(cronScheduleBuilder).build(); // 放入参数,运行时的方法可以获取 jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job); // 判断是否存在 if (scheduler.checkExists(getJobKey(jobId, jobGroup))) { // 防止创建时存在数据问题 先移除,然后在执行创建操作 scheduler.deleteJob(getJobKey(jobId, jobGroup)); } scheduler.scheduleJob(jobDetail, trigger); // 暂停任务 if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue())) { scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); } }
Example #26
Source File: SysJobServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 暂停任务 * * @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 #27
Source File: SysJobServiceImpl.java From RuoYi-Vue with MIT License | 5 votes |
/** * 恢复任务 * * @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 #28
Source File: SysJobServiceImpl.java From RuoYi-Vue with MIT License | 5 votes |
/** * 立即运行任务 * * @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 #29
Source File: SysJobServiceImpl.java From RuoYi-Vue with MIT License | 5 votes |
/** * 新增任务 * * @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 #30
Source File: ScheduleUtils.java From RuoYi-Vue with MIT License | 5 votes |
/** * 创建定时任务 */ public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException { Class<? extends Job> jobClass = getQuartzJobClass(job); // 构建job信息 Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build(); // 表达式调度构建器 CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression()); cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder); // 按新的cronExpression表达式构建一个新的trigger CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(jobId, jobGroup)) .withSchedule(cronScheduleBuilder).build(); // 放入参数,运行时的方法可以获取 jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job); // 判断是否存在 if (scheduler.checkExists(getJobKey(jobId, jobGroup))) { // 防止创建时存在数据问题 先移除,然后在执行创建操作 scheduler.deleteJob(getJobKey(jobId, jobGroup)); } scheduler.scheduleJob(jobDetail, trigger); // 暂停任务 if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue())) { scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); } }