diff --git a/api/app/lib/schedule/alarms_push.js b/api/app/lib/schedule/alarms_push.js
index fd06379..1262c5b 100644
--- a/api/app/lib/schedule/alarms_push.js
+++ b/api/app/lib/schedule/alarms_push.js
@@ -1168,11 +1168,11 @@ module.exports = function (app, opts) {
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
}
@@ -1195,7 +1195,7 @@ module.exports = function (app, opts) {
}
h.rowspan = rowspan1
})
- console.log('数据组合', JSON.stringify(pepProject_name));
+ // console.log('数据组合', JSON.stringify(pepProject_name));
//
dataAlarmG1 = pepProject_name
}
@@ -1214,10 +1214,8 @@ module.exports = function (app, opts) {
let alarmContent = ''
let alarmHtmlTitle = packageTableTitle(alarmTitleArr)
-
if (type == 1) {
-
-
+
alarmData.map((h, hi) => {
if (h.projects && h.projects.length) {
@@ -1232,46 +1230,46 @@ module.exports = function (app, opts) {
f.devices.map((c, ci) => {
let showOne3 = (ci == 0) ? true : false
if (c.alarmDatas && c.alarmDatas.length) {
- c.alarmDatas.map(a => {
- let tableData = '
'
-
- for (let t of alarmTitleArr) {
- if (t.f) {
- tableData += `${t.f(a) || ''} | `
- } else if (t.k) {
-
- switch (t.k) {
- case 'name':
- if (showOne1 && showOne2 && showOne3) {
- tableData += `${h[t.k] || ''} | `
- }
- break;
- case 'Structure':
-
- if (showOne2 && showOne3) {
- tableData += `${x['name'] || ''} | `
- }
- break;
- case 'factor':
-
- if (showOne3) {
- tableData += `${(f['name']+'('+f.rowspan+'/'+f.devicesLength+')') || ''} | `
- }
- break;
- case 'SourceName':
- tableData += `${a[t.k] || ''} | `
- break;
- default:
- break;
- }
+ //取设备里面告警最新的一条数据
+ if (c.alarmDatas.length > 1) {
+ c.alarmDatas.sort((a, b) => new Date(b.StartTime) - new Date(a.StartTime))
+ }
+ let alarmNewest = c.alarmDatas[0] || {}
+ let tableData = '
'
+ for (let t of alarmTitleArr) {
+ if (t.f) {
+ tableData += `${t.f(alarmNewest) || ''} | `
+ } else if (t.k) {
+ switch (t.k) {
+ case 'name':
+ if (showOne1 && showOne2 && showOne3) {
+ tableData += `${h[t.k] || ''} | `
+ }
+ break;
+ case 'Structure':
+ if (showOne2 && showOne3) {
+ tableData += `${x['name'] || ''} | `
+ }
+ break;
+ case 'factor':
+ if (showOne3) {
+ tableData += `${(f['name'] + '(' + f.rowspan + '/' + f.devicesLength + ')') || ''} | `
+ }
+ break;
+ case 'SourceName':
+ tableData += `${alarmNewest[t.k] || ''} | `
+ break;
+ default:
+ break;
}
}
- tableData += '
'
- alarmContent += tableData
- if (a[keyOfStartTime] && moment(a[keyOfStartTime]).isBetween(newAddStartTime, newAddEndTime)) {
- newAddCount++
- }
- })
+ }
+ tableData += ''
+ alarmContent += tableData
+ if (alarmNewest[keyOfStartTime] && moment(alarmNewest[keyOfStartTime]).isBetween(newAddStartTime, newAddEndTime)) {
+ newAddCount++
+ }
+
}
})
}
@@ -1382,7 +1380,7 @@ module.exports = function (app, opts) {
}
if (proDebug) {
console.log(`相关设备及测点信息:`);
- console.log(deviceSensorRes);
+ // console.log(deviceSensorRes);
}
let alarmTitle = dataAlarmTitle.concat(
videoAlarmTitle.slice(2).map(v => {