From 5c1bba336483330f21e2dccfe3dba6d67464f269 Mon Sep 17 00:00:00 2001 From: "xueli.xue" Date: Thu, 19 May 2016 17:53:36 +0800 Subject: [PATCH] =?UTF-8?q?V1.3=E7=89=88=E6=9C=AC=EF=BC=8C=E9=98=B6?= =?UTF-8?q?=E6=AE=B5A=EF=BC=9AGLUE=E6=A8=A1=E5=BC=8F=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/db/tables_xxl_job.sql | 19 +++++-- .../xxl/job/controller/JobInfoController.java | 12 ++-- .../com/xxl/job/core/model/XxlJobInfo.java | 33 ++++++++++- .../mybatis-mapper/XxlJobInfoMapper.xml | 24 ++++++-- .../webapp/WEB-INF/template/jobinfo/index.ftl | 17 +++++- .../main/webapp/static/js/jobcode.index.1.js | 3 +- .../main/webapp/static/js/jobinfo.index.1.js | 57 +++++++++++++++++-- 7 files changed, 143 insertions(+), 22 deletions(-) diff --git a/doc/db/tables_xxl_job.sql b/doc/db/tables_xxl_job.sql index 703e2d0e..23559f7b 100644 --- a/doc/db/tables_xxl_job.sql +++ b/doc/db/tables_xxl_job.sql @@ -1,7 +1,3 @@ -# DROP TABLE IF EXISTS XXL_JOB_QRTZ_FIRED_TRIGGERS; -# DROP TABLE IF EXISTS XXL_JOB_QRTZ_PAUSED_TRIGGER_GRPS; -# DROP TABLE IF EXISTS XXL_JOB_QRTZ_SCHEDULER_STATE; -# DROP TABLE IF EXISTS XXL_JOB_QRTZ_LOCKS; CREATE TABLE XXL_JOB_QRTZ_JOB_DETAILS ( @@ -160,6 +156,9 @@ CREATE TABLE `xxl_job_qrtz_trigger_info` ( `author` varchar(64) DEFAULT NULL COMMENT '作者', `alarm_email` varchar(255) DEFAULT NULL COMMENT '报警邮件', `alarm_threshold` int(11) DEFAULT NULL COMMENT '报警阀值(连续失败次数)', + `glue_switch` int(11) DEFAULT '0' COMMENT 'GLUE模式开关:0-否,1-是', + `glue_source` text COMMENT 'GLUE源代码', + `glue_remark` varchar(128) DEFAULT NULL COMMENT 'GLUE备注', PRIMARY KEY (`id`) ); @@ -180,5 +179,17 @@ CREATE TABLE `xxl_job_qrtz_trigger_log` ( PRIMARY KEY (`id`) ); +CREATE TABLE `xxl_job_qrtz_trigger_logglue` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `job_group` varchar(255) NOT NULL, + `job_name` varchar(255) NOT NULL, + `glue_source` text, + `glue_remark` varchar(128) NOT NULL, + `add_time` timestamp NULL DEFAULT NULL, + `update_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ; + + commit; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/controller/JobInfoController.java b/xxl-job-admin/src/main/java/com/xxl/job/controller/JobInfoController.java index b9f70d3c..ab1568ee 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/controller/JobInfoController.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/controller/JobInfoController.java @@ -70,7 +70,7 @@ public class JobInfoController { @ResponseBody public ReturnT add(String jobGroup, String jobName, String jobCron, String jobDesc, String handler_address, String handler_name, String handler_params, - String author, String alarmEmail, int alarmThreshold) { + String author, String alarmEmail, int alarmThreshold, int glueSwitch) { // valid if (JobGroupEnum.match(jobGroup) == null) { @@ -88,7 +88,7 @@ public class JobInfoController { if (StringUtils.isBlank(handler_address)) { return new ReturnT(500, "请输入“机器地址”"); } - if (StringUtils.isBlank(handler_name)) { + if (glueSwitch==0 && StringUtils.isBlank(handler_name)) { return new ReturnT(500, "请输入“执行器”"); } if (StringUtils.isBlank(author)) { @@ -127,6 +127,9 @@ public class JobInfoController { jobInfo.setAuthor(author); jobInfo.setAlarmEmail(alarmEmail); jobInfo.setAlarmThreshold(alarmThreshold); + jobInfo.setGlueSwitch(glueSwitch); + jobInfo.setGlueSource(null); + jobInfo.setGlueRemark(null); xxlJobInfoDao.save(jobInfo); try { @@ -148,7 +151,7 @@ public class JobInfoController { @ResponseBody public ReturnT reschedule(String jobGroup, String jobName, String jobCron, String jobDesc, String handler_address, String handler_name, String handler_params, - String author, String alarmEmail, int alarmThreshold) { + String author, String alarmEmail, int alarmThreshold, int glueSwitch) { // valid if (JobGroupEnum.match(jobGroup) == null) { @@ -166,7 +169,7 @@ public class JobInfoController { if (StringUtils.isBlank(handler_address)) { return new ReturnT(500, "请输入“机器地址”"); } - if (StringUtils.isBlank(handler_name)) { + if (glueSwitch==0 && StringUtils.isBlank(handler_name)) { return new ReturnT(500, "请输入“执行器”"); } if (StringUtils.isBlank(author)) { @@ -192,6 +195,7 @@ public class JobInfoController { jobInfo.setAuthor(author); jobInfo.setAlarmEmail(alarmEmail); jobInfo.setAlarmThreshold(alarmThreshold); + jobInfo.setGlueSwitch(glueSwitch); try { // fresh quartz 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 aafcaba6..f838863f 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 @@ -24,6 +24,10 @@ public class XxlJobInfo { private String alarmEmail; // 报警邮件 private int alarmThreshold; // 报警阀值 + private int glueSwitch; // GLUE模式开关:0-否,1-是 + private String glueSource; // GLUE源代码 + private String glueRemark; // GLUE备注 + // copy from quartz private String jobStatus; // 任务状态 【base on quartz】 @@ -131,12 +135,37 @@ public class XxlJobInfo { this.jobStatus = jobStatus; } + public int getGlueSwitch() { + return glueSwitch; + } + + public void setGlueSwitch(int glueSwitch) { + this.glueSwitch = glueSwitch; + } + + public String getGlueSource() { + return glueSource; + } + + public void setGlueSource(String glueSource) { + this.glueSource = glueSource; + } + + public String getGlueRemark() { + return glueRemark; + } + + public void setGlueRemark(String glueRemark) { + this.glueRemark = glueRemark; + } + @Override public String toString() { return "XxlJobInfo [id=" + id + ", jobGroup=" + jobGroup + ", jobName=" + jobName + ", jobCron=" + jobCron + ", jobDesc=" + jobDesc + ", jobClass=" + jobClass + ", jobData=" + jobData + ", addTime=" + addTime + ", updateTime=" + updateTime + ", author=" + author + ", alarmEmail=" + alarmEmail - + ", alarmThreshold=" + alarmThreshold + ", jobStatus=" + jobStatus + "]"; + + ", alarmThreshold=" + alarmThreshold + ", glueSwitch=" + glueSwitch + ", glueSource=" + glueSource + + ", glueRemark=" + glueRemark + ", jobStatus=" + jobStatus + "]"; } - + } diff --git a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml index bd158ad7..ad1c24c3 100644 --- a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml +++ b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml @@ -19,6 +19,10 @@ + + + + @@ -33,7 +37,10 @@ t.update_time, t.author, t.alarm_email, - t.alarm_threshold + t.alarm_threshold, + t.glue_switch, + t.glue_source, + t.glue_remark
-
+
+
+
+ + +
+
@@ -194,10 +201,16 @@
-
+
+
+
+ + +
+
diff --git a/xxl-job-admin/src/main/webapp/static/js/jobcode.index.1.js b/xxl-job-admin/src/main/webapp/static/js/jobcode.index.1.js index e6479455..6ade8c47 100644 --- a/xxl-job-admin/src/main/webapp/static/js/jobcode.index.1.js +++ b/xxl-job-admin/src/main/webapp/static/js/jobcode.index.1.js @@ -8,10 +8,11 @@ $(function() { }); codeEditor.setValue( $("#demoCode").val() ); + // editor height var height = Math.max(document.documentElement.clientHeight, document.body.offsetHeight); $(".CodeMirror").attr('style', 'height:'+ height +'px'); - + // code source save $("#save").click(function() { var codeSource = codeEditor.getValue(); var codeRemark = $("#codeRemark").val(); diff --git a/xxl-job-admin/src/main/webapp/static/js/jobinfo.index.1.js b/xxl-job-admin/src/main/webapp/static/js/jobinfo.index.1.js index f0727ff4..527c0240 100644 --- a/xxl-job-admin/src/main/webapp/static/js/jobinfo.index.1.js +++ b/xxl-job-admin/src/main/webapp/static/js/jobinfo.index.1.js @@ -61,6 +61,7 @@ $(function() { { "data": 'author', "visible" : true}, { "data": 'alarmEmail', "visible" : false}, { "data": 'alarmThreshold', "visible" : false}, + { "data": 'glueSwitch', "visible" : false}, { "data": 'jobStatus', "visible" : true, @@ -87,8 +88,13 @@ $(function() { } // log url var logUrl = base_url +'/joblog?jobGroup='+ row.jobGroup +'&jobName='+ row.jobName; + // log url - var codeUrl = base_url +'/jobcode?id='+ row.id; + var codeHtml = ""; + if(row.glueSwitch != 0){ + var codeUrl = base_url +'/jobcode?id='+ row.id; + codeHtml = ' ' + } // job data var jobDataMap = eval('(' + row.jobData + ')'); @@ -100,18 +106,19 @@ $(function() { ' jobDesc="'+ row.jobDesc +'" '+ ' jobClass="'+ row.jobClass +'" '+ ' jobData="'+ row.jobData +'" '+ - ' author="'+ row.author +'" '+ - ' alarmEmail="'+ row.alarmEmail +'" '+ - ' alarmThreshold="'+ row.alarmThreshold +'" '+ ' handler_params="'+jobDataMap.handler_params +'" '+ ' handler_address="'+ jobDataMap.handler_address +'" '+ ' handler_name="'+ jobDataMap.handler_name +'" '+ + ' author="'+ row.author +'" '+ + ' alarmEmail="'+ row.alarmEmail +'" '+ + ' alarmThreshold="'+ row.alarmThreshold +'" '+ + ' glueSwitch="'+ row.glueSwitch +'" '+ '>'+ ' '+ pause_resume + '
'+ ' '+ - ' '+ + codeHtml + ' '+ '

