|
@ -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( |
|
@ -105,9 +105,13 @@ module.exports = function (app, opts) { |
|
|
pLog(`curMinOfYear / ${curMinOfYear}`) |
|
|
pLog(`curMinOfYear / ${curMinOfYear}`) |
|
|
for (let { dataValues: c } of configListRes) { |
|
|
for (let { dataValues: c } of configListRes) { |
|
|
|
|
|
|
|
|
if (isDev && c.id != 86) { |
|
|
// if (isDev && c.id != 20) {
|
|
|
continue |
|
|
// continue
|
|
|
} |
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// if (isDev && c.name != '张掖持续') {
|
|
|
|
|
|
// continue
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
if (c.tacticsParams && c.tactics) { |
|
|
if (c.tacticsParams && c.tactics) { |
|
|
pLog(`当前运行EM配置:id=${c.id} name=${c.name}`); |
|
|
pLog(`当前运行EM配置:id=${c.id} name=${c.name}`); |
|
@ -1246,7 +1250,9 @@ module.exports = function (app, opts) { |
|
|
LEFT JOIN ${iota}.Device |
|
|
LEFT JOIN ${iota}.Device |
|
|
ON Device.id = toString(t_device_sensor.iota_device_id) |
|
|
ON Device.id = toString(t_device_sensor.iota_device_id) |
|
|
WHERE |
|
|
WHERE |
|
|
t_sensor.structure IN (${[...dataAlarmG1StructureId, -1].join(',')}) |
|
|
t_sensor.structure IN (${[...dataAlarmG1StructureId, -1].join(',') |
|
|
|
|
|
// 3025
|
|
|
|
|
|
}) |
|
|
AND |
|
|
AND |
|
|
t_sensor.factor IN (${[...factorId, -1].join(',')}) |
|
|
t_sensor.factor IN (${[...factorId, -1].join(',')}) |
|
|
` |
|
|
` |
|
@ -1285,7 +1291,9 @@ module.exports = function (app, opts) { |
|
|
FROM |
|
|
FROM |
|
|
alarms |
|
|
alarms |
|
|
WHERE |
|
|
WHERE |
|
|
alarms.StructureId In (${[...dataAlarmG1StructureId, ...dataAlarmStructureId, -1].join(',')}) |
|
|
alarms.StructureId In (${[...dataAlarmG1StructureId, ...dataAlarmStructureId, -1].join(',') |
|
|
|
|
|
// 3025
|
|
|
|
|
|
}) |
|
|
AND |
|
|
AND |
|
|
alarms.AlarmGroup IN (1,4,5) |
|
|
alarms.AlarmGroup IN (1,4,5) |
|
|
AND |
|
|
AND |
|
@ -1314,17 +1322,19 @@ module.exports = function (app, opts) { |
|
|
// 这一步能被分配的告警应该也能最终体现在邮件中
|
|
|
// 这一步能被分配的告警应该也能最终体现在邮件中
|
|
|
|
|
|
|
|
|
let deviceRepeatMap = {} |
|
|
let deviceRepeatMap = {} |
|
|
equipment.map(f => { |
|
|
|
|
|
f.alarmDatas = [] |
|
|
equipment.map(equip => { |
|
|
|
|
|
equip.alarmDatas = [] |
|
|
alarmDatas.map(r => { |
|
|
alarmDatas.map(r => { |
|
|
if (r.sourceId == f.iotaDeviceId) { |
|
|
// !!! 这里这里 经常这两个id对不上导致告警没有推送
|
|
|
|
|
|
if (r.sourceId == equip.iotaDeviceId) { |
|
|
if (!deviceRepeatMap[r.sourceId]) { |
|
|
if (!deviceRepeatMap[r.sourceId]) { |
|
|
// 没有这个deviceId则不重复
|
|
|
// 没有这个deviceId则不重复
|
|
|
deviceRepeatMap[r.sourceId] = true |
|
|
deviceRepeatMap[r.sourceId] = true |
|
|
f.alarmDatas.push({ |
|
|
equip.alarmDatas.push({ |
|
|
...r, |
|
|
...r, |
|
|
// 可能有的设备绑定了不同的测点 所以这里展示测点名称
|
|
|
// 可能有的设备绑定了不同的测点 所以这里展示测点名称
|
|
|
SourceName: r.SubDevices && r.SubDevices.length ? f. |
|
|
SourceName: r.SubDevices && r.SubDevices.length ? equip. |
|
|
deviceName : r.SourceName |
|
|
deviceName : r.SourceName |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
@ -1334,16 +1344,16 @@ module.exports = function (app, opts) { |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
// 为监测因素分配绑定的设备
|
|
|
// 为监测因素分配绑定的设备
|
|
|
factorData.map(v => { |
|
|
factorData.map(factor => { |
|
|
v.devices = [] |
|
|
factor.devices = [] |
|
|
equipment.map(f => { |
|
|
equipment.map(f => { |
|
|
if (v.id == f.factorId && v.structureId == f.structureId) { |
|
|
if (factor.id == f.factorId && factor.structureId == f.structureId) { |
|
|
v.devices.push({ ...f }) |
|
|
factor.devices.push({ ...f }) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
if (strucMap[v.structureId]) { |
|
|
if (strucMap[factor.structureId]) { |
|
|
// 并为 strucMap 补充 factor 监测因素信息
|
|
|
// 并为 strucMap 补充 factor 监测因素信息
|
|
|
strucMap[v.structureId].factor.push({ ...v }) |
|
|
strucMap[factor.structureId].factor.push({ ...factor }) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
@ -1748,8 +1758,8 @@ module.exports = function (app, opts) { |
|
|
|
|
|
|
|
|
if (isDev) { |
|
|
if (isDev) { |
|
|
// !开发测试用的数据
|
|
|
// !开发测试用的数据
|
|
|
// emails = ['gao.zhiyuan@free-sun.com.cn']
|
|
|
emails = ['gao.zhiyuan@free-sun.com.cn'] |
|
|
emails=['zhao.bin@free-sun.com.cn'] |
|
|
// emails = ['zhao.bin@free-sun.com.cn']
|
|
|
// emails = ['wen.lele@free-sun.com.cn']
|
|
|
// emails = ['wen.lele@free-sun.com.cn']
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|