Sfoglia il codice sorgente

调度报表新增"运行中"中状态项,数据加载SQL优化

xuxueli 7 anni fa
parent
commit
0169d537ef

+ 3 - 1
doc/XXL-JOB官方文档.md Vedi File

@@ -1144,6 +1144,8 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
1144 1144
 - 1、修复打包部署时资源文件乱码问题;
1145 1145
 - 2、修复新版本chrome滚动到顶部失效问题;
1146 1146
 - 3、国际化:调度中心实现国际化,支持中文、英文两种语言,默认为中文。
1147
+- 4、调度报表新增"运行中"中状态项,数据加载SQL优化;
1148
+- 5、调度报表缓存优化,修复大数据量执行日志加载缓慢的问题;
1147 1149
 
1148 1150
 ### TODO LIST
1149 1151
 - 1、任务权限管理:执行器为粒度分配权限,核心操作校验权限;
@@ -1161,7 +1163,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
1161 1163
 - 13、任务依赖增强,新增任务类型 "流程任务",流程节点可挂载普通类型任务,承担任务依赖功能。现有子任务模型取消;需要考虑任务依赖死循环问题;
1162 1164
 - 14、分片任务某一分片失败,支持分片转移;
1163 1165
 - 15、调度中心触发任务后,先推送触发队列,异步触发,然后立即返回。降低quartz线程占用时长。
1164
-- 16、调度报表加载速度慢问题;
1166
+
1165 1167
 
1166 1168
 ## 七、其他
1167 1169
 

+ 1 - 1
xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/I18nUtil.java Vedi File

