From 2c1c24a39386199f642b62e9878e95b004db736e Mon Sep 17 00:00:00 2001 From: wenlele Date: Tue, 9 May 2023 17:19:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/schedule/alarms_push.js | 170 +++++++++++++++++++++------- 1 file changed, 128 insertions(+), 42 deletions(-) diff --git a/api/app/lib/schedule/alarms_push.js b/api/app/lib/schedule/alarms_push.js index 1f56037..4624de7 100644 --- a/api/app/lib/schedule/alarms_push.js +++ b/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 = '' + + for (let t of alarmTitleArr) { + if (t.f) { + tableData += `${t.f(a) || ''}` + } else if (t.k) { + + switch (t.k) { + case 'name': + if (showOne1) { + tableData += `${h[t.k] || ''}` + } + break; + case 'Structure': + + if (showOne2) { + tableData += `${x['name'] || ''}` + } + break; + case 'factor': + + if (showOne3) { + tableData += `${f['name'] || ''}` + } + break; + case 'SourceName': + tableData += `${a[t.k] || ''}` + break; + default: + break; + } + } + + + } + tableData += '' + 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 = '' - // for (let t of titleArr) { - // if (t.v) { - // tableData += `${t.v || ''}` - // } else if (t.f) { - // tableData += `${t.f(data) || ''}` - // } else if (t.k) { - // tableData += `${data[t.k] || ''}` - // } else { - // tableData += `` - // } - // } - - // tableData += '' - // 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' ?