|
|
@ -105,11 +105,27 @@ public class XxlJobServiceImpl implements IXxlJobService {
|
|
|
|
|
|
|
|
|
|
|
|
// add in db
|
|
|
|
// add in db
|
|
|
|
xxlJobInfoDao.save(jobInfo);
|
|
|
|
xxlJobInfoDao.save(jobInfo);
|
|
|
|
int jobId = jobInfo.getId();
|
|
|
|
if (jobInfo.getId() < 1) {
|
|
|
|
if (jobId < 1) {
|
|
|
|
|
|
|
|
return new ReturnT<String>(500, "新增任务失败");
|
|
|
|
return new ReturnT<String>(500, "新增任务失败");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// add in quartz
|
|
|
|
|
|
|
|
String qz_group = String.valueOf(jobInfo.getJobGroup());
|
|
|
|
|
|
|
|
String qz_name = String.valueOf(jobInfo.getId());
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
XxlJobDynamicScheduler.addJob(qz_name, qz_group, jobInfo.getJobCron());
|
|
|
|
|
|
|
|
XxlJobDynamicScheduler.pauseJob(qz_name, qz_group);
|
|
|
|
return ReturnT.SUCCESS;
|
|
|
|
return ReturnT.SUCCESS;
|
|
|
|
|
|
|
|
} catch (SchedulerException e) {
|
|
|
|
|
|
|
|
logger.error("", e);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
xxlJobInfoDao.delete(jobInfo.getId());
|
|
|
|
|
|
|
|
XxlJobDynamicScheduler.removeJob(qz_name, qz_group);
|
|
|
|
|
|
|
|
} catch (SchedulerException e1) {
|
|
|
|
|
|
|
|
logger.error("", e1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return new ReturnT<String>(500, "新增任务失败:" + e.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -206,8 +222,8 @@ public class XxlJobServiceImpl implements IXxlJobService {
|
|
|
|
String name = String.valueOf(xxlJobInfo.getId());
|
|
|
|
String name = String.valueOf(xxlJobInfo.getId());
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
XxlJobDynamicScheduler.pauseJob(name, group); // jobStatus do not store
|
|
|
|
boolean ret = XxlJobDynamicScheduler.pauseJob(name, group); // jobStatus do not store
|
|
|
|
return ReturnT.SUCCESS;
|
|
|
|
return ret?ReturnT.SUCCESS:ReturnT.FAIL;
|
|
|
|
} catch (SchedulerException e) {
|
|
|
|
} catch (SchedulerException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
return ReturnT.FAIL;
|
|
|
|
return ReturnT.FAIL;
|
|
|
@ -221,12 +237,7 @@ public class XxlJobServiceImpl implements IXxlJobService {
|
|
|
|
String name = String.valueOf(xxlJobInfo.getId());
|
|
|
|
String name = String.valueOf(xxlJobInfo.getId());
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
boolean ret = false;
|
|
|
|
boolean ret = XxlJobDynamicScheduler.resumeJob(name, group);
|
|
|
|
if (XxlJobDynamicScheduler.checkExists(name, group)) {
|
|
|
|
|
|
|
|
ret = XxlJobDynamicScheduler.resumeJob(name, group);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
ret = XxlJobDynamicScheduler.addJob(name, group, xxlJobInfo.getJobCron());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret?ReturnT.SUCCESS:ReturnT.FAIL;
|
|
|
|
return ret?ReturnT.SUCCESS:ReturnT.FAIL;
|
|
|
|
} catch (SchedulerException e) {
|
|
|
|
} catch (SchedulerException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|