|
@ -27,9 +27,9 @@ module.exports = function (app, opts) { |
|
|
const { pushBySms, pushByEmail, sendNoticeToWeb } = app.fs.utils |
|
|
const { pushBySms, pushByEmail, sendNoticeToWeb } = app.fs.utils |
|
|
const curMinOfYear = moment().diff(moment().startOf('year'), 'minutes') |
|
|
const curMinOfYear = moment().diff(moment().startOf('year'), 'minutes') |
|
|
|
|
|
|
|
|
const pLog = (msg1,msg2) => { |
|
|
const pLog = (msg1, msg2) => { |
|
|
if (proDebug) { |
|
|
if (proDebug) { |
|
|
console.log(msg1,msg2) |
|
|
console.log(msg1, msg2) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -407,7 +407,7 @@ module.exports = function (app, opts) { |
|
|
ON anxinStation.id = anxinIpcStation.station |
|
|
ON anxinStation.id = anxinIpcStation.station |
|
|
ORDER BY cameraAlarm.createTime DESC |
|
|
ORDER BY cameraAlarm.createTime DESC |
|
|
` |
|
|
` |
|
|
).toPromise() : [] |
|
|
).toPromise() : [] |
|
|
let returnD = [] |
|
|
let returnD = [] |
|
|
let positionD = {} |
|
|
let positionD = {} |
|
|
// 每个设备一个告警
|
|
|
// 每个设备一个告警
|
|
@ -540,9 +540,9 @@ module.exports = function (app, opts) { |
|
|
${dataAlarmOption.length ? ' AND ' + dataAlarmOption.join(' AND ') : ''} |
|
|
${dataAlarmOption.length ? ' AND ' + dataAlarmOption.join(' AND ') : ''} |
|
|
ORDER BY StartTime DESC |
|
|
ORDER BY StartTime DESC |
|
|
`).toPromise() : []
|
|
|
`).toPromise() : []
|
|
|
//本地化
|
|
|
//本地化
|
|
|
const dataAlarmsLocal=!c.alarmSubType || dataAlarmSubType_.length ? |
|
|
const dataAlarmsLocal = !c.alarmSubType || dataAlarmSubType_.length ? |
|
|
await clickHouse.dataAlarm.query(` |
|
|
await clickHouse.dataAlarm.query(` |
|
|
SELECT * FROM alarms |
|
|
SELECT * FROM alarms |
|
|
LEFT JOIN sensors |
|
|
LEFT JOIN sensors |
|
|
AS anxinStation |
|
|
AS anxinStation |
|
@ -554,13 +554,13 @@ module.exports = function (app, opts) { |
|
|
${dataAlarmOption.length ? ' AND ' + dataAlarmOption.join(' AND ') : ''} |
|
|
${dataAlarmOption.length ? ' AND ' + dataAlarmOption.join(' AND ') : ''} |
|
|
ORDER BY StartTime DESC |
|
|
ORDER BY StartTime DESC |
|
|
`).toPromise() : []
|
|
|
`).toPromise() : []
|
|
|
//合并本地化和安心云的告警
|
|
|
//合并本地化和安心云的告警
|
|
|
dataAlarms=[...dataAlarms,...dataAlarmsLocal] |
|
|
dataAlarms = [...dataAlarms, ...dataAlarmsLocal] |
|
|
pLog('合并的告警列表(安心云+本地)',dataAlarms.length) |
|
|
pLog('合并的告警列表(安心云+本地)', dataAlarms.length) |
|
|
pLog('合并的告警列表(安心云+本地)',dataAlarmsLocal.length) |
|
|
pLog('合并的告警列表(安心云+本地)', dataAlarmsLocal.length) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let dataAlarmTitle2 = [{ |
|
|
let dataAlarmTitle2 = [{ |
|
|
n: '项目', |
|
|
n: '项目', |
|
@ -1152,21 +1152,21 @@ module.exports = function (app, opts) { |
|
|
` |
|
|
` |
|
|
|
|
|
|
|
|
let dataAlarmG1Data = dataAlarms.filter(a => a.AlarmGroup == 1) |
|
|
let dataAlarmG1Data = dataAlarms.filter(a => a.AlarmGroup == 1) |
|
|
pLog('数据中断',dataAlarmG1Data.length) |
|
|
pLog('数据中断', dataAlarmG1Data.length) |
|
|
if (dataAlarmG1Data.length) { |
|
|
if (dataAlarmG1Data.length) { |
|
|
//安心云项目是structureId数组
|
|
|
//安心云项目是structureId数组
|
|
|
let dataAlarmG1StructureId = new Set() |
|
|
let dataAlarmG1StructureId = new Set() |
|
|
//本地化项目structureId数组
|
|
|
//本地化项目structureId数组
|
|
|
let dataAlarmStructureId = new Set() |
|
|
let dataAlarmStructureId = new Set() |
|
|
dataAlarmG1Data.map(c => { |
|
|
dataAlarmG1Data.map(c => { |
|
|
if(c.project){ |
|
|
if (c.project) { |
|
|
dataAlarmStructureId.add(c.StructureId) |
|
|
dataAlarmStructureId.add(c.StructureId) |
|
|
}else{ |
|
|
} else { |
|
|
dataAlarmG1StructureId.add(c.StructureId) |
|
|
dataAlarmG1StructureId.add(c.StructureId) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
pLog('安心云项目结构物id',dataAlarmG1StructureId) |
|
|
pLog('安心云项目结构物id', dataAlarmG1StructureId) |
|
|
pLog('本地化项目结构物id',dataAlarmStructureId) |
|
|
pLog('本地化项目结构物id', dataAlarmStructureId) |
|
|
//查询结构物的监测因素(安心云)
|
|
|
//查询结构物的监测因素(安心云)
|
|
|
let factorData = await clickHouse.anxinyun.query( |
|
|
let factorData = await clickHouse.anxinyun.query( |
|
|
`
|
|
|
`
|
|
@ -1184,19 +1184,19 @@ module.exports = function (app, opts) { |
|
|
).toPromise() || [] |
|
|
).toPromise() || [] |
|
|
//查询结构物的监测因素(本地化项目)
|
|
|
//查询结构物的监测因素(本地化项目)
|
|
|
let factorDataLocal = await clickHouse.dataAlarm.query( |
|
|
let factorDataLocal = await clickHouse.dataAlarm.query( |
|
|
` SELECT
|
|
|
` SELECT
|
|
|
StructId AS structureId,SafetyFactorTypeName AS name,SafetyFactorTypeId AS id |
|
|
StructId AS structureId,SafetyFactorTypeName AS name,SafetyFactorTypeId AS id |
|
|
FROM |
|
|
FROM |
|
|
sensors |
|
|
sensors |
|
|
WHERE sensors.StructId in (${[...dataAlarmStructureId].join(',')},-1)` |
|
|
WHERE sensors.StructId in (${[...dataAlarmStructureId].join(',')},-1)` |
|
|
).toPromise() || [] |
|
|
).toPromise() || [] |
|
|
pLog('安心云项目监测因素',factorData.length) |
|
|
pLog('安心云项目监测因素', factorData.length) |
|
|
pLog('本地化项目监测因素',factorDataLocal) |
|
|
pLog('本地化项目监测因素', factorDataLocal) |
|
|
//合并(安心云+本地化项目)
|
|
|
//合并(安心云+本地化项目)
|
|
|
factorData=[...factorDataLocal,...factorData] |
|
|
factorData = [...factorDataLocal, ...factorData] |
|
|
pLog('安心云+本地监测因素',factorData.length) |
|
|
pLog('安心云+本地监测因素', factorData.length) |
|
|
let factorId = factorData.map(f => f.id) |
|
|
let factorId = factorData.map(f => f.id) |
|
|
let factorIdLocal=factorIdLocal.map(f => f.id) |
|
|
let factorIdLocal = factorIdLocal.map(f => f.id) |
|
|
//查询结构物对应的测点(安心云)
|
|
|
//查询结构物对应的测点(安心云)
|
|
|
let equipment = await clickHouse.dataAlarm.query( |
|
|
let equipment = await clickHouse.dataAlarm.query( |
|
|
`
|
|
|
`
|
|
@ -1225,13 +1225,13 @@ module.exports = function (app, opts) { |
|
|
FROM sensors |
|
|
FROM sensors |
|
|
WHERE sensors.StructId IN (${[...dataAlarmStructureId].join(',')},-1) |
|
|
WHERE sensors.StructId IN (${[...dataAlarmStructureId].join(',')},-1) |
|
|
AND sensors.SafetyFactorTypeId IN (${factorIdLocal.join(',')},-1) |
|
|
AND sensors.SafetyFactorTypeId IN (${factorIdLocal.join(',')},-1) |
|
|
`
|
|
|
` |
|
|
).toPromise() || [] |
|
|
).toPromise() || [] |
|
|
pLog('安心云项目测点',equipment.length) |
|
|
pLog('安心云项目测点', equipment.length) |
|
|
pLog('本地化项目测点',equipmentLocal) |
|
|
pLog('本地化项目测点', equipmentLocal) |
|
|
//合并本地化数据+安心云数据
|
|
|
//合并本地化数据+安心云数据
|
|
|
equipment=[...equipment,...equipmentLocal] |
|
|
equipment = [...equipment, ...equipmentLocal] |
|
|
pLog('本地化+安心云测点',equipment.length) |
|
|
pLog('本地化+安心云测点', equipment.length) |
|
|
const alarmDataRes = await clickHouse.dataAlarm.query( |
|
|
const alarmDataRes = await clickHouse.dataAlarm.query( |
|
|
`
|
|
|
`
|
|
|
SELECT |
|
|
SELECT |
|
@ -1243,27 +1243,27 @@ 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.SubDevices AS SubDevices |
|
|
FROM |
|
|
FROM |
|
|
alarms |
|
|
alarms |
|
|
WHERE |
|
|
WHERE |
|
|
alarms.StructureId In (${[...dataAlarmG1StructureId,...dataAlarmStructureId].join(',')},-1) |
|
|
alarms.StructureId In (${[...dataAlarmG1StructureId, ...dataAlarmStructureId].join(',')},-1) |
|
|
AND |
|
|
AND |
|
|
alarms.AlarmGroup = 1 |
|
|
alarms.AlarmGroup = 1 |
|
|
AND |
|
|
AND |
|
|
alarms.State < 3 |
|
|
alarms.State < 3 |
|
|
` |
|
|
` |
|
|
// ,
|
|
|
|
|
|
// alarms.subStations AS subStations
|
|
|
|
|
|
).toPromise() || [] |
|
|
).toPromise() || [] |
|
|
let alarmDatas = [] |
|
|
let alarmDatas = [] |
|
|
for (let alarms of alarmDataRes) { |
|
|
for (let alarms of alarmDataRes) { |
|
|
if (alarms.subStations && alarms.subStations.length) { |
|
|
if (alarms.SubDevices && alarms.SubDevices.length) { |
|
|
pLog('拆解 subStations' + alarms.alarmId + ' ' + alarms.subStations.length + '个') |
|
|
pLog('拆解 SubDevices' + alarms.alarmId + ' ' + alarms.SubDevices.length + '个') |
|
|
for (let subStation of alarms.subStations) { |
|
|
for (let SubDevice of alarms.SubDevices) { |
|
|
alarmDatas.push({ |
|
|
alarmDatas.push({ |
|
|
...alarms, |
|
|
...alarms, |
|
|
alarmId: subStation |
|
|
alarmId: SubDevice |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
@ -1666,7 +1666,7 @@ module.exports = function (app, opts) { |
|
|
`).toPromise()
|
|
|
`).toPromise()
|
|
|
: [] |
|
|
: [] |
|
|
let receiverId = [] |
|
|
let receiverId = [] |
|
|
console.log('接收邮件的人',receiverRes) |
|
|
console.log('接收邮件的人', receiverRes) |
|
|
let emails = receiverRes.reduce((arr, r) => { |
|
|
let emails = receiverRes.reduce((arr, r) => { |
|
|
if (r.email) { |
|
|
if (r.email) { |
|
|
arr.push(r.email) |
|
|
arr.push(r.email) |
|
|