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

@ -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, "新增任务失败");
} }
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 @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();

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

Loading…
Cancel
Save