|
@ -4,7 +4,7 @@ let isDev = false |
|
|
// isDev = true
|
|
|
// isDev = true
|
|
|
|
|
|
|
|
|
let proDebug = false |
|
|
let proDebug = false |
|
|
// proDebug = true
|
|
|
proDebug = true |
|
|
|
|
|
|
|
|
module.exports = function (app, opts) { |
|
|
module.exports = function (app, opts) { |
|
|
const alarmsPush = app.fs.scheduleInit( |
|
|
const alarmsPush = app.fs.scheduleInit( |
|
@ -1179,7 +1179,7 @@ module.exports = function (app, opts) { |
|
|
).toPromise() || [] |
|
|
).toPromise() || [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const alarmDatas = await clickHouse.dataAlarm.query( |
|
|
const alarmDataRes = await clickHouse.dataAlarm.query( |
|
|
`
|
|
|
`
|
|
|
SELECT |
|
|
SELECT |
|
|
alarms.AlarmId AS alarmId, |
|
|
alarms.AlarmId AS alarmId, |
|
@ -1190,7 +1190,8 @@ module.exports = function (app, opts) { |
|
|
alarms.SourceName AS SourceName, |
|
|
alarms.SourceName AS SourceName, |
|
|
alarms.AlarmCode AS AlarmCode, |
|
|
alarms.AlarmCode AS AlarmCode, |
|
|
alarms.SourceTypeId AS SourceTypeId, |
|
|
alarms.SourceTypeId AS SourceTypeId, |
|
|
alarms.StructureId AS StructureId |
|
|
alarms.StructureId AS StructureId, |
|
|
|
|
|
alarms.subStations AS subStations, |
|
|
FROM |
|
|
FROM |
|
|
alarms |
|
|
alarms |
|
|
WHERE |
|
|
WHERE |
|
@ -1202,6 +1203,21 @@ module.exports = function (app, opts) { |
|
|
` |
|
|
` |
|
|
).toPromise() || [] |
|
|
).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 = [] |
|
|
let matchedAlarmIds = [] |
|
|
// 这一步能被分配的告警应该也能最终体现在邮件中
|
|
|
// 这一步能被分配的告警应该也能最终体现在邮件中
|
|
@ -1256,54 +1272,55 @@ module.exports = function (app, opts) { |
|
|
// 上面的代码自内而外构建数据
|
|
|
// 上面的代码自内而外构建数据
|
|
|
// 下面的逻辑自外向内!!!
|
|
|
// 下面的逻辑自外向内!!!
|
|
|
|
|
|
|
|
|
// // 处理那些没有被匹配到的告警信息
|
|
|
// 处理那些没有被匹配到的告警信息
|
|
|
// // 将设备没有绑定到测点的告警也推出去
|
|
|
// 将设备没有绑定到测点的告警也推出去
|
|
|
// for (let a of alarmDatas) {
|
|
|
for (let a of alarmDatas) { |
|
|
// if (!matchedAlarmIds.includes(a.alarmId)) {
|
|
|
if (!matchedAlarmIds.includes(a.alarmId)) { |
|
|
// let curStruc = strucMap[a.StructureId]
|
|
|
pLog('未匹配到的告警 ' + a.alarmId) |
|
|
// if (curStruc) {
|
|
|
// let curStruc = strucMap[a.StructureId]
|
|
|
// // curStruc 可以推出 告警属于哪个 project -> pomsProject
|
|
|
// if (curStruc) {
|
|
|
// let curProject = pepProject_name.filter(p => p.anxinProjectId && p.anxinProjectId.includes(curStruc.projectId));
|
|
|
// // curStruc 可以推出 告警属于哪个 project -> pomsProject
|
|
|
// for (let cp of curProject) {
|
|
|
// let curProject = pepProject_name.filter(p => p.anxinProjectId && p.anxinProjectId.includes(curStruc.projectId));
|
|
|
// // cp.projects 是结构物信息
|
|
|
// for (let cp of curProject) {
|
|
|
// let curStruc = cp.projects.find(cpp => cpp.id == a.StructureId)
|
|
|
// // cp.projects 是结构物信息
|
|
|
// if (!curStruc) {
|
|
|
// let curStruc = cp.projects.find(cpp => cpp.id == a.StructureId)
|
|
|
// console.error(`没有查到结构物信息:${a.StructureId}?!不应该不应该!`);
|
|
|
// if (!curStruc) {
|
|
|
// } else {
|
|
|
// console.error(`没有查到结构物信息:${a.StructureId}?!不应该不应该!`);
|
|
|
// // let emptyFactor = { id: -1 }
|
|
|
// } else {
|
|
|
// let emptyFactor = curStruc.factor.find(f => f.id == -1)
|
|
|
// // let emptyFactor = { id: -1 }
|
|
|
// if (!emptyFactor) {
|
|
|
// let emptyFactor = curStruc.factor.find(f => f.id == -1)
|
|
|
// curStruc.factor.push({
|
|
|
// if (!emptyFactor) {
|
|
|
// id: -1,
|
|
|
// curStruc.factor.push({
|
|
|
// devices: [{
|
|
|
// id: -1,
|
|
|
// alarmDatas: [
|
|
|
// devices: [{
|
|
|
// { ...a }
|
|
|
// alarmDatas: [
|
|
|
// ],
|
|
|
// { ...a }
|
|
|
// iotaDeviceId: a.sourceId,
|
|
|
// ],
|
|
|
// name: a.SourceName,
|
|
|
// iotaDeviceId: a.sourceId,
|
|
|
// structureId: a.StructureId,
|
|
|
// name: a.SourceName,
|
|
|
// }]
|
|
|
// structureId: a.StructureId,
|
|
|
// })
|
|
|
// }]
|
|
|
// } else {
|
|
|
// })
|
|
|
// let curDevice = emptyFactor.devices.find(d => d.iotaDeviceId == a.sourceId)
|
|
|
// } else {
|
|
|
// if (!curDevice) {
|
|
|
// let curDevice = emptyFactor.devices.find(d => d.iotaDeviceId == a.sourceId)
|
|
|
// emptyFactor.devices.push({
|
|
|
// if (!curDevice) {
|
|
|
// alarmDatas: [
|
|
|
// emptyFactor.devices.push({
|
|
|
// { ...a }
|
|
|
// alarmDatas: [
|
|
|
// ],
|
|
|
// { ...a }
|
|
|
// iotaDeviceId: a.sourceId,
|
|
|
// ],
|
|
|
// name: a.SourceName,
|
|
|
// iotaDeviceId: a.sourceId,
|
|
|
// structureId: a.StructureId,
|
|
|
// name: a.SourceName,
|
|
|
// })
|
|
|
// structureId: a.StructureId,
|
|
|
// } else {
|
|
|
// })
|
|
|
// curDevice.alarmDatas.push({ ...a })
|
|
|
// } else {
|
|
|
// }
|
|
|
// curDevice.alarmDatas.push({ ...a })
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
pepProject_name.forEach(h => { |
|
|
pepProject_name.forEach(h => { |
|
|
let rowspan1 = 0 |
|
|
let rowspan1 = 0 |
|
|