Java Code Examples for com.xxl.job.admin.core.model.XxlJobInfo#getJobCron()

The following examples show how to use com.xxl.job.admin.core.model.XxlJobInfo#getJobCron() . 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: XxlJobServiceImpl.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> start(int id) {
	XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
	String group = String.valueOf(xxlJobInfo.getJobGroup());
	String name = String.valueOf(xxlJobInfo.getId());
	String cronExpression = xxlJobInfo.getJobCron();

	try {
		boolean ret = XxlJobDynamicScheduler.addJob(name, group, cronExpression);
		return ret?ReturnT.SUCCESS:ReturnT.FAIL;
	} catch (SchedulerException e) {
		logger.error(e.getMessage(), e);
		return ReturnT.FAIL;
	}
}
 
Example 2
Source File: XxlJobServiceImpl.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> start(Integer id) {
    XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
    if (JobTypeEnum.CRON.eq(xxlJobInfo.getType())) {
        if (!CronExpression.isValidExpression(xxlJobInfo.getJobCron())) {
            return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid"));
        }
    } else {
        //表单校验
        String msg = validate(xxlJobInfo.getIntervalSeconds(), xxlJobInfo.getRepeatCount(),
                xxlJobInfo.getStartExecuteTime(), xxlJobInfo.getEndExecuteTime());
        if (!StringUtils.isEmpty(msg)) {
            return new ReturnT<String>(ReturnT.FAIL_CODE, msg);
        }
    }
    String group = String.valueOf(xxlJobInfo.getJobGroup());
    String name = String.valueOf(xxlJobInfo.getId());
    String cronExpression = xxlJobInfo.getJobCron();
    boolean ret = false;
    try {
        //判断定时类型
        if (JobTypeEnum.CRON.eq(xxlJobInfo.getType())) {
            ret = XxlJobDynamicScheduler.addJob(name, group, cronExpression);
        } else {
            /*if (!DateUtil.isMatch(xxlJobInfo.get())) {
                return new ReturnT<>(ReturnT.START_JOB_FAI, "触发时间不能小于当前时间.");
            }*/
            ret = XxlJobDynamicScheduler.addJob(name, group, xxlJobInfo.getStartExecuteTime(), xxlJobInfo.getEndExecuteTime(), xxlJobInfo.getIntervalSeconds(), xxlJobInfo.getRepeatCount());
        }
        return ret ? ReturnT.SUCCESS : ReturnT.FAIL;
    } catch (SchedulerException e) {
        logger.error(e.getMessage(), e);
        return ReturnT.FAIL;
    }
}
 
Example 3
Source File: XxlJobServiceImpl.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> start(Integer id) {
    XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
    if (JobTypeEnum.CRON.eq(xxlJobInfo.getType())) {
        if (!CronExpression.isValidExpression(xxlJobInfo.getJobCron())) {
            return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid"));
        }
    } else {
        //表单校验
        String msg = validate(xxlJobInfo.getIntervalSeconds(), xxlJobInfo.getRepeatCount(),
                xxlJobInfo.getStartExecuteTime(), xxlJobInfo.getEndExecuteTime());
        if (!StringUtils.isEmpty(msg)) {
            return new ReturnT<String>(ReturnT.FAIL_CODE, msg);
        }
    }
    String group = String.valueOf(xxlJobInfo.getJobGroup());
    String name = String.valueOf(xxlJobInfo.getId());
    String cronExpression = xxlJobInfo.getJobCron();
    boolean ret = false;
    try {
        //判断定时类型
        if (JobTypeEnum.CRON.eq(xxlJobInfo.getType())) {
            ret = XxlJobDynamicScheduler.addJob(name, group, cronExpression);
        } else {
            /*if (!DateUtil.isMatch(xxlJobInfo.get())) {
                return new ReturnT<>(ReturnT.START_JOB_FAI, "触发时间不能小于当前时间.");
            }*/
            ret = XxlJobDynamicScheduler.addJob(name, group, xxlJobInfo.getStartExecuteTime(), xxlJobInfo.getEndExecuteTime(), xxlJobInfo.getIntervalSeconds(), xxlJobInfo.getRepeatCount());
        }
        return ret ? ReturnT.SUCCESS : ReturnT.FAIL;
    } catch (SchedulerException e) {
        logger.error(e.getMessage(), e);
        return ReturnT.FAIL;
    }
}