|
|
@ -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}`); |
|
|
@ -133,7 +137,7 @@ module.exports = function (app, opts) { |
|
|
|
const corPepProject = |
|
|
|
pepProjectRes.find(p => p.id == poms.pepProjectId) |
|
|
|
//添加true,优化成EM推送不需要关联项企项目的状态
|
|
|
|
if (corPepProject && (c.timeType.some(ct => ct == corPepProject.construction_status_id)||true)) { |
|
|
|
if (corPepProject && (c.timeType.some(ct => ct == corPepProject.construction_status_id) || true)) { |
|
|
|
pepProjectName_.push(corPepProject.project_name) |
|
|
|
pepProject_name.push({ id: poms.id, anxinProjectId: poms.anxinProjectId, name: corPepProject.project_name }) |
|
|
|
} else { |
|
|
@ -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 }) |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
@ -1528,13 +1538,13 @@ module.exports = function (app, opts) { |
|
|
|
if (h.projects && h.projects.length) { |
|
|
|
h.projects.map((x, xi) => { |
|
|
|
//用于设备全部中断做特殊标记
|
|
|
|
let problem=0 |
|
|
|
let count=0 |
|
|
|
let problem = 0 |
|
|
|
let count = 0 |
|
|
|
let showOne1 = (xi == 0) ? true : false |
|
|
|
if (x.factor && x.factor.length) { |
|
|
|
x.factor.map((f, fi) => { |
|
|
|
problem+=f.problem |
|
|
|
count+=f.devicesLength |
|
|
|
problem += f.problem |
|
|
|
count += f.devicesLength |
|
|
|
let showOne2 = (fi == 0) ? true : false |
|
|
|
if (f.devices && f.devices.length) { |
|
|
|
f.devices.map((c, ci) => { |
|
|
@ -1559,7 +1569,7 @@ module.exports = function (app, opts) { |
|
|
|
break; |
|
|
|
case 'Structure': |
|
|
|
if (showOne2 && showOne3 && showOne4) { |
|
|
|
tableData +=problem==count?`<th style="color: red;" rowspan=${x.rowspan}>${x['name']+'('+'测点数据全部中断'+')' || ''}</th>`: `<th rowspan=${x.rowspan}>${x['name'] || ''}</th>` |
|
|
|
tableData += problem == count ? `<th style="color: red;" rowspan=${x.rowspan}>${x['name'] + '(' + '测点数据全部中断' + ')' || ''}</th>` : `<th rowspan=${x.rowspan}>${x['name'] || ''}</th>` |
|
|
|
} |
|
|
|
break; |
|
|
|
case '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']
|
|
|
|
} |
|
|
|
|
|
|
|