Browse Source

11111111111

dev
wenlele 2 years ago
parent
commit
3dbcb4ea37
  1. 35
      api/app/lib/schedule/alarms_push.js

35
api/app/lib/schedule/alarms_push.js

@ -829,28 +829,47 @@ module.exports = function (app, opts) {
t_sensor.name AS name,
t_sensor.structure AS structureId,
t_sensor.factor AS factorId,
t_device_sensor.iota_device_id AS iotaDeviceId,
${dataAlarm}.alarms.State AS state,
${dataAlarm}.alarms.AlarmGroup AS alarmGroup,
${dataAlarm}.alarms.SourceId AS sourceId
t_device_sensor.iota_device_id AS iotaDeviceId
FROM
t_sensor
LEFT JOIN t_device_sensor
ON t_device_sensor.sensor = t_sensor.id
LEFT JOIN ${dataAlarm}.alarms
ON ${dataAlarm}.alarms.SourceId = t_device_sensor.iota_device_id
WHERE
t_sensor.structure = (${d.StructureId})
AND
t_sensor.factor IN (${factorId.join(',')})
`
).toPromise() || []
const alarmDatas = await clickHouse.dataAlarm.query(
`
SELECT
alarms.id AS id,
alarms.State AS state,
alarms.AlarmGroup AS alarmGroup,
alarms.SourceId AS sourceId
FROM
alarms
WHERE
alarms.StructureId = (${d.StructureId})
AND
alarms.AlarmGroup = 1
AND
${dataAlarm}.alarms.AlarmGroup = 1
alarms.State < 3
`
).toPromise() || []
equipment.map(r => {
alarmDatas.map(u => {
if (r.iotaDeviceId == u.sourceId) {
r.sourceId = u.sourceId
}
})
})
d.factor = []
factorData.map(c => {
let breakData = equipment.filter(m => (m.iotaDeviceId && m.sourceId && m.state < 3 && m.alarmGroup == 1 && m.factorId == c.id))
let breakData = equipment.filter(m => (m.factorId == c.id && m.sourceId))
d.factor.push({
name: c.name,
sum: equipment.length,

Loading…
Cancel
Save