Search in sources :

Example 1 with AgileQuartzJob

use of com.jeeagile.quartz.entity.AgileQuartzJob in project jeeagile by jeeagile.

the class AgileQuartzJobServiceImpl method selectModel.

@Override
public AgileQuartzJob selectModel(Serializable id) {
    AgileQuartzJob agileQuartzJob = this.getById(id);
    AgileQuartzJobInfo agileQuartzJobInfo = new AgileQuartzJobInfo();
    if (agileQuartzJob != null && agileQuartzJob.isNotEmptyPk()) {
        BeanUtils.copyProperties(agileQuartzJob, agileQuartzJobInfo);
        agileQuartzJobInfo.setNextTime(AgileCronUtil.getNextTime(agileQuartzJob.getJobCron()));
    }
    return agileQuartzJobInfo;
}
Also used : AgileQuartzJob(com.jeeagile.quartz.entity.AgileQuartzJob) AgileQuartzJobInfo(com.jeeagile.quartz.vo.AgileQuartzJobInfo)

Example 2 with AgileQuartzJob

use of com.jeeagile.quartz.entity.AgileQuartzJob in project jeeagile by jeeagile.

the class AgileQuartzJobServiceImpl method changeQuartzJobStatus.

@Override
public boolean changeQuartzJobStatus(AgileUpdateStatus agileUpdateStatus) {
    AgileQuartzJob agileQuartzJob = this.getById(agileUpdateStatus.getId());
    agileQuartzJob.setJobStatus(agileUpdateStatus.getStatus());
    boolean updateFlag = this.updateById(agileQuartzJob);
    if (updateFlag) {
        if (AgileStatusEnum.NORMAL.getCode().equals(agileUpdateStatus.getStatus())) {
            AgileScheduleUtil.resumeJob(agileQuartzJob);
        } else {
            AgileScheduleUtil.pauseJob(agileQuartzJob);
        }
    }
    return updateFlag;
}
Also used : AgileQuartzJob(com.jeeagile.quartz.entity.AgileQuartzJob)

Example 3 with AgileQuartzJob

use of com.jeeagile.quartz.entity.AgileQuartzJob in project jeeagile by jeeagile.

the class AgileQuartzJobServiceImpl method updateModel.

@Override
public boolean updateModel(AgileQuartzJob agileQuartzJob) {
    this.validateData(agileQuartzJob);
    AgileQuartzJob oldAgileQuartzJob = this.getById(agileQuartzJob.getId());
    if (this.updateById(agileQuartzJob)) {
        // 删除正在执行的任务
        AgileScheduleUtil.deleteScheduleJob(oldAgileQuartzJob);
        AgileScheduleUtil.createScheduleJob(agileQuartzJob);
        return true;
    }
    return false;
}
Also used : AgileQuartzJob(com.jeeagile.quartz.entity.AgileQuartzJob)

Example 4 with AgileQuartzJob

use of com.jeeagile.quartz.entity.AgileQuartzJob in project jeeagile by jeeagile.

the class AgileAbstractJob method execute.

@Override
public void execute(JobExecutionContext jobExecutionContext) {
    JobDataMap jobDataMap = jobExecutionContext.getMergedJobDataMap();
    AgileQuartzJob agileQuartzJob = (AgileQuartzJob) jobDataMap.get(AgileScheduleConstants.TASK_JOB_PROPERTIES);
    Throwable throwable = null;
    Date startTime = new Date();
    try {
        if (agileQuartzJob != null && agileQuartzJob.isNotEmptyPk()) {
            doExecute(jobExecutionContext, agileQuartzJob);
        } else {
            throw new AgileFrameException("任务调度参数为空!");
        }
    } catch (Exception ex) {
        log.error("任务执行异常:", ex);
        throwable = ex;
    } finally {
        saveJobLog(agileQuartzJob, startTime, throwable);
    }
}
Also used : JobDataMap(org.quartz.JobDataMap) AgileFrameException(com.jeeagile.core.exception.AgileFrameException) AgileQuartzJob(com.jeeagile.quartz.entity.AgileQuartzJob) AgileFrameException(com.jeeagile.core.exception.AgileFrameException)

Aggregations

AgileQuartzJob (com.jeeagile.quartz.entity.AgileQuartzJob)4 AgileFrameException (com.jeeagile.core.exception.AgileFrameException)1 AgileQuartzJobInfo (com.jeeagile.quartz.vo.AgileQuartzJobInfo)1 JobDataMap (org.quartz.JobDataMap)1