wenlele 1 year ago
parent
commit
786f55a221
  1. 48
      api/app/lib/schedule/alarms_push.js

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

Loading…
Cancel
Save