EquipmentVisual.js
26.7 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
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
let action = null;
layui.config({
base: "/js/",
version: 1
}).use(['system'], function () {
var form = layui.form,
$ = layui.jquery,
element = layui.element,
table = layui.table,
system = layui.system,
sysU = new system.u(),
sendDataWhere = null,
paramData = {
eqCode: null,
eqType: null,
otherCoce: null,
eqImg: null,
eqName: "",
projectName:""
},
areaName = "equipment",
controllerName = "BaseEquipment",
app = null;
action = {
//页签tabs点击事件
tabVisualTabMethod: function (data) {
if (data.index == 2 || data.index == 3) {
app.methods.initEqFileAndAlarmDataList();
}
else if (data.index == 4) {
app.methods.initEqMaintainDataList();
}
},
//表格行点击事件
customTableCelClick: function (obj, tableId) {
if (tableId == app.data.tableColsEqPartElem) {
app.methods.initEqPartMaintainDataList(obj.data.partCode);
}
},
}
app = {
data: {
colsFailure: [[
{ field: "zizeng", width: 80, title: "序号", fixed: "left", type: "numbers" },
{ field: "equipmentName", width: 220, title: "设备" },
{ field: "alarmMessage", width: 300, title: "报警信息" },
{ field: "createTime", width: 150, title: "开始时间" },
{ field: "updateTime", width: 150, title: "结束时间" },
{
field: "errorduration", width: 200, title: "故障时间(分)", templet: function (d) {
var minutes = Math.floor(d.errorduration / 60); // 获取整数分钟
var remainingSeconds = Math.floor(d.errorduration % 60); // 获取剩余的秒数
return minutes + "分钟" + remainingSeconds + "秒";
}
},
]],
tableIns: null,
colsFile: [[
{ field: "id", width: 100, title: "编码", hide: true },
{ field: "zizeng", width: 80, title: "序号", fixed: "left", type: "numbers" },
{ field: 'fileName', width: 300, title: '文档名称' },
{
field: 'url', width: 300, title: '文件下载', templet: function (d) {
var target = "_blank";
if (d.suffix.indexOf("pdf") > -1 || d.suffix.indexOf("docx") > -1 || d.suffix.indexOf("doc") > -1 || d.suffix.indexOf("xlsx") > -1) {
target = "_self";
}
return `<a href="../../Document/${d.url}" target='${target}' style="color:cornflowerblue;text-decoration: underline;cursor:pointer;">${d.fileName}</a>`;
}
},
{ field: 'size', width: 100, title: '文档大小' },
{ field: 'targetId', title: '设备Code', hide: true },
{ field: 'targetTableName', width: 120, title: '适用的设备', hide: true },
{ field: 'suffix', width: 100, title: '文档类型' },
{ field: 'remark', width: 120, title: '备注' },
{ field: 'createTime', width: 150, title: '创建时间' },
{ field: 'createBy', width: 100, title: '创建人' }
]],
colsProper: [[
{ field: "index", width: 70, title: "序号", fixed: "left" },
{ field: "EquipmentName", width: 180, title: "设备名称" }
//{
// field: "Proper",
// width: 150,
// title: "妥善率",
// templet: function (d) {
// var color = "black",
// properValue = parseFloat(d.Proper); // 将字符串转换为数值
// if (properValue < 99) { // 比较数值
// color = "red";
// }
// return `<span style="color: ${color};">${d.Proper}</span>`; // 返回原始字符串
// }
//},
//{
// field: "remark", width: 200, title: "故障时间-总时间(分)",
// templet: function (d) {
// return `${d.ErrorDuration}--${d.SumDuration}`; // 返回原始字符串
// }
//}
]],
tableColsFileObj: null,
tableColsFileElem: "mainFile",
colsAlarm: [[
{ field: "Id", width: 80, hide: true, title: "Id" },
{ field: "zizeng", width: 80, title: "序号", fixed: "left", type: "numbers" },
{ field: "EquipmentCode", width: 200, title: "设备编号", hide: true, },
{ field: "EquipmentName", width: 200, title: "设备名称" },
{
field: "AlarmMessage", width: 420, title: "报警信息", templet: function (d) {
return d.AlarmMessage + " " + d.Remark;
}
},
{
field: "ErrorDuration", width: 140, title: "报警持续时间", templet: function (d) {
return app.methods.convertSecondsToTime(d.ErrorDuration)
}
},
{ field: "CreateTime", width: 150, title: "创建时间" },
]],
colsEqPart: [[
{ field: "partCode", width: 200, hide: true, title: "部件编码" },
{ field: "partName", width: 200, title: "设备部件" },
{ field: "indicator", width: 200, title: "保养周期", type: "numbers" },
{ field: "indicatorType", width: 280, title: "保养类型", hide: true },
{ field: "dictLabel", width: 150, title: "保养类型名称" },
{ field: "price", width: 200, title: "保养费用" },
/* { field: "price", width: 100, title: "距离下次保养(天)" },*/
]],
colsEqMaintainRecord: [[
{ field: "EquipmentCode", width: 80, hide: true, title: "设备编码" },
{ field: "EquipmentTypeCode", width: 150, title: "设备类型编码", hide: true },
{ field: "PartCode", width: 80, hide: true, title: "部件编码" },
{ field: "PartName", width: 150, title: "设备部件" },
{ field: "LastMaintainTime", width: 150, title: "上次保养时间" },
{ field: "NextMaintainTime", width: 150, title: "下次保养时间" },
{ field: "MaintainTime", width: 150, title: "本次保养时间" },
{ field: "Maintainer", width: 150, title: "操作人" },
{ field: "MaintainContent", width: 150, title: "保养结果" },
{ field: "MaintainPrice", width: 150, title: "维保费用" },
{ field: "PushStatus", width: 150, title: "推送状态" },
{ field: "Attachment", width: 150, title: "附件" },
{ field: "Remark", width: 150, title: "备注" },
]],
tableColsAlarmObj: null,
tableColsAlarmElem: "mainAlarm",
tableColsEqPartElem: "equipmentPartDt",
tableColsEqMaintainedElem: "maintainedDt",
tableColsEqUnMaintainElem: "unMaintainDt",
echartOpt: {
eqDeviceStatusEle: document.getElementById("deviceStatus"),
eqOeeParametersEle: document.getElementById("eqOeeParameter"),
eqMttrMtbfEle: document.getElementById("eqMttrMtbf"),
xAxisData: "".GetTimeRange("", "", 6)
},
//下拉框配置
selectOption: {
//返回的数据 用于后续操作
selectData: {
}
},
},
methods: {
//文件列表页签
initFileTable: function (data) {
let options = {
elem: "#" + app.data.tableColsFileElem,
cols: app.data.colsFile,
data: data,
page: false,
limit: Number.MAX_VALUE,
height: "full-90",//如果是主明细页签,列表主体高度要设置,否则分页导航不直观展示
doneExtend: function (res, obj) {
}
}
app.data.tableColsFileObj = sysU.initTable(options);
},
//报警列表页签
initAlarmTable: function (data) {
let options = {
elem: "#" + app.data.tableColsAlarmElem,
cols: app.data.colsAlarm,
data: data,
page: false,
limit: Number.MAX_VALUE,
height: "full-90",//如果是主明细页签,列表主体高度要设置,否则分页导航不直观展示
doneExtend: function (res, obj) {
}
}
app.data.tableColsAlarmObj = sysU.initTable(options);
},
//设备保养页签-设备概述、设备部件
initEqPartTable: function (val) {
var data = val.main;
//设备概述代码
$('#projectInfo').text("所属项目:" + paramData.projectName);
var bg = "layui-badge-dot layui-bg-green",
statusText = "在线";
if (data[0].status == "Failure" || data[0].status == "Error") {
statusText = "故障";
bg = "layui-badge-dot layui-bg-red";
}
if (data[0].seconds > 300 || data[0].seconds == -1) {
statusText = "离线";
bg = "layui-badge-dot layui-bg-gray";
}
statusText = `ip:<span style=" display: inline-block;" >${data[0].ip}</span><span class="${bg}" style=" left: 7px;"></span> <span style="padding-left: 8px;">${statusText}</span`;
$('#eqStatusIP').html(statusText);
$('#maintainNumber').text(!data[0].MaintainNumber ? "0" : data[0].MaintainNumber);
$('#toBeMaintainNumber').text(!data[0].ToBeMaintainedNumber ? "0" : data[0].ToBeMaintainedNumber);
$('#lastMaintainTime').text(!data[0].lastMaintainTime ? "无" : data[0].lastMaintainTime);
$('#sumAmount').text(!data[0].sumAmount ? "0" : data[0].sumAmount);
//设备部件表格
let options = {
elem: "#" + app.data.tableColsEqPartElem,
cols: app.data.colsEqPart,
data: val.eqmaintainHeadList,
page: true,
height: "full-450",//如果是主明细页签,列表主体高度要设置,否则分页导航不直观展示
doneExtend: function (res, obj) {
//设备保养、未保养
app.methods.initEqPartMaintainDataList();
}
}
app.data.tableColsAlarmObj = sysU.initTable(options);
},
//设备保养页签-已保养
initEqMaintainedTable: function (data) {
//设备部件表格
let options = {
elem: "#" + app.data.tableColsEqMaintainedElem,
cols: app.data.colsEqMaintainRecord,
data: data,
page: true,
height: "full-440",//如果是主明细页签,列表主体高度要设置,否则分页导航不直观展示
doneExtend: function (res, obj) {
}
}
app.data.tableColsAlarmObj = sysU.initTable(options);
},
//设备保养页签-未保养
initEqUnMaintainTable: function (data) {
//设备部件表格
let options = {
elem: "#" + app.data.tableColsEqUnMaintainElem,
cols: app.data.colsEqMaintainRecord,
data: data,
page: true,
height: "full-440",//如果是主明细页签,列表主体高度要设置,否则分页导航不直观展示
doneExtend: function (res, obj) {
}
}
app.data.tableColsAlarmObj = sysU.initTable(options);
},
//健康表现页签
initHealthTable(data) {
let myChart = echarts.init(app.data.echartOpt.eqDeviceStatusEle)
window.eqHealthStatus.series[0].data = [];
window.eqHealthStatus.series[0].data.push({ value: data.equipmentHealth.EquipmentStatus.RunProportion, name: '运行' })
window.eqHealthStatus.series[0].data.push({ value: data.equipmentHealth.EquipmentStatus.FreeProportion, name: '空闲' })
window.eqHealthStatus.series[0].data.push({ value: data.equipmentHealth.EquipmentStatus.AlarmProportion, name: '故障' })
window.eqHealthStatus.series[0].data.push({ value: data.equipmentHealth.EquipmentStatus.OfflineProportion, name: '离线' })
myChart.clear()
myChart.setOption(window.eqHealthStatus)
//设备信息、开机时间
var eqInfo = data.eqInfo[0];
var statusText = "在线",
bg = "layui-badge-dot layui-bg-green";
if (eqInfo.status == "Failure" || eqInfo.status == "Error") {
statusText = "故障";
bg = "layui-badge-dot layui-bg-red";
}
if (eqInfo.econds > 300 || eqInfo.seconds == -1) {
statusText = "离线";
bg = "layui-badge-dot layui-bg-gray";
bg = "layui-badge-dot layui-bg-gray";
}
$("#eqInfo").html(`<span style='width: 50px;display: inline-block;'>编码:</span>${eqInfo.EquipmentCode} <br/>
<span style='width: 50px;display: inline-block;'>项目:</span>${paramData.projectName}<br/>
<span style='width: 50px;display: inline-block;'>IP:</span><span>${eqInfo.ip}</span><span class="${bg}" style=" left: 7px;"></span> <span style="padding-left: 8px;">${statusText}</span><br/>
<span style='width: 50px;display: inline-block;'>SIM:</span>${!eqInfo.simNumber ? "" : eqInfo.simNumber}`)
$("#TodayPowerTime").text(app.methods.convertSecondsToTime(data.equipmentHealth.EquipmentStatus.TodayPowerTime) )
$("#CurrentMonthPowerTime").text(app.methods.convertSecondsToTime(data.equipmentHealth.EquipmentStatus.CurrentMonthPowerTime) )
//占比和时间明细
$("#RunProportion").text(data.equipmentHealth.EquipmentStatus.RunProportion + "%")
$("#RunProportionVal").text("当天" + app.methods.convertSecondsToTime(data.equipmentHealth.EquipmentStatus.RunTime))
$("#FreeProportion").text(data.equipmentHealth.EquipmentStatus.FreeProportion + "%")
$("#FreeProportionVal").text("当天" + app.methods.convertSecondsToTime(data.equipmentHealth.EquipmentStatus.FreeTime))
$("#AlarmProportion").text(data.equipmentHealth.EquipmentStatus.AlarmProportion + "%")
$("#AlarmProportionVal").text("当天" + app.methods.convertSecondsToTime(data.equipmentHealth.EquipmentStatus.AlarmTime) )
$("#OfflineProportion").text(data.equipmentHealth.EquipmentStatus.OfflineProportion + "%")
$("#OfflineProportionVal").text("当天" + app.methods.convertSecondsToTime(data.equipmentHealth.EquipmentStatus.OfflineTime) )
},
//文件、报警、健康表现 请求数据接口
initEqFileAndAlarmDataList() {
var ajaxConfig = {
data: { equipmentCode: paramData.otherCode, equipmentTypeCode: paramData.eqType },
url: `/${areaName}/${controllerName}/GetEquipmentFileList`,
success: function (result) {
if (sysU.successBefore(result)) return false;
app.methods.initFileTable(result.Result.fileList);
app.methods.initAlarmTable(result.Result.alarmList);
app.methods.initHealthTable(result.Result);
}
};
sysU.ajax(ajaxConfig);
},
//健康表现页签 OEE
initOEEechart(data) {
var xAxisData = app.data.echartOpt.xAxisData;
window.eqOeeParameters.xAxis[0].data = xAxisData;
var seriesData = []
for (let i = 0; i < xAxisData.length; i++) {
const result = data.GetArrValueRows({ key: 'Date', val: xAxisData[i] });
let dataOee = 0;
if (result.length == 1) {
dataOee = result[0].Oee.replace("%", "")
}
seriesData.push(dataOee);
}
window.eqOeeParameters.series[0].data = seriesData;
let myChart = echarts.init(app.data.echartOpt.eqOeeParametersEle)
myChart.clear()
myChart.setOption(window.eqOeeParameters)
},
//健康表现页签 MTTR、MTBF
initMttrMtbfEchart(data) {
var xAxisData=app.data.echartOpt.xAxisData;
window.eqMttrMtbf.xAxis[0].data = xAxisData;
window.eqMttrMtbf.series = [];
var seriesItemMttr = {
name: "MTTR",
type: 'line',
data: []
};
var seriesItemMtbf = {
name: "MTBF",
type: 'line',
data: []
};
for (let i = 0; i < xAxisData.length; i++) {
const result = data.GetArrValueRows({ key: 'Date', val: xAxisData[i] });
let dataMttr = 0;
let dataMtbf = 0;
if (result.length == 1) {
dataMttr = result[0].Mttr
dataMtbf = result[0].Mtbf
}
seriesItemMttr.data.push(dataMttr);
seriesItemMtbf.data.push(dataMtbf);
}
window.eqMttrMtbf.series.push(seriesItemMttr)
window.eqMttrMtbf.series.push(seriesItemMtbf)
//新增默认 目标值
window.eqMttrMtbf.series.push({
name: "目标值",
symbolSize: 10, //小圆点的大小
color: 'red',
type: 'line',
data: ["2.5", "2.5", "2.5", "2.5", "2.5", "2.5", "2.5"],
lineStyle: {
normal: {
width: 3,
type: 'dashed',
},
},
itemStyle: {
normal: {
lineStyle: {
width: 4, //线条宽度
},
},
},
});
let myChart = echarts.init(app.data.echartOpt.eqMttrMtbfEle)
myChart.clear()
myChart.setOption(window.eqMttrMtbf)
},
//健康表现里的OEE、MTTR、MTBF、妥善率7天总数
initstatisticsParams(data) {
$("#totalOee").text(data.Oee)
$("#totalMttr").text(data.Mttr)
$("#totalMtbf").text(data.Mtbf)
var $totalProper = $("#totalProper");
$totalProper.text(data.Proper);
// 将字符串转换为数字进行比较
if (parseInt(data.Proper) < 99) {
$totalProper.css("color", "red");
} else {
$totalProper.css("color", "black");
}
},
//妥善率
initAvailability: function (data) {
debugger
var datas = app.methods.oeeAndMttrAndMTBFDataHandle(data, app.data.echartOpt.xAxisData, "Proper");
let options = {
elem: "#eqavailability",
cols: app.data.colsProper,
data: datas,
height: 'full-400', // 最大高度减去其他容器已占有的高度差
page: false
}
sysU.initTable(options);
},
//健康表现里的OEE、MTTR、MTBF、妥善率 请求数据接口
initEqFileParameterDataList() {
var endDay = new Date();
var startDay = new Date(endDay.getTime() - (6 * 24 * 60 * 60 * 1000)); // 6天前
var ajaxConfig = {
data: {
projectName: paramData.projectName,
argument: paramData.eqCode,
tag: 1,
startDay: startDay.format("yyyy-MM-dd"),
endDay: endDay.format("yyyy-MM-dd"),
},
url: `/api/BusEquipmentData/GetEquipmentsExtendIndexData`,
type: "get",
success: function (result) {
if (sysU.successBefore(result)) return false;
app.methods.initMttrMtbfEchart(result.Result.detailDt);
app.methods.initOEEechart(result.Result.detailDt);
app.methods.initstatisticsParams(result.Result.sumDt);
app.methods.initAvailability(result.Result.detailDt);
}
};
sysU.ajax(ajaxConfig);
},
//读取设备概述、设备部件保养数据 请求数据接口
initEqMaintainDataList() {
var ajaxConfig = {
data: { equipmentCode: paramData.eqCode, equipmentTypeCode: paramData.eqType },
url: `/${areaName}/${controllerName}/GetEquipmentMaintainList`,
success: function (result) {
if (sysU.successBefore(result)) return false;
app.methods.initEqPartTable(result.Result);
}
};
sysU.ajax(ajaxConfig);
},
//设备部件保养、未保养数据 请求数据接口
initEqPartMaintainDataList(obj) {
var ajaxConfig = {
data: { eqCode: paramData.eqCode, partCode: obj },
url: `/${areaName}/${controllerName}/GetEquipmentMaintainRecordList`,
success: function (result) {
if (sysU.successBefore(result)) return false;
//加载设备部件保养、未保养 表格
app.methods.initEqMaintainedTable(result.Result.maintainList);
app.methods.initEqUnMaintainTable(result.Result.tobemaintainList);
}
};
sysU.ajax(ajaxConfig);
},
//秒转换小时、分钟
convertSecondsToTime: function (seconds) {
seconds = parseInt(seconds);
if (typeof seconds !== 'number') return seconds;
var hours = Math.floor(seconds / 3600);
var minutes = Math.floor((seconds % 3600) / 60);
var remainingSeconds = Math.floor( seconds % 60);
var result = '';
if (hours > 0) {
result += hours + '小时';
}
if (minutes > 0) {
result += minutes + '分';
}
result += remainingSeconds + '秒';
return result;
},
//dataSources 数据源,dateList:日期列表,comparisonKeys 返回的列表的key
oeeAndMttrAndMTBFDataHandle: function (dataSources, dateList, comparisonKeys) {
var resultData = []
const uniqueEqName = dataSources.uniqueFunc('EquipmentName');
let index = 0
var nowVal = "";
for (let i = 0; i < uniqueEqName.length; i++) {
nowVal = "";
index = 0
var defaultCol = { index: i + 1, EquipmentName: uniqueEqName[i].EquipmentName }
dateList.forEach((item) => {
for (let xp = 0; xp < dataSources.length; xp++) {
if (uniqueEqName[i].EquipmentName == dataSources[xp].EquipmentName && dataSources[xp].Date == item) {
nowVal = dataSources[xp][comparisonKeys];
break
}
}
defaultCol['date' + index++] = nowVal;
})
resultData.push(defaultCol)
}
return resultData;
},
//初始化表单
initFrom() {
paramData.eqCode = "".GetUrlParam("eqCode");
paramData.eqType = "".GetUrlParam("eqType");
paramData.eqName = "".GetUrlParam("eqName");
paramData.eqImg = "".GetUrlParam("eqImg");
paramData.otherCode = "".GetUrlParam("otherCode");
paramData.projectName = "".GetUrlParam("projectName");
$("#bread-visual").text(`设备可视化【${paramData.eqName}】`)
$("#eqCode").text(`${paramData.eqCode}`) //保养数据-设备名
if (paramData.eqImg != "null") {
$(".eqImg").attr('src', `/images/equipment/${paramData.eqImg}`)
}
for (var i = 0; i < app.data.echartOpt.xAxisData.length; i++) {
app.data.colsProper[0].push({ field: "date" + i, width: 100, title: app.data.echartOpt.xAxisData[i] });
}
}
},
registerEvent: function () {
},
init: function () {
app.methods.initFrom();
app.registerEvent();
app.methods.initEqFileAndAlarmDataList();
app.methods.initEqFileParameterDataList()
}
};
app.init();
});