LocationAndTaskMonitor.js
21.5 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
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
layui.config({
base: "/js/"
}).use(['layer', 'jquery'], function () {
var layer = layui.layer,
$ = layui.jquery
//滚动速度设置
var timer = 120;
//定时器
var upScroll;
//滚动内容
var content = $("#content")[0];
var msg1 = $("#msg1")[0];
var msg2 = $("#msg2")[0];
var Roadway = "0";
var name = "";
var open = 0;
var index;
//滚动效果
function myScrollTop() {
if (content.scrollTop >= (content.scrollHeight - content.clientHeight - 10)) {
content.scrollTop = 0;
} else {
content.scrollTop++;
}
}
//鼠标悬停停止滚动
content.onmouseover = function () {
clearInterval(upScroll);
};
//鼠标离开继续滚动
content.onmouseout = function () {
upScroll = setInterval(myScrollTop, timer);
};
//更新滚动数据
var html = "";
function findTask() {
if (open == 0) {
$.ajax({
async: false,
url: "/monitor/LocationAndTaskMonitor/FindTask",
type: "post",
data: { Roadway: Roadway },
dataType: "json",
success: function (result) {
clearInterval(upScroll);
if (result.data.length > 0) {
html = "";
for (var i = 0; i < result.data.length; i++) {
html += "<li>" +
"Id:" + result.data[i].Id + " 出库单号:" + result.data[i].SourceCode + " 物料号:" + result.data[i].MaterialCode + " 站台:" + result.data[i].Station + " 数量:" + result.data[i].Qty + " 分配数量:" + result.data[i].QtyDivided
"</li>";
}
msg2.innerHTML = "";
msg1.innerHTML = html;
if (content.scrollHeight > content.clientHeight) {
msg2.innerHTML = html;
}
upScroll = setInterval(myScrollTop, timer);
} else {
html = "";
html += "<li>" +
"无出库任务" +
"</li>";
msg2.innerHTML = "";
msg1.innerHTML = html;
}
}
});
}
}
//生成仓位托盘扇形图
function findPallet() {
if (open == 0) {
if (Roadway == "5") {
var text = "小板板托盘数据";
} else {
var text = "托盘数据";
}
$.ajax({
async: false,
url: "/monitor/LocationAndTaskMonitor/FindPallet",
type: "post",
data: { Roadway: Roadway },
dataType: "json",
success: function (result) {
var servicedata = [];
var legendServicedata = [];
for (var i = 0; i < result.data.length; i++) {
var obj = new Object();
obj.name = result.data[i].name;
obj.value = result.data[i].num;
servicedata[i] = obj;
legendServicedata[i] = result.data[i].name;
}
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('pallet'));
// 指定图表的配置项和数据
var option = {
title: {
text: text,
subtext: name,
left: 'center'
},
//tooltip: {
// trigger: 'item',
// formatter: '{a} <br/>{b} : {c} ({d}%)'
//},
legend: {
orient: 'vertical',
// top: 'middle',
x: 'left',
//bottom: 10,
//left: 'center',
data: legendServicedata
},
series: [
{
type: 'pie',
radius: '65%',
center: ['50%', '50%'],
selectedMode: 'single',
data: servicedata,
// 设置值域的标签
label: {
normal: {
show: true,
position: "outer", // 设置标签位置,默认在饼状图外 可选值:'outer' ¦ 'inner(饼状图上)'
fontSize: 20,
//lineHeight: 30,
//color: '#999',
formatter: "{b}: {c} 个"
}
}
}
]
};
myChart.setOption(option);
}
});
}
}
//生成出库分配任务扇形图
function findTaskNum() {
if (open == 0) {
if (Roadway == "5") {
var text = "大板托盘数据";
} else {
var text = "分配出库任务数据";
}
$.ajax({
async: false,
url: "/monitor/LocationAndTaskMonitor/FindTaskNum",
type: "post",
data: { Roadway: Roadway },
dataType: "json",
success: function (result) {
var servicedata = [];
var legendServicedata = [];
for (var i = 0; i < result.data.length; i++) {
var obj = new Object();
obj.name = result.data[i].name;
obj.value = result.data[i].num;
servicedata[i] = obj;
legendServicedata[i] = result.data[i].name;
}
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('task'));
// 指定图表的配置项和数据
var option = {
title: {
text: text,
subtext: name,
left: 'center'
},
legend: {
orient: 'vertical',
x: 'left',
data: legendServicedata
},
series: [
{
type: 'pie',
radius: '65%',
center: ['50%', '50%'],
selectedMode: 'single',
data: servicedata,
// 设置值域的标签
label: {
normal: {
show: true,
position: "outer", // 设置标签位置,默认在饼状图外 可选值:'outer' ¦ 'inner(饼状图上)'
fontSize: 20,
formatter: "{b}: {c} 个"
}
}
}
]
};
myChart.setOption(option);
}
});
}
}
$("#contentH3").on("click", function () {
index = window.top.layer.open({
type: 2,
title: ['全屏', 'font-size:18px;'],
content: "/monitor/LocationAndTaskMonitor/Index",
area: ["100%", "100%"],
maxmin: true,
success: function (layero, index) {
open = 1;
},
end: function () {
open = 0;
}
});
});
//堆垛机移动 数据解析监控
function STKMove(stk) {
var road = Number(stk.SRM_NO) - Number(10);
if (road == 1) {
$('#srm_lab').text('原材料堆垛机:');
} else if (road == 2) {
$('#srm_lab').text('PP卷堆垛机:');
} else if (road == 3) {
$('#srm_lab').text('PP片堆垛机:');
} else if (road == 4) {
$('#srm_lab').text('铜箔堆垛机:');
} else if (road == 5) {
$('#srm_lab').text('成品堆垛机:');
}
//铜箔堆垛机wcs的Y跟wms相反
if (stk.SRM_NO == 14) {
stk.AxisY_NO = Number(27) - Number(stk.AxisY_NO);
}
if (stk.Heart == 0 && road != 1) {
$('#stk').text('离线');
$('#stk').css('color', 'dimgray');
} else {
$('#stk_XYZ').text('Y:' + stk.AxisY_NO + ' Z:' + stk.AxisZ_NO + ";");
$('#stk_XYZ').css('color', 'blue');
if (stk.Fork1_Task_Type == 0) {
$('#stk_Fork1_Task_Type').text('无任务;');
$('#stk_Fork1_Task_Type').css('color', 'green');
} else if (stk.Fork1_Task_Type == 1) {
$('#stk_Fork1_Task_Type').text('单步行走;');
$('#stk_Fork1_Task_Type').css('color', 'orange');
} else if (stk.Fork1_Task_Type == 2) {
$('#stk_Fork1_Task_Type').text('单步走取;');
$('#stk_Fork1_Task_Type').css('color', 'orange');
} else if (stk.Fork1_Task_Type == 3) {
$('#stk_Fork1_Task_Type').text('单步走放;');
$('#stk_Fork1_Task_Type').css('color', 'orange');
} else if (stk.Fork1_Task_Type == 4) {
$('#stk_Fork1_Task_Type').text('走取走放;');
$('#stk_Fork1_Task_Type').css('color', 'orange');
}
if (stk.SRM_Mode == 5) {
$('#stk_SRM_Mode').text('联机;');
$('#stk_SRM_Mode').css('color', 'green');
} else if (stk.SRM_Mode == 1) {
$('#stk_SRM_Mode').text('维修;');
$('#stk_SRM_Mode').css('color', 'red');
} else if (stk.SRM_Mode == 2) {
$('#stk_SRM_Mode').text('手动;');
$('#stk_SRM_Mode').css('color', 'red');
} else if (stk.SRM_Mode == 3) {
$('#stk_SRM_Mode').text('机载操作;');
$('#stk_SRM_Mode').css('color', 'red');
} else if (stk.SRM_Mode == 4) {
$('#stk_SRM_Mode').text('单机自动;');
$('#stk_SRM_Mode').css('color', 'red');
}
if (stk.SRM_Err == 0 && stk.Fork1_Err == 0) {
$('#stk_SRM_Err').text('无异常;');
$('#stk_SRM_Err').css('color', 'green');
if (road == 2) {
PPSTKMsg = "";
} else if (road == 3) {
PJSTKMsg = "";
}
else if (road == 4) {
TBSTKMsg = "";
}
} else {
$('#stk_SRM_Err').text('异常:' + stk.Error1 + ';');
$('#stk_SRM_Err').css('color', 'red');
if (road == 2) {
PPSTKMsg = "PP卷堆垛机报错";
} else if (road == 3) {
PJSTKMsg = "PP片堆垛机报错";
}
else if (road == 4) {
TBSTKMsg = "铜箔堆垛机报错";
}
}
if (stk.Fork1_Goods == 0) {
$('#stk_Fork1_Goods').text('无货;' + ' 任务取:X(' + stk.Fork1_Pick_AxisX_NO + ')Y(' + stk.Fork1_Pick_AxisY_NO + ')Z(' + stk.Fork1_Pick_AxisZ_NO + ')' + ' 任务放:X(' + stk.Fork1_Release_AxisX_NO + ')Y(' + stk.Fork1_Release_AxisY_NO + ')Z(' + stk.Fork1_Release_AxisZ_NO + ')');
$('#stk_Fork1_Goods').css('color', 'green');
} else {
$('#stk_Fork1_Goods').text('有货:' + stk.Fork1_Code + ';' + ' 任务取:X(' + stk.Fork1_Pick_AxisX_NO + ')Y(' + stk.Fork1_Pick_AxisY_NO + ')Z(' + stk.Fork1_Pick_AxisZ_NO + ')' + ' 任务放:X(' + stk.Fork1_Release_AxisX_NO + ')Y(' + stk.Fork1_Release_AxisY_NO + ')Z(' + stk.Fork1_Release_AxisZ_NO + ')');
$('#stk_Fork1_Goods').css('color', 'orange');
}
if (stk.Status_Port1 == 1) {
$('#stk_Status_Port1').text(' 站台: 201无货 ');
$('#stk_Status_Port1').css('color', 'green');
} else {
$('#stk_Status_Port1').text(' 站台: 201有货 ');
$('#stk_Status_Port1').css('color', 'orange');
}
if (stk.Status_Port2 == 1) {
$('#stk_Status_Port2').text(' 202无货 ');
$('#stk_Status_Port2').css('color', 'green');
} else {
$('#stk_Status_Port2').text(' 202有货 ');
$('#stk_Status_Port2').css('color', 'orange');
}
if (stk.Status_Port3 == 1) {
$('#stk_Status_Port3').text(' 203无货 ');
$('#stk_Status_Port3').css('color', 'green');
} else {
$('#stk_Status_Port3').text(' 203有货 ');
$('#stk_Status_Port3').css('color', 'orange');
}
if (road == 2 && road == 3) {
if (stk.Status_Port4 == 1) {
$('#stk_Status_Port4').text(' 204无货 ');
$('#stk_Status_Port4').css('color', 'green');
} else {
$('#stk_Status_Port4').text(' 204有货 ');
$('#stk_Status_Port4').css('color', 'orange');
}
}
if (road == 3) {
if (stk.Status_Port5 == 1) {
$('#stk_Status_Port5').text(' 205无货 ');
$('#stk_Status_Port5').css('color', 'green');
} else {
$('#stk_Status_Port5').text(' 205有货 ');
$('#stk_Status_Port5').css('color', 'orange');
}
if (stk.Status_Port6 == 1) {
$('#stk_Status_Port6').text(' 206无货 ');
$('#stk_Status_Port6').css('color', 'green');
} else {
$('#stk_Status_Port6').text(' 206有货 ');
$('#stk_Status_Port6').css('color', 'orange');
}
}
}
}
//Rgv状态监控
function RGVStatus(rgv) {
var road = rgv.RGV_NO;
if (road == 1) {
road = Number(road) + Number(10);
}
if (road == 11) {
$('#rgv_lab').text('原材料RGV:');
} else if (road == 12) {
$('#rgv_lab').text('PP卷RGV:');
} else if (road == 13) {
$('#rgv_lab').text('PP片RGV:');
} else if (road == 14) {
$('#rgv_lab').text('铜箔RGV:');
} else if (road == 15) {
$('#rgv_lab').text('成品RGV:');
}
if (rgv.Heart == 0) {
$('#rgv').text('离线');
$('#rgv').css('color', 'dimgray');
} else {
if (rgv.Fork1_Task_Type == 0) {
$('#rgv_Fork1_Task_Type').text('无任务;');
$('#rgv_Fork1_Task_Type').css('color', 'green');
} else if (rgv.Fork1_Task_Type == 1) {
$('#rgv_Fork1_Task_Type').text('单步行走;');
$('#rgv_Fork1_Task_Type').css('color', 'orange');
} else if (rgv.Fork1_Task_Type == 2) {
$('#rgv_Fork1_Task_Type').text('单步走取;');
$('#rgv_Fork1_Task_Type').css('color', 'orange');
} else if (rgv.Fork1_Task_Type == 3) {
$('#rgv_Fork1_Task_Type').text('单步走放;');
$('#rgv_Fork1_Task_Type').css('color', 'orange');
} else if (rgv.Fork1_Task_Type == 4) {
$('#rgv_Fork1_Task_Type').text('走取走放;');
$('#rgv_Fork1_Task_Type').css('color', 'orange');
}
if (rgv.RGV_Mode == 5) {
$('#rgv_RGV_Mode').text('联机;');
$('#rgv_RGV_Mode').css('color', 'green');
} else if (rgv.RGV_Mode == 1) {
$('#rgv_RGV_Mode').text('维修;');
$('#rgv_RGV_Mode').css('color', 'red');
} else if (rgv.RGV_Mode == 2) {
$('#rgv_RGV_Mode').text('手动;');
$('#rgv_RGV_Mode').css('color', 'red');
} else if (rgv.RGV_Mode == 3) {
$('#rgv_RGV_Mode').text('机载操作;');
$('#rgv_RGV_Mode').css('color', 'red');
} else if (rgv.RGV_Mode == 4) {
$('#rgv_RGV_Mode').text('单机自动;');
$('#rgv_RGV_Mode').css('color', 'red');
}
if (rgv.RGV_Err == 0 && rgv.Fork1_Err == 0) {
$('#rgv_RGV_Err').text('无异常;');
$('#rgv_RGV_Err').css('color', 'green');
if (road == 13) {
PPRGVMsg = "";
}
else if (road == 14) {
TBRGVMsg = "";
}
} else {
$('#rgv_RGV_Err').text('异常:' + rgv.Error1 + ';');
$('#rgv_RGV_Err').css('color', 'red');
if (road == 13) {
PPRGVMsg = "PP片RGV报错";
}
else if (road == 14) {
TBRGVMsg = "铜箔RGV报错";
}
}
if (rgv.Fork1_Goods == 0) {
$('#rgv_Fork1_Goods').text('无货;' + rgv.Fork1_Code + ';' + ' 任务取:X(' + rgv.Fork1_Pick_AxisX_NO + ')Y(' + rgv.Fork1_Pick_AxisY_NO + ')Z(' + rgv.Fork1_Pick_AxisZ_NO + ')' + ' 任务放:X(' + rgv.Fork1_Release_AxisX_NO + ')Y(' + rgv.Fork1_Release_AxisY_NO + ')Z(' + rgv.Fork1_Release_AxisZ_NO + ')');
$('#rgv_Fork1_Goods').css('color', 'green');
} else {
$('#rgv_Fork1_Goods').text('有货:' + rgv.Fork1_Code + ';' + ' 任务取:X(' + rgv.Fork1_Pick_AxisX_NO + ')Y(' + rgv.Fork1_Pick_AxisY_NO + ')Z(' + rgv.Fork1_Pick_AxisZ_NO + ')' + ' 任务放:X(' + rgv.Fork1_Release_AxisX_NO + ')Y(' + rgv.Fork1_Release_AxisY_NO + ')Z(' + rgv.Fork1_Release_AxisZ_NO + ')');
$('#rgv_Fork1_Goods').css('color', 'orange');
}
}
}
function PushLoad() {
var connection = new signalR.HubConnectionBuilder()
.withUrl("/ChartHub"
)
.build();
connection.on("sendStkData", function (json) {
json.forEach(function (j) {
if (j.SRM_NO == (Number(Roadway) + Number(10))) {
STKMove(j)
}
});
});
connection.start().then(function () {
}).catch(function (err) {
return console.error(err.toString());
});
var agvconnection = new signalR.HubConnectionBuilder()
.withUrl("/ChartHub"
)
.build();
agvconnection.on("sendAgvData", function (json) {
json.forEach(function (j) {
if (j.RGV_NO == Roadway) {
RGVStatus(j);
}
else if (j.RGV_NO == (Number(Roadway) + Number(10))) {
RGVStatus(j);
}
});
});
agvconnection.start().then(function () {
}).catch(function (err) {
return console.error(err.toString());
});
}
$(function () {
var index = parent.layer.getFrameIndex(window.name);
if (index != undefined) {
$("#contentH3").unbind("click").bind("click", function () {
parent.layer.close(index);
});
}
layer.open({
title: ['选择', 'font-size:18px;'],
content: '请选择仓库'
, offset: 'auto'
, area: ['450px', '150px']
, btn: ['原材料', 'PP卷', 'PP片', '铜箔', '成品']
, yes: function (index, layero) {
Roadway = "1";
name = "原材料";
layer.close(index);
}
, btn2: function (index, layero) {
Roadway = "2";
name = "pp卷";
}
, btn3: function (index, layero) {
Roadway = "3";
name = "pp片";
}
, btn4: function (index, layero) {
Roadway = "4";
name = "铜箔";
}
, btn5: function (index, layero) {
Roadway = "5";
name = "成品库";
}
, cancel: function () {
Roadway = "1";
name = "原材料";
}
, end: function () {
upScroll = setInterval(myScrollTop, timer);
setInterval(findTask, 5000);
setInterval(findPallet, 3000);
setInterval(findTaskNum, 3000);
PushLoad();
}
});
})
});