'; @@ -318,6 +325,34 @@ $(function() { $(".remote_panel").show(); // remote }); + // GLUE模式开启 + $("#addModal .form .ifGLUE").click(function(){ + var ifGLUE = $(this).is(':checked'); + var $handler_name = $("#addModal .form input[name='handler_name']"); + var $glueSwitch = $("#addModal .form input[name='glueSwitch']"); + if (ifGLUE) { + $handler_name.val(""); + $handler_name.attr("readonly","readonly"); + $glueSwitch.val(1); + } else { + $handler_name.removeAttr("readonly"); + $glueSwitch.val(0); + } + }); + $("#updateModal .form .ifGLUE").click(function(){ + var ifGLUE = $(this).is(':checked'); + var $handler_name = $("#updateModal .form input[name='handler_name']"); + var $glueSwitch = $("#updateModal .form input[name='glueSwitch']"); + if (ifGLUE) { + $handler_name.val(""); + $handler_name.attr("readonly","readonly"); + $glueSwitch.val(1); + } else { + $handler_name.removeAttr("readonly"); + $glueSwitch.val(0); + } + }); + // 更新 $("#job_list").on('click', '.update',function() { $("#updateModal .form input[name='jobGroup']").val($(this).parent('p').attr("jobGroup")); @@ -330,6 +365,18 @@ $(function() { $("#updateModal .form input[name='author']").val($(this).parent('p').attr("author")); $("#updateModal .form input[name='alarmEmail']").val($(this).parent('p').attr("alarmEmail")); $("#updateModal .form input[name='alarmThreshold']").val($(this).parent('p').attr("alarmThreshold")); + $("#updateModal .form input[name='glueSwitch']").val($(this).parent('p').attr("glueSwitch")); + + // GLUE check + var $glueSwitch = $("#updateModal .form input[name='glueSwitch']"); + var $handler_name = $("#updateModal .form input[name='handler_name']"); + if ($glueSwitch.val() != 0) { + $handler_name.attr("readonly","readonly"); + $("#updateModal .form .ifGLUE").attr("checked", true); + } else { + $handler_name.removeAttr("readonly"); + $("#updateModal .form .ifGLUE").attr("checked", false); + } $('#updateModal').modal({backdrop: false, keyboard: false}).modal('show'); });