From 2bfd1cb7a7b23961e0e2cf0d207646878adc6b28 Mon Sep 17 00:00:00 2001 From: "xueli.xue" Date: Sat, 16 Jan 2016 16:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 + doc/db/tables_xxl_log.sql | 40 +++++-- xxl-job-admin/pom.xml | 2 +- .../xxl/job/controller/IndexController.java | 2 +- ...Controller.java => JobInfoController.java} | 10 +- .../xxl/job/controller/JobLogController.java | 63 +++++------ .../com/xxl/job/core/constant/Constants.java | 32 ++++++ .../com/xxl/job/core/model/XxlJobInfo.java | 88 ++++++++++++--- .../com/xxl/job/core/model/XxlJobLog.java | 16 ++- .../core/resolver/WebExceptionResolver.java | 41 +++++++ .../java/com/xxl/job/dao/IXxlJobLogDao.java | 11 +- .../xxl/job/dao/impl/XxlJobLogDaoImpl.java | 66 ++++++----- .../mybatis-mapper/XxlJobLogMapper.xml | 105 ++++++++++-------- .../src/main/resources/springmvc-context.xml | 2 + .../WEB-INF/template/common/common.macro.ftl | 2 +- .../template/{job => jobinfo}/index.ftl | 28 ++++- .../webapp/WEB-INF/template/joblog/index.ftl | 53 +++++---- xxl-job-admin/src/main/webapp/favicon.ico | Bin 0 -> 1150 bytes .../js/{job.index.1.js => jobinfo.index.1.js} | 2 +- .../main/webapp/static/js/joblog.index.1.js | 53 ++++++--- 20 files changed, 421 insertions(+), 197 deletions(-) rename xxl-job-admin/src/main/java/com/xxl/job/controller/{JobController.java => JobInfoController.java} (94%) create mode 100644 xxl-job-admin/src/main/java/com/xxl/job/core/constant/Constants.java create mode 100644 xxl-job-admin/src/main/java/com/xxl/job/core/resolver/WebExceptionResolver.java rename xxl-job-admin/src/main/webapp/WEB-INF/template/{job => jobinfo}/index.ftl (88%) create mode 100644 xxl-job-admin/src/main/webapp/favicon.ico rename xxl-job-admin/src/main/webapp/static/js/{job.index.1.js => jobinfo.index.1.js} (97%) diff --git a/README.md b/README.md index b10ef4f5..0b45a70a 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ github地址:https://github.com/xuxueli/xxl-job git.osc地址:http://git.oschina.net/xuxueli0323/xxl-job 博客地址(内附使用教程):http://www.cnblogs.com/xuxueli/p/5021979.html + +技术交流群(仅作技术交流):367260654 # 特点:基于quartz封装实现的的集群任务调度管理平台 1、简单:支持通过Web页面对任务进行CRUD操作,操作简单,一分钟上手; diff --git a/doc/db/tables_xxl_log.sql b/doc/db/tables_xxl_log.sql index 6af3e0a0..867b3283 100644 --- a/doc/db/tables_xxl_log.sql +++ b/doc/db/tables_xxl_log.sql @@ -10,6 +10,7 @@ # DROP TABLE IF EXISTS XXL_JOB_QRTZ_JOB_DETAILS; # DROP TABLE IF EXISTS XXL_JOB_QRTZ_CALENDARS; # DROP TABLE IF EXISTS `xxl_job_qrtz_trigger_log`; +# DROP TABLE IF EXISTS `xxl_job_qrtz_trigger_info`; CREATE TABLE XXL_JOB_QRTZ_JOB_DETAILS ( @@ -158,18 +159,35 @@ CREATE TABLE XXL_JOB_QRTZ_LOCKS CREATE TABLE `xxl_job_qrtz_trigger_log` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `job_name` varchar(255) NOT NULL, - `job_cron` varchar(128) DEFAULT NULL, - `job_class` varchar(255) DEFAULT NULL, - `job_data` varchar(2048) DEFAULT NULL, - `trigger_time` datetime DEFAULT NULL, - `trigger_status` varchar(255) DEFAULT NULL, - `trigger_msg` varchar(2048) DEFAULT NULL, - `handle_time` datetime DEFAULT NULL, - `handle_status` varchar(255) DEFAULT NULL, - `handle_msg` varchar(2048) DEFAULT NULL, + `job_group` varchar(255) NOT NULL COMMENT '任务组', + `job_name` varchar(255) NOT NULL COMMENT '任务名', + `job_cron` varchar(128) NOT NULL COMMENT '任务执行CORN表达式', + `job_class` varchar(255) NOT NULL COMMENT '任务执行JobBean', + `job_data` varchar(2048) DEFAULT NULL COMMENT '任务执行数据', + `trigger_time` datetime DEFAULT NULL COMMENT '调度-时间', + `trigger_status` varchar(255) DEFAULT NULL COMMENT '调度-结果', + `trigger_msg` varchar(2048) DEFAULT NULL COMMENT '调度-日志', + `handle_time` datetime DEFAULT NULL COMMENT '执行-时间', + `handle_status` varchar(255) DEFAULT NULL COMMENT '执行-状态', + `handle_msg` varchar(2048) DEFAULT NULL COMMENT '执行-日志', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=127 DEFAULT CHARSET=utf8; +); + +CREATE TABLE `xxl_job_qrtz_trigger_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `job_group` varchar(255) NOT NULL COMMENT '任务组', + `job_name` varchar(255) NOT NULL COMMENT '任务名', + `job_cron` varchar(128) NOT NULL COMMENT '任务执行CORN表达式', + `job_class` varchar(255) NOT NULL COMMENT '任务执行JobBean', + `job_data` varchar(2048) DEFAULT NULL COMMENT '任务执行数据', + `trigger_time` datetime DEFAULT NULL COMMENT '调度-时间', + `trigger_status` varchar(255) DEFAULT NULL COMMENT '调度-结果', + `trigger_msg` varchar(2048) DEFAULT NULL COMMENT '调度-日志', + `handle_time` datetime DEFAULT NULL COMMENT '执行-时间', + `handle_status` varchar(255) DEFAULT NULL COMMENT '执行-状态', + `handle_msg` varchar(2048) DEFAULT NULL COMMENT '执行-日志', + PRIMARY KEY (`id`) +); commit; diff --git a/xxl-job-admin/pom.xml b/xxl-job-admin/pom.xml index 4fd7a6df..b6215796 100644 --- a/xxl-job-admin/pom.xml +++ b/xxl-job-admin/pom.xml @@ -127,7 +127,7 @@ org.quartz-scheduler quartz - 2.2.1 + 2.2.2 diff --git a/xxl-job-admin/src/main/java/com/xxl/job/controller/IndexController.java b/xxl-job-admin/src/main/java/com/xxl/job/controller/IndexController.java index caffe293..d73c4ca4 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/controller/IndexController.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/controller/IndexController.java @@ -13,7 +13,7 @@ public class IndexController { @RequestMapping("/") public String index(Model model) { - return "redirect:job"; + return "redirect:jobinfo"; } @RequestMapping("/help") diff --git a/xxl-job-admin/src/main/java/com/xxl/job/controller/JobController.java b/xxl-job-admin/src/main/java/com/xxl/job/controller/JobInfoController.java similarity index 94% rename from xxl-job-admin/src/main/java/com/xxl/job/controller/JobController.java rename to xxl-job-admin/src/main/java/com/xxl/job/controller/JobInfoController.java index 2a3b9412..128916a9 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/controller/JobController.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/controller/JobInfoController.java @@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import com.xxl.job.client.handler.HandlerRepository; import com.xxl.job.client.util.JacksonUtil; +import com.xxl.job.core.constant.Constants.JobGroupEnum; import com.xxl.job.core.model.ReturnT; import com.xxl.job.core.model.XxlJobInfo; import com.xxl.job.core.util.DynamicSchedulerUtil; @@ -33,17 +34,16 @@ import com.xxl.job.service.job.HttpJobBean; * @author xuxueli 2015-12-19 16:13:16 */ @Controller -@RequestMapping("/job") -public class JobController { +@RequestMapping("/jobinfo") +public class JobInfoController { @Resource private IXxlJobInfoDao xxlJobInfoDao; @RequestMapping public String index(Model model) { - //List> jobList = DynamicSchedulerUtil.getJobList(); - //model.addAttribute("jobList", jobList); - return "job/index"; + model.addAttribute("JobGroupList", JobGroupEnum.values()); + return "jobinfo/index"; } @RequestMapping("/pageList") diff --git a/xxl-job-admin/src/main/java/com/xxl/job/controller/JobLogController.java b/xxl-job-admin/src/main/java/com/xxl/job/controller/JobLogController.java index 3122a421..a0c79f2e 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/controller/JobLogController.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/controller/JobLogController.java @@ -1,7 +1,6 @@ package com.xxl.job.controller; import java.text.ParseException; -import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -17,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; +import com.xxl.job.core.constant.Constants.JobGroupEnum; import com.xxl.job.core.model.ReturnT; import com.xxl.job.core.model.XxlJobLog; import com.xxl.job.dao.IXxlJobLogDao; @@ -32,33 +32,9 @@ public class JobLogController { @Resource public IXxlJobLogDao xxlJobLogDao; - @RequestMapping("/save") - @ResponseBody - public ReturnT triggerLog(int triggerLogId, String status, String msg) { - XxlJobLog log = xxlJobLogDao.load(triggerLogId); - if (log!=null) { - log.setHandleTime(new Date()); - log.setHandleStatus(status); - log.setHandleMsg(msg); - xxlJobLogDao.updateHandleInfo(log); - return ReturnT.SUCCESS; - } - return ReturnT.FAIL; - } - @RequestMapping - public String index(Model model, String jobName, String filterTime) { - - // 默认filterTime - Calendar todayz = Calendar.getInstance(); - todayz.set(Calendar.HOUR_OF_DAY, 0); - todayz.set(Calendar.MINUTE, 0); - todayz.set(Calendar.SECOND, 0); - model.addAttribute("triggerTimeStart", todayz.getTime()); - model.addAttribute("triggerTimeEnd", Calendar.getInstance().getTime()); - - model.addAttribute("jobName", jobName); - model.addAttribute("filterTime", filterTime); + public String index(Model model) { + model.addAttribute("JobGroupList", JobGroupEnum.values()); return "joblog/index"; } @@ -66,7 +42,8 @@ public class JobLogController { @ResponseBody public Map pageList(@RequestParam(required = false, defaultValue = "0") int start, @RequestParam(required = false, defaultValue = "10") int length, - String jobName, String filterTime) { + String jobGroup, String jobName, String filterTime) { + // parse param Date triggerTimeStart = null; Date triggerTimeEnd = null; @@ -74,24 +51,36 @@ public class JobLogController { String[] temp = filterTime.split(" - "); if (temp!=null && temp.length == 2) { try { - triggerTimeEnd = DateUtils.parseDate(temp[0], new String[]{"yyyy-MM-dd HH:mm:ss"}); + triggerTimeStart = DateUtils.parseDate(temp[0], new String[]{"yyyy-MM-dd HH:mm:ss"}); triggerTimeEnd = DateUtils.parseDate(temp[1], new String[]{"yyyy-MM-dd HH:mm:ss"}); - } catch (ParseException e) { - e.printStackTrace(); - } + } catch (ParseException e) { } } } // page query - List list = xxlJobLogDao.pageList(start, length, jobName, triggerTimeStart, triggerTimeEnd); - int list_count = xxlJobLogDao.pageListCount(start, length, jobName, triggerTimeStart, triggerTimeEnd); + List list = xxlJobLogDao.pageList(start, length, jobGroup, jobName, triggerTimeStart, triggerTimeEnd); + int list_count = xxlJobLogDao.pageListCount(start, length, jobGroup, jobName, triggerTimeStart, triggerTimeEnd); // package result Map maps = new HashMap(); - maps.put("recordsTotal", list_count); // 总记录数 - maps.put("recordsFiltered", list_count);// 过滤后的总记录数 - maps.put("data", list); // 分页列表 + maps.put("recordsTotal", list_count); // 总记录数 + maps.put("recordsFiltered", list_count); // 过滤后的总记录数 + maps.put("data", list); // 分页列表 return maps; } + @RequestMapping("/save") + @ResponseBody + public ReturnT triggerLog(int triggerLogId, String status, String msg) { + XxlJobLog log = xxlJobLogDao.load(triggerLogId); + if (log!=null) { + log.setHandleTime(new Date()); + log.setHandleStatus(status); + log.setHandleMsg(msg); + xxlJobLogDao.updateHandleInfo(log); + return ReturnT.SUCCESS; + } + return ReturnT.FAIL; + } + } diff --git a/xxl-job-admin/src/main/java/com/xxl/job/core/constant/Constants.java b/xxl-job-admin/src/main/java/com/xxl/job/core/constant/Constants.java new file mode 100644 index 00000000..1f76a5b0 --- /dev/null +++ b/xxl-job-admin/src/main/java/com/xxl/job/core/constant/Constants.java @@ -0,0 +1,32 @@ +package com.xxl.job.core.constant; + +/** + * job group + * @author xuxueli 2016-1-15 14:23:05 + */ +public class Constants { + + public enum JobGroupEnum{ + DEFAULT("默认"), + WAIMAI("外卖"), + MOVIE("电影"); + private String desc; + private JobGroupEnum(String desc){ + this.desc = desc; + } + public String getDesc() { + return desc; + } + public static JobGroupEnum match(String name){ + if (name==null || name.trim().length()==0) { + return null; + } + for (JobGroupEnum group : JobGroupEnum.values()) { + if (group.name().equals(name)) { + return group; + } + } + return null; + } + } +} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/core/model/XxlJobInfo.java b/xxl-job-admin/src/main/java/com/xxl/job/core/model/XxlJobInfo.java index e539af01..749b1047 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/core/model/XxlJobInfo.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/core/model/XxlJobInfo.java @@ -9,69 +9,125 @@ import java.util.Date; public class XxlJobInfo { private int id; - // job info - private String jobName; - private String jobCron; // base on quartz - private String jobClass; // base on quartz - private String jobStatus; // base on quartz - private String jobData; // base on db, Map-JSON-String + + private String jobGroup; // base on quartz 任务组 + private String jobName; // base on quartz 任务名 + private String jobCron; // base on quartz 任务执行CRON表达式 + private String jobClass; // base on quartz 任务执行JobBean + private String jobData; // base on db, Map-JSON-String 任务执行数据 + private Date addTime; private Date updateTime; + private String author; // 作者 + private String alarmEmail; // 报警邮件 + private int alarmThreshold; // 报警阀值 + + // copy from quartz + private String jobStatus; // 任务状态 + public int getId() { return id; } + public void setId(int id) { this.id = id; } + + public String getJobGroup() { + return jobGroup; + } + + public void setJobGroup(String jobGroup) { + this.jobGroup = jobGroup; + } + public String getJobName() { return jobName; } + public void setJobName(String jobName) { this.jobName = jobName; } + public String getJobCron() { return jobCron; } + public void setJobCron(String jobCron) { this.jobCron = jobCron; } + public String getJobClass() { return jobClass; } + public void setJobClass(String jobClass) { this.jobClass = jobClass; } - public String getJobStatus() { - return jobStatus; - } - public void setJobStatus(String jobStatus) { - this.jobStatus = jobStatus; - } + public String getJobData() { return jobData; } + public void setJobData(String jobData) { this.jobData = jobData; } + public Date getAddTime() { return addTime; } + public void setAddTime(Date addTime) { this.addTime = addTime; } + public Date getUpdateTime() { return updateTime; } + public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } - + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + + public String getAlarmEmail() { + return alarmEmail; + } + + public void setAlarmEmail(String alarmEmail) { + this.alarmEmail = alarmEmail; + } + + public int getAlarmThreshold() { + return alarmThreshold; + } + + public void setAlarmThreshold(int alarmThreshold) { + this.alarmThreshold = alarmThreshold; + } + + public String getJobStatus() { + return jobStatus; + } + + public void setJobStatus(String jobStatus) { + this.jobStatus = jobStatus; + } + @Override public String toString() { - return "XxlJobInfo [id=" + id + ", jobName=" + jobName + ", jobCron=" + jobCron + ", jobClass=" + jobClass - + ", jobStatus=" + jobStatus + ", jobData=" + jobData + ", addTime=" + addTime + ", updateTime=" - + updateTime + "]"; + return "XxlJobInfo [id=" + id + ", jobGroup=" + jobGroup + ", jobName=" + jobName + ", jobCron=" + jobCron + + ", jobClass=" + jobClass + ", jobData=" + jobData + ", addTime=" + addTime + ", updateTime=" + + updateTime + ", author=" + author + ", alarmEmail=" + alarmEmail + ", alarmThreshold=" + + alarmThreshold + ", jobStatus=" + jobStatus + "]"; } } diff --git a/xxl-job-admin/src/main/java/com/xxl/job/core/model/XxlJobLog.java b/xxl-job-admin/src/main/java/com/xxl/job/core/model/XxlJobLog.java index 4aaf7c32..c4b8a2ed 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/core/model/XxlJobLog.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/core/model/XxlJobLog.java @@ -9,7 +9,9 @@ import java.util.Date; public class XxlJobLog { private int id; + // job info + private String jobGroup; private String jobName; private String jobCron; private String jobClass; @@ -31,6 +33,12 @@ public class XxlJobLog { public void setId(int id) { this.id = id; } + public String getJobGroup() { + return jobGroup; + } + public void setJobGroup(String jobGroup) { + this.jobGroup = jobGroup; + } public String getJobName() { return jobName; } @@ -94,10 +102,10 @@ public class XxlJobLog { @Override public String toString() { - return "XxlJobLog [id=" + id + ", jobName=" + jobName + ", jobCron=" + jobCron + ", jobClass=" + jobClass - + ", jobData=" + jobData + ", triggerTime=" + triggerTime + ", triggerStatus=" + triggerStatus - + ", triggerMsg=" + triggerMsg + ", handleTime=" + handleTime + ", handleStatus=" + handleStatus - + ", handleMsg=" + handleMsg + "]"; + return "XxlJobLog [id=" + id + ", jobGroup=" + jobGroup + ", jobName=" + jobName + ", jobCron=" + jobCron + + ", jobClass=" + jobClass + ", jobData=" + jobData + ", triggerTime=" + triggerTime + + ", triggerStatus=" + triggerStatus + ", triggerMsg=" + triggerMsg + ", handleTime=" + handleTime + + ", handleStatus=" + handleStatus + ", handleMsg=" + handleMsg + "]"; } } diff --git a/xxl-job-admin/src/main/java/com/xxl/job/core/resolver/WebExceptionResolver.java b/xxl-job-admin/src/main/java/com/xxl/job/core/resolver/WebExceptionResolver.java new file mode 100644 index 00000000..3bc58d7f --- /dev/null +++ b/xxl-job-admin/src/main/java/com/xxl/job/core/resolver/WebExceptionResolver.java @@ -0,0 +1,41 @@ +package com.xxl.job.core.resolver; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.HandlerExceptionResolver; +import org.springframework.web.servlet.ModelAndView; + +import com.xxl.job.client.util.JacksonUtil; +import com.xxl.job.core.model.ReturnT; + +/** + * common exception resolver + * @author xuxueli 2016-1-6 19:22:18 + */ +public class WebExceptionResolver implements HandlerExceptionResolver { + private static transient Logger logger = LoggerFactory.getLogger(WebExceptionResolver.class); + + @Override + public ModelAndView resolveException(HttpServletRequest request, + HttpServletResponse response, Object handler, Exception ex) { + logger.error("system catch exception:{}", ex); + + ModelAndView mv = new ModelAndView(); + HandlerMethod method = (HandlerMethod)handler; + ResponseBody responseBody = method.getMethodAnnotation(ResponseBody.class); + if (responseBody != null) { + mv.addObject("result", JacksonUtil.writeValueAsString(new ReturnT(500, ex.toString().replaceAll("\n", "
")))); + mv.setViewName("/common/common.result"); + } else { + mv.addObject("exceptionMsg", ex.toString().replaceAll("\n", "
")); + mv.setViewName("/common/common.exception"); + } + return mv; + } + +} \ No newline at end of file diff --git a/xxl-job-admin/src/main/java/com/xxl/job/dao/IXxlJobLogDao.java b/xxl-job-admin/src/main/java/com/xxl/job/dao/IXxlJobLogDao.java index 40394dc4..5f6b206c 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/dao/IXxlJobLogDao.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/dao/IXxlJobLogDao.java @@ -1,6 +1,5 @@ package com.xxl.job.dao; - import java.util.Date; import java.util.List; @@ -12,16 +11,14 @@ import com.xxl.job.core.model.XxlJobLog; */ public interface IXxlJobLogDao { - public int save(XxlJobLog xxlJobLog); + public List pageList(int offset, int pagesize, String jobGroup, String jobName, Date triggerTimeStart, Date triggerTimeEnd); + public int pageListCount(int offset, int pagesize, String jobGroup, String jobName, Date triggerTimeStart, Date triggerTimeEnd); public XxlJobLog load(int id); + public XxlJobLog loadByGroupAndName(String jobGroup, String jobName); + public int save(XxlJobLog xxlJobLog); public int updateTriggerInfo(XxlJobLog xxlJobLog); - public int updateHandleInfo(XxlJobLog xxlJobLog); - public List pageList(int offset, int pagesize,String jobName, Date triggerTimeStart, Date triggerTimeEnd); - - public int pageListCount(int offset, int pagesize,String jobName, Date triggerTimeStart, Date triggerTimeEnd); - } diff --git a/xxl-job-admin/src/main/java/com/xxl/job/dao/impl/XxlJobLogDaoImpl.java b/xxl-job-admin/src/main/java/com/xxl/job/dao/impl/XxlJobLogDaoImpl.java index a3185a3e..ef628454 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/dao/impl/XxlJobLogDaoImpl.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/dao/impl/XxlJobLogDaoImpl.java @@ -23,18 +23,52 @@ public class XxlJobLogDaoImpl implements IXxlJobLogDao { public SqlSessionTemplate sqlSessionTemplate; @Override - public int save(XxlJobLog xxlJobLog) { - if (xxlJobLog!=null && xxlJobLog.getJobData().length()>2000) { - xxlJobLog.setJobData(xxlJobLog.getJobData().substring(0, 2000)); - } - return sqlSessionTemplate.insert("XxlJobLogMapper.save", xxlJobLog); + public List pageList(int offset, int pagesize, String jobGroup, String jobName, Date triggerTimeStart, Date triggerTimeEnd) { + HashMap params = new HashMap(); + params.put("offset", offset); + params.put("pagesize", pagesize); + params.put("jobGroup", jobGroup); + params.put("jobName", jobName); + params.put("triggerTimeStart", triggerTimeStart); + params.put("triggerTimeEnd", triggerTimeEnd); + + return sqlSessionTemplate.selectList("XxlJobLogMapper.pageList", params); + } + + @Override + public int pageListCount(int offset, int pagesize, String jobGroup, String jobName, Date triggerTimeStart, Date triggerTimeEnd) { + HashMap params = new HashMap(); + params.put("offset", offset); + params.put("pagesize", pagesize); + params.put("jobGroup", jobGroup); + params.put("jobName", jobName); + params.put("triggerTimeStart", triggerTimeStart); + params.put("triggerTimeEnd", triggerTimeEnd); + + return sqlSessionTemplate.selectOne("XxlJobLogMapper.pageListCount", params); } @Override public XxlJobLog load(int id) { return sqlSessionTemplate.selectOne("XxlJobLogMapper.load", id); } + + @Override + public XxlJobLog loadByGroupAndName(String jobGroup, String jobName) { + HashMap params = new HashMap(); + params.put("jobGroup", jobGroup); + params.put("jobName", jobName); + return sqlSessionTemplate.selectOne("XxlJobLogMapper.loadByGroupAndName", params); + } + @Override + public int save(XxlJobLog xxlJobLog) { + if (xxlJobLog!=null && xxlJobLog.getJobData().length()>2000) { + xxlJobLog.setJobData(xxlJobLog.getJobData().substring(0, 2000)); + } + return sqlSessionTemplate.insert("XxlJobLogMapper.save", xxlJobLog); + } + @Override public int updateTriggerInfo(XxlJobLog xxlJobLog) { if (xxlJobLog!=null && xxlJobLog.getTriggerMsg().length()>2000) { @@ -50,27 +84,5 @@ public class XxlJobLogDaoImpl implements IXxlJobLogDao { } return sqlSessionTemplate.update("XxlJobLogMapper.updateHandleInfo", xxlJobLog); } - - @Override - public List pageList(int offset, int pagesize,String jobName, Date triggerTimeStart, Date triggerTimeEnd) { - HashMap params = new HashMap(); - params.put("offset", offset); - params.put("pagesize", pagesize); - params.put("jobName", jobName); - params.put("triggerTimeStart", triggerTimeStart); - params.put("triggerTimeEnd", triggerTimeEnd); - return sqlSessionTemplate.selectList("XxlJobLogMapper.pageList", params); - } - - @Override - public int pageListCount(int offset, int pagesize,String jobName, Date triggerTimeStart, Date triggerTimeEnd) { - HashMap params = new HashMap(); - params.put("offset", offset); - params.put("pagesize", pagesize); - params.put("jobName", jobName); - params.put("triggerTimeStart", triggerTimeStart); - params.put("triggerTimeEnd", triggerTimeEnd); - return sqlSessionTemplate.selectOne("XxlJobLogMapper.pageListCount", params); - } } diff --git a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml index 24f1179c..0fa5af79 100644 --- a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml +++ b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml @@ -6,6 +6,7 @@ + @@ -22,6 +23,7 @@ t.id, + t.job_group, t.job_name, t.job_cron, t.job_class, @@ -34,16 +36,71 @@ t.handle_msg + + + + + + + + INSERT INTO `xxl_job_qrtz_trigger_log` ( - `job_name`, + `job_group`, + `job_name`, `job_cron`, `job_class`, `job_data` ) VALUES ( - #{jobName}, - #{jobCron}, - #{jobClass}, + #{jobGroup}, + #{jobName}, + #{jobCron}, + #{jobClass}, #{jobData} ); @@ -51,12 +108,6 @@ - - UPDATE `xxl_job_qrtz_trigger_log` SET @@ -75,38 +126,4 @@ WHERE `id`= #{id} - - - - \ No newline at end of file diff --git a/xxl-job-admin/src/main/resources/springmvc-context.xml b/xxl-job-admin/src/main/resources/springmvc-context.xml index 6d7548c3..4f165449 100644 --- a/xxl-job-admin/src/main/resources/springmvc-context.xml +++ b/xxl-job-admin/src/main/resources/springmvc-context.xml @@ -38,6 +38,8 @@ + + diff --git a/xxl-job-admin/src/main/webapp/WEB-INF/template/job/index.ftl b/xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/index.ftl similarity index 88% rename from xxl-job-admin/src/main/webapp/WEB-INF/template/job/index.ftl rename to xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/index.ftl index 6aaf3b3f..0f0b3853 100644 --- a/xxl-job-admin/src/main/webapp/WEB-INF/template/job/index.ftl +++ b/xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/index.ftl @@ -30,6 +30,16 @@
+
+
+ 任务组 + +
+
@@ -128,16 +138,24 @@