@@ -28,7 +28,7 @@ public class I18nUtil {
28 28
 
29 29
     public static Properties loadI18nProp(){
30 30
         if (prop != null && (System.currentTimeMillis()-lastCacheTim)<60*1000) {
31
-            return prop;
31
+            //return prop;
32 32
         }
33 33
         try {
34 34
             // bild i18n prop

+ 1 - 2
xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java Vedi File

@@ -41,8 +41,7 @@ public interface XxlJobLogDao {
41 41
 	public int triggerCountByHandleCode(@Param("handleCode") int handleCode);
42 42
 
43 43
 	public List<Map<String, Object>> triggerCountByDay(@Param("from") Date from,
44
-													   @Param("to") Date to,
45
-													   @Param("handleCode") int handleCode);
44
+													   @Param("to") Date to);
46 45
 
47 46
 	public int clearLog(@Param("jobGroup") int jobGroup,
48 47
 						@Param("jobId") int jobId,

+ 17 - 19
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java Vedi File

@@ -323,35 +323,30 @@ public class XxlJobServiceImpl implements XxlJobService {
323 323
 	@Override
324 324
 	public ReturnT<Map<String, Object>> triggerChartDate(Date startDate, Date endDate) {
325 325
 		List<String> triggerDayList = new ArrayList<String>();
326
+		List<Integer> triggerDayCountRunningList = new ArrayList<Integer>();
326 327
 		List<Integer> triggerDayCountSucList = new ArrayList<Integer>();
327 328
 		List<Integer> triggerDayCountFailList = new ArrayList<Integer>();
329
+		int triggerCountRunningTotal = 0;
328 330
 		int triggerCountSucTotal = 0;
329 331
 		int triggerCountFailTotal = 0;
330 332
 
331
-		List<Map<String, Object>> triggerCountMapAll = xxlJobLogDao.triggerCountByDay(startDate, endDate, -1);
332
-		List<Map<String, Object>> triggerCountMapSuc = xxlJobLogDao.triggerCountByDay(startDate, endDate, ReturnT.SUCCESS_CODE);
333
+		List<Map<String, Object>> triggerCountMapAll = xxlJobLogDao.triggerCountByDay(startDate, endDate);
333 334
 		if (CollectionUtils.isNotEmpty(triggerCountMapAll)) {
334 335
 			for (Map<String, Object> item: triggerCountMapAll) {
335 336
 				String day = String.valueOf(item.get("triggerDay"));
336
-				int dayAllCount = Integer.valueOf(String.valueOf(item.get("triggerCount")));
337
-				int daySucCount = 0;
338
-				int dayFailCount = dayAllCount - daySucCount;
339
-
340
-				if (CollectionUtils.isNotEmpty(triggerCountMapSuc)) {
341
-					for (Map<String, Object> sucItem: triggerCountMapSuc) {
342
-						String daySuc = String.valueOf(sucItem.get("triggerDay"));
343
-						if (day.equals(daySuc)) {
344
-							daySucCount = Integer.valueOf(String.valueOf(sucItem.get("triggerCount")));
345
-							dayFailCount = dayAllCount - daySucCount;
346
-						}
347
-					}
348
-				}
337
+				int triggerDayCount = Integer.valueOf(String.valueOf(item.get("triggerDayCount")));
338
+				int triggerDayCountRunning = Integer.valueOf(String.valueOf(item.get("triggerDayCountRunning")));
339
+				int triggerDayCountSuc = Integer.valueOf(String.valueOf(item.get("triggerDayCountSuc")));
340
+				int triggerDayCountFail = triggerDayCount - triggerDayCountRunning - triggerDayCountSuc;
349 341
 
350 342
 				triggerDayList.add(day);
351
-				triggerDayCountSucList.add(daySucCount);
352
-				triggerDayCountFailList.add(dayFailCount);
353
-				triggerCountSucTotal += daySucCount;
354
-				triggerCountFailTotal += dayFailCount;
343
+				triggerDayCountRunningList.add(triggerDayCountRunning);
344
+				triggerDayCountSucList.add(triggerDayCountSuc);
345
+				triggerDayCountFailList.add(triggerDayCountFail);
346
+
347
+				triggerCountRunningTotal += triggerDayCountRunning;
348
+				triggerCountSucTotal += triggerDayCountSuc;
349
+				triggerCountFailTotal += triggerDayCountFail;
355 350
 			}
356 351
 		} else {
357 352
             for (int i = 4; i > -1; i--) {
@@ -363,8 +358,11 @@ public class XxlJobServiceImpl implements XxlJobService {
363 358
 
364 359
 		Map<String, Object> result = new HashMap<String, Object>();
365 360
 		result.put("triggerDayList", triggerDayList);
361
+		result.put("triggerDayCountRunningList", triggerDayCountRunningList);
366 362
 		result.put("triggerDayCountSucList", triggerDayCountSucList);
367 363
 		result.put("triggerDayCountFailList", triggerDayCountFailList);
364
+
365
+		result.put("triggerCountRunningTotal", triggerCountRunningTotal);
368 366
 		result.put("triggerCountSucTotal", triggerCountSucTotal);
369 367
 		result.put("triggerCountFailTotal", triggerCountFailTotal);
370 368
 		return new ReturnT<Map<String, Object>>(result);

+ 0 - 4
xxl-job-admin/src/main/resources/i18n/message.properties Vedi File

@@ -93,11 +93,7 @@ job_dashboard_jobgroup_num_tip=调度中心在线的执行器机器数量
93 93
 job_dashboard_report=调度报表
94 94
 job_dashboard_report_loaddata_fail=调度报表数据加载异常
95 95
 job_dashboard_date_report=日期分布图
96
-job_dashboard_date_report_suc_count=成功调度次数
97
-job_dashboard_date_report_fail_count=失败调度次数
98 96
 job_dashboard_rate_report=成功比例图
99
-job_dashboard_rate_report_suc_count=成功调度次数
100
-job_dashboard_rate_report_fail_count=失败调度次数
101 97
 
102 98
 ## job info
103 99
 jobinfo_name=任务管理

+ 0 - 4
xxl-job-admin/src/main/resources/i18n/message_en.properties Vedi File

@@ -93,11 +93,7 @@ job_dashboard_jobgroup_num_tip=The number of online executor machines perceived
93 93
 job_dashboard_report=Scheduling report
94 94
 job_dashboard_report_loaddata_fail=Scheduling report load data error
95 95
 job_dashboard_date_report=Date distribution
96
-job_dashboard_date_report_suc_count=Successful scheduling number
97
-job_dashboard_date_report_fail_count=Fail scheduling number
98 96
 job_dashboard_rate_report=Percentage distribution
99
-job_dashboard_rate_report_suc_count=Successful scheduling percentage
100
-job_dashboard_rate_report_fail_count=Fail scheduling percentage
101 97
 
102 98
 ## job info
103 99
 jobinfo_name=Job Manage

+ 8 - 7
xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml Vedi File

@@ -163,13 +163,14 @@
163 163
 	</select>
164 164
 
165 165
     <select id="triggerCountByDay" resultType="java.util.Map" >
166
-        SELECT DATE_FORMAT(trigger_time,'%Y-%m-%d') triggerDay, COUNT(id) triggerCount
167
-        FROM XXL_JOB_QRTZ_TRIGGER_LOG
168
-        WHERE trigger_time BETWEEN #{from} and #{to}
169
-		<if test="handleCode gt 0">
170
-			AND handle_code = #{handleCode}
171
-		</if>
172
-        GROUP BY triggerDay;
166
+		SELECT
167
+			DATE_FORMAT(trigger_time,'%Y-%m-%d') triggerDay,
168
+			COUNT(handle_code) triggerDayCount,
169
+			SUM(CASE WHEN handle_code = 0 then 1 else 0 end) as triggerDayCountRunning,
170
+			SUM(CASE WHEN handle_code = 200 then 1 else 0 end) as triggerDayCountSuc
171
+		FROM XXL_JOB_QRTZ_TRIGGER_LOG
172
+		WHERE trigger_time BETWEEN #{from} and #{to}
173
+		GROUP BY triggerDay;
173 174
     </select>
174 175
 
175 176
 	<delete id="clearLog" >

+ 23 - 12
xxl-job-admin/src/main/webapp/static/js/index.js Vedi File

@@ -89,7 +89,7 @@ $(function () {
89 89
                    }
90 90
                },
91 91
                legend: {
92
-                   data:[I18n.job_dashboard_date_report_suc_count, I18n.job_dashboard_date_report_fail_count]
92
+                   data:[I18n.joblog_status_suc, I18n.joblog_status_fail, I18n.joblog_status_running]
93 93
                },
94 94
                toolbox: {
95 95
                    feature: {
@@ -116,14 +116,14 @@ $(function () {
116 116
                ],
117 117
                series : [
118 118
                    {
119
-                       name:I18n.job_dashboard_date_report_suc_count,
119
+                       name:I18n.joblog_status_suc,
120 120
                        type:'line',
121 121
                        stack: 'Total',
122 122
                        areaStyle: {normal: {}},
123 123
                        data: data.content.triggerDayCountSucList
124 124
                    },
125 125
                    {
126
-                       name:I18n.job_dashboard_date_report_fail_count,
126
+                       name:I18n.joblog_status_fail,
127 127
                        type:'line',
128 128
                        stack: 'Total',
129 129
                        label: {
@@ -134,9 +134,16 @@ $(function () {
134 134
                        },
135 135
                        areaStyle: {normal: {}},
136 136
                        data: data.content.triggerDayCountFailList
137
+                   },
138
+                   {
139
+                       name:I18n.joblog_status_running,
140
+                       type:'line',
141
+                       stack: 'Total',
142
+                       areaStyle: {normal: {}},
143
+                       data: data.content.triggerDayCountRunningList
137 144
                    }
138 145
                ],
139
-                color:['#00A65A', '#F39C12']
146
+                color:['#00A65A', '#c23632', '#F39C12']
140 147
         };
141 148
 
142 149
         var lineChart = echarts.init(document.getElementById('lineChart'));
@@ -155,27 +162,31 @@ $(function () {
155 162
             },
156 163
             tooltip : {
157 164
                 trigger: 'item',
158
-                formatter: "{a} <br/>{b} : {c} ({d}%)"
165
+                formatter: "{b} : {c} ({d}%)"
159 166
             },
160 167
             legend: {
161 168
                 orient: 'vertical',
162 169
                 left: 'left',
163
-                data: [I18n.job_dashboard_rate_report_suc_count, I18n.job_dashboard_rate_report_fail_count ]
170
+                data: [I18n.joblog_status_suc, I18n.joblog_status_fail, I18n.joblog_status_running ]
164 171
             },
165 172
             series : [
166 173
                 {
167
-                    name: '分布比例',
174
+                    //name: '分布比例',
168 175
                     type: 'pie',
169 176
                     radius : '55%',
170 177
                     center: ['50%', '60%'],
171 178
                     data:[
172 179
                         {
173
-                            value:data.content.triggerCountSucTotal,
174
-                            name:I18n.job_dashboard_rate_report_suc_count
180
+                            name:I18n.joblog_status_suc,
181
+                            value:data.content.triggerCountSucTotal
182
+                        },
183
+                        {
184
+                            name:I18n.joblog_status_fail,
185
+                            value:data.content.triggerCountFailTotal
175 186
                         },
176 187
                         {
177
-                            value:data.content.triggerCountFailTotal,
178
-                            name:I18n.job_dashboard_rate_report_fail_count
188
+                            name:I18n.joblog_status_running,
189
+                            value:data.content.triggerCountRunningTotal
179 190
                         }
180 191
                     ],
181 192
                     itemStyle: {
@@ -187,7 +198,7 @@ $(function () {
187 198
                     }
188 199
                 }
189 200
             ],
190
-            color:['#00A65A', '#F39C12']
201
+            color:['#00A65A', '#c23632', '#F39C12']
191 202
         };
192 203
         var pieChart = echarts.init(document.getElementById('pieChart'));
193 204
         pieChart.setOption(option);

+ 1 - 1
xxl-job-admin/src/test/java/com/xxl/job/admin/dao/XxlJobLogDaoTest.java Vedi File

@@ -50,7 +50,7 @@ public class XxlJobLogDaoTest {
50 50
         dto = xxlJobLogDao.load(log.getId());
51 51
 
52 52
 
53
-        List<Map<String, Object>> list2 = xxlJobLogDao.triggerCountByDay(DateUtils.addDays(new Date(), 30), new Date(), 200);
53
+        List<Map<String, Object>> list2 = xxlJobLogDao.triggerCountByDay(DateUtils.addDays(new Date(), 30), new Date());
54 54
 
55 55
         int ret4 = xxlJobLogDao.clearLog(1, 1, new Date(), 100);
56 56