提交 006d14b4 编写于 作者: sq3536's avatar sq3536

jobs start stop exec

上级 125378c4
package cn.ibizlab.core.extensions.service;
import cn.ibizlab.core.task.service.impl.JobsInfoServiceImpl;
import cn.ibizlab.util.errors.BadRequestAlertException;
import com.baomidou.jobs.service.JobsHelper;
import com.baomidou.mybatisplus.extension.api.Assert;
import lombok.extern.slf4j.Slf4j;
import cn.ibizlab.core.task.domain.JobsInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Primary;
import java.math.BigInteger;
/**
* 实体[任务信息] 自定义服务对象
*/
......@@ -30,6 +35,24 @@ public class JobsInfoServiceEx extends JobsInfoServiceImpl {
public JobsInfo execute(JobsInfo et) {
return super.execute(et);
}
@Override
public JobsInfo start(JobsInfo et) {
JobsInfo dbJobInfo = getById(et.getId());
if (null == dbJobInfo) {
throw new BadRequestAlertException("未找到任务","JobsInfo","");
}
et.setStatus(1);
et.setLastTime(new BigInteger("0"));
if(!JobsHelper.cronValidate(dbJobInfo.getCron()))
throw new BadRequestAlertException("CRON 表达式不可用","JobsInfo",dbJobInfo.getCron());
// next trigger time (10s后生效,避开预读周期)
et.setNextTime(BigInteger.valueOf(JobsHelper.cronNextTime(dbJobInfo.getCron()) + 10000));
this.update(et);
return et;
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册