|
|
@ -556,7 +556,7 @@ module.exports = function (app, opts) { |
|
|
|
`).toPromise() : []
|
|
|
|
//合并本地化和安心云的告警
|
|
|
|
dataAlarms=[...dataAlarms,...dataAlarmsLocal] |
|
|
|
console.log('合并的告警列表(安心云+本地)',dataAlarms,dataAlarmsLocal) |
|
|
|
pLog('合并的告警列表(安心云+本地)',dataAlarms.length,dataAlarmsLocal.length) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -918,7 +918,6 @@ module.exports = function (app, opts) { |
|
|
|
|
|
|
|
pLog(`查得数据告警 ${dataAlarms.length} 条`); |
|
|
|
// pLog(dataAlarms);
|
|
|
|
console.log('dataAlarms111',dataAlarms) |
|
|
|
if (dataAlarms.length) { |
|
|
|
const alarmIds = dataAlarms |
|
|
|
.map(ar => "'" + ar.AlarmId + "'") |
|
|
@ -934,7 +933,6 @@ module.exports = function (app, opts) { |
|
|
|
|
|
|
|
let deviceIds = new Set() |
|
|
|
for (let d of dataAlarms) { |
|
|
|
console.log('xxxxx1111',d) |
|
|
|
d = { ...d, stationId: d.id } |
|
|
|
|
|
|
|
/** 按监测因素筛选 且为测点告警 */ |
|
|
@ -1105,7 +1103,6 @@ module.exports = function (app, opts) { |
|
|
|
|
|
|
|
deviceStatistic.add(d.SourceId) |
|
|
|
} |
|
|
|
console.log('xxxxx1112',c) |
|
|
|
if (c.tactics == 'abnormal_rate') { |
|
|
|
pLog(`异常设备数量 - ${deviceStatistic.size}`) |
|
|
|
pLog(`异常视频告警数量 - ${videoAlarms.length}`) |
|
|
@ -1123,7 +1120,6 @@ module.exports = function (app, opts) { |
|
|
|
} |
|
|
|
// 注1
|
|
|
|
if (apMergeDeVeAnxinProjectId_.length || isDev) { |
|
|
|
console.log('xascascasca',isDev) |
|
|
|
for (let a of videoAlarms) { |
|
|
|
let existStruc = a.struc.find(asc => apMergeDeVeAlarms[asc.id] || isDev) |
|
|
|
if (existStruc) { |
|
|
@ -1154,8 +1150,7 @@ module.exports = function (app, opts) { |
|
|
|
` |
|
|
|
|
|
|
|
let dataAlarmG1Data = dataAlarms.filter(a => a.AlarmGroup == 1) |
|
|
|
console.log('dataAlarmG1Datasssss',dataAlarms) |
|
|
|
console.log('dataAlarmG1Datasssss',dataAlarmG1Data.length) |
|
|
|
pLog('数据中断',dataAlarmG1Data.length) |
|
|
|
if (dataAlarmG1Data.length) { |
|
|
|
//安心云项目是structureId数组
|
|
|
|
let dataAlarmG1StructureId = new Set() |
|
|
@ -1168,7 +1163,8 @@ module.exports = function (app, opts) { |
|
|
|
dataAlarmG1StructureId.add(c.StructureId) |
|
|
|
} |
|
|
|
}) |
|
|
|
console.log('xxx1qqqq',dataAlarmG1StructureId) |
|
|
|
pLog('安心云项目结构物id',dataAlarmG1StructureId) |
|
|
|
pLog('本地化项目结构物id',dataAlarmStructureId) |
|
|
|
//查询结构物的监测因素(安心云)
|
|
|
|
let factorData = await clickHouse.anxinyun.query( |
|
|
|
`
|
|
|
@ -1181,7 +1177,7 @@ module.exports = function (app, opts) { |
|
|
|
LEFT JOIN t_factor |
|
|
|
ON t_factor.id = t_structure_factor.factor |
|
|
|
WHERE |
|
|
|
t_structure_factor.structure IN (${[...dataAlarmG1StructureId]}) |
|
|
|
t_structure_factor.structure IN (${[...dataAlarmG1StructureId].join(',')},'-1') |
|
|
|
` |
|
|
|
).toPromise() || [] |
|
|
|
//查询结构物的监测因素(本地化项目)
|
|
|
@ -1190,11 +1186,13 @@ module.exports = function (app, opts) { |
|
|
|
StructId AS structureId,SafetyFactorTypeName AS name,SafetyFactorTypeId AS id |
|
|
|
FROM |
|
|
|
sensors |
|
|
|
WHERE sensors.StructId in (${[...dataAlarmStructureId]})` |
|
|
|
WHERE sensors.StructId in (${[...dataAlarmStructureId].join(',')},'-1')` |
|
|
|
).toPromise() || [] |
|
|
|
console.log('factorDataLocal',factorDataLocal) |
|
|
|
pLog('安心云项目监测因素',factorData.length) |
|
|
|
pLog('本地化项目监测因素',factorDataLocal) |
|
|
|
//合并(安心云+本地化项目)
|
|
|
|
factorData=[...factorDataLocal,...factorData] |
|
|
|
pLog('安心云+本地监测因素',factorData.length) |
|
|
|
let factorId = factorData.map(f => f.id) |
|
|
|
let factorIdLocal=factorIdLocal.map(f => f.id) |
|
|
|
//查询结构物对应的测点(安心云)
|
|
|
@ -1210,7 +1208,7 @@ module.exports = function (app, opts) { |
|
|
|
LEFT JOIN t_device_sensor |
|
|
|
ON t_device_sensor.sensor = t_sensor.id |
|
|
|
WHERE |
|
|
|
t_sensor.structure IN (${[...dataAlarmG1StructureId]},) |
|
|
|
t_sensor.structure IN (${[...dataAlarmG1StructureId].join(',')},'-1') |
|
|
|
AND |
|
|
|
t_sensor.factor IN (${factorId.join(',')}) |
|
|
|
` |
|
|
@ -1223,13 +1221,15 @@ module.exports = function (app, opts) { |
|
|
|
SafetyFactorTypeId AS factorId, |
|
|
|
SensorId AS iotaDeviceId |
|
|
|
FROM sensors |
|
|
|
WHERE sensors.StructId IN (${[...dataAlarmStructureId]},) |
|
|
|
AND sensors.SafetyFactorTypeId IN (${factorIdLocal.join(',')}) |
|
|
|
WHERE sensors.StructId IN (${[...dataAlarmStructureId].join(',')},'-1') |
|
|
|
AND sensors.SafetyFactorTypeId IN (${factorIdLocal.join(',')},'-1') |
|
|
|
`
|
|
|
|
).toPromise() || [] |
|
|
|
console.log('equipmentLocal',equipmentLocal) |
|
|
|
pLog('安心云项目测点',equipment.length) |
|
|
|
pLog('本地化项目测点',equipmentLocal) |
|
|
|
//合并本地化数据+安心云数据
|
|
|
|
equipment=[...equipment,...equipmentLocal] |
|
|
|
pLog('本地化+安心云测点',equipment.length) |
|
|
|
const alarmDataRes = await clickHouse.dataAlarm.query( |
|
|
|
`
|
|
|
|
SELECT |
|
|
@ -1245,7 +1245,7 @@ module.exports = function (app, opts) { |
|
|
|
FROM |
|
|
|
alarms |
|
|
|
WHERE |
|
|
|
alarms.StructureId In (${[...dataAlarmG1StructureId,...dataAlarmStructureId]}) |
|
|
|
alarms.StructureId In (${[...dataAlarmG1StructureId,...dataAlarmStructureId].join(',')},'-1') |
|
|
|
AND |
|
|
|
alarms.AlarmGroup = 1 |
|
|
|
AND |
|
|
@ -1254,7 +1254,6 @@ module.exports = function (app, opts) { |
|
|
|
// ,
|
|
|
|
// alarms.subStations AS subStations
|
|
|
|
).toPromise() || [] |
|
|
|
console.log('alarmDataRes111',alarmDataRes) |
|
|
|
let alarmDatas = [] |
|
|
|
for (let alarms of alarmDataRes) { |
|
|
|
if (alarms.subStations && alarms.subStations.length) { |
|
|
|