parent
3d15669b3b
commit
6fd7c943f2
@ -1,95 +1,95 @@
|
|||||||
package com.xxl.job.admin.controller;
|
package com.xxl.job.admin.controller;
|
||||||
|
|
||||||
import com.xxl.job.admin.core.model.XxlJobGroup;
|
import com.xxl.job.admin.core.model.XxlJobGroup;
|
||||||
import com.xxl.job.admin.core.model.XxlJobInfo;
|
import com.xxl.job.admin.core.model.XxlJobInfo;
|
||||||
import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum;
|
import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum;
|
||||||
import com.xxl.job.admin.dao.XxlJobGroupDao;
|
import com.xxl.job.admin.dao.XxlJobGroupDao;
|
||||||
import com.xxl.job.admin.service.XxlJobService;
|
import com.xxl.job.admin.service.XxlJobService;
|
||||||
import com.xxl.job.core.biz.model.ReturnT;
|
import com.xxl.job.core.biz.model.ReturnT;
|
||||||
import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
|
import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
|
||||||
import com.xxl.job.core.glue.GlueTypeEnum;
|
import com.xxl.job.core.glue.GlueTypeEnum;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* index controller
|
* index controller
|
||||||
* @author xuxueli 2015-12-19 16:13:16
|
* @author xuxueli 2015-12-19 16:13:16
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/jobinfo")
|
@RequestMapping("/jobinfo")
|
||||||
public class JobInfoController {
|
public class JobInfoController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private XxlJobGroupDao xxlJobGroupDao;
|
private XxlJobGroupDao xxlJobGroupDao;
|
||||||
@Resource
|
@Resource
|
||||||
private XxlJobService xxlJobService;
|
private XxlJobService xxlJobService;
|
||||||
|
|
||||||
@RequestMapping
|
@RequestMapping
|
||||||
public String index(Model model, @RequestParam(required = false, defaultValue = "-1") int jobGroup) {
|
public String index(Model model, @RequestParam(required = false, defaultValue = "-1") int jobGroup) {
|
||||||
|
|
||||||
// 枚举-字典
|
// 枚举-字典
|
||||||
model.addAttribute("ExecutorRouteStrategyEnum", ExecutorRouteStrategyEnum.values()); // 路由策略-列表
|
model.addAttribute("ExecutorRouteStrategyEnum", ExecutorRouteStrategyEnum.values()); // 路由策略-列表
|
||||||
model.addAttribute("GlueTypeEnum", GlueTypeEnum.values()); // Glue类型-字典
|
model.addAttribute("GlueTypeEnum", GlueTypeEnum.values()); // Glue类型-字典
|
||||||
model.addAttribute("ExecutorBlockStrategyEnum", ExecutorBlockStrategyEnum.values()); // 阻塞处理策略-字典
|
model.addAttribute("ExecutorBlockStrategyEnum", ExecutorBlockStrategyEnum.values()); // 阻塞处理策略-字典
|
||||||
|
|
||||||
// 任务组
|
// 任务组
|
||||||
List<XxlJobGroup> jobGroupList = xxlJobGroupDao.findAll();
|
List<XxlJobGroup> jobGroupList = xxlJobGroupDao.findAll();
|
||||||
model.addAttribute("JobGroupList", jobGroupList);
|
model.addAttribute("JobGroupList", jobGroupList);
|
||||||
model.addAttribute("jobGroup", jobGroup);
|
model.addAttribute("jobGroup", jobGroup);
|
||||||
|
|
||||||
return "jobinfo/jobinfo.index";
|
return "jobinfo/jobinfo.index";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/pageList")
|
@RequestMapping("/pageList")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String, Object> pageList(@RequestParam(required = false, defaultValue = "0") int start,
|
public Map<String, Object> pageList(@RequestParam(required = false, defaultValue = "0") int start,
|
||||||
@RequestParam(required = false, defaultValue = "10") int length,
|
@RequestParam(required = false, defaultValue = "10") int length,
|
||||||
int jobGroup, String jobDesc, String executorHandler, String filterTime) {
|
int jobGroup, String jobDesc, String executorHandler, String filterTime) {
|
||||||
|
|
||||||
return xxlJobService.pageList(start, length, jobGroup, jobDesc, executorHandler, filterTime);
|
return xxlJobService.pageList(start, length, jobGroup, jobDesc, executorHandler, filterTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/add")
|
@RequestMapping("/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ReturnT<String> add(XxlJobInfo jobInfo) {
|
public ReturnT<String> add(XxlJobInfo jobInfo) {
|
||||||
return xxlJobService.add(jobInfo);
|
return xxlJobService.add(jobInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/update")
|
@RequestMapping("/update")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ReturnT<String> update(XxlJobInfo jobInfo) {
|
public ReturnT<String> update(XxlJobInfo jobInfo) {
|
||||||
return xxlJobService.update(jobInfo);
|
return xxlJobService.update(jobInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/remove")
|
@RequestMapping("/remove")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ReturnT<String> remove(int id) {
|
public ReturnT<String> remove(int id) {
|
||||||
return xxlJobService.remove(id);
|
return xxlJobService.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/pause")
|
@RequestMapping("/pause")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ReturnT<String> pause(int id) {
|
public ReturnT<String> pause(int id) {
|
||||||
return xxlJobService.pause(id);
|
return xxlJobService.pause(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/resume")
|
@RequestMapping("/resume")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ReturnT<String> resume(int id) {
|
public ReturnT<String> resume(int id) {
|
||||||
return xxlJobService.resume(id);
|
return xxlJobService.resume(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/trigger")
|
@RequestMapping("/trigger")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ReturnT<String> triggerJob(int id) {
|
public ReturnT<String> triggerJob(int id) {
|
||||||
return xxlJobService.triggerJob(id);
|
return xxlJobService.triggerJob(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,385 +1,385 @@
|
|||||||
package com.xxl.job.admin.service.impl;
|
package com.xxl.job.admin.service.impl;
|
||||||
|
|
||||||
import com.xxl.job.admin.core.model.XxlJobGroup;
|
import com.xxl.job.admin.core.model.XxlJobGroup;
|
||||||
import com.xxl.job.admin.core.model.XxlJobInfo;
|
import com.xxl.job.admin.core.model.XxlJobInfo;
|
||||||
import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum;
|
import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum;
|
||||||
import com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler;
|
import com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler;
|
||||||
import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
|
import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
|
||||||
import com.xxl.job.admin.core.util.I18nUtil;
|
import com.xxl.job.admin.core.util.I18nUtil;
|
||||||
import com.xxl.job.admin.dao.XxlJobGroupDao;
|
import com.xxl.job.admin.dao.XxlJobGroupDao;
|
||||||
import com.xxl.job.admin.dao.XxlJobInfoDao;
|
import com.xxl.job.admin.dao.XxlJobInfoDao;
|
||||||
import com.xxl.job.admin.dao.XxlJobLogDao;
|
import com.xxl.job.admin.dao.XxlJobLogDao;
|
||||||
import com.xxl.job.admin.dao.XxlJobLogGlueDao;
|
import com.xxl.job.admin.dao.XxlJobLogGlueDao;
|
||||||
import com.xxl.job.admin.service.XxlJobService;
|
import com.xxl.job.admin.service.XxlJobService;
|
||||||
import com.xxl.job.core.biz.model.ReturnT;
|
import com.xxl.job.core.biz.model.ReturnT;
|
||||||
import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
|
import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
|
||||||
import com.xxl.job.core.glue.GlueTypeEnum;
|
import com.xxl.job.core.glue.GlueTypeEnum;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.time.DateUtils;
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
import org.apache.commons.lang3.time.FastDateFormat;
|
import org.apache.commons.lang3.time.FastDateFormat;
|
||||||
import org.quartz.CronExpression;
|
import org.quartz.CronExpression;
|
||||||
import org.quartz.SchedulerException;
|
import org.quartz.SchedulerException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* core job action for xxl-job
|
* core job action for xxl-job
|
||||||
* @author xuxueli 2016-5-28 15:30:33
|
* @author xuxueli 2016-5-28 15:30:33
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class XxlJobServiceImpl implements XxlJobService {
|
public class XxlJobServiceImpl implements XxlJobService {
|
||||||
private static Logger logger = LoggerFactory.getLogger(XxlJobServiceImpl.class);
|
private static Logger logger = LoggerFactory.getLogger(XxlJobServiceImpl.class);
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private XxlJobGroupDao xxlJobGroupDao;
|
private XxlJobGroupDao xxlJobGroupDao;
|
||||||
@Resource
|
@Resource
|
||||||
private XxlJobInfoDao xxlJobInfoDao;
|
private XxlJobInfoDao xxlJobInfoDao;
|
||||||
@Resource
|
@Resource
|
||||||
public XxlJobLogDao xxlJobLogDao;
|
public XxlJobLogDao xxlJobLogDao;
|
||||||
@Resource
|
@Resource
|
||||||
private XxlJobLogGlueDao xxlJobLogGlueDao;
|
private XxlJobLogGlueDao xxlJobLogGlueDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> pageList(int start, int length, int jobGroup, String jobDesc, String executorHandler, String filterTime) {
|
public Map<String, Object> pageList(int start, int length, int jobGroup, String jobDesc, String executorHandler, String filterTime) {
|
||||||
|
|
||||||
// page list
|
// page list
|
||||||
List<XxlJobInfo> list = xxlJobInfoDao.pageList(start, length, jobGroup, jobDesc, executorHandler);
|
List<XxlJobInfo> list = xxlJobInfoDao.pageList(start, length, jobGroup, jobDesc, executorHandler);
|
||||||
int list_count = xxlJobInfoDao.pageListCount(start, length, jobGroup, jobDesc, executorHandler);
|
int list_count = xxlJobInfoDao.pageListCount(start, length, jobGroup, jobDesc, executorHandler);
|
||||||
|
|
||||||
// fill job info
|
// fill job info
|
||||||
if (list!=null && list.size()>0) {
|
if (list!=null && list.size()>0) {
|
||||||
for (XxlJobInfo jobInfo : list) {
|
for (XxlJobInfo jobInfo : list) {
|
||||||
XxlJobDynamicScheduler.fillJobInfo(jobInfo);
|
XxlJobDynamicScheduler.fillJobInfo(jobInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// package result
|
// package result
|
||||||
Map<String, Object> maps = new HashMap<String, Object>();
|
Map<String, Object> maps = new HashMap<String, Object>();
|
||||||
maps.put("recordsTotal", list_count); // 总记录数
|
maps.put("recordsTotal", list_count); // 总记录数
|
||||||
maps.put("recordsFiltered", list_count); // 过滤后的总记录数
|
maps.put("recordsFiltered", list_count); // 过滤后的总记录数
|
||||||
maps.put("data", list); // 分页列表
|
maps.put("data", list); // 分页列表
|
||||||
return maps;
|
return maps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnT<String> add(XxlJobInfo jobInfo) {
|
public ReturnT<String> add(XxlJobInfo jobInfo) {
|
||||||
// valid
|
// valid
|
||||||
XxlJobGroup group = xxlJobGroupDao.load(jobInfo.getJobGroup());
|
XxlJobGroup group = xxlJobGroupDao.load(jobInfo.getJobGroup());
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_choose")+I18nUtil.getString("jobinfo_field_jobgroup")) );
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_choose")+I18nUtil.getString("jobinfo_field_jobgroup")) );
|
||||||
}
|
}
|
||||||
if (!CronExpression.isValidExpression(jobInfo.getJobCron())) {
|
if (!CronExpression.isValidExpression(jobInfo.getJobCron())) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid") );
|
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid") );
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(jobInfo.getJobDesc())) {
|
if (StringUtils.isBlank(jobInfo.getJobDesc())) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_jobdesc")) );
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_jobdesc")) );
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(jobInfo.getAuthor())) {
|
if (StringUtils.isBlank(jobInfo.getAuthor())) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_author")) );
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_author")) );
|
||||||
}
|
}
|
||||||
if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
|
if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorRouteStrategy")+I18nUtil.getString("system_unvalid")) );
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorRouteStrategy")+I18nUtil.getString("system_unvalid")) );
|
||||||
}
|
}
|
||||||
if (ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), null) == null) {
|
if (ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), null) == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorBlockStrategy")+I18nUtil.getString("system_unvalid")) );
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorBlockStrategy")+I18nUtil.getString("system_unvalid")) );
|
||||||
}
|
}
|
||||||
if (GlueTypeEnum.match(jobInfo.getGlueType()) == null) {
|
if (GlueTypeEnum.match(jobInfo.getGlueType()) == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_gluetype")+I18nUtil.getString("system_unvalid")) );
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_gluetype")+I18nUtil.getString("system_unvalid")) );
|
||||||
}
|
}
|
||||||
if (GlueTypeEnum.BEAN==GlueTypeEnum.match(jobInfo.getGlueType()) && StringUtils.isBlank(jobInfo.getExecutorHandler())) {
|
if (GlueTypeEnum.BEAN==GlueTypeEnum.match(jobInfo.getGlueType()) && StringUtils.isBlank(jobInfo.getExecutorHandler())) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+"JobHandler") );
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+"JobHandler") );
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix "\r" in shell
|
// fix "\r" in shell
|
||||||
if (GlueTypeEnum.GLUE_SHELL==GlueTypeEnum.match(jobInfo.getGlueType()) && jobInfo.getGlueSource()!=null) {
|
if (GlueTypeEnum.GLUE_SHELL==GlueTypeEnum.match(jobInfo.getGlueType()) && jobInfo.getGlueSource()!=null) {
|
||||||
jobInfo.setGlueSource(jobInfo.getGlueSource().replaceAll("\r", ""));
|
jobInfo.setGlueSource(jobInfo.getGlueSource().replaceAll("\r", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChildJobId valid
|
// ChildJobId valid
|
||||||
if (StringUtils.isNotBlank(jobInfo.getChildJobId())) {
|
if (StringUtils.isNotBlank(jobInfo.getChildJobId())) {
|
||||||
String[] childJobIds = StringUtils.split(jobInfo.getChildJobId(), ",");
|
String[] childJobIds = StringUtils.split(jobInfo.getChildJobId(), ",");
|
||||||
for (String childJobIdItem: childJobIds) {
|
for (String childJobIdItem: childJobIds) {
|
||||||
if (StringUtils.isNotBlank(childJobIdItem) && StringUtils.isNumeric(childJobIdItem)) {
|
if (StringUtils.isNotBlank(childJobIdItem) && StringUtils.isNumeric(childJobIdItem)) {
|
||||||
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.valueOf(childJobIdItem));
|
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.valueOf(childJobIdItem));
|
||||||
if (childJobInfo==null) {
|
if (childJobInfo==null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
||||||
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem));
|
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
||||||
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_unvalid")), childJobIdItem));
|
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_unvalid")), childJobIdItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jobInfo.setChildJobId(StringUtils.join(childJobIds, ","));
|
jobInfo.setChildJobId(StringUtils.join(childJobIds, ","));
|
||||||
}
|
}
|
||||||
|
|
||||||
// add in db
|
// add in db
|
||||||
xxlJobInfoDao.save(jobInfo);
|
xxlJobInfoDao.save(jobInfo);
|
||||||
if (jobInfo.getId() < 1) {
|
if (jobInfo.getId() < 1) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_add")+I18nUtil.getString("system_fail")) );
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_add")+I18nUtil.getString("system_fail")) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// add in quartz
|
// add in quartz
|
||||||
String qz_group = String.valueOf(jobInfo.getJobGroup());
|
String qz_group = String.valueOf(jobInfo.getJobGroup());
|
||||||
String qz_name = String.valueOf(jobInfo.getId());
|
String qz_name = String.valueOf(jobInfo.getId());
|
||||||
try {
|
try {
|
||||||
XxlJobDynamicScheduler.addJob(qz_name, qz_group, jobInfo.getJobCron());
|
XxlJobDynamicScheduler.addJob(qz_name, qz_group, jobInfo.getJobCron());
|
||||||
//XxlJobDynamicScheduler.pauseJob(qz_name, qz_group);
|
//XxlJobDynamicScheduler.pauseJob(qz_name, qz_group);
|
||||||
return ReturnT.SUCCESS;
|
return ReturnT.SUCCESS;
|
||||||
} catch (SchedulerException e) {
|
} catch (SchedulerException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
try {
|
try {
|
||||||
xxlJobInfoDao.delete(jobInfo.getId());
|
xxlJobInfoDao.delete(jobInfo.getId());
|
||||||
XxlJobDynamicScheduler.removeJob(qz_name, qz_group);
|
XxlJobDynamicScheduler.removeJob(qz_name, qz_group);
|
||||||
} catch (SchedulerException e1) {
|
} catch (SchedulerException e1) {
|
||||||
logger.error(e.getMessage(), e1);
|
logger.error(e.getMessage(), e1);
|
||||||
}
|
}
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_add")+I18nUtil.getString("system_fail"))+":" + e.getMessage());
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_add")+I18nUtil.getString("system_fail"))+":" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnT<String> update(XxlJobInfo jobInfo) {
|
public ReturnT<String> update(XxlJobInfo jobInfo) {
|
||||||
|
|
||||||
// valid
|
// valid
|
||||||
if (!CronExpression.isValidExpression(jobInfo.getJobCron())) {
|
if (!CronExpression.isValidExpression(jobInfo.getJobCron())) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid") );
|
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid") );
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(jobInfo.getJobDesc())) {
|
if (StringUtils.isBlank(jobInfo.getJobDesc())) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_jobdesc")) );
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_jobdesc")) );
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(jobInfo.getAuthor())) {
|
if (StringUtils.isBlank(jobInfo.getAuthor())) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_author")) );
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_author")) );
|
||||||
}
|
}
|
||||||
if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
|
if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorRouteStrategy")+I18nUtil.getString("system_unvalid")) );
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorRouteStrategy")+I18nUtil.getString("system_unvalid")) );
|
||||||
}
|
}
|
||||||
if (ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), null) == null) {
|
if (ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), null) == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorBlockStrategy")+I18nUtil.getString("system_unvalid")) );
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorBlockStrategy")+I18nUtil.getString("system_unvalid")) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChildJobId valid
|
// ChildJobId valid
|
||||||
if (StringUtils.isNotBlank(jobInfo.getChildJobId())) {
|
if (StringUtils.isNotBlank(jobInfo.getChildJobId())) {
|
||||||
String[] childJobIds = StringUtils.split(jobInfo.getChildJobId(), ",");
|
String[] childJobIds = StringUtils.split(jobInfo.getChildJobId(), ",");
|
||||||
for (String childJobIdItem: childJobIds) {
|
for (String childJobIdItem: childJobIds) {
|
||||||
if (StringUtils.isNotBlank(childJobIdItem) && StringUtils.isNumeric(childJobIdItem)) {
|
if (StringUtils.isNotBlank(childJobIdItem) && StringUtils.isNumeric(childJobIdItem)) {
|
||||||
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.valueOf(childJobIdItem));
|
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.valueOf(childJobIdItem));
|
||||||
if (childJobInfo==null) {
|
if (childJobInfo==null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
||||||
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem));
|
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem));
|
||||||
}
|
}
|
||||||
// avoid cycle relate
|
// avoid cycle relate
|
||||||
if (childJobInfo.getId() == jobInfo.getId()) {
|
if (childJobInfo.getId() == jobInfo.getId()) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format(I18nUtil.getString("jobinfo_field_childJobId_limit"), childJobIdItem));
|
return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format(I18nUtil.getString("jobinfo_field_childJobId_limit"), childJobIdItem));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
||||||
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_unvalid")), childJobIdItem));
|
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_unvalid")), childJobIdItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jobInfo.setChildJobId(StringUtils.join(childJobIds, ","));
|
jobInfo.setChildJobId(StringUtils.join(childJobIds, ","));
|
||||||
}
|
}
|
||||||
|
|
||||||
// stage job info
|
// stage job info
|
||||||
XxlJobInfo exists_jobInfo = xxlJobInfoDao.loadById(jobInfo.getId());
|
XxlJobInfo exists_jobInfo = xxlJobInfoDao.loadById(jobInfo.getId());
|
||||||
if (exists_jobInfo == null) {
|
if (exists_jobInfo == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id")+I18nUtil.getString("system_not_found")) );
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id")+I18nUtil.getString("system_not_found")) );
|
||||||
}
|
}
|
||||||
//String old_cron = exists_jobInfo.getJobCron();
|
//String old_cron = exists_jobInfo.getJobCron();
|
||||||
|
|
||||||
exists_jobInfo.setJobCron(jobInfo.getJobCron());
|
exists_jobInfo.setJobCron(jobInfo.getJobCron());
|
||||||
exists_jobInfo.setJobDesc(jobInfo.getJobDesc());
|
exists_jobInfo.setJobDesc(jobInfo.getJobDesc());
|
||||||
exists_jobInfo.setAuthor(jobInfo.getAuthor());
|
exists_jobInfo.setAuthor(jobInfo.getAuthor());
|
||||||
exists_jobInfo.setAlarmEmail(jobInfo.getAlarmEmail());
|
exists_jobInfo.setAlarmEmail(jobInfo.getAlarmEmail());
|
||||||
exists_jobInfo.setExecutorRouteStrategy(jobInfo.getExecutorRouteStrategy());
|
exists_jobInfo.setExecutorRouteStrategy(jobInfo.getExecutorRouteStrategy());
|
||||||
exists_jobInfo.setExecutorHandler(jobInfo.getExecutorHandler());
|
exists_jobInfo.setExecutorHandler(jobInfo.getExecutorHandler());
|
||||||
exists_jobInfo.setExecutorParam(jobInfo.getExecutorParam());
|
exists_jobInfo.setExecutorParam(jobInfo.getExecutorParam());
|
||||||
exists_jobInfo.setExecutorBlockStrategy(jobInfo.getExecutorBlockStrategy());
|
exists_jobInfo.setExecutorBlockStrategy(jobInfo.getExecutorBlockStrategy());
|
||||||
exists_jobInfo.setExecutorFailStrategy(jobInfo.getExecutorFailStrategy());
|
exists_jobInfo.setExecutorFailStrategy(jobInfo.getExecutorFailStrategy());
|
||||||
exists_jobInfo.setExecutorTimeout(jobInfo.getExecutorTimeout());
|
exists_jobInfo.setExecutorTimeout(jobInfo.getExecutorTimeout());
|
||||||
exists_jobInfo.setExecutorFailRetryCount(jobInfo.getExecutorFailRetryCount());
|
exists_jobInfo.setExecutorFailRetryCount(jobInfo.getExecutorFailRetryCount());
|
||||||
exists_jobInfo.setChildJobId(jobInfo.getChildJobId());
|
exists_jobInfo.setChildJobId(jobInfo.getChildJobId());
|
||||||
xxlJobInfoDao.update(exists_jobInfo);
|
xxlJobInfoDao.update(exists_jobInfo);
|
||||||
|
|
||||||
// fresh quartz
|
// fresh quartz
|
||||||
String qz_group = String.valueOf(exists_jobInfo.getJobGroup());
|
String qz_group = String.valueOf(exists_jobInfo.getJobGroup());
|
||||||
String qz_name = String.valueOf(exists_jobInfo.getId());
|
String qz_name = String.valueOf(exists_jobInfo.getId());
|
||||||
try {
|
try {
|
||||||
boolean ret = XxlJobDynamicScheduler.rescheduleJob(qz_group, qz_name, exists_jobInfo.getJobCron());
|
boolean ret = XxlJobDynamicScheduler.rescheduleJob(qz_group, qz_name, exists_jobInfo.getJobCron());
|
||||||
return ret?ReturnT.SUCCESS:ReturnT.FAIL;
|
return ret?ReturnT.SUCCESS:ReturnT.FAIL;
|
||||||
} catch (SchedulerException e) {
|
} catch (SchedulerException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ReturnT.FAIL;
|
return ReturnT.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnT<String> remove(int id) {
|
public ReturnT<String> remove(int id) {
|
||||||
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
|
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
|
||||||
String group = String.valueOf(xxlJobInfo.getJobGroup());
|
String group = String.valueOf(xxlJobInfo.getJobGroup());
|
||||||
String name = String.valueOf(xxlJobInfo.getId());
|
String name = String.valueOf(xxlJobInfo.getId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
XxlJobDynamicScheduler.removeJob(name, group);
|
XxlJobDynamicScheduler.removeJob(name, group);
|
||||||
xxlJobInfoDao.delete(id);
|
xxlJobInfoDao.delete(id);
|
||||||
xxlJobLogDao.delete(id);
|
xxlJobLogDao.delete(id);
|
||||||
xxlJobLogGlueDao.deleteByJobId(id);
|
xxlJobLogGlueDao.deleteByJobId(id);
|
||||||
return ReturnT.SUCCESS;
|
return ReturnT.SUCCESS;
|
||||||
} catch (SchedulerException e) {
|
} catch (SchedulerException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
return ReturnT.FAIL;
|
return ReturnT.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnT<String> pause(int id) {
|
public ReturnT<String> pause(int id) {
|
||||||
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
|
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
|
||||||
String group = String.valueOf(xxlJobInfo.getJobGroup());
|
String group = String.valueOf(xxlJobInfo.getJobGroup());
|
||||||
String name = String.valueOf(xxlJobInfo.getId());
|
String name = String.valueOf(xxlJobInfo.getId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
boolean ret = XxlJobDynamicScheduler.pauseJob(name, group); // jobStatus do not store
|
boolean ret = XxlJobDynamicScheduler.pauseJob(name, group); // jobStatus do not store
|
||||||
return ret?ReturnT.SUCCESS:ReturnT.FAIL;
|
return ret?ReturnT.SUCCESS:ReturnT.FAIL;
|
||||||
} catch (SchedulerException e) {
|
} catch (SchedulerException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
return ReturnT.FAIL;
|
return ReturnT.FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnT<String> resume(int id) {
|
public ReturnT<String> resume(int id) {
|
||||||
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
|
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
|
||||||
String group = String.valueOf(xxlJobInfo.getJobGroup());
|
String group = String.valueOf(xxlJobInfo.getJobGroup());
|
||||||
String name = String.valueOf(xxlJobInfo.getId());
|
String name = String.valueOf(xxlJobInfo.getId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
boolean ret = XxlJobDynamicScheduler.resumeJob(name, group);
|
boolean ret = XxlJobDynamicScheduler.resumeJob(name, group);
|
||||||
return ret?ReturnT.SUCCESS:ReturnT.FAIL;
|
return ret?ReturnT.SUCCESS:ReturnT.FAIL;
|
||||||
} catch (SchedulerException e) {
|
} catch (SchedulerException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
return ReturnT.FAIL;
|
return ReturnT.FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnT<String> triggerJob(int id) {
|
public ReturnT<String> triggerJob(int id) {
|
||||||
|
|
||||||
JobTriggerPoolHelper.trigger(id);
|
JobTriggerPoolHelper.trigger(id);
|
||||||
return ReturnT.SUCCESS;
|
return ReturnT.SUCCESS;
|
||||||
|
|
||||||
/*XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
|
/*XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
|
||||||
if (xxlJobInfo == null) {
|
if (xxlJobInfo == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id")+I18nUtil.getString("system_unvalid")) );
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id")+I18nUtil.getString("system_unvalid")) );
|
||||||
}
|
}
|
||||||
|
|
||||||
String group = String.valueOf(xxlJobInfo.getJobGroup());
|
String group = String.valueOf(xxlJobInfo.getJobGroup());
|
||||||
String name = String.valueOf(xxlJobInfo.getId());
|
String name = String.valueOf(xxlJobInfo.getId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
XxlJobDynamicScheduler.triggerJob(name, group);
|
XxlJobDynamicScheduler.triggerJob(name, group);
|
||||||
return ReturnT.SUCCESS;
|
return ReturnT.SUCCESS;
|
||||||
} catch (SchedulerException e) {
|
} catch (SchedulerException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, e.getMessage());
|
return new ReturnT<String>(ReturnT.FAIL_CODE, e.getMessage());
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> dashboardInfo() {
|
public Map<String, Object> dashboardInfo() {
|
||||||
|
|
||||||
int jobInfoCount = xxlJobInfoDao.findAllCount();
|
int jobInfoCount = xxlJobInfoDao.findAllCount();
|
||||||
int jobLogCount = xxlJobLogDao.triggerCountByHandleCode(-1);
|
int jobLogCount = xxlJobLogDao.triggerCountByHandleCode(-1);
|
||||||
int jobLogSuccessCount = xxlJobLogDao.triggerCountByHandleCode(ReturnT.SUCCESS_CODE);
|
int jobLogSuccessCount = xxlJobLogDao.triggerCountByHandleCode(ReturnT.SUCCESS_CODE);
|
||||||
|
|
||||||
// executor count
|
// executor count
|
||||||
Set<String> executerAddressSet = new HashSet<String>();
|
Set<String> executerAddressSet = new HashSet<String>();
|
||||||
List<XxlJobGroup> groupList = xxlJobGroupDao.findAll();
|
List<XxlJobGroup> groupList = xxlJobGroupDao.findAll();
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(groupList)) {
|
if (CollectionUtils.isNotEmpty(groupList)) {
|
||||||
for (XxlJobGroup group: groupList) {
|
for (XxlJobGroup group: groupList) {
|
||||||
if (CollectionUtils.isNotEmpty(group.getRegistryList())) {
|
if (CollectionUtils.isNotEmpty(group.getRegistryList())) {
|
||||||
executerAddressSet.addAll(group.getRegistryList());
|
executerAddressSet.addAll(group.getRegistryList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int executorCount = executerAddressSet.size();
|
int executorCount = executerAddressSet.size();
|
||||||
|
|
||||||
Map<String, Object> dashboardMap = new HashMap<String, Object>();
|
Map<String, Object> dashboardMap = new HashMap<String, Object>();
|
||||||
dashboardMap.put("jobInfoCount", jobInfoCount);
|
dashboardMap.put("jobInfoCount", jobInfoCount);
|
||||||
dashboardMap.put("jobLogCount", jobLogCount);
|
dashboardMap.put("jobLogCount", jobLogCount);
|
||||||
dashboardMap.put("jobLogSuccessCount", jobLogSuccessCount);
|
dashboardMap.put("jobLogSuccessCount", jobLogSuccessCount);
|
||||||
dashboardMap.put("executorCount", executorCount);
|
dashboardMap.put("executorCount", executorCount);
|
||||||
return dashboardMap;
|
return dashboardMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String TRIGGER_CHART_DATA_CACHE = "trigger_chart_data_cache";
|
private static final String TRIGGER_CHART_DATA_CACHE = "trigger_chart_data_cache";
|
||||||
@Override
|
@Override
|
||||||
public ReturnT<Map<String, Object>> chartInfo(Date startDate, Date endDate) {
|
public ReturnT<Map<String, Object>> chartInfo(Date startDate, Date endDate) {
|
||||||
/*// get cache
|
/*// get cache
|
||||||
String cacheKey = TRIGGER_CHART_DATA_CACHE + "_" + startDate.getTime() + "_" + endDate.getTime();
|
String cacheKey = TRIGGER_CHART_DATA_CACHE + "_" + startDate.getTime() + "_" + endDate.getTime();
|
||||||
Map<String, Object> chartInfo = (Map<String, Object>) LocalCacheUtil.get(cacheKey);
|
Map<String, Object> chartInfo = (Map<String, Object>) LocalCacheUtil.get(cacheKey);
|
||||||
if (chartInfo != null) {
|
if (chartInfo != null) {
|
||||||
return new ReturnT<Map<String, Object>>(chartInfo);
|
return new ReturnT<Map<String, Object>>(chartInfo);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
// process
|
// process
|
||||||
List<String> triggerDayList = new ArrayList<String>();
|
List<String> triggerDayList = new ArrayList<String>();
|
||||||
List<Integer> triggerDayCountRunningList = new ArrayList<Integer>();
|
List<Integer> triggerDayCountRunningList = new ArrayList<Integer>();
|
||||||
List<Integer> triggerDayCountSucList = new ArrayList<Integer>();
|
List<Integer> triggerDayCountSucList = new ArrayList<Integer>();
|
||||||
List<Integer> triggerDayCountFailList = new ArrayList<Integer>();
|
List<Integer> triggerDayCountFailList = new ArrayList<Integer>();
|
||||||
int triggerCountRunningTotal = 0;
|
int triggerCountRunningTotal = 0;
|
||||||
int triggerCountSucTotal = 0;
|
int triggerCountSucTotal = 0;
|
||||||
int triggerCountFailTotal = 0;
|
int triggerCountFailTotal = 0;
|
||||||
|
|
||||||
List<Map<String, Object>> triggerCountMapAll = xxlJobLogDao.triggerCountByDay(startDate, endDate);
|
List<Map<String, Object>> triggerCountMapAll = xxlJobLogDao.triggerCountByDay(startDate, endDate);
|
||||||
if (CollectionUtils.isNotEmpty(triggerCountMapAll)) {
|
if (CollectionUtils.isNotEmpty(triggerCountMapAll)) {
|
||||||
for (Map<String, Object> item: triggerCountMapAll) {
|
for (Map<String, Object> item: triggerCountMapAll) {
|
||||||
String day = String.valueOf(item.get("triggerDay"));
|
String day = String.valueOf(item.get("triggerDay"));
|
||||||
int triggerDayCount = Integer.valueOf(String.valueOf(item.get("triggerDayCount")));
|
int triggerDayCount = Integer.valueOf(String.valueOf(item.get("triggerDayCount")));
|
||||||
int triggerDayCountRunning = Integer.valueOf(String.valueOf(item.get("triggerDayCountRunning")));
|
int triggerDayCountRunning = Integer.valueOf(String.valueOf(item.get("triggerDayCountRunning")));
|
||||||
int triggerDayCountSuc = Integer.valueOf(String.valueOf(item.get("triggerDayCountSuc")));
|
int triggerDayCountSuc = Integer.valueOf(String.valueOf(item.get("triggerDayCountSuc")));
|
||||||
int triggerDayCountFail = triggerDayCount - triggerDayCountRunning - triggerDayCountSuc;
|
int triggerDayCountFail = triggerDayCount - triggerDayCountRunning - triggerDayCountSuc;
|
||||||
|
|
||||||
triggerDayList.add(day);
|
triggerDayList.add(day);
|
||||||
triggerDayCountRunningList.add(triggerDayCountRunning);
|
triggerDayCountRunningList.add(triggerDayCountRunning);
|
||||||
triggerDayCountSucList.add(triggerDayCountSuc);
|
triggerDayCountSucList.add(triggerDayCountSuc);
|
||||||
triggerDayCountFailList.add(triggerDayCountFail);
|
triggerDayCountFailList.add(triggerDayCountFail);
|
||||||
|
|
||||||
triggerCountRunningTotal += triggerDayCountRunning;
|
triggerCountRunningTotal += triggerDayCountRunning;
|
||||||
triggerCountSucTotal += triggerDayCountSuc;
|
triggerCountSucTotal += triggerDayCountSuc;
|
||||||
triggerCountFailTotal += triggerDayCountFail;
|
triggerCountFailTotal += triggerDayCountFail;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 4; i > -1; i--) {
|
for (int i = 4; i > -1; i--) {
|
||||||
triggerDayList.add(FastDateFormat.getInstance("yyyy-MM-dd").format(DateUtils.addDays(new Date(), -i)));
|
triggerDayList.add(FastDateFormat.getInstance("yyyy-MM-dd").format(DateUtils.addDays(new Date(), -i)));
|
||||||
triggerDayCountSucList.add(0);
|
triggerDayCountSucList.add(0);
|
||||||
triggerDayCountFailList.add(0);
|
triggerDayCountFailList.add(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<String, Object>();
|
Map<String, Object> result = new HashMap<String, Object>();
|
||||||
result.put("triggerDayList", triggerDayList);
|
result.put("triggerDayList", triggerDayList);
|
||||||
result.put("triggerDayCountRunningList", triggerDayCountRunningList);
|
result.put("triggerDayCountRunningList", triggerDayCountRunningList);
|
||||||
result.put("triggerDayCountSucList", triggerDayCountSucList);
|
result.put("triggerDayCountSucList", triggerDayCountSucList);
|
||||||
result.put("triggerDayCountFailList", triggerDayCountFailList);
|
result.put("triggerDayCountFailList", triggerDayCountFailList);
|
||||||
|
|
||||||
result.put("triggerCountRunningTotal", triggerCountRunningTotal);
|
result.put("triggerCountRunningTotal", triggerCountRunningTotal);
|
||||||
result.put("triggerCountSucTotal", triggerCountSucTotal);
|
result.put("triggerCountSucTotal", triggerCountSucTotal);
|
||||||
result.put("triggerCountFailTotal", triggerCountFailTotal);
|
result.put("triggerCountFailTotal", triggerCountFailTotal);
|
||||||
|
|
||||||
/*// set cache
|
/*// set cache
|
||||||
LocalCacheUtil.set(cacheKey, result, 60*1000); // cache 60s*/
|
LocalCacheUtil.set(cacheKey, result, 60*1000); // cache 60s*/
|
||||||
|
|
||||||
return new ReturnT<Map<String, Object>>(result);
|
return new ReturnT<Map<String, Object>>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,186 +1,186 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.xxl.job.admin.dao.XxlJobInfoDao">
|
<mapper namespace="com.xxl.job.admin.dao.XxlJobInfoDao">
|
||||||
|
|
||||||
<resultMap id="XxlJobInfo" type="com.xxl.job.admin.core.model.XxlJobInfo" >
|
<resultMap id="XxlJobInfo" type="com.xxl.job.admin.core.model.XxlJobInfo" >
|
||||||
<result column="id" property="id" />
|
<result column="id" property="id" />
|
||||||
|
|
||||||
<result column="job_group" property="jobGroup" />
|
<result column="job_group" property="jobGroup" />
|
||||||
<result column="job_cron" property="jobCron" />
|
<result column="job_cron" property="jobCron" />
|
||||||
<result column="job_desc" property="jobDesc" />
|
<result column="job_desc" property="jobDesc" />
|
||||||
|
|
||||||
<result column="add_time" property="addTime" />
|
<result column="add_time" property="addTime" />
|
||||||
<result column="update_time" property="updateTime" />
|
<result column="update_time" property="updateTime" />
|
||||||
|
|
||||||
<result column="author" property="author" />
|
<result column="author" property="author" />
|
||||||
<result column="alarm_email" property="alarmEmail" />
|
<result column="alarm_email" property="alarmEmail" />
|
||||||
|
|
||||||
<result column="executor_route_strategy" property="executorRouteStrategy" />
|
<result column="executor_route_strategy" property="executorRouteStrategy" />
|
||||||
<result column="executor_handler" property="executorHandler" />
|
<result column="executor_handler" property="executorHandler" />
|
||||||
<result column="executor_param" property="executorParam" />
|
<result column="executor_param" property="executorParam" />
|
||||||
<result column="executor_block_strategy" property="executorBlockStrategy" />
|
<result column="executor_block_strategy" property="executorBlockStrategy" />
|
||||||
<result column="executor_fail_strategy" property="executorFailStrategy" />
|
<result column="executor_fail_strategy" property="executorFailStrategy" />
|
||||||
<result column="executor_timeout" property="executorTimeout" />
|
<result column="executor_timeout" property="executorTimeout" />
|
||||||
<result column="executor_fail_retry_count" property="executorFailRetryCount" />
|
<result column="executor_fail_retry_count" property="executorFailRetryCount" />
|
||||||
|
|
||||||
<result column="glue_type" property="glueType" />
|
<result column="glue_type" property="glueType" />
|
||||||
<result column="glue_source" property="glueSource" />
|
<result column="glue_source" property="glueSource" />
|
||||||
<result column="glue_remark" property="glueRemark" />
|
<result column="glue_remark" property="glueRemark" />
|
||||||
<result column="glue_updatetime" property="glueUpdatetime" />
|
<result column="glue_updatetime" property="glueUpdatetime" />
|
||||||
|
|
||||||
<result column="child_jobid" property="childJobId" />
|
<result column="child_jobid" property="childJobId" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
t.id,
|
t.id,
|
||||||
t.job_group,
|
t.job_group,
|
||||||
t.job_cron,
|
t.job_cron,
|
||||||
t.job_desc,
|
t.job_desc,
|
||||||
t.add_time,
|
t.add_time,
|
||||||
t.update_time,
|
t.update_time,
|
||||||
t.author,
|
t.author,
|
||||||
t.alarm_email,
|
t.alarm_email,
|
||||||
t.executor_route_strategy,
|
t.executor_route_strategy,
|
||||||
t.executor_handler,
|
t.executor_handler,
|
||||||
t.executor_param,
|
t.executor_param,
|
||||||
t.executor_block_strategy,
|
t.executor_block_strategy,
|
||||||
t.executor_fail_strategy,
|
t.executor_fail_strategy,
|
||||||
t.executor_timeout,
|
t.executor_timeout,
|
||||||
t.executor_fail_retry_count,
|
t.executor_fail_retry_count,
|
||||||
t.glue_type,
|
t.glue_type,
|
||||||
t.glue_source,
|
t.glue_source,
|
||||||
t.glue_remark,
|
t.glue_remark,
|
||||||
t.glue_updatetime,
|
t.glue_updatetime,
|
||||||
t.child_jobid
|
t.child_jobid
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="pageList" parameterType="java.util.HashMap" resultMap="XxlJobInfo">
|
<select id="pageList" parameterType="java.util.HashMap" resultMap="XxlJobInfo">
|
||||||
SELECT <include refid="Base_Column_List" />
|
SELECT <include refid="Base_Column_List" />
|
||||||
FROM XXL_JOB_QRTZ_TRIGGER_INFO AS t
|
FROM XXL_JOB_QRTZ_TRIGGER_INFO AS t
|
||||||
<trim prefix="WHERE" prefixOverrides="AND | OR" >
|
<trim prefix="WHERE" prefixOverrides="AND | OR" >
|
||||||
<if test="jobGroup gt 0">
|
<if test="jobGroup gt 0">
|
||||||
AND t.job_group = #{jobGroup}
|
AND t.job_group = #{jobGroup}
|
||||||
</if>
|
</if>
|
||||||
<if test="jobDesc != null and jobDesc != ''">
|
<if test="jobDesc != null and jobDesc != ''">
|
||||||
AND t.job_desc like CONCAT(CONCAT('%', #{jobDesc}), '%')
|
AND t.job_desc like CONCAT(CONCAT('%', #{jobDesc}), '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="executorHandler != null and executorHandler != ''">
|
<if test="executorHandler != null and executorHandler != ''">
|
||||||
AND t.executor_handler like CONCAT(CONCAT('%', #{executorHandler}), '%')
|
AND t.executor_handler like CONCAT(CONCAT('%', #{executorHandler}), '%')
|
||||||
</if>
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
ORDER BY id DESC
|
ORDER BY id DESC
|
||||||
LIMIT #{offset}, #{pagesize}
|
LIMIT #{offset}, #{pagesize}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="pageListCount" parameterType="java.util.HashMap" resultType="int">
|
<select id="pageListCount" parameterType="java.util.HashMap" resultType="int">
|
||||||
SELECT count(1)
|
SELECT count(1)
|
||||||
FROM XXL_JOB_QRTZ_TRIGGER_INFO AS t
|
FROM XXL_JOB_QRTZ_TRIGGER_INFO AS t
|
||||||
<trim prefix="WHERE" prefixOverrides="AND | OR" >
|
<trim prefix="WHERE" prefixOverrides="AND | OR" >
|
||||||
<if test="jobGroup gt 0">
|
<if test="jobGroup gt 0">
|
||||||
AND t.job_group = #{jobGroup}
|
AND t.job_group = #{jobGroup}
|
||||||
</if>
|
</if>
|
||||||
<if test="jobDesc != null and jobDesc != ''">
|
<if test="jobDesc != null and jobDesc != ''">
|
||||||
AND t.job_desc like CONCAT(CONCAT('%', #{jobDesc}), '%')
|
AND t.job_desc like CONCAT(CONCAT('%', #{jobDesc}), '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="executorHandler != null and executorHandler != ''">
|
<if test="executorHandler != null and executorHandler != ''">
|
||||||
AND t.executor_handler like CONCAT(CONCAT('%', #{executorHandler}), '%')
|
AND t.executor_handler like CONCAT(CONCAT('%', #{executorHandler}), '%')
|
||||||
</if>
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobInfo" useGeneratedKeys="true" keyProperty="id" >
|
<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobInfo" useGeneratedKeys="true" keyProperty="id" >
|
||||||
INSERT INTO XXL_JOB_QRTZ_TRIGGER_INFO (
|
INSERT INTO XXL_JOB_QRTZ_TRIGGER_INFO (
|
||||||
job_group,
|
job_group,
|
||||||
job_cron,
|
job_cron,
|
||||||
job_desc,
|
job_desc,
|
||||||
add_time,
|
add_time,
|
||||||
update_time,
|
update_time,
|
||||||
author,
|
author,
|
||||||
alarm_email,
|
alarm_email,
|
||||||
executor_route_strategy,
|
executor_route_strategy,
|
||||||
executor_handler,
|
executor_handler,
|
||||||
executor_param,
|
executor_param,
|
||||||
executor_block_strategy,
|
executor_block_strategy,
|
||||||
executor_fail_strategy,
|
executor_fail_strategy,
|
||||||
executor_timeout,
|
executor_timeout,
|
||||||
executor_fail_retry_count,
|
executor_fail_retry_count,
|
||||||
glue_type,
|
glue_type,
|
||||||
glue_source,
|
glue_source,
|
||||||
glue_remark,
|
glue_remark,
|
||||||
glue_updatetime,
|
glue_updatetime,
|
||||||
child_jobid
|
child_jobid
|
||||||
) VALUES (
|
) VALUES (
|
||||||
#{jobGroup},
|
#{jobGroup},
|
||||||
#{jobCron},
|
#{jobCron},
|
||||||
#{jobDesc},
|
#{jobDesc},
|
||||||
NOW(),
|
NOW(),
|
||||||
NOW(),
|
NOW(),
|
||||||
#{author},
|
#{author},
|
||||||
#{alarmEmail},
|
#{alarmEmail},
|
||||||
#{executorRouteStrategy},
|
#{executorRouteStrategy},
|
||||||
#{executorHandler},
|
#{executorHandler},
|
||||||
#{executorParam},
|
#{executorParam},
|
||||||
#{executorBlockStrategy},
|
#{executorBlockStrategy},
|
||||||
#{executorFailStrategy},
|
#{executorFailStrategy},
|
||||||
#{executorTimeout},
|
#{executorTimeout},
|
||||||
#{executorFailRetryCount},
|
#{executorFailRetryCount},
|
||||||
#{glueType},
|
#{glueType},
|
||||||
#{glueSource},
|
#{glueSource},
|
||||||
#{glueRemark},
|
#{glueRemark},
|
||||||
NOW(),
|
NOW(),
|
||||||
#{childJobId}
|
#{childJobId}
|
||||||
);
|
);
|
||||||
<!--<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
|
<!--<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
|
||||||
SELECT LAST_INSERT_ID()
|
SELECT LAST_INSERT_ID()
|
||||||
/*SELECT @@IDENTITY AS id*/
|
/*SELECT @@IDENTITY AS id*/
|
||||||
</selectKey>-->
|
</selectKey>-->
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<select id="loadById" parameterType="java.util.HashMap" resultMap="XxlJobInfo">
|
<select id="loadById" parameterType="java.util.HashMap" resultMap="XxlJobInfo">
|
||||||
SELECT <include refid="Base_Column_List" />
|
SELECT <include refid="Base_Column_List" />
|
||||||
FROM XXL_JOB_QRTZ_TRIGGER_INFO AS t
|
FROM XXL_JOB_QRTZ_TRIGGER_INFO AS t
|
||||||
WHERE t.id = #{id}
|
WHERE t.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="update" parameterType="com.xxl.job.admin.core.model.XxlJobInfo" >
|
<update id="update" parameterType="com.xxl.job.admin.core.model.XxlJobInfo" >
|
||||||
UPDATE XXL_JOB_QRTZ_TRIGGER_INFO
|
UPDATE XXL_JOB_QRTZ_TRIGGER_INFO
|
||||||
SET
|
SET
|
||||||
job_cron = #{jobCron},
|
job_cron = #{jobCron},
|
||||||
job_desc = #{jobDesc},
|
job_desc = #{jobDesc},
|
||||||
update_time = NOW(),
|
update_time = NOW(),
|
||||||
author = #{author},
|
author = #{author},
|
||||||
alarm_email = #{alarmEmail},
|
alarm_email = #{alarmEmail},
|
||||||
executor_route_strategy = #{executorRouteStrategy},
|
executor_route_strategy = #{executorRouteStrategy},
|
||||||
executor_handler = #{executorHandler},
|
executor_handler = #{executorHandler},
|
||||||
executor_param = #{executorParam},
|
executor_param = #{executorParam},
|
||||||
executor_block_strategy = #{executorBlockStrategy},
|
executor_block_strategy = #{executorBlockStrategy},
|
||||||
executor_fail_strategy = #{executorFailStrategy},
|
executor_fail_strategy = #{executorFailStrategy},
|
||||||
executor_timeout = ${executorTimeout},
|
executor_timeout = ${executorTimeout},
|
||||||
executor_fail_retry_count = ${executorFailRetryCount},
|
executor_fail_retry_count = ${executorFailRetryCount},
|
||||||
glue_type = #{glueType},
|
glue_type = #{glueType},
|
||||||
glue_source = #{glueSource},
|
glue_source = #{glueSource},
|
||||||
glue_remark = #{glueRemark},
|
glue_remark = #{glueRemark},
|
||||||
glue_updatetime = #{glueUpdatetime},
|
glue_updatetime = #{glueUpdatetime},
|
||||||
child_jobid = #{childJobId}
|
child_jobid = #{childJobId}
|
||||||
WHERE id = #{id}
|
WHERE id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="delete" parameterType="java.util.HashMap">
|
<delete id="delete" parameterType="java.util.HashMap">
|
||||||
DELETE
|
DELETE
|
||||||
FROM XXL_JOB_QRTZ_TRIGGER_INFO
|
FROM XXL_JOB_QRTZ_TRIGGER_INFO
|
||||||
WHERE id = #{id}
|
WHERE id = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<select id="getJobsByGroup" parameterType="java.util.HashMap" resultMap="XxlJobInfo">
|
<select id="getJobsByGroup" parameterType="java.util.HashMap" resultMap="XxlJobInfo">
|
||||||
SELECT <include refid="Base_Column_List" />
|
SELECT <include refid="Base_Column_List" />
|
||||||
FROM XXL_JOB_QRTZ_TRIGGER_INFO AS t
|
FROM XXL_JOB_QRTZ_TRIGGER_INFO AS t
|
||||||
WHERE t.job_group = #{jobGroup}
|
WHERE t.job_group = #{jobGroup}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findAllCount" resultType="int">
|
<select id="findAllCount" resultType="int">
|
||||||
SELECT count(1)
|
SELECT count(1)
|
||||||
FROM XXL_JOB_QRTZ_TRIGGER_INFO
|
FROM XXL_JOB_QRTZ_TRIGGER_INFO
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue