xueli.xue 8 年 前
コミット
6574d7f9de

+ 1 - 0
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/IndexController.java ファイルの表示

@@ -37,6 +37,7 @@ public class IndexController {
37 37
 	}
38 38
 
39 39
     @RequestMapping("/triggerChartDate")
40
+	@ResponseBody
40 41
 	public ReturnT<Map<String, Object>> triggerChartDate() {
41 42
         ReturnT<Map<String, Object>> triggerChartDate = xxlJobService.triggerChartDate();
42 43
         return triggerChartDate;

+ 1 - 1
xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobLogDao.java ファイルの表示

@@ -27,6 +27,6 @@ public interface IXxlJobLogDao {
27 27
 
28 28
 	public int triggerCountByHandleCode(int handleCode);
29 29
 
30
-    Map<String,Integer> triggerCountByDay(Date from, Date to);
30
+	public List<Map<String, Object>> triggerCountByDay(Date from, Date to, int handleCode);
31 31
 
32 32
 }

+ 3 - 2
xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobLogDaoImpl.java ファイルの表示

@@ -84,11 +84,12 @@ public class XxlJobLogDaoImpl implements IXxlJobLogDao {
84 84
 	}
85 85
 
86 86
 	@Override
87
-	public Map<String, Integer> triggerCountByDay(Date from, Date to) {
87
+	public List<Map<String, Object>> triggerCountByDay(Date from, Date to, int handleCode) {
88 88
 		Map<String, Object> params = new HashMap<String, Object>();
89 89
 		params.put("from", from);
90 90
 		params.put("to", to);
91
-		return sqlSessionTemplate.selectOne("XxlJobLogMapper.triggerCountByDay", params);
91
+		params.put("handleCode", handleCode);
92
+		return sqlSessionTemplate.selectList("XxlJobLogMapper.triggerCountByDay", params);
92 93
 	}
93 94
 
94 95
 }

+ 41 - 2
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java ファイルの表示

@@ -297,9 +297,48 @@ public class XxlJobServiceImpl implements IXxlJobService {
297 297
 		Date from = DateUtils.addDays(new Date(), -30);
298 298
 		Date to = new Date();
299 299
 
300
-		Map<String, Integer> triggerCountMap = xxlJobLogDao.triggerCountByDay(from, to);
300
+		List<String> triggerDayList = new ArrayList<String>();
301
+		List<Integer> triggerDayCountSucList = new ArrayList<Integer>();
302
+		List<Integer> triggerDayCountFailList = new ArrayList<Integer>();
303
+		int triggerCountSucTotal = 0;
304
+		int triggerCountFailTotal = 0;
305
+
306
+		List<Map<String, Object>> triggerCountMapAll = xxlJobLogDao.triggerCountByDay(from, to, -1);
307
+		List<Map<String, Object>> triggerCountMapSuc = xxlJobLogDao.triggerCountByDay(from, to, ReturnT.SUCCESS_CODE);
308
+		if (CollectionUtils.isNotEmpty(triggerCountMapAll)) {
309
+			for (Map<String, Object> item: triggerCountMapAll) {
310
+				String day = String.valueOf(item.get("triggerDay"));
311
+				int dayAllCount = Integer.valueOf(String.valueOf(item.get("triggerCount")));
312
+				int daySucCount = 0;
313
+				int dayFailCount = dayAllCount - daySucCount;
314
+
315
+				if (CollectionUtils.isNotEmpty(triggerCountMapSuc)) {
316
+					for (Map<String, Object> sucItem: triggerCountMapSuc) {
317
+						String daySuc = String.valueOf(sucItem.get("triggerDay"));
318
+						if (day.equals(daySuc)) {
319
+							daySucCount = Integer.valueOf(String.valueOf(sucItem.get("triggerCount")));
320
+							dayFailCount = dayAllCount - daySucCount;
321
+						}
322
+					}
323
+				}
324
+
325
+				triggerDayList.add(day);
326
+				triggerDayCountSucList.add(daySucCount);
327
+				triggerDayCountFailList.add(dayFailCount);
328
+				triggerCountSucTotal += daySucCount;
329
+				triggerCountFailTotal += dayFailCount;
330
+			}
331
+		} else {
332
+			return new ReturnT<Map<String, Object>>(ReturnT.FAIL_CODE, null);
333
+		}
301 334
 
302
-		return null;
335
+		Map<String, Object> result = new HashMap<String, Object>();
336
+		result.put("triggerDayList", triggerDayList);
337
+		result.put("triggerDayCountSucList", triggerDayCountSucList);
338
+		result.put("triggerDayCountFailList", triggerDayCountFailList);
339
+		result.put("triggerCountSucTotal", triggerCountSucTotal);
340
+		result.put("triggerCountFailTotal", triggerCountFailTotal);
341
+		return new ReturnT<Map<String, Object>>(result);
303 342
 	}
304 343
 
305 344
 }

