赖素文
authored
|
1
2
3
4
|
let action = null;
layui.config({
base: "/js/",
version: 1
|
HuXiYu
authored
|
5
|
}).use(['system',"vue"], function () {
|
赖素文
authored
|
6
7
8
9
10
11
12
13
14
15
16
|
var form = layui.form,
$ = layui.jquery,
element = layui.element,
table = layui.table,
system = layui.system,
sysU = new system.u(),
sendDataWhere = null,
sendDataDescWhere = null,
areaName = "configure",
controllerName = "BaseProject",
projectKeys = null,
|
HuXiYu
authored
|
17
|
projectName = "",
|
赖素文
authored
|
18
|
intervalTime = null,
|
HuXiYu
authored
|
19
|
vueApp=null,
|
赖素文
authored
|
20
21
22
23
24
25
26
27
|
app = null;
action = {
}
app = {
data: {
|
赖素文
authored
|
28
29
30
31
32
33
|
cols: [[
{ field: "zizeng", width: 80, title: "序号", fixed: "left", type: "numbers" },
{
field: "equipmentName", width: 220, title: "设备"
},
{
|
赖素文
authored
|
34
|
field: "Status", width: 150, title: "ip地址(5min无数据)", templet: function (d) {
|
HuXiYu
authored
|
35
|
//if (d.Status == "" || d.Status == null) return "";
|
赖素文
authored
|
36
37
|
var bg = "layui-badge-dot layui-bg-green",
statusText = "在线";
|
HuXiYu
authored
|
38
|
if (d.Status == "Failure" || d.Status=="Error") {
|
赖素文
authored
|
39
40
41
|
statusText = "故障";
bg = "layui-badge-dot layui-bg-red";
}
|
HuXiYu
authored
|
42
|
if (d.seconds > 300 || d.seconds==-1) {
|
赖素文
authored
|
43
44
45
46
47
48
49
|
statusText = "离线";
bg = "layui-badge-dot layui-bg-gray";
}
return `<span class="${bg}" style=" left: 7px;"></span> <span style="padding-left: 8px;">${statusText}</span`;
}
}
]],
|
赖素文
authored
|
50
51
52
53
54
55
|
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: "开始时间" },
|
赖素文
authored
|
56
57
58
59
60
61
62
63
64
|
{ field: "updateTime", width: 150, title: "结束时间" },
{
field: "errorduration", width: 200, title: "故障时间(分)", templet: function (d) {
var minutes = Math.floor(d.errorduration / 60); // 获取整数分钟
var remainingSeconds = d.errorduration % 60; // 获取剩余的秒数
return minutes + "分钟" + remainingSeconds + "秒";
}
},
|
赖素文
authored
|
65
|
]],
|
赖素文
authored
|
66
67
|
tableIns: null,
tableElem: "mainList",
|
王硕
authored
|
68
|
refreshDataTimeEle: document.getElementById('refreshDataTime'),
|
赖素文
authored
|
69
70
71
72
73
|
echartOpt: {
eqTuoShanRateEle: document.getElementById("eqTuoShanRate"),
eqAlarmsNumberEle: document.getElementById("eqAlarmsNumber"),
tuoShanRatelegendData: "".GetTimeRange("","",7)
}
|
赖素文
authored
|
74
75
|
},
methods: {
|
赖素文
authored
|
76
77
|
initTable: function (opt) {
var config = { projectKeys: projectKeys }
|
王硕
authored
|
78
|
|
赖素文
authored
|
79
80
81
|
if (opt != undefined) $.extend(config, opt);
let options = {
elem: "#" + app.data.tableElem,
|
HuXiYu
authored
|
82
|
url: `/configure/BaseProject/GetEqInfoByProjectKeys`,
|
赖素文
authored
|
83
84
85
86
87
88
89
90
|
cols: app.data.cols,
height: 'full-400', // 最大高度减去其他容器已占有的高度差
where: config,
page: false
}
app.data.tableIns = sysU.initTable(options);
},
|
王硕
authored
|
91
92
|
//每台设备妥善率
initEchartsTuoShanRate: function (failureTime) {
|
王硕
authored
|
93
94
|
let legendDataTemp = failureTime.uniqueFunc("equipmentName")
let legendData = []
|
赖素文
authored
|
95
|
|
王硕
authored
|
96
97
|
window.eqTuoShanRateOpt.xAxis[0].data = app.data.echartOpt.tuoShanRatelegendData
window.eqTuoShanRateOpt.series = [];
|
王硕
authored
|
98
99
100
|
for (let i = 0; i < legendDataTemp.length; i++) {
legendData.push(legendDataTemp[i].equipmentName)
|
王硕
authored
|
101
|
var seriesItem = {
|
王硕
authored
|
102
|
name: legendDataTemp[i].equipmentName,
|
王硕
authored
|
103
104
105
106
107
|
type: 'line',
data: []
};
for (let j = 0; j < app.data.echartOpt.tuoShanRatelegendData.length; j++) {
const timeVal = app.data.echartOpt.tuoShanRatelegendData[j];
|
赖素文
authored
|
108
109
110
|
const result = failureTime.GetArrValueRows({ key: 'Date', val: timeVal }, {
key: 'equipmentName', val: seriesItem.name
});
|
赖素文
authored
|
111
|
|
王硕
authored
|
112
|
let data = 0;
|
赖素文
authored
|
113
114
115
116
|
if (result.length == 1) {
data = (1 - (result[0].sumTime / 86400)) * 100
} else {
//console.log(`ProjectOverview 文件 GetArrValueRows 读取到:${result.length}条数据`)
|
王硕
authored
|
117
118
119
120
121
|
}
seriesItem.data.push(data.toFixed(2));
}
window.eqTuoShanRateOpt.series.push(seriesItem)
}
|
赖素文
authored
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
//新增默认 目标值
legendData.push("目标值")
window.eqTuoShanRateOpt.series.push({
name: "目标值",
symbolSize: 10, //小圆点的大小
color: 'red',
type: 'line',
data: ["99", "99", "99", "99", "99", "99", "99", "99"],
lineStyle: {
normal: {
width: 3,
type: 'dashed',
},
},
itemStyle: {
normal: {
lineStyle: {
width: 4, //线条宽度
},
},
},
});
|
王硕
authored
|
144
|
window.eqTuoShanRateOpt.legend.data = legendData
|
王硕
authored
|
145
|
let myChart = echarts.init(app.data.echartOpt.eqTuoShanRateEle)
|
赖素文
authored
|
146
|
|
赖素文
authored
|
147
148
149
150
|
myChart.clear()
myChart.setOption(window.eqTuoShanRateOpt)
},
|
王硕
authored
|
151
|
initEchartsAlarmsNumber: function (failureCount) {
|
王硕
authored
|
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
|
var xaxisdata = [];
var faultFrequency = []
let totalCount = 0;
// 计算所有 x.count 的总和
failureCount.forEach(x => {
totalCount += x.count;
});
const relativeCount = []
failureCount.forEach(x => {
let totalCountNum = (x.count / totalCount) * 100
relativeCount.push(totalCountNum.toFixed(2))
xaxisdata.push(x.equipmentName)
faultFrequency.push(x.count)
})
if (failureCount.length <= 15) {
window.eqAlarmsNumber.dataZoom[0].end = 99
} else {
window.eqAlarmsNumber.dataZoom[0].end = 20
}
window.eqAlarmsNumber.xAxis[0].data =[]
window.eqAlarmsNumber.xAxis[0].data = xaxisdata;
window.eqAlarmsNumber.series[0].data = faultFrequency;
window.eqAlarmsNumber.series[1].data = relativeCount;
|
赖素文
authored
|
177
178
179
180
|
let myChart = echarts.init(app.data.echartOpt.eqAlarmsNumberEle)
myChart.clear()
myChart.setOption(window.eqAlarmsNumber)
},
|
赖素文
authored
|
181
|
|
赖素文
authored
|
182
183
184
185
186
187
188
189
190
191
192
|
initTableFailure40: function (failureOverFourty) {
let options = {
elem: "#mainAlarms" ,
cols: app.data.colsFailure,
data: failureOverFourty,
height: 'full-400', // 最大高度减去其他容器已占有的高度差
page: false
}
app.data.tableIns = sysU.initTable(options);
},
|
HuXiYu
authored
|
193
|
refreshDataMethod: function () {
|
王硕
authored
|
194
195
|
let currenttime = parseInt(app.data.refreshDataTimeEle.innerHTML);
if (currenttime === 0) {
|
HuXiYu
authored
|
196
|
currenttime = vueApp.refreshDataTime;
|
王硕
authored
|
197
198
199
200
201
202
203
204
|
app.methods.getEquipmentDataList();
app.methods.getEqEchartsDataList();
} else {
currenttime--;
}
app.data.refreshDataTimeEle.innerHTML = currenttime;
},
|
赖素文
authored
|
205
206
207
208
209
210
211
|
/**
* 初始化vue
*/
initVue: function () {
vueApp = new Vue({
el: '.vueApp',
data: {
|
HuXiYu
authored
|
212
|
refreshDataTime:40,
|
赖素文
authored
|
213
214
|
head: {
projectName: 0
|
HuXiYu
authored
|
215
216
217
|
},
body: {
eqCount: 0,
|
赖素文
authored
|
218
|
eqRunCount: 0,
|
HuXiYu
authored
|
219
|
eqStandBy: 0,
|
HuXiYu
authored
|
220
|
eqOffline: 0,
|
HuXiYu
authored
|
221
222
|
eqError:0,
|
HuXiYu
authored
|
223
|
eqOnlineRate:0,
|
HuXiYu
authored
|
224
|
},
|
赖素文
authored
|
225
226
227
228
|
},
methods: {
},
|
HuXiYu
authored
|
229
|
ready: function () {
|
HuXiYu
authored
|
230
|
this.head.projectName = `${projectName}`;
|
赖素文
authored
|
231
|
}
|
赖素文
authored
|
232
233
234
|
});
},
/**
|
HuXiYu
authored
|
235
|
* vue 集合赋值 result.Result.eqCount
|
赖素文
authored
|
236
|
*/
|
HuXiYu
authored
|
237
|
initVueDataValue: function (result) {
|
HuXiYu
authored
|
238
239
|
var res = result.Result;
vueApp.body.eqCount = res.eqSumCount;
|
赖素文
authored
|
240
|
vueApp.body.eqRunCount = res.eqRunCount;
|
HuXiYu
authored
|
241
|
vueApp.body.eqStandBy = res.eqStandByCount;
|
HuXiYu
authored
|
242
243
244
|
vueApp.body.eqError = res.eqErrorCount;
vueApp.body.eqOffline = res.eqOffLineCount;
|
HuXiYu
authored
|
245
|
vueApp.body.eqOnlineRate = res.runningRate;
|
赖素文
authored
|
246
247
248
|
},
getUrlParam: function () {
|
赖素文
authored
|
249
250
|
projectKeys = localStorage.getItem("projectMapKeys");
projectName = localStorage.getItem("projectMapName");
|
赖素文
authored
|
251
|
},
|
HuXiYu
authored
|
252
253
254
255
256
257
258
259
260
261
262
263
|
getEquipmentDataList() {
var ajaxConfig = {
data: { pageRequest: null, entity: { flag: "projectMapList", keys: projectKeys } },
url: `/configure/BaseProject/LoadProjectOverview`,
success: function (result) {
if (sysU.successBefore(result)) return false;
app.methods.initVueDataValue(result);
}
};
sysU.ajax(ajaxConfig);
},
|
王硕
authored
|
264
|
//妥善率/故障次数/设备故 障统一数据请求接口
|
王硕
authored
|
265
266
267
268
269
270
271
|
getEqEchartsDataList() {
var ajaxConfig = {
data: { projectKeys: projectKeys },
url: `/configure/BaseProject/GetFailureList`,
success: function (result) {
if (sysU.successBefore(result)) return false;
app.methods.initEchartsTuoShanRate(result.Result.failureTime);
|
王硕
authored
|
272
|
app.methods.initEchartsAlarmsNumber(result.Result.failureCount);
|
赖素文
authored
|
273
|
app.methods.initTableFailure40(result.Result.failureOverFourty);
|
王硕
authored
|
274
275
276
277
|
}
};
sysU.ajax(ajaxConfig);
},
|
赖素文
authored
|
278
279
280
|
init: function () {
var tempElem = $(".sys-a-det");
tempElem.attr("href", tempElem.data("scr") + `?projectKeys=${projectKeys}`)
|
HuXiYu
authored
|
281
282
|
app.methods.getEquipmentDataList();
|
王硕
authored
|
283
|
app.methods.getEqEchartsDataList();
|
赖素文
authored
|
284
|
intervalTime=setInterval(app.methods.refreshDataMethod, 1000);
|
赖素文
authored
|
285
|
}
|
赖素文
authored
|
286
287
|
},
registerEvent: function () {
|
赖素文
authored
|
288
289
290
|
$(".sys-a-det").click(function () {
if (intervalTime != null) clearInterval(intervalTime)
})
|
赖素文
authored
|
291
292
293
|
},
init: function () {
app.methods.getUrlParam();
|
赖素文
authored
|
294
|
app.methods.initVue();
|
赖素文
authored
|
295
|
app.methods.initTable();
|
王硕
authored
|
296
|
app.methods.init();
|
赖素文
authored
|
297
298
299
300
|
}
};
app.init();
});
|