Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
X
XXL-JOB
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
靳帅
XXL-JOB
Commits
51259d8c
提交
51259d8c
authored
12月 01, 2015
作者:
xueli.xue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init
上级
65243e76
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
82 行增加
和
27 行删除
+82
-27
IndexController.java
...min/src/main/java/com/xxl/controller/IndexController.java
+4
-4
DynamicSchedulerUtil.java
...in/src/main/java/com/xxl/quartz/DynamicSchedulerUtil.java
+21
-9
index.ftl
xxl-job-admin/src/main/webapp/WEB-INF/template/job/index.ftl
+57
-14
没有找到文件。
xxl-job-admin/src/main/java/com/xxl/controller/IndexController.java
浏览文件 @
51259d8c
package
com
.
xxl
.
controller
;
import
java.util.Set
;
import
java.util.List
;
import
java.util.Map
;
import
org.quartz.JobKey
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -16,8 +16,8 @@ public class IndexController {
@RequestMapping
(
"index"
)
public
String
index
(
Model
model
)
{
Set
<
JobKey
>
list
=
DynamicSchedulerUtil
.
getJobKeys
();
model
.
addAttribute
(
"jobList"
,
l
ist
);
List
<
Map
<
String
,
Object
>>
jobList
=
DynamicSchedulerUtil
.
getJobList
();
model
.
addAttribute
(
"jobList"
,
jobL
ist
);
return
"job/index"
;
}
...
...
xxl-job-admin/src/main/java/com/xxl/quartz/DynamicSchedulerUtil.java
浏览文件 @
51259d8c
package
com
.
xxl
.
quartz
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -38,21 +41,30 @@ public final class DynamicSchedulerUtil implements InitializingBean {
}
// getJobKeys
public
static
Set
<
JobKey
>
getJobKeys
(){
public
static
List
<
Map
<
String
,
Object
>>
getJobList
(){
List
<
Map
<
String
,
Object
>>
jobList
=
new
ArrayList
<
Map
<
String
,
Object
>>();
try
{
String
groupName
=
scheduler
.
getJobGroupNames
().
get
(
0
);
return
scheduler
.
getJobKeys
(
GroupMatcher
.
jobGroupEquals
(
groupName
));
Set
<
JobKey
>
jobKeys
=
scheduler
.
getJobKeys
(
GroupMatcher
.
jobGroupEquals
(
groupName
));
if
(
jobKeys
!=
null
&&
jobKeys
.
size
()>
0
)
{
for
(
JobKey
jobKey
:
jobKeys
)
{
TriggerKey
triggerKey
=
TriggerKey
.
triggerKey
(
jobKey
.
getName
(),
Scheduler
.
DEFAULT_GROUP
);
Trigger
trigger
=
scheduler
.
getTrigger
(
triggerKey
);
JobDetail
jobDetail
=
scheduler
.
getJobDetail
(
jobKey
);
Map
<
String
,
Object
>
jobMap
=
new
HashMap
<
String
,
Object
>();
jobMap
.
put
(
"TriggerKey"
,
triggerKey
);
jobMap
.
put
(
"Trigger"
,
trigger
);
jobMap
.
put
(
"JobDetail"
,
jobDetail
);
jobList
.
add
(
jobMap
);
}
}
}
catch
(
SchedulerException
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
public
static
void
getJobDetail
(
String
triggerKeyName
){
// TriggerKey : name + group
String
group
=
Scheduler
.
DEFAULT_GROUP
;
TriggerKey
triggerKey
=
TriggerKey
.
triggerKey
(
triggerKeyName
,
group
);
return
jobList
;
}
// addJob 新增
...
...
xxl-job-admin/src/main/webapp/WEB-INF/template/job/index.ftl
浏览文件 @
51259d8c
...
...
@@ -4,6 +4,9 @@
<title>
调度中心
</title>
<
#
import
"/
common
/
common
.
macro
.
ftl
"
as
netCommon
>
<
@
netCommon
.
commonStyle
/>
<!-- DataTables -->
<link
rel=
"stylesheet"
href=
"${request.contextPath}/static/adminlte/plugins/datatables/dataTables.bootstrap.css"
>
</head>
<body
class=
"hold-transition skin-blue sidebar-mini"
>
<div
class=
"wrapper"
>
...
...
@@ -22,22 +25,53 @@
<li
class=
"active"
>
使用教程
</li>
</ol>
</section>
<!-- Main content -->
<section
class=
"content"
>
<div
class=
"callout callout-info"
>
<h4>
在线任务:
</h4>
<
#
if
jobList
?
exists
&&
jobList
?
size
gt
0
>
<
#
list
jobList
as
item
>
<p>
${item}
</p>
</
#
list>
</
#
if>
</div>
</section>
<!-- /.content -->
<section
class=
"content"
>
<div
class=
"row"
>
<div
class=
"col-xs-12"
>
<div
class=
"box"
>
<div
class=
"box-header"
><h3
class=
"box-title"
>
任务列表
</h3></div>
<div
class=
"box-body"
>
<table
id=
"example1"
class=
"table table-bordered table-striped"
>
<thead>
<tr>
<th>
任务ID
</th>
<th>
cron
</th>
<th>
Job类路径
</th>
<th>
简介
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody>
<
#
if
jobList
?
exists
&&
jobList
?
size
gt
0
>
<
#
list
jobList
as
item
>
<tr>
<td>
${item['TriggerKey'].name}
</td>
<td>
${item['Trigger'].cronExpression}
</td>
<td>
${item['JobDetail'].jobClass}
</td>
<td>
-
</td>
<td>
X
</td>
</tr>
</
#
list>
</
#
if>
</tbody>
<tfoot>
<tr>
<th>
任务ID
</th>
<th>
cron
</th>
<th>
Job类路径
</th>
<th>
简介
</th>
<th>
操作
</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</section>
</div>
<!-- /.content-wrapper -->
<!-- footer -->
<
@
netCommon
.
commonFooter
/>
...
...
@@ -45,5 +79,14 @@
<
@
netCommon
.
commonControl
/>
</div>
<
@
netCommon
.
commonScript
/>
<!-- DataTables -->
<script
src=
"${request.contextPath}/static/adminlte/plugins/datatables/jquery.dataTables.min.js"
></script>
<script
src=
"${request.contextPath}/static/adminlte/plugins/datatables/dataTables.bootstrap.min.js"
></script>
<!-- page script -->
<script>
$
(
function
()
{
$
(
"#example1"
).
DataTable
();
});
</script>
</body>
</html>
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论