|
@ -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 = (msg) => { |
|
|
const pLog = (msg1,msg2) => { |
|
|
if (proDebug) { |
|
|
if (proDebug) { |
|
|
console.log(msg) |
|
|
console.log(msg1,msg2) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -288,7 +288,7 @@ module.exports = function (app, opts) { |
|
|
let deviceCountRes = |
|
|
let deviceCountRes = |
|
|
strucThingId.length ? |
|
|
strucThingId.length ? |
|
|
await clickHouse.iot.query(` |
|
|
await clickHouse.iot.query(` |
|
|
SELECT count(id) AS count FROM Device WHERE thingId IN (${strucThingId.map(t => `'${t}'`).join(',')}, '-1') |
|
|
SELECT count(id) AS count FROM Device WHERE thingId IN (${strucThingId.map(t => `'${t}'`).join(',')}, -1) |
|
|
`).toPromise()
|
|
|
`).toPromise()
|
|
|
: [] |
|
|
: [] |
|
|
deviceCount = deviceCountRes.length ? deviceCountRes[0].count : 0 |
|
|
deviceCount = deviceCountRes.length ? deviceCountRes[0].count : 0 |
|
@ -556,7 +556,9 @@ module.exports = function (app, opts) { |
|
|
`).toPromise() : []
|
|
|
`).toPromise() : []
|
|
|
//合并本地化和安心云的告警
|
|
|
//合并本地化和安心云的告警
|
|
|
dataAlarms=[...dataAlarms,...dataAlarmsLocal] |
|
|
dataAlarms=[...dataAlarms,...dataAlarmsLocal] |
|
|
pLog('合并的告警列表(安心云+本地)',dataAlarms.length,dataAlarmsLocal.length) |
|
|
pLog('合并的告警列表(安心云+本地)',dataAlarms.length) |
|
|
|
|
|
pLog('合并的告警列表(安心云+本地)',dataAlarmsLocal.length) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -924,7 +926,7 @@ module.exports = function (app, opts) { |
|
|
dataAlarmDetails = |
|
|
dataAlarmDetails = |
|
|
await clickHouse.dataAlarm.query(` |
|
|
await clickHouse.dataAlarm.query(` |
|
|
SELECT * FROM alarm_details |
|
|
SELECT * FROM alarm_details |
|
|
WHERE AlarmId IN (${alarmIds.join(',')}, '-1') |
|
|
WHERE AlarmId IN (${alarmIds.join(',')}, -1) |
|
|
AND AlarmState = 0 |
|
|
AND AlarmState = 0 |
|
|
`).toPromise()
|
|
|
`).toPromise()
|
|
|
} |
|
|
} |
|
@ -1177,7 +1179,7 @@ module.exports = function (app, opts) { |
|
|
LEFT JOIN t_factor |
|
|
LEFT JOIN t_factor |
|
|
ON t_factor.id = t_structure_factor.factor |
|
|
ON t_factor.id = t_structure_factor.factor |
|
|
WHERE |
|
|
WHERE |
|
|
t_structure_factor.structure IN (${[...dataAlarmG1StructureId].join(',')},'-1') |
|
|
t_structure_factor.structure IN (${[...dataAlarmG1StructureId].join(',')},-1) |
|
|
` |
|
|
` |
|
|
).toPromise() || [] |
|
|
).toPromise() || [] |
|
|
//查询结构物的监测因素(本地化项目)
|
|
|
//查询结构物的监测因素(本地化项目)
|
|
@ -1186,7 +1188,7 @@ module.exports = function (app, opts) { |
|
|
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) |
|
@ -1208,7 +1210,7 @@ module.exports = function (app, opts) { |
|
|
LEFT JOIN t_device_sensor |
|
|
LEFT JOIN t_device_sensor |
|
|
ON t_device_sensor.sensor = t_sensor.id |
|
|
ON t_device_sensor.sensor = t_sensor.id |
|
|
WHERE |
|
|
WHERE |
|
|
t_sensor.structure IN (${[...dataAlarmG1StructureId].join(',')},'-1') |
|
|
t_sensor.structure IN (${[...dataAlarmG1StructureId].join(',')},-1) |
|
|
AND |
|
|
AND |
|
|
t_sensor.factor IN (${factorId.join(',')}) |
|
|
t_sensor.factor IN (${factorId.join(',')}) |
|
|
` |
|
|
` |
|
@ -1221,8 +1223,8 @@ module.exports = function (app, opts) { |
|
|
SafetyFactorTypeId AS factorId, |
|
|
SafetyFactorTypeId AS factorId, |
|
|
SensorId AS iotaDeviceId |
|
|
SensorId AS iotaDeviceId |
|
|
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) |
|
@ -1245,7 +1247,7 @@ module.exports = function (app, opts) { |
|
|
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 |
|
|