diff --git a/features/1.1.0.md b/features/1.1.0.md
index bcfab61..24c8e08 100644
--- a/features/1.1.0.md
+++ b/features/1.1.0.md
@@ -2,4 +2,5 @@
- 支持钉钉预警通知
- 调度记录增加执行时间
- 任务超时报警机制
-- 支持分片任务
\ No newline at end of file
+- 支持分片任务
+- 支持SimpleTrigger任务
\ No newline at end of file
diff --git a/frost-api/src/main/java/vip/justlive/frost/api/model/JobInfo.java b/frost-api/src/main/java/vip/justlive/frost/api/model/JobInfo.java
index 493bcd7..32bd44b 100644
--- a/frost-api/src/main/java/vip/justlive/frost/api/model/JobInfo.java
+++ b/frost-api/src/main/java/vip/justlive/frost/api/model/JobInfo.java
@@ -44,6 +44,21 @@ public class JobInfo {
RETRY;
}
+ public enum MODE {
+ /**
+ * 简单任务
+ */
+ SIMPLE,
+ /**
+ * 延时任务
+ */
+ DELAY,
+ /**
+ * cron表达式任务
+ */
+ CRON;
+ }
+
/**
* 编号
*/
@@ -59,11 +74,6 @@ public class JobInfo {
*/
private JobGroup group;
- /**
- * 定时表达式
- */
- private String cron;
-
/**
* 任务状态
*/
@@ -119,4 +129,26 @@ public class JobInfo {
*/
private Integer sharding;
+ /**
+ * 任务模式
+ */
+ private String mode;
+
+ /**
+ * 简单任务的时间戳
+ */
+ private Long timestamp;
+
+ /**
+ * 延时任务延时
+ */
+ private Long initDelay;
+ private Long delay;
+
+ /**
+ * 定时表达式
+ */
+ private String cron;
+
+
}
diff --git a/frost-center/src/main/resources/static/js/frost.js b/frost-center/src/main/resources/static/js/frost.js
index 93d7cad..d1749aa 100644
--- a/frost-center/src/main/resources/static/js/frost.js
+++ b/frost-center/src/main/resources/static/js/frost.js
@@ -189,6 +189,7 @@ public class DemoScriptJob implements IJob {
$scope.modalDatas = { opt: 1};
$scope.modalDatas.type = 'BEAN';
$scope.modalDatas.failStrategy = 'NOTIFY';
+ $scope.modalDatas.mode = 'CRON';
$scope.modalDatas.childrenJobs = [];
$scope.modalDatas.extraSettings = $scope.extraSettings;
$scope.modalDatas.translationTexts = $scope.translationTexts;
@@ -245,28 +246,34 @@ public class DemoScriptJob implements IJob {
if ($scope.modalDatas.childrenJobs.length > 0) {
childJobIds = $scope.modalDatas.childrenJobs.map(r => r.id);
}
- var job = {
- name: $scope.modalDatas.name,
- cron: $scope.modalDatas.cron,
- type: $scope.modalDatas.type,
- param: $scope.modalDatas.param,
- auto: $scope.modalDatas.auto,
- failStrategy: $scope.modalDatas.failStrategy,
- notifyMails: mails,
- timeout : $scope.modalDatas.timeout,
- useSharding : $scope.modalDatas.useSharding,
- sharding : $scope.modalDatas.sharding,
- childJobIds: childJobIds
- };
- if($scope.modalDatas.type == 'SCRIPT'){
+
+ var job = {};
+ angular.copy($scope.modalDatas, job);
+ job.notifyMails = mails;
+ job.childJobIds = childJobIds;
+
+ if ($scope.modalDatas.mode == 'SIMPLE') {
+ job.timestamp = new Date($scope.modalDatas.execDate).getTime();
+ delete job.cron;
+ delete job.initDelay;
+ delete job.delay;
+ } else if ($scope.modalDatas.mode == 'CRON') {
+ delete job.initDelay;
+ delete job.delay;
+ } else if ($scope.modalDatas.mode == 'DELAY') {
+ var delayArr = $scope.modalDatas.delayStr.split(',');
+ job.initDelay = delayArr[0];
+ job.delay = delayArr[1];
+ delete job.cron;
+ }
+
+ if ($scope.modalDatas.type == 'SCRIPT'){
job.script = $scope.defaultScript;
-
if ($scope.modalDatas.useExecutor) {
job.group = {
groupKey: $scope.modalDatas.groupKey
};
}
-
} else {
job.group = {
jobKey: $scope.modalDatas.jobKey,
@@ -396,17 +403,17 @@ public class DemoScriptJob implements IJob {
if (data.data.notifyMails) {
mails = data.data.notifyMails.join();
}
- $scope.modalDatas.type = data.data.type;
+
+ angular.extend($scope.modalDatas, data.data);
$scope.modalDatas.preType = data.data.type;
- $scope.modalDatas.cron = data.data.cron;
- $scope.modalDatas.name = data.data.name;
- $scope.modalDatas.param = data.data.param;
- $scope.modalDatas.failStrategy = data.data.failStrategy;
$scope.modalDatas.notifyMails = mails;
- $scope.modalDatas.childJobIds = data.data.childJobIds;
- $scope.modalDatas.timeout = data.data.timeout;
- $scope.modalDatas.useSharding = data.data.useSharding;
- $scope.modalDatas.sharding = data.data.sharding;
+
+ if (data.data.mode == 'SIMPLE') {
+ $scope.modalDatas.execDate = new Date(data.data.timestamp);
+ } else if (data.data.mode == 'DELAY') {
+ $scope.modalDatas.delayStr = data.data.initDelay + "," + data.data.delay;
+ }
+
if (data.data.group) {
$scope.modalDatas.groupKey = data.data.group.groupKey;
$scope.modalDatas.jobs = $scope.modalDatas.executorMap[$scope.modalDatas.groupKey];
@@ -464,19 +471,27 @@ public class DemoScriptJob implements IJob {
if ($scope.modalDatas.childrenJobs.length > 0) {
childJobIds = $scope.modalDatas.childrenJobs.map(r => r.id);
}
- var job = {
- id: id,
- name: $scope.modalDatas.name,
- cron: $scope.modalDatas.cron,
- type: $scope.modalDatas.type,
- param: $scope.modalDatas.param,
- failStrategy: $scope.modalDatas.failStrategy,
- notifyMails: mails,
- timeout: $scope.modalDatas.timeout,
- useSharding : $scope.modalDatas.useSharding,
- sharding : $scope.modalDatas.sharding,
- childJobIds: childJobIds
- };
+ var job = {};
+ angular.copy($scope.modalDatas, job);
+ job.id = id;
+ job.notifyMails = mails;
+ job.childJobIds = childJobIds;
+
+ if ($scope.modalDatas.mode == 'SIMPLE') {
+ job.timestamp = new Date($scope.modalDatas.execDate).getTime();
+ delete job.cron;
+ delete job.initDelay;
+ delete job.delay;
+ } else if ($scope.modalDatas.mode == 'CRON') {
+ delete job.initDelay;
+ delete job.delay;
+ } else if ($scope.modalDatas.mode == 'DELAY') {
+ var delayArr = $scope.modalDatas.delayStr.split(',');
+ job.initDelay = delayArr[0];
+ job.delay = delayArr[1];
+ delete job.cron;
+ }
+
if (job.type == 'SCRIPT') {
if ($scope.modalDatas.useExecutor) {
job.group = {
diff --git a/frost-center/src/main/resources/templates/views/addJob.html b/frost-center/src/main/resources/templates/views/addJob.html
index c28140e..bd99887 100644
--- a/frost-center/src/main/resources/templates/views/addJob.html
+++ b/frost-center/src/main/resources/templates/views/addJob.html
@@ -58,6 +58,19 @@
+
+
+
+
+
+
+
+
+
+
@@ -121,10 +155,11 @@
diff --git a/frost-center/src/main/resources/templates/views/jobs.html b/frost-center/src/main/resources/templates/views/jobs.html
index 9ce4dd9..7cd4ca8 100644
--- a/frost-center/src/main/resources/templates/views/jobs.html
+++ b/frost-center/src/main/resources/templates/views/jobs.html
@@ -14,7 +14,7 @@
任务编号 |
名称 |
分组信息 |
-
Cron |
+
定时信息 |
状态 |
操作 |
@@ -24,7 +24,7 @@
|
|
[{{job.group.groupKey?job.group.groupKey:'…'}}]-[{{job.group.jobKey?job.group.jobKey:'…'}}] |
-
|
+
{{job.mode == 'SIMPLE'? (job.timestamp | date:'yyyy-MM-dd HH:mm:ss'):(job.cron || (job.initDelay + "," + job.delay))}} |
{{job.status}} |
|