xueli.xue 8 vuotta sitten
vanhempi
commit
3f7b4d4ae9

+ 6 - 0
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/IndexController.java Näytä tiedosto

@@ -35,6 +35,12 @@ public class IndexController {
35 35
 
36 36
 		return "index";
37 37
 	}
38
+
39
+    @RequestMapping("/triggerChartDate")
40
+	public ReturnT<Map<String, Object>> triggerChartDate() {
41
+        ReturnT<Map<String, Object>> triggerChartDate = xxlJobService.triggerChartDate();
42
+        return triggerChartDate;
43
+    }
38 44
 	
39 45
 	@RequestMapping("/toLogin")
40 46
 	@PermessionLimit(limit=false)

+ 4 - 1
xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobLogDao.java Näytä tiedosto

@@ -4,6 +4,7 @@ import com.xxl.job.admin.core.model.XxlJobLog;
4 4
 
5 5
 import java.util.Date;
6 6
 import java.util.List;
7
+import java.util.Map;
7 8
 
8 9
 /**
9 10
  * job log
@@ -24,6 +25,8 @@ public interface IXxlJobLogDao {
24 25
 	
25 26
 	public int delete(int jobId);
26 27
 
27
-	public int findByHandleCodeCount(int handleCode);
28
+	public int triggerCountByHandleCode(int handleCode);
29
+
30
+    Map<String,Integer> triggerCountByDay(Date from, Date to);
28 31
 
29 32
 }

+ 11 - 2
xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobLogDaoImpl.java Näytä tiedosto

@@ -9,6 +9,7 @@ import javax.annotation.Resource;
9 9
 import java.util.Date;
10 10
 import java.util.HashMap;
11 11
 import java.util.List;
12
+import java.util.Map;
12 13
 
13 14
 /**
14 15
  * job log
@@ -78,8 +79,16 @@ public class XxlJobLogDaoImpl implements IXxlJobLogDao {
78 79
 	}
79 80
 
80 81
 	@Override
81
-	public int findByHandleCodeCount(int handleCode) {
82
-		return sqlSessionTemplate.selectOne("XxlJobLogMapper.findByHandleCodeCount", handleCode);
82
+	public int triggerCountByHandleCode(int handleCode) {
83
+		return sqlSessionTemplate.selectOne("XxlJobLogMapper.triggerCountByHandleCode", handleCode);
84
+	}
85
+
86
+	@Override
87
+	public Map<String, Integer> triggerCountByDay(Date from, Date to) {
88
+		Map<String, Object> params = new HashMap<String, Object>();
89
+		params.put("from", from);
90
+		params.put("to", to);
91
+		return sqlSessionTemplate.selectOne("XxlJobLogMapper.triggerCountByDay", params);
83 92
 	}
84 93
 
85 94
 }

+ 4 - 1
xxl-job-admin/src/main/java/com/xxl/job/admin/service/IXxlJobService.java Näytä tiedosto

@@ -27,5 +27,8 @@ public interface IXxlJobService {
27 27
 	
28 28
 	public ReturnT<String> triggerJob(int id);
29 29
 
30
-    Map<String,Object> dashboardInfo();
30
+	public Map<String,Object> dashboardInfo();
31
+
32
+	public ReturnT<Map<String,Object>> triggerChartDate();
33
+
31 34
 }

+ 13 - 2
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java Näytä tiedosto

@@ -11,6 +11,7 @@ import com.xxl.job.core.biz.model.ReturnT;
11 11
 import com.xxl.job.core.registry.RegistHelper;
12 12
 import org.apache.commons.collections.CollectionUtils;
13 13
 import org.apache.commons.lang.StringUtils;
14
+import org.apache.commons.lang.time.DateUtils;
14 15
 import org.quartz.CronExpression;
15 16
 import org.quartz.SchedulerException;
16 17
 import org.slf4j.Logger;
@@ -260,8 +261,8 @@ public class XxlJobServiceImpl implements IXxlJobService {
260 261
 	public Map<String, Object> dashboardInfo() {
261 262
 
262 263
 		int jobInfoCount = xxlJobInfoDao.findAllCount();
263
-		int jobLogCount = xxlJobLogDao.findByHandleCodeCount(-1);
264
-		int jobLogSuccessCount = xxlJobLogDao.findByHandleCodeCount(ReturnT.SUCCESS_CODE);
264
+		int jobLogCount = xxlJobLogDao.triggerCountByHandleCode(-1);
265
+		int jobLogSuccessCount = xxlJobLogDao.triggerCountByHandleCode(ReturnT.SUCCESS_CODE);
265 266
 
266 267
 		// executor count
267 268
 		Set<String> executerAddressSet = new HashSet<String>();
@@ -291,4 +292,14 @@ public class XxlJobServiceImpl implements IXxlJobService {
291 292
 		return dashboardMap;
292 293
 	}
293 294
 
295
+	@Override
296
+	public ReturnT<Map<String, Object>> triggerChartDate() {
297
+		Date from = DateUtils.addDays(new Date(), -30);
298
+		Date to = new Date();
299
+
300
+		Map<String, Integer> triggerCountMap = xxlJobLogDao.triggerCountByDay(from, to);
301
+
302
+		return null;
303
+	}
304
+
294 305
 }

+ 9 - 2
xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml Näytä tiedosto

@@ -124,14 +124,21 @@
124 124
 		WHERE job_id = #{jobId}
125 125
 	</delete>
126 126
 
127
-	<select id="findByHandleCodeCount" parameterType="java.lang.Integer" resultType="java.lang.Integer">
127
+	<select id="triggerCountByHandleCode" parameterType="java.lang.Integer" resultType="java.lang.Integer">
128 128
 		SELECT count(1)
129 129
 		FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
130 130
 		<trim prefix="WHERE" prefixOverrides="AND | OR" >
131
-			<if test="_parameter gt 0">
131
+			<if test="_parameter
132
+			 gt 0">
132 133
 				AND t.handle_code = #{handleCode}
133 134
 			</if>
134 135
 		</trim>
135 136
 	</select>
137
+
138
+    <select id="triggerCountByDay" parameterType="java.util.Map" resultType="java.util.Map" >
139
+        SELECT DATE_FORMAT(trigger_time,'%Y-%m-%d') triggerDay, COUNT(id) triggerCount
140
+        FROM XXL_JOB_QRTZ_TRIGGER_LOG
141
+        GROUP BY triggerDay;
142
+    </select>
136 143
 	
137 144
 </mapper>

+ 34 - 5
xxl-job-admin/src/main/webapp/WEB-INF/template/index.ftl Näytä tiedosto

@@ -16,7 +16,7 @@
16 16
 	<div class="content-wrapper">
17 17
 		<!-- Content Header (Page header) -->
18 18
 		<section class="content-header">
19
-			<h1>仪表盘<small>任务调度中心</small></h1>
19
+			<h1>运行报表<small>任务调度中心</small></h1>
20 20
 			<!--
21 21
 			<ol class="breadcrumb">
22 22
 				<li><a><i class="fa fa-dashboard"></i>调度中心</a></li>
@@ -28,7 +28,7 @@
28 28
 		<!-- Main content -->
29 29
 		<section class="content">
30 30
 
31
-            <!-- 简要报表 -->
31
+            <!-- 任务信息 -->
32 32
             <div class="row">
33 33
 
34 34
                 <#-- 任务信息 -->
@@ -49,7 +49,7 @@
49 49
                 </div>
50 50
 
51 51
                 <#-- 调度信息 -->
52
-                <div class="col-md-4 col-sm-6 col-xs-12">
52
+                <div class="col-md-4 col-sm-6 col-xs-12" style="display: none;">
53 53
                     <div class="info-box bg-yellow">
54 54
                         <span class="info-box-icon"><i class="fa fa-calendar"></i></span>
55 55
 
@@ -70,7 +70,7 @@
70 70
                 <#-- 执行器 -->
71 71
                 <div class="col-md-4 col-sm-6 col-xs-12">
72 72
                     <div class="info-box bg-green">
73
-                        <span class="info-box-icon"><i class="fa fa-thumbs-o-up"></i></span>
73
+                        <span class="info-box-icon"><i class="fa ion-ios-settings-strong"></i></span>
74 74
 
75 75
                         <div class="info-box-content">
76 76
                             <span class="info-box-text">执行器数量</span>
@@ -85,7 +85,31 @@
85 85
                 </div>
86 86
 
87 87
             </div>
88
-            <!-- /.row -->
88
+
89
+            <#-- 调度报表:时间区间筛选,左侧折线图 + 右侧饼图 -->
90
+            <div class="row">
91
+                <div class="col-md-12">
92
+                    <div class="box">
93
+                        <div class="box-header with-border">
94
+                            <h3 class="box-title">调度报表</h3>
95
+                            <#--<input type="text" class="form-control" id="filterTime" readonly >-->
96
+                        </div>
97
+                        <div class="box-body">
98
+                            <div class="row">
99
+                                <#-- 左侧折线图 -->
100
+                                <div class="col-md-8">
101
+                                    <div id="lineChart" style="height: 350px;"></div>
102
+                                </div>
103
+                                <#-- 右侧饼图 -->
104
+                                <div class="col-md-4">
105
+                                    <div id="pieChart" style="height: 350px;"></div>
106
+                                </div>
107
+                            </div>
108
+                        </div>
109
+                    </div>
110
+                </div>
111
+            </div>
112
+
89 113
 
90 114
 		</section>
91 115
 		<!-- /.content -->
@@ -96,5 +120,10 @@
96 120
 	<@netCommon.commonFooter />
97 121
 </div>
98 122
 <@netCommon.commonScript />
123
+<#--<script src="${request.contextPath}/static/adminlte/plugins/daterangepicker/moment.min.js"></script>
124
+<script src="${request.contextPath}/static/adminlte/plugins/daterangepicker/daterangepicker.js"></script>-->
125
+<script src="${request.contextPath}/static/plugins/echarts/echarts.common.min.js"></script>
126
+<script src="${request.contextPath}/static/js/index.js"></script>
127
+
99 128
 </body>
100 129
 </html>

+ 157 - 0
xxl-job-admin/src/main/webapp/static/js/index.js Näytä tiedosto

@@ -0,0 +1,157 @@
1
+/**
2
+ * Created by xuxueli on 17/4/24.
3
+ */
4
+
5
+
6
+$(function () {
7
+
8
+    // lineChart
9
+    var lineChart = echarts.init(document.getElementById('lineChart'));
10
+    lineChart.setOption(lineChartDate());
11
+
12
+    function lineChartDate() {
13
+        var option = {
14
+               title: {
15
+                   text: '日期分布图'
16
+               },
17
+               tooltip : {
18
+                   trigger: 'axis',
19
+                   axisPointer: {
20
+                       type: 'cross',
21
+                       label: {
22
+                           backgroundColor: '#6a7985'
23
+                       }
24
+                   }
25
+               },
26
+               legend: {
27
+                   data:['成功调度次数','失败调度次数']
28
+               },
29
+               toolbox: {
30
+                   feature: {
31
+                       saveAsImage: {}
32
+                   }
33
+               },
34
+               grid: {
35
+                   left: '3%',
36
+                   right: '4%',
37
+                   bottom: '3%',
38
+                   containLabel: true
39
+               },
40
+               xAxis : [
41
+                   {
42
+                       type : 'category',
43
+                       boundaryGap : false,
44
+                       data : ['2017-10-01','2017-10-02','2017-10-03','2017-10-04','2017-10-05','2017-10-06','2017-10-07']
45
+                   }
46
+               ],
47
+               yAxis : [
48
+                   {
49
+                       type : 'value'
50
+                   }
51
+               ],
52
+               series : [
53
+                   {
54
+                       name:'成功调度次数',
55
+                       type:'line',
56
+                       stack: '总量',
57
+                       areaStyle: {normal: {}},
58
+                       data:[820, 932, 901, 934, 1290, 1330, 1320]
59
+                   },
60
+                   {
61
+                       name:'失败调度次数',
62
+                       type:'line',
63
+                       stack: '总量',
64
+                       label: {
65
+                           normal: {
66
+                               show: true,
67
+                               position: 'top'
68
+                           }
69
+                       },
70
+                       areaStyle: {normal: {}},
71
+                       data:[120, 132, 101, 134, 90, 230, 210]
72
+                   }
73
+               ],
74
+                color:['#00A65A', '#F39C12']
75
+        };
76
+        return option;
77
+    }
78
+
79
+    // pie chart
80
+    var pieChart = echarts.init(document.getElementById('pieChart'));
81
+    pieChart.setOption(pieChartDate());
82
+
83
+    function pieChartDate() {
84
+        option = {
85
+            title : {
86
+                text: '调度总次数',
87
+                /*subtext: 'subtext',*/
88
+                x:'center'
89
+            },
90
+            tooltip : {
91
+                trigger: 'item',
92
+                formatter: "{a} <br/>{b} : {c} ({d}%)"
93
+            },
94
+            legend: {
95
+                orient: 'vertical',
96
+                left: 'left',
97
+                data: ['成功调度次数','失败调度次数']
98
+            },
99
+            series : [
100
+                {
101
+                    name: '访问来源',
102
+                    type: 'pie',
103
+                    radius : '55%',
104
+                    center: ['50%', '60%'],
105
+                    data:[
106
+                        {value:800, name:'成功调度次数'},
107
+                        {value:200, name:'失败调度次数'}
108
+                    ],
109
+                    itemStyle: {
110
+                        emphasis: {
111
+                            shadowBlur: 10,
112
+                            shadowOffsetX: 0,
113
+                            shadowColor: 'rgba(0, 0, 0, 0.5)'
114
+                        }
115
+                    }
116
+                }
117
+            ],
118
+            color:['#00A65A', '#F39C12']
119
+        };
120
+        return option;
121
+    }
122
+
123
+    // 过滤时间
124
+    /*$('#filterTime').daterangepicker({
125
+        autoApply:false,
126
+        singleDatePicker:false,
127
+        showDropdowns:false,        // 是否显示年月选择条件
128
+        timePicker: true, 			// 是否显示小时和分钟选择条件
129
+        timePickerIncrement: 10, 	// 时间的增量,单位为分钟
130
+        timePicker24Hour : true,
131
+        opens : 'left', //日期选择框的弹出位置
132
+        ranges: {
133
+            '最近1小时': [moment().subtract(1, 'hours'), moment()],
134
+            '今日': [moment().startOf('day'), moment().endOf('day')],
135
+            '昨日': [moment().subtract(1, 'days').startOf('day'), moment().subtract(1, 'days').endOf('day')],
136
+            '最近7日': [moment().subtract(6, 'days'), moment()],
137
+            '最近30日': [moment().subtract(29, 'days'), moment()],
138
+            '本月': [moment().startOf('month'), moment().endOf('month')],
139
+            '上个月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
140
+        },
141
+        locale : {
142
+            format: 'YYYY-MM-DD HH:mm:ss',
143
+            separator : ' - ',
144
+            customRangeLabel : '自定义',
145
+            applyLabel : '确定',
146
+            cancelLabel : '取消',
147
+            fromLabel : '起始时间',
148
+            toLabel : '结束时间',
149
+            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
150
+            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月' ],
151
+            firstDay : 1,
152
+            startDate: moment().startOf('day'),
153
+            endDate: moment().endOf('day')
154
+        }
155
+    });*/
156
+
157
+});

File diff suppressed because it is too large
+ 29 - 0
xxl-job-admin/src/main/webapp/static/plugins/echarts/echarts.common.min.js