ProjectOverview.js
8.92 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
let action = null;
layui.config({
base: "/js/",
version: 1
}).use(['system',"vue"], function () {
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,
projectName = "",
vueApp=null,
app = null;
action = {
}
app = {
data: {
cols: [[
{ field: "zizeng", width: 80, title: "序号", fixed: "left", type: "numbers" },
{
field: "equipmentName", width: 220, title: "设备"
},
{
field: "Status", width: 150, title: "ip地址", templet: function (d) {
//if (d.Status == "" || d.Status == null) return "";
var bg = "layui-badge-dot layui-bg-green",
statusText = "在线";
if (d.Status == "Failure") {
statusText = "故障";
bg = "layui-badge-dot layui-bg-red";
}
if (d.seconds > 300 || d.seconds==-1) {
statusText = "离线";
bg = "layui-badge-dot layui-bg-gray";
}
return `<span class="${bg}" style=" left: 7px;"></span> <span style="padding-left: 8px;">${statusText}</span`;
}
}
]],
tableIns: null,
tableElem: "mainList",
echartOpt: {
eqTuoShanRateEle: document.getElementById("eqTuoShanRate"),
eqAlarmsNumberEle: document.getElementById("eqAlarmsNumber"),
tuoShanRatelegendData: "".GetTimeRange("","",7)
}
},
methods: {
initTable: function (opt) {
var config = { projectKeys: projectKeys }
if (opt != undefined) $.extend(config, opt);
let options = {
elem: "#" + app.data.tableElem,
url: `/configure/BaseProject/GetEqInfoByProjectKeys`,
cols: app.data.cols,
height: 'full-400', // 最大高度减去其他容器已占有的高度差
where: config,
page: false
}
app.data.tableIns = sysU.initTable(options);
},
//每台设备妥善率
initEchartsTuoShanRate: function (failureTime) {
let legendData = failureTime.uniqueFunc("equipmentName")
window.eqTuoShanRateOpt.legend.data = legendData
window.eqTuoShanRateOpt.xAxis[0].data = app.data.echartOpt.tuoShanRatelegendData
window.eqTuoShanRateOpt.series = [];
for (let i = 0; i < legendData.length; i++) {
var seriesItem = {
name: legendData[i].equipmentName,
type: 'line',
data: []
};
for (let j = 0; j < app.data.echartOpt.tuoShanRatelegendData.length; j++) {
const timeVal = app.data.echartOpt.tuoShanRatelegendData[j];
const nowVal = failureTime.GetArrValueRow("Date", timeVal);
let data = 0;
if (nowVal.length > 0) {
data = (1 - (nowVal[0].sumTime / 86400)) * 100
}
seriesItem.data.push(data.toFixed(2));
}
window.eqTuoShanRateOpt.series.push(seriesItem)
}
let myChart = echarts.init(app.data.echartOpt.eqTuoShanRateEle)
myChart.clear()
myChart.setOption(window.eqTuoShanRateOpt)
},
initEchartsAlarmsNumber: function (failureCount) {
debugger
console.log(failureCount)
// 创建存储图例数据和 x 轴数据的变量
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;
/* window.eqAlarmsNumber.series = seriesData;*/
let myChart = echarts.init(app.data.echartOpt.eqAlarmsNumberEle)
myChart.clear()
myChart.setOption(window.eqAlarmsNumber)
},
/**
* 初始化vue
*/
initVue: function () {
vueApp = new Vue({
el: '.vueApp',
data: {
head: {
projectName: 0
},
body: {
eqCount: 0,
eqOnline: 0,
eqStandBy: 0,
eqOffline: 0,
eqError:0,
eqOnlineRate:0,
},
},
methods: {
},
ready: function () {
this.head.projectName = `${projectName}`;
}
});
},
/**
* vue 集合赋值 result.Result.eqCount
*/
initVueDataValue: function (result) {
var res = result.Result;
vueApp.body.eqCount = res.eqSumCount;
vueApp.body.eqOnline = res.eqOnLineCount;
vueApp.body.eqStandBy = res.eqStandByCount;
vueApp.body.eqError = res.eqErrorCount;
vueApp.body.eqOffline = res.eqOffLineCount;
vueApp.body.eqOnlineRate = res.runningRate;
},
getUrlParam: function () {
projectKeys = localStorage.getItem("projectMapKeys");
projectName = localStorage.getItem("projectMapName");
},
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);
},
//妥善率/故障次数/设备故 障统一数据请求接口
getEqEchartsDataList() {
var ajaxConfig = {
data: { projectKeys: projectKeys },
url: `/configure/BaseProject/GetFailureList`,
success: function (result) {
if (sysU.successBefore(result)) return false;
//console.log(result.Result.failureCount)
app.methods.initEchartsTuoShanRate(result.Result.failureTime);
app.methods.initEchartsAlarmsNumber(result.Result.failureCount);
}
};
sysU.ajax(ajaxConfig);
},
init: function () {
var tempElem = $(".sys-a-det");
tempElem.attr("href", tempElem.data("scr") + `?projectKeys=${projectKeys}`)
app.methods.getEquipmentDataList();
app.methods.getEqEchartsDataList();
}
},
registerEvent: function () {
},
init: function () {
app.methods.getUrlParam();
app.methods.initVue();
app.methods.initTable();
app.methods.init();
}
};
app.init();
});