wenlele 2 years ago
parent
commit
2c1c24a393
  1. 170
      api/app/lib/schedule/alarms_push.js

170
api/app/lib/schedule/alarms_push.js

@ -197,7 +197,7 @@ module.exports = function (app, opts) {
// !开发测试用的数据
if (isDev) {
// searchStrucIds = searchStrucIds.concat([991, 1052, 700])
searchStrucIds = searchStrucIds.concat([27, 991, 1040, 50, 59.128, 407, 409, 877, 1035, 1077])
searchStrucIds = searchStrucIds.concat([991])
}
if (searchStrucIds.length) {
@ -1157,35 +1157,49 @@ module.exports = function (app, opts) {
})
})
}
pepProject_name.map(h => {
pepProject_name.forEach(h => {
let rowspan1 = 0
if (h.projects.length) {
h.projects.map(x => {
h.projects.forEach(x => {
let rowspan2 = 0
if (x.factor.length) {
x.factor.map(f => {
x.factor.forEach(f => {
let rowspan3 = 0
if (f.devices.length) {
f.devices.map(c => {
if (c.alarmDatas.length) {
c.alarmDatas.map(a => {
dataAlarmG1.push({
name: h.name,
Structure:x.name,
factor:f.name,
SourceName:a.SourceName,
StartTime:a.StartTime
f.devices = f.devices.filter(b => b.alarmDatas && b.alarmDatas.length > 0)
if (f.devices.length) {
f.devices.forEach(c => {
if (c.alarmDatas.length) {
c.alarmDatas.forEach(a => {
rowspan1 += 1
rowspan2 += 1
rowspan3 += 1
})
})
}
})
} else {
delete c.alarmDatas
}
})
} else {
delete f.devices
}
} else {
delete f.devices
}
f.rowspan = rowspan3
})
} else {
delete x.factor
}
x.rowspan = rowspan2
})
} else {
delete h.projects
}
h.rowspan = rowspan1
})
pepProject_name.map(h => {
})
dataAlarmG1 = pepProject_name
}
@ -1233,33 +1247,105 @@ module.exports = function (app, opts) {
// })
// // }
if (type == 1) {
alarmData.map((h, hi) => {
let rowspan1 = 0
if (h.projects && h.projects.length) {
h.projects.map((x, xi) => {
let rowspan2 = 0
let showOne1 = xi == 0 ? true : false
if (x.factor && x.factor.length) {
x.factor.map((f, fi) => {
let rowspan3 = 0
let showOne2 = fi == 0 ? true : false
if (f.devices && f.devices.length) {
f.devices.map((c, ci) => {
let showOne3 = ci == 0 ? true : false
if (c.alarmDatas && c.alarmDatas.length) {
c.alarmDatas.map(a => {
rowspan1 += 1
rowspan2 += 1
rowspan3 += 1
// dataAlarmG1.push({
// name: h.name,
// Structure: x.name,
// factor: f.name,
// SourceName: a.SourceName,
// StartTime: a.StartTime
// })
let tableData = '<tr>'
for (let t of alarmTitleArr) {
if (t.f) {
tableData += `<td>${t.f(a) || ''}</td>`
} else if (t.k) {
switch (t.k) {
case 'name':
if (showOne1) {
tableData += `<th rowspan=${h.rowspan}>${h[t.k] || ''}</th>`
}
break;
case 'Structure':
if (showOne2) {
tableData += `<th rowspan=${x.rowspan}>${x['name'] || ''}</th>`
}
break;
case 'factor':
if (showOne3) {
tableData += `<th rowspan=${f.rowspan}>${f['name'] || ''}</th>`
}
break;
case 'SourceName':
tableData += `<td>${a[t.k] || ''}</td>`
break;
default:
break;
}
}
}
tableData += '</tr>'
alarmContent += tableData
if (a[keyOfStartTime] && moment(a[keyOfStartTime]).isBetween(newAddStartTime, newAddEndTime)) {
newAddCount++
}
})
}
})
}
})
}
})
}
})
} else {
for (let [index, a] of alarmData.entries()) {
for (let [index, a] of alarmData.entries()) {
// if (type == 1) {
// let tableData = '<tr>'
// for (let t of titleArr) {
// if (t.v) {
// tableData += `<td>${t.v || ''}</td>`
// } else if (t.f) {
// tableData += `<td>${t.f(data) || ''}</td>`
// } else if (t.k) {
// tableData += `<td>${data[t.k] || ''}</td>`
// } else {
// tableData += `<td></td>`
// }
// }
// tableData += '</tr>'
// alarmContent += tableData
// } else {
alarmContent += packageTableData({ data: a, titleArr: alarmTitleArr })
// }
if (a[keyOfStartTime] && moment(a[keyOfStartTime]).isBetween(newAddStartTime, newAddEndTime)) {
newAddCount++
if (a[keyOfStartTime] && moment(a[keyOfStartTime]).isBetween(newAddStartTime, newAddEndTime)) {
newAddCount++
}
}
}
tableTitlePrefix +=
titlePrefix != '数据异常&视频异常' ?
c.tactics == 'abnormal_rate' ?

Loading…
Cancel
Save