|
|
@ -130,6 +130,7 @@ module.exports = function (app, opts) { |
|
|
|
pepProject_name.push({ id: poms.id, anxinProjectId: poms.anxinProjectId, name: corPepProject.project_name }) |
|
|
|
} else { |
|
|
|
// 不符合当前项目的时间节点
|
|
|
|
pLog(`不符合当前项目的时间节点`) |
|
|
|
continue |
|
|
|
} |
|
|
|
} else { |
|
|
@ -220,6 +221,7 @@ module.exports = function (app, opts) { |
|
|
|
searchStrucIds.unshift(-1) |
|
|
|
} else { |
|
|
|
// 没有结构物可查
|
|
|
|
pLog(`没有结构物可查`) |
|
|
|
continue |
|
|
|
} |
|
|
|
let pepProjectName = |
|
|
@ -654,8 +656,6 @@ module.exports = function (app, opts) { |
|
|
|
}, { |
|
|
|
n: '告警信息', |
|
|
|
k: 'AlarmContent' |
|
|
|
}, { |
|
|
|
|
|
|
|
}, { |
|
|
|
n: '告警等级(当前)', |
|
|
|
k: '', |
|
|
@ -1045,12 +1045,9 @@ module.exports = function (app, opts) { |
|
|
|
* 以测点关联 |
|
|
|
*/ |
|
|
|
if ( |
|
|
|
isDev || |
|
|
|
( |
|
|
|
apMergeDeVeAnxinProjectId_.length && |
|
|
|
d.SourceName && d.SourceName.includes('扬尘') && |
|
|
|
apMergeDeVeAnxinProjectId_.some(pid => pid == (strucMap[d.StructureId] || {}).projectId) |
|
|
|
) |
|
|
|
apMergeDeVeAnxinProjectId_.length && |
|
|
|
d.SourceName && d.SourceName.includes('扬尘') && |
|
|
|
apMergeDeVeAnxinProjectId_.some(pid => pid == (strucMap[d.StructureId] || {}).projectId) |
|
|
|
) { |
|
|
|
// SourceTypeId 0: 'DTU' / 1: '传感器' / 2: '测点'
|
|
|
|
|
|
|
@ -1113,6 +1110,7 @@ module.exports = function (app, opts) { |
|
|
|
pLog(`异常比率 ${rate} 设定值 ${deviceProportion}`) |
|
|
|
if (rate < parseFloat(deviceProportion)) { |
|
|
|
// 设备异常率低于设定值
|
|
|
|
pLog(`异常设备率低于设定值`) |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
@ -1121,9 +1119,9 @@ module.exports = function (app, opts) { |
|
|
|
.replace('**', abnormalDeviceCount.toFixed(0)) |
|
|
|
} |
|
|
|
// 注1
|
|
|
|
if (apMergeDeVeAnxinProjectId_.length || isDev) { |
|
|
|
if (apMergeDeVeAnxinProjectId_.length) { |
|
|
|
for (let a of videoAlarms) { |
|
|
|
let existStruc = a.struc.find(asc => apMergeDeVeAlarms[asc.id] || isDev) |
|
|
|
let existStruc = a.struc.find(asc => apMergeDeVeAlarms[asc.id]) |
|
|
|
if (existStruc) { |
|
|
|
apMergeDeVeAlarms[existStruc.id].video_exception.push(a) |
|
|
|
} |
|
|
@ -1179,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,-1].join(',')}) |
|
|
|
t_structure_factor.structure IN (${[...dataAlarmG1StructureId, -1].join(',')}) |
|
|
|
` |
|
|
|
).toPromise() || [] : [] |
|
|
|
//查询结构物的监测因素(本地化项目)
|
|
|
@ -1188,14 +1186,14 @@ module.exports = function (app, opts) { |
|
|
|
StructId AS structureId,SafetyFactorTypeName AS name,SafetyFactorTypeId AS id |
|
|
|
FROM |
|
|
|
sensors |
|
|
|
WHERE sensors.StructId in (${[...dataAlarmStructureId,-1].join(',')})` |
|
|
|
WHERE sensors.StructId in (${[...dataAlarmStructureId, -1].join(',')})` |
|
|
|
).toPromise() || [] |
|
|
|
pLog('安心云项目监测因素', factorData.length) |
|
|
|
pLog('本地化项目监测因素', factorDataLocal) |
|
|
|
//安心云的factorId
|
|
|
|
let factorId = factorData.map(f => f.id) |
|
|
|
//本地化的factorId
|
|
|
|
let factorIdLocal=factorDataLocal.map(f => f.id) |
|
|
|
let factorIdLocal = factorDataLocal.map(f => f.id) |
|
|
|
pLog('安心云+本地监测因素', factorData.length) |
|
|
|
//查询结构物对应的测点(安心云)
|
|
|
|
let equipment = await clickHouse.anxinyun.query( |
|
|
@ -1210,9 +1208,9 @@ module.exports = function (app, opts) { |
|
|
|
LEFT JOIN t_device_sensor |
|
|
|
ON t_device_sensor.sensor = t_sensor.id |
|
|
|
WHERE |
|
|
|
t_sensor.structure IN (${[...dataAlarmG1StructureId,-1].join(',')}) |
|
|
|
t_sensor.structure IN (${[...dataAlarmG1StructureId, -1].join(',')}) |
|
|
|
AND |
|
|
|
t_sensor.factor IN (${[...factorId,-1].join(',')}) |
|
|
|
t_sensor.factor IN (${[...factorId, -1].join(',')}) |
|
|
|
` |
|
|
|
).toPromise() || [] |
|
|
|
//查询结构物对应的测点(本地化)
|
|
|
@ -1223,8 +1221,8 @@ module.exports = function (app, opts) { |
|
|
|
SafetyFactorTypeId AS factorId, |
|
|
|
SensorId AS iotaDeviceId |
|
|
|
FROM sensors |
|
|
|
WHERE sensors.StructId IN (${[...dataAlarmStructureId,-1].join(',')}) |
|
|
|
AND sensors.SafetyFactorTypeId IN (${[...factorIdLocal,-1].join(',')}) |
|
|
|
WHERE sensors.StructId IN (${[...dataAlarmStructureId, -1].join(',')}) |
|
|
|
AND sensors.SafetyFactorTypeId IN (${[...factorIdLocal, -1].join(',')}) |
|
|
|
` |
|
|
|
).toPromise() || [] |
|
|
|
pLog('安心云项目测点', equipment.length) |
|
|
@ -1248,7 +1246,7 @@ module.exports = function (app, opts) { |
|
|
|
FROM |
|
|
|
alarms |
|
|
|
WHERE |
|
|
|
alarms.StructureId In (${[...dataAlarmG1StructureId, ...dataAlarmStructureId,-1].join(',')}) |
|
|
|
alarms.StructureId In (${[...dataAlarmG1StructureId, ...dataAlarmStructureId, -1].join(',')}) |
|
|
|
AND |
|
|
|
alarms.AlarmGroup = 1 |
|
|
|
AND |
|
|
@ -1307,7 +1305,7 @@ module.exports = function (app, opts) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (projectList.length) { |
|
|
|
if (true || projectList.length) { |
|
|
|
pepProject_name.map(s => { |
|
|
|
s.projects = [] |
|
|
|
projectList.map(f => { |
|
|
@ -1631,10 +1629,11 @@ module.exports = function (app, opts) { |
|
|
|
de.id = corSensor.sensor |
|
|
|
} |
|
|
|
} |
|
|
|
let corVideoException = curStrucAlarm.video_exception.filter(v => { |
|
|
|
// ! de.id 是告警信息关联查出来的测点的id
|
|
|
|
return v.station.some(vs => vs.id == de.id) |
|
|
|
}) |
|
|
|
let corVideoException = |
|
|
|
curStrucAlarm.video_exception ? curStrucAlarm.video_exception.filter(v => { |
|
|
|
// ! de.id 是告警信息关联查出来的测点的id
|
|
|
|
return v.station.some(vs => vs.id == de.id) |
|
|
|
}) : [] |
|
|
|
if (!corVideoException.length) { |
|
|
|
// 构造一个长度 以便在for循环里把 data_exception 放进去
|
|
|
|
corVideoException.push({}) |
|
|
@ -1691,7 +1690,7 @@ module.exports = function (app, opts) { |
|
|
|
html: html |
|
|
|
}) |
|
|
|
|
|
|
|
//存日志 存动态 socket到前端
|
|
|
|
// //存日志 存动态 socket到前端
|
|
|
|
let dataToSave = { |
|
|
|
time: moment().format(), |
|
|
|
pushConfigId: c.id, |
|
|
|