Browse Source

fix : Cannot read property 'length' of undefined

dev
CODE 1 year ago
parent
commit
84e27fb6b3
  1. 20
      api/app/lib/schedule/alarms_push.js

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

@ -1,7 +1,7 @@
const moment = require('moment') const moment = require('moment')
let isDev = false let isDev = false
// isDev = true isDev = true
let proDebug = false let proDebug = false
proDebug = true proDebug = true
@ -1179,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,-1].join(',')}) t_structure_factor.structure IN (${[...dataAlarmG1StructureId, -1].join(',')})
` `
).toPromise() || [] : [] ).toPromise() || [] : []
//查询结构物的监测因素(本地化项目) //查询结构物的监测因素(本地化项目)
@ -1188,14 +1188,14 @@ 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,-1].join(',')})` WHERE sensors.StructId in (${[...dataAlarmStructureId, -1].join(',')})`
).toPromise() || [] ).toPromise() || []
pLog('安心云项目监测因素', factorData.length) pLog('安心云项目监测因素', factorData.length)
pLog('本地化项目监测因素', factorDataLocal) pLog('本地化项目监测因素', factorDataLocal)
//安心云的factorId //安心云的factorId
let factorId = factorData.map(f => f.id) let factorId = factorData.map(f => f.id)
//本地化的factorId //本地化的factorId
let factorIdLocal=factorDataLocal.map(f => f.id) let factorIdLocal = factorDataLocal.map(f => f.id)
pLog('安心云+本地监测因素', factorData.length) pLog('安心云+本地监测因素', factorData.length)
//查询结构物对应的测点(安心云) //查询结构物对应的测点(安心云)
let equipment = await clickHouse.anxinyun.query( let equipment = await clickHouse.anxinyun.query(
@ -1210,9 +1210,9 @@ 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,-1].join(',')}) t_sensor.structure IN (${[...dataAlarmG1StructureId, -1].join(',')})
AND AND
t_sensor.factor IN (${[...factorId,-1].join(',')}) t_sensor.factor IN (${[...factorId, -1].join(',')})
` `
).toPromise() || [] ).toPromise() || []
//查询结构物对应的测点(本地化) //查询结构物对应的测点(本地化)
@ -1223,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,-1].join(',')}) WHERE sensors.StructId IN (${[...dataAlarmStructureId, -1].join(',')})
AND sensors.SafetyFactorTypeId IN (${[...factorIdLocal,-1].join(',')}) AND sensors.SafetyFactorTypeId IN (${[...factorIdLocal, -1].join(',')})
` `
).toPromise() || [] ).toPromise() || []
pLog('安心云项目测点', equipment.length) pLog('安心云项目测点', equipment.length)
@ -1248,7 +1248,7 @@ module.exports = function (app, opts) {
FROM FROM
alarms alarms
WHERE WHERE
alarms.StructureId In (${[...dataAlarmG1StructureId, ...dataAlarmStructureId,-1].join(',')}) alarms.StructureId In (${[...dataAlarmG1StructureId, ...dataAlarmStructureId, -1].join(',')})
AND AND
alarms.AlarmGroup = 1 alarms.AlarmGroup = 1
AND AND
@ -1307,7 +1307,7 @@ module.exports = function (app, opts) {
} }
} }
if (projectList.length) { if (true || projectList.length) {
pepProject_name.map(s => { pepProject_name.map(s => {
s.projects = [] s.projects = []
projectList.map(f => { projectList.map(f => {

Loading…
Cancel
Save