+ 5 - 2
xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml ファイルの表示

@@ -128,8 +128,7 @@
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
132
-			 gt 0">
131
+			<if test="_parameter gt 0">
133 132
 				AND t.handle_code = #{handleCode}
134 133
 			</if>
135 134
 		</trim>
@@ -138,6 +137,10 @@
138 137
     <select id="triggerCountByDay" parameterType="java.util.Map" resultType="java.util.Map" >
139 138
         SELECT DATE_FORMAT(trigger_time,'%Y-%m-%d') triggerDay, COUNT(id) triggerCount
140 139
         FROM XXL_JOB_QRTZ_TRIGGER_LOG
140
+        WHERE trigger_time BETWEEN #{from} and #{to}
141
+		<if test="handleCode gt 0">
142
+			AND handle_code = #{handleCode}
143
+		</if>
141 144
         GROUP BY triggerDay;
142 145
     </select>
143 146
 	

+ 2 - 2
xxl-job-admin/src/main/webapp/WEB-INF/template/index.ftl ファイルの表示

@@ -49,7 +49,7 @@
49 49
                 </div>
50 50
 
51 51
                 <#-- 调度信息 -->
52
-                <div class="col-md-4 col-sm-6 col-xs-12" style="display: none;">
52
+                <div class="col-md-4 col-sm-6 col-xs-12" >
53 53
                     <div class="info-box bg-yellow">
54 54
                         <span class="info-box-icon"><i class="fa fa-calendar"></i></span>
55 55
 
@@ -91,7 +91,7 @@
91 91
                 <div class="col-md-12">
92 92
                     <div class="box">
93 93
                         <div class="box-header with-border">
94
-                            <h3 class="box-title">调度报表</h3>
94
+                            <h3 class="box-title">调度报表(一月之内)</h3>
95 95
                             <#--<input type="text" class="form-control" id="filterTime" readonly >-->
96 96
                         </div>
97 97
                         <div class="box-body">

+ 41 - 14
xxl-job-admin/src/main/webapp/static/js/index.js ファイルの表示

@@ -5,11 +5,30 @@
5 5
 
6 6
 $(function () {
7 7
 
8
-    // lineChart
9
-    var lineChart = echarts.init(document.getElementById('lineChart'));
10
-    lineChart.setOption(lineChartDate());
8
+    /**
9
+     *
10
+     */
11
+    $.ajax({
12
+        type : 'POST',
13
+        url : base_url + '/triggerChartDate',
14
+        data : {        },
15
+        dataType : "json",
16
+        success : function(data){
17
+            if (data.code == 200) {
18
+                lineChartInit(data)
19
+                pieChartInit(data);
20
+            } else {
21
+                ComAlert.show(2, data.msg || '调度报表数据加载异常' );
22
+            }
23
+        }
24
+    });
25
+
11 26
 
12
-    function lineChartDate() {
27
+
28
+    /**
29
+     * 折线图
30
+     */
31
+    function lineChartInit(data) {
13 32
         var option = {
14 33
                title: {
15 34
                    text: '日期分布图'
@@ -73,15 +92,16 @@ $(function () {
73 92
                ],
74 93
                 color:['#00A65A', '#F39C12']
75 94
         };
76
-        return option;
77
-    }
78 95
 
79
-    // pie chart
80
-    var pieChart = echarts.init(document.getElementById('pieChart'));
81
-    pieChart.setOption(pieChartDate());
96
+        var lineChart = echarts.init(document.getElementById('lineChart'));
97
+        lineChart.setOption(option);
98
+    }
82 99
 
83
-    function pieChartDate() {
84
-        option = {
100
+    /**
101
+     * 饼图
102
+     */
103
+    function pieChartInit(data) {
104
+        var option = {
85 105
             title : {
86 106
                 text: '调度总次数',
87 107
                 /*subtext: 'subtext',*/
@@ -103,8 +123,14 @@ $(function () {
103 123
                     radius : '55%',
104 124
                     center: ['50%', '60%'],
105 125
                     data:[
106
-                        {value:800, name:'成功调度次数'},
107
-                        {value:200, name:'失败调度次数'}
126
+                        {
127
+                            value:data.content.triggerCountSucTotal,
128
+                            name:'成功调度次数'
129
+                        },
130
+                        {
131
+                            value:data.content.triggerCountFailTotal,
132
+                            name:'失败调度次数'
133
+                        }
108 134
                     ],
109 135
                     itemStyle: {
110 136
                         emphasis: {
@@ -117,7 +143,8 @@ $(function () {
117 143
             ],
118 144
             color:['#00A65A', '#F39C12']
119 145
         };
120
-        return option;
146
+        var pieChart = echarts.init(document.getElementById('pieChart'));
147
+        pieChart.setOption(option);
121 148
     }
122 149
 
123 150
     // 过滤时间