chart.jsp
18.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
<%@ include file="/common/taglibs.jsp" %>
<%@ page language="java" pageEncoding="UTF-8" %>
<style>
</style>
<div>
<div>
<div class="clearfix">
</div>
<div class="row">
<div class="col-md-6 col-sm-6">
<!-- BEGIN PORTLET-->
<div class="portlet solid grey-cararra bordered">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-bullhorn"></i><fmt:message key="料仓利用率"/>
</div>
</div>
<div class="portlet-body">
<div id="storageUsedChart" style="height: 330px;">
</div>
</div>
</div>
<!-- END PORTLET-->
</div>
<div class="col-md-6 col-sm-6">
<!-- BEGIN PORTLET-->
<div class="portlet solid bordered grey-cararra">
<div class="portlet-title">
<div class="caption">
<a href="${ctx}/system/dataReport.html"><i class="fa fa-bar-chart-o"></i><fmt:message key="物料分布"/></a>
</div>
</div>
<div class="portlet-body">
<div id="sizeUsageChart" style="height: 330px;">
</div>
</div>
</div>
<!-- END PORTLET-->
</div>
</div>
<div class="clearfix">
</div>
<div class="row ">
<!--温度 -->
<div class="col-md-6 col-sm-6">
<div class="portlet box purple-wisteria">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-calendar"></i><fmt:message key="最近7日数据"/>
</div>
</div>
<div class="portlet-body">
<div id="inOutChart" style="height:300px">
</div>
</div>
</div>
</div>
<!--实时湿度 -->
<div class="col-md-6 col-sm-6">
<div class="portlet box red-sunglo">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-calendar"></i><fmt:message key="本周数据"/>
</div>
</div>
<div class="portlet-body">
<div id="weekChart" style="height:300px">
</div>
</div>
</div>
</div>
</div>
<fmt:message key="home.chart.storage.total" scope="page" var="storageTotal"/>
<fmt:message key="home.chart.storage.useage" scope="page" var="storageUsage"/>
<fmt:message key="home.chart.storage.empty" scope="page" var="storageEmpty"/>
<fmt:message key="dataReport.solderStock.warming" var="label_warming"/>
<fmt:message key="dataReport.solderStock.warming" var="label_warmed"/>
<fmt:message key="dataReport.solderStock.soonToExpire" var="label_soonToExpire"/>
<fmt:message key="dataReport.solderStock.invalid" var="label_invalid"/>
<c:set var="scripts" scope="request">
<script src="${ctx}/scripts/echarts.min.js"></script>
<script src="${ctx}/scripts/chart.js?id=aa"></script>
<script type="text/javascript">
setCtx('${ctx}');
//-----------料仓利用率-----------
function showStorageUsageBar(storageList){
var dom = document.getElementById("storageUsedChart");
var usedChart = echarts.init(dom);
usedChart.clear();
usedChart.showLoading();
var data = storageList;
usedChart.hideLoading();
var usedCounts = new Array();
var emptyCounts = new Array();
var names = new Array();
for(i in data){
var storage = data[i];
names.push(storage.name);
usedCounts.push(storage.totalSlots - storage.emptySlots);
emptyCounts.push(storage.emptySlots);
}
usedOption = {
color: ['#c23531','#308014'],
tooltip : {
trigger: 'axis',
axisPointer : { // 坐标轴指示器,坐标轴触发有效
type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
toolbox: {
feature: {
dataView: {show: true, readOnly: true},
saveAsImage: {show: true}
}
},
legend: {
data: ['${storageUsage}', '${storageEmpty}']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category',
data: names,
axisTick: {
alignWithLabel: true
}
},
yAxis: {
type: 'value'
},
series: [
{
name: '${storageUsage}',
type: 'bar',
stack: '${storageTotal}',
// label: {
// normal: {
// show: true,
// position: 'insideRight'
// }
// },
data: usedCounts
},
{
name: '${storageEmpty}',
type: 'bar',
stack: '${storageTotal}',
// label: {
// normal: {
// show: true,
// position: 'insideRight'
// }
// },
data: emptyCounts
},
{
name: '${storageTotal} : ${usedPosData.value}',
type: 'pie',
radius : '15%',
center: ['20%', '20%'],
tooltip : {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
data:[
{value:${usedPosData.value - usedPosData.value2}, name:'${storageUsage}',itemStyle:{normal:{color:'#c23531'}}},
{value:${usedPosData.value2}, name:'${storageEmpty}',itemStyle:{normal:{color:'#308014'}}}
]
}
]
};
usedChart.setOption(usedOption);
}
function showSizeUsageBar(storageList){
var dom = document.getElementById("sizeUsageChart");
var usedChart = echarts.init(dom);
usedChart.clear();
usedChart.showLoading();
var data = storageList;
usedChart.hideLoading();
var sizeData = {};
for(var i in data){
var usageMap = data[i].usageMap;
for(var sizeStr in usageMap){
var usageData = usageMap[sizeStr];
var sizeItem = sizeData[sizeStr];
if(sizeItem){
sizeItem.totalCount = sizeItem.totalCount + usageData.totalCount;
sizeItem.usedCount = sizeItem.usedCount + usageData.usedCount;
}else{
sizeItem = usageData;
}
sizeData[sizeStr] = sizeItem;
}
}
var usedCounts = new Array();
var emptyCounts = new Array();
var names = new Array();
for(var sizeStr in sizeData){
var sizeItem = sizeData[sizeStr];
names.push(sizeStr);
usedCounts.push(sizeItem.usedCount);
emptyCounts.push(sizeItem.totalCount - sizeItem.usedCount);
}
usedOption = {
color: ['#3398DB'],
tooltip : {
trigger: 'axis',
axisPointer : { // 坐标轴指示器,坐标轴触发有效
type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
toolbox: {
feature: {
dataView: {show: true, readOnly: true},
saveAsImage: {show: true}
}
},
legend: {
//data: ['${storageUsage}', '${storageEmpty}']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category',
data: names,
axisTick: {
alignWithLabel: true
}
},
yAxis: {
type: 'value'
},
series: [
{
name: '${storageUsage}',
type: 'bar',
stack: '${storageTotal}',
//barMaxWidth : 35,
itemStyle:{
normal: {
//color: '#c23531'
}
},
// label: {
// normal: {
// show: true,
// position: 'insideRight'
// }
// },
data: usedCounts
},
<%--{--%>
<%--name: '${storageEmpty}',--%>
<%--type: 'bar',--%>
<%--stack: '${storageTotal}',--%>
<%--itemStyle:{--%>
<%--normal: {--%>
<%--color: '#308014'--%>
<%--}--%>
<%--},--%>
<%--// label: {--%>
<%--// normal: {--%>
<%--// show: true,--%>
<%--// position: 'insideRight'--%>
<%--// }--%>
<%--// },--%>
<%--data: emptyCounts--%>
<%--},--%>
]
};
usedChart.setOption(usedOption);
}
//-------------出入库-------------
function showInOutChart(days){
var inOutDom = document.getElementById("inOutChart");
var inOutChart = echarts.init(inOutDom);
var inOutOption;
var alarmOption;
inOutChart.showLoading();
$.post('${ctx}/rest/api/inOutData?days='+days, function(data) {
var days = new Array();
var putIns = new Array();
var checkOuts = new Array();
var orders = new Array();
var lastTimes = new Array();
for(i in data){
var inOutItem = data[i];
days.push(inOutItem.label);
putIns.push(inOutItem.value);
checkOuts.push(inOutItem.value2);
orders.push(inOutItem.value5);
lastTimes.push(inOutItem.value4);
}
inOutChart.hideLoading();
inOutOption = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
crossStyle: {
color: '#999'
}
}
},
toolbox: {
feature: {
dataView: {show: true, readOnly: true},
saveAsImage: {show: true}
}
},
legend: {
data:['入库量','出库量',"工单数"]
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
data: days,
axisPointer: {
type: 'shadow'
}
}
],
yAxis: [
{
type: 'value',
name: '吞吐量',
min: 0,
//max: 250,
//interval: 50,
minInterval: 10,
axisLabel: {
formatter: '{value} '
}
}
],
series: [
{
name:'入库量',
type:'line',
itemStyle:{
normal: {
color: '#9b59b6'
}
},
data:putIns
},
{
name:'出库量',
type:'line',
itemStyle:{
normal: {
color: '#dfba49'
}
},
data:checkOuts
},
{
name:'工单数',
type:'line',
// itemStyle:{
// normal: {
// color: '#dfba49'
// }
// },
data:orders
}
]
};
inOutChart.setOption(inOutOption);
});
}
//---------本周数据------------
function showWeekDataChart(){
var dom = document.getElementById("weekChart");
var usedChart = echarts.init(dom);
usedChart.clear();
usedChart.showLoading();
$.post('${ctx}/rest/api/weekData', function(data) {
usedChart.hideLoading();
var names = ["入库盘数","出库盘数","工单数"];
var dataArray = new Array();
dataArray.push(data.value);
dataArray.push(data.value1);
dataArray.push(data.value2);
usedOption = {
color: ['#91c7ae'],
tooltip : {
trigger: 'axis',
axisPointer : { // 坐标轴指示器,坐标轴触发有效
type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
toolbox: {
feature: {
dataView: {show: true, readOnly: true},
saveAsImage: {show: true}
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category',
data: names,
axisTick: {
alignWithLabel: true
}
},
yAxis: {
type: 'value'
},
series: [
{
type: 'bar',
data: dataArray
},
]
};
usedChart.setOption(usedOption);
});
}
loadUsedData = function(){
$.post('${ctx}/service/store/storageList', function(data) {
showStorageUsageBar(data);
showSizeUsageBar(data);
});
}
loadUsedData();
showInOutChart(7);
showWeekDataChart();
//setTimeout(function(){
//loadInOutData(6);
//loadUsedData();
//loadHumidityData(7);
//},1000);
</script>
</c:set>