Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
X
XXL-JOB
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
靳帅
XXL-JOB
Commits
25a331be
提交
25a331be
authored
11月 05, 2020
作者:
xueli.xue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
任务下次运行时间优化:支持Cron、固定间隔等多种时间计算。
上级
51682bce
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
33 行增加
和
25 行删除
+33
-25
JobInfoController.java
.../java/com/xxl/job/admin/controller/JobInfoController.java
+15
-5
XxlJobServiceImpl.java
...ava/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java
+3
-3
message_en.properties
xxl-job-admin/src/main/resources/i18n/message_en.properties
+0
-1
message_zh_CN.properties
...ob-admin/src/main/resources/i18n/message_zh_CN.properties
+0
-1
message_zh_TC.properties
...ob-admin/src/main/resources/i18n/message_zh_TC.properties
+0
-1
jobinfo.index.1.js
...job-admin/src/main/resources/static/js/jobinfo.index.1.js
+11
-12
cronGen.js
...dmin/src/main/resources/static/plugins/cronGen/cronGen.js
+2
-1
cronGen_en.js
...n/src/main/resources/static/plugins/cronGen/cronGen_en.js
+2
-1
没有找到文件。
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobInfoController.java
浏览文件 @
25a331be
...
@@ -8,6 +8,7 @@ import com.xxl.job.admin.core.model.XxlJobUser;
...
@@ -8,6 +8,7 @@ import com.xxl.job.admin.core.model.XxlJobUser;
import
com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum
;
import
com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum
;
import
com.xxl.job.admin.core.scheduler.MisfireStrategyEnum
;
import
com.xxl.job.admin.core.scheduler.MisfireStrategyEnum
;
import
com.xxl.job.admin.core.scheduler.ScheduleTypeEnum
;
import
com.xxl.job.admin.core.scheduler.ScheduleTypeEnum
;
import
com.xxl.job.admin.core.thread.JobScheduleHelper
;
import
com.xxl.job.admin.core.thread.JobTriggerPoolHelper
;
import
com.xxl.job.admin.core.thread.JobTriggerPoolHelper
;
import
com.xxl.job.admin.core.trigger.TriggerTypeEnum
;
import
com.xxl.job.admin.core.trigger.TriggerTypeEnum
;
import
com.xxl.job.admin.core.util.I18nUtil
;
import
com.xxl.job.admin.core.util.I18nUtil
;
...
@@ -18,6 +19,8 @@ import com.xxl.job.core.biz.model.ReturnT;
...
@@ -18,6 +19,8 @@ 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
com.xxl.job.core.util.DateUtil
;
import
com.xxl.job.core.util.DateUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
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
;
...
@@ -36,6 +39,7 @@ import java.util.*;
...
@@ -36,6 +39,7 @@ import java.util.*;
@Controller
@Controller
@RequestMapping
(
"/jobinfo"
)
@RequestMapping
(
"/jobinfo"
)
public
class
JobInfoController
{
public
class
JobInfoController
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
JobInfoController
.
class
);
@Resource
@Resource
private
XxlJobGroupDao
xxlJobGroupDao
;
private
XxlJobGroupDao
xxlJobGroupDao
;
...
@@ -148,23 +152,29 @@ public class JobInfoController {
...
@@ -148,23 +152,29 @@ public class JobInfoController {
@RequestMapping
(
"/nextTriggerTime"
)
@RequestMapping
(
"/nextTriggerTime"
)
@ResponseBody
@ResponseBody
public
ReturnT
<
List
<
String
>>
nextTriggerTime
(
String
cron
)
{
public
ReturnT
<
List
<
String
>>
nextTriggerTime
(
String
scheduleType
,
String
scheduleConf
)
{
XxlJobInfo
paramXxlJobInfo
=
new
XxlJobInfo
();
paramXxlJobInfo
.
setScheduleType
(
scheduleType
);
paramXxlJobInfo
.
setScheduleConf
(
scheduleConf
);
List
<
String
>
result
=
new
ArrayList
<>();
List
<
String
>
result
=
new
ArrayList
<>();
try
{
try
{
CronExpression
cronExpression
=
new
CronExpression
(
cron
);
Date
lastTime
=
new
Date
();
Date
lastTime
=
new
Date
();
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
lastTime
=
cronExpression
.
getNextValidTimeAfter
(
lastTime
);
lastTime
=
JobScheduleHelper
.
generateNextValidTime
(
paramXxlJobInfo
,
lastTime
);
if
(
lastTime
!=
null
)
{
if
(
lastTime
!=
null
)
{
result
.
add
(
DateUtil
.
formatDateTime
(
lastTime
));
result
.
add
(
DateUtil
.
formatDateTime
(
lastTime
));
}
else
{
}
else
{
break
;
break
;
}
}
}
}
}
catch
(
ParseException
e
)
{
}
catch
(
Exception
e
)
{
return
new
ReturnT
<
List
<
String
>>(
ReturnT
.
FAIL_CODE
,
I18nUtil
.
getString
(
"jobinfo_field_cron_unvalid"
));
logger
.
error
(
e
.
getMessage
(),
e
);
return
new
ReturnT
<
List
<
String
>>(
ReturnT
.
FAIL_CODE
,
(
I18nUtil
.
getString
(
"schedule_type"
)+
I18nUtil
.
getString
(
"system_unvalid"
))
+
e
.
getMessage
());
}
}
return
new
ReturnT
<
List
<
String
>>(
result
);
return
new
ReturnT
<
List
<
String
>>(
result
);
}
}
}
}
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java
浏览文件 @
25a331be
...
@@ -79,11 +79,11 @@ public class XxlJobServiceImpl implements XxlJobService {
...
@@ -79,11 +79,11 @@ public class XxlJobServiceImpl implements XxlJobService {
}
}
if
(
scheduleTypeEnum
==
ScheduleTypeEnum
.
CRON
)
{
if
(
scheduleTypeEnum
==
ScheduleTypeEnum
.
CRON
)
{
if
(
jobInfo
.
getScheduleConf
()==
null
||
!
CronExpression
.
isValidExpression
(
jobInfo
.
getScheduleConf
()))
{
if
(
jobInfo
.
getScheduleConf
()==
null
||
!
CronExpression
.
isValidExpression
(
jobInfo
.
getScheduleConf
()))
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
I18nUtil
.
getString
(
"jobinfo_field_cron_unvalid"
)
);
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"Cron"
+
I18nUtil
.
getString
(
"system_unvalid"
)
);
}
}
}
else
if
(
scheduleTypeEnum
==
ScheduleTypeEnum
.
FIX_RATE
/* || scheduleTypeEnum == ScheduleTypeEnum.FIX_DELAY*/
)
{
}
else
if
(
scheduleTypeEnum
==
ScheduleTypeEnum
.
FIX_RATE
/* || scheduleTypeEnum == ScheduleTypeEnum.FIX_DELAY*/
)
{
if
(
jobInfo
.
getScheduleConf
()
==
null
)
{
if
(
jobInfo
.
getScheduleConf
()
==
null
)
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
(
I18nUtil
.
getString
(
"schedule_type"
)
+
I18nUtil
.
getString
(
"system_unvalid"
)
)
);
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
(
I18nUtil
.
getString
(
"schedule_type"
))
);
}
}
try
{
try
{
int
fixSecond
=
Integer
.
valueOf
(
jobInfo
.
getScheduleConf
());
int
fixSecond
=
Integer
.
valueOf
(
jobInfo
.
getScheduleConf
());
...
@@ -183,7 +183,7 @@ public class XxlJobServiceImpl implements XxlJobService {
...
@@ -183,7 +183,7 @@ public class XxlJobServiceImpl implements XxlJobService {
}
}
if
(
scheduleTypeEnum
==
ScheduleTypeEnum
.
CRON
)
{
if
(
scheduleTypeEnum
==
ScheduleTypeEnum
.
CRON
)
{
if
(
jobInfo
.
getScheduleConf
()==
null
||
!
CronExpression
.
isValidExpression
(
jobInfo
.
getScheduleConf
()))
{
if
(
jobInfo
.
getScheduleConf
()==
null
||
!
CronExpression
.
isValidExpression
(
jobInfo
.
getScheduleConf
()))
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
I18nUtil
.
getString
(
"jobinfo_field_cron
_unvalid"
)
);
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"Cron"
+
I18nUtil
.
getString
(
"system
_unvalid"
)
);
}
}
}
else
if
(
scheduleTypeEnum
==
ScheduleTypeEnum
.
FIX_RATE
/*|| scheduleTypeEnum == ScheduleTypeEnum.FIX_DELAY*/
)
{
}
else
if
(
scheduleTypeEnum
==
ScheduleTypeEnum
.
FIX_RATE
/*|| scheduleTypeEnum == ScheduleTypeEnum.FIX_DELAY*/
)
{
if
(
jobInfo
.
getScheduleConf
()
==
null
)
{
if
(
jobInfo
.
getScheduleConf
()
==
null
)
{
...
...
xxl-job-admin/src/main/resources/i18n/message_en.properties
浏览文件 @
25a331be
...
@@ -117,7 +117,6 @@ jobinfo_field_jobdesc=Job description
...
@@ -117,7 +117,6 @@ jobinfo_field_jobdesc=Job description
jobinfo_field_timeout
=
Job timeout period
jobinfo_field_timeout
=
Job timeout period
jobinfo_field_gluetype
=
GLUE Type
jobinfo_field_gluetype
=
GLUE Type
jobinfo_field_executorparam
=
Param
jobinfo_field_executorparam
=
Param
jobinfo_field_cron_unvalid
=
The Cron is illegal
jobinfo_field_author
=
Author
jobinfo_field_author
=
Author
jobinfo_field_alarmemail
=
Alarm email
jobinfo_field_alarmemail
=
Alarm email
jobinfo_field_alarmemail_placeholder
=
Please enter alarm mail, if there are more than one comma separated
jobinfo_field_alarmemail_placeholder
=
Please enter alarm mail, if there are more than one comma separated
...
...
xxl-job-admin/src/main/resources/i18n/message_zh_CN.properties
浏览文件 @
25a331be
...
@@ -116,7 +116,6 @@ jobinfo_field_jobgroup=执行器
...
@@ -116,7 +116,6 @@ jobinfo_field_jobgroup=执行器
jobinfo_field_jobdesc
=
任务描述
jobinfo_field_jobdesc
=
任务描述
jobinfo_field_gluetype
=
运行模式
jobinfo_field_gluetype
=
运行模式
jobinfo_field_executorparam
=
任务参数
jobinfo_field_executorparam
=
任务参数
jobinfo_field_cron_unvalid
=
Cron格式非法
jobinfo_field_author
=
负责人
jobinfo_field_author
=
负责人
jobinfo_field_timeout
=
任务超时时间
jobinfo_field_timeout
=
任务超时时间
jobinfo_field_alarmemail
=
报警邮件
jobinfo_field_alarmemail
=
报警邮件
...
...
xxl-job-admin/src/main/resources/i18n/message_zh_TC.properties
浏览文件 @
25a331be
...
@@ -116,7 +116,6 @@ jobinfo_field_jobgroup=執行器
...
@@ -116,7 +116,6 @@ jobinfo_field_jobgroup=執行器
jobinfo_field_jobdesc
=
任務描述
jobinfo_field_jobdesc
=
任務描述
jobinfo_field_gluetype
=
運行模式
jobinfo_field_gluetype
=
運行模式
jobinfo_field_executorparam
=
任務參數
jobinfo_field_executorparam
=
任務參數
jobinfo_field_cron_unvalid
=
Cron 格式非法
jobinfo_field_author
=
負責人
jobinfo_field_author
=
負責人
jobinfo_field_timeout
=
任務超時秒數
jobinfo_field_timeout
=
任務超時秒數
jobinfo_field_alarmemail
=
告警郵件
jobinfo_field_alarmemail
=
告警郵件
...
...
xxl-job-admin/src/main/resources/static/js/jobinfo.index.1.js
浏览文件 @
25a331be
...
@@ -118,10 +118,16 @@ $(function() {
...
@@ -118,10 +118,16 @@ $(function() {
start_stop_div
=
'<li><a href="javascript:void(0);" class="job_operate" _type="job_resume" >'
+
I18n
.
jobinfo_opt_start
+
'</a></li>
\
n'
;
start_stop_div
=
'<li><a href="javascript:void(0);" class="job_operate" _type="job_resume" >'
+
I18n
.
jobinfo_opt_start
+
'</a></li>
\
n'
;
}
}
// job_next_time_html
var
job_next_time_html
=
''
;
if
(
row
.
scheduleType
==
'CRON'
||
row
.
scheduleType
==
'FIX_RATE'
)
{
job_next_time_html
=
'<li><a href="javascript:void(0);" class="job_next_time" >'
+
I18n
.
jobinfo_opt_next_time
+
'</a></li>
\
n'
;
}
// log url
// log url
var
logHref
=
base_url
+
'/joblog?jobId='
+
row
.
id
;
var
logHref
=
base_url
+
'/joblog?jobId='
+
row
.
id
;
//
log
url
//
code
url
var
codeBtn
=
""
;
var
codeBtn
=
""
;
if
(
'BEAN'
!=
row
.
glueType
)
{
if
(
'BEAN'
!=
row
.
glueType
)
{
var
codeUrl
=
base_url
+
'/jobcode?jobId='
+
row
.
id
;
var
codeUrl
=
base_url
+
'/jobcode?jobId='
+
row
.
id
;
...
@@ -143,7 +149,7 @@ $(function() {
...
@@ -143,7 +149,7 @@ $(function() {
' <li><a href="javascript:void(0);" class="job_trigger" >'
+
I18n
.
jobinfo_opt_run
+
'</a></li>
\
n'
+
' <li><a href="javascript:void(0);" class="job_trigger" >'
+
I18n
.
jobinfo_opt_run
+
'</a></li>
\
n'
+
' <li><a href="'
+
logHref
+
'">'
+
I18n
.
jobinfo_opt_log
+
'</a></li>
\
n'
+
' <li><a href="'
+
logHref
+
'">'
+
I18n
.
jobinfo_opt_log
+
'</a></li>
\
n'
+
' <li><a href="javascript:void(0);" class="job_registryinfo" >'
+
I18n
.
jobinfo_opt_registryinfo
+
'</a></li>
\
n'
+
' <li><a href="javascript:void(0);" class="job_registryinfo" >'
+
I18n
.
jobinfo_opt_registryinfo
+
'</a></li>
\
n'
+
' <li><a href="javascript:void(0);" class="job_next_time" >'
+
I18n
.
jobinfo_opt_next_time
+
'</a></li>
\
n'
+
job_next_time_html
+
' <li class="divider"></li>
\
n'
+
' <li class="divider"></li>
\
n'
+
codeBtn
+
codeBtn
+
start_stop_div
+
start_stop_div
+
...
@@ -329,17 +335,16 @@ $(function() {
...
@@ -329,17 +335,16 @@ $(function() {
var
id
=
$
(
this
).
parents
(
'ul'
).
attr
(
"_id"
);
var
id
=
$
(
this
).
parents
(
'ul'
).
attr
(
"_id"
);
var
row
=
tableData
[
'key'
+
id
];
var
row
=
tableData
[
'key'
+
id
];
var
jobCron
=
row
.
jobCron
;
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
url
:
base_url
+
"/jobinfo/nextTriggerTime"
,
url
:
base_url
+
"/jobinfo/nextTriggerTime"
,
data
:
{
data
:
{
"cron"
:
jobCron
"scheduleType"
:
row
.
scheduleType
,
"scheduleConf"
:
row
.
scheduleConf
},
},
dataType
:
"json"
,
dataType
:
"json"
,
success
:
function
(
data
){
success
:
function
(
data
){
if
(
data
.
code
!=
200
)
{
if
(
data
.
code
!=
200
)
{
layer
.
open
({
layer
.
open
({
title
:
I18n
.
jobinfo_opt_next_time
,
title
:
I18n
.
jobinfo_opt_next_time
,
...
@@ -585,9 +590,6 @@ $(function() {
...
@@ -585,9 +590,6 @@ $(function() {
required
:
true
,
required
:
true
,
maxlength
:
50
maxlength
:
50
},
},
jobCron
:
{
required
:
true
},
author
:
{
author
:
{
required
:
true
required
:
true
}
}
...
@@ -596,9 +598,6 @@ $(function() {
...
@@ -596,9 +598,6 @@ $(function() {
jobDesc
:
{
jobDesc
:
{
required
:
I18n
.
system_please_input
+
I18n
.
jobinfo_field_jobdesc
required
:
I18n
.
system_please_input
+
I18n
.
jobinfo_field_jobdesc
},
},
jobCron
:
{
required
:
I18n
.
system_please_input
+
"Cron"
},
author
:
{
author
:
{
required
:
I18n
.
system_please_input
+
I18n
.
jobinfo_field_author
required
:
I18n
.
system_please_input
+
I18n
.
jobinfo_field_author
}
}
...
...
xxl-job-admin/src/main/resources/static/plugins/cronGen/cronGen.js
浏览文件 @
25a331be
...
@@ -641,7 +641,8 @@
...
@@ -641,7 +641,8 @@
type
:
'GET'
,
type
:
'GET'
,
url
:
base_url
+
"/jobinfo/nextTriggerTime"
,
url
:
base_url
+
"/jobinfo/nextTriggerTime"
,
data
:
{
data
:
{
"cron"
:
inputElement
.
val
(),
"scheduleType"
:
'CRON'
,
"scheduleConf"
:
inputElement
.
val
()
},
},
dataType
:
"json"
,
dataType
:
"json"
,
success
:
function
(
data
){
success
:
function
(
data
){
...
...
xxl-job-admin/src/main/resources/static/plugins/cronGen/cronGen_en.js
浏览文件 @
25a331be
...
@@ -641,7 +641,8 @@
...
@@ -641,7 +641,8 @@
type
:
'GET'
,
type
:
'GET'
,
url
:
base_url
+
"/jobinfo/nextTriggerTime"
,
url
:
base_url
+
"/jobinfo/nextTriggerTime"
,
data
:
{
data
:
{
"cron"
:
inputElement
.
val
(),
"scheduleType"
:
'CRON'
,
"scheduleConf"
:
inputElement
.
val
()
},
},
dataType
:
"json"
,
dataType
:
"json"
,
success
:
function
(
data
){
success
:
function
(
data
){
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论