Browse Source

拆解 subStations

dev
CODE 1 year ago
parent
commit
f973bbc0aa
  1. 35
      api/app/lib/schedule/alarms_push.js

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

@ -4,7 +4,7 @@ let isDev = false
// isDev = true
let proDebug = false
// proDebug = true
proDebug = true
module.exports = function (app, opts) {
const alarmsPush = app.fs.scheduleInit(
@ -1179,7 +1179,7 @@ module.exports = function (app, opts) {
).toPromise() || []
const alarmDatas = await clickHouse.dataAlarm.query(
const alarmDataRes = await clickHouse.dataAlarm.query(
`
SELECT
alarms.AlarmId AS alarmId,
@ -1190,7 +1190,8 @@ module.exports = function (app, opts) {
alarms.SourceName AS SourceName,
alarms.AlarmCode AS AlarmCode,
alarms.SourceTypeId AS SourceTypeId,
alarms.StructureId AS StructureId
alarms.StructureId AS StructureId,
alarms.subStations AS subStations,
FROM
alarms
WHERE
@ -1202,6 +1203,21 @@ module.exports = function (app, opts) {
`
).toPromise() || []
let alarmDatas = []
for (let alarms of alarmDataRes) {
if (alarms.subStations && alarms.subStations.length) {
pLog('拆解 subStations' + alarms.alarmId + ' ' + alarms.subStations.length + '个')
for (let subStation of alarms.subStations) {
alarmDatas.push({
...alarms,
alarmId: subStation
})
}
} else {
alarmDatas.push(alarms)
}
}
// 为设备分配自己产生的告警数据
let matchedAlarmIds = []
// 这一步能被分配的告警应该也能最终体现在邮件中
@ -1256,10 +1272,11 @@ module.exports = function (app, opts) {
// 上面的代码自内而外构建数据
// 下面的逻辑自外向内!!!
// // 处理那些没有被匹配到的告警信息
// // 将设备没有绑定到测点的告警也推出去
// for (let a of alarmDatas) {
// if (!matchedAlarmIds.includes(a.alarmId)) {
// 处理那些没有被匹配到的告警信息
// 将设备没有绑定到测点的告警也推出去
for (let a of alarmDatas) {
if (!matchedAlarmIds.includes(a.alarmId)) {
pLog('未匹配到的告警 ' + a.alarmId)
// let curStruc = strucMap[a.StructureId]
// if (curStruc) {
// // curStruc 可以推出 告警属于哪个 project -> pomsProject
@ -1302,8 +1319,8 @@ module.exports = function (app, opts) {
// }
// }
// }
// }
// }
}
}
pepProject_name.forEach(h => {
let rowspan1 = 0

Loading…
Cancel
Save