pull/1/head
xueli.xue 8 years ago
parent d66bdc8811
commit 8d99be356a

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

@ -75,7 +75,7 @@ $(function() {
"render": function ( data, type, row ) {
if ('NORMAL' == data) {
return '<small class="label label-success" ><i class="fa fa-clock-o"></i>'+ data +'</small>';
} else if ('PAUSED' == data || 'NONE' == data){
} else if ('PAUSED' == data){
return '<small class="label label-default" title="暂停" ><i class="fa fa-clock-o"></i>'+ data +'</small>';
} else if ('BLOCKED' == data){
return '<small class="label label-default" title="阻塞[串行]" ><i class="fa fa-clock-o"></i>'+ data +'</small>';
@ -90,7 +90,7 @@ $(function() {
var pause_resume = "";
if ('NORMAL' == row.jobStatus) {
pause_resume = '<button class="btn btn-primary btn-xs job_operate" type="job_pause" type="button">暂停</button> ';
} else if ('PAUSED' == row.jobStatus || 'NONE' == row.jobStatus){
} else if ('PAUSED' == row.jobStatus){
pause_resume = '<button class="btn btn-primary btn-xs job_operate" type="job_resume" type="button">恢复</button> ';
}
// log url

Loading…
Cancel
Save