|  | @ -130,6 +130,7 @@ module.exports = function (app, opts) { | 
			
		
	
		
		
			
				
					|  |  |                                  pepProject_name.push({ id: poms.id, anxinProjectId: poms.anxinProjectId, name: corPepProject.project_name }) |  |  |                                  pepProject_name.push({ id: poms.id, anxinProjectId: poms.anxinProjectId, name: corPepProject.project_name }) | 
			
		
	
		
		
			
				
					|  |  |                               } else { |  |  |                               } else { | 
			
		
	
		
		
			
				
					|  |  |                                  // 不符合当前项目的时间节点
 |  |  |                                  // 不符合当前项目的时间节点
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                  pLog(`不符合当前项目的时间节点`) | 
			
		
	
		
		
			
				
					|  |  |                                  continue |  |  |                                  continue | 
			
		
	
		
		
			
				
					|  |  |                               } |  |  |                               } | 
			
		
	
		
		
			
				
					|  |  |                            } else { |  |  |                            } else { | 
			
		
	
	
		
		
			
				
					|  | @ -220,6 +221,7 @@ module.exports = function (app, opts) { | 
			
		
	
		
		
			
				
					|  |  |                         searchStrucIds.unshift(-1) |  |  |                         searchStrucIds.unshift(-1) | 
			
		
	
		
		
			
				
					|  |  |                      } else { |  |  |                      } else { | 
			
		
	
		
		
			
				
					|  |  |                         // 没有结构物可查
 |  |  |                         // 没有结构物可查
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         pLog(`没有结构物可查`) | 
			
		
	
		
		
			
				
					|  |  |                         continue |  |  |                         continue | 
			
		
	
		
		
			
				
					|  |  |                      } |  |  |                      } | 
			
		
	
		
		
			
				
					|  |  |                      let pepProjectName = |  |  |                      let pepProjectName = | 
			
		
	
	
		
		
			
				
					|  | @ -654,8 +656,6 @@ module.exports = function (app, opts) { | 
			
		
	
		
		
			
				
					|  |  |                      }, { |  |  |                      }, { | 
			
		
	
		
		
			
				
					|  |  |                         n: '告警信息', |  |  |                         n: '告警信息', | 
			
		
	
		
		
			
				
					|  |  |                         k: 'AlarmContent' |  |  |                         k: 'AlarmContent' | 
			
		
	
		
		
			
				
					|  |  |                      }, { |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                      }, { |  |  |                      }, { | 
			
		
	
		
		
			
				
					|  |  |                         n: '告警等级(当前)', |  |  |                         n: '告警等级(当前)', | 
			
		
	
		
		
			
				
					|  |  |                         k: '', |  |  |                         k: '', | 
			
		
	
	
		
		
			
				
					|  | @ -1045,12 +1045,9 @@ module.exports = function (app, opts) { | 
			
		
	
		
		
			
				
					|  |  |                             *    以测点关联 |  |  |                             *    以测点关联 | 
			
		
	
		
		
			
				
					|  |  |                            */ |  |  |                            */ | 
			
		
	
		
		
			
				
					|  |  |                            if ( |  |  |                            if ( | 
			
		
	
		
		
			
				
					
					|  |  |                               isDev || |  |  |                               apMergeDeVeAnxinProjectId_.length && | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                               ( |  |  |                               d.SourceName && d.SourceName.includes('扬尘') && | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                                  apMergeDeVeAnxinProjectId_.length && |  |  |                               apMergeDeVeAnxinProjectId_.some(pid => pid == (strucMap[d.StructureId] || {}).projectId) | 
			
				
				
			
		
	
		
		
			
				
					|  |  |                                  d.SourceName && d.SourceName.includes('扬尘') && |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                                  apMergeDeVeAnxinProjectId_.some(pid => pid == (strucMap[d.StructureId] || {}).projectId) |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                               ) |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |                            ) { |  |  |                            ) { | 
			
		
	
		
		
			
				
					|  |  |                               // SourceTypeId   0: 'DTU' / 1: '传感器' / 2: '测点'
 |  |  |                               // SourceTypeId   0: 'DTU' / 1: '传感器' / 2: '测点'
 | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | @ -1113,6 +1110,7 @@ module.exports = function (app, opts) { | 
			
		
	
		
		
			
				
					|  |  |                         pLog(`异常比率 ${rate} 设定值 ${deviceProportion}`) |  |  |                         pLog(`异常比率 ${rate} 设定值 ${deviceProportion}`) | 
			
		
	
		
		
			
				
					|  |  |                         if (rate < parseFloat(deviceProportion)) { |  |  |                         if (rate < parseFloat(deviceProportion)) { | 
			
		
	
		
		
			
				
					|  |  |                            // 设备异常率低于设定值
 |  |  |                            // 设备异常率低于设定值
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                            pLog(`异常设备率低于设定值`) | 
			
		
	
		
		
			
				
					|  |  |                            continue |  |  |                            continue | 
			
		
	
		
		
			
				
					|  |  |                         } |  |  |                         } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | @ -1121,9 +1119,9 @@ module.exports = function (app, opts) { | 
			
		
	
		
		
			
				
					|  |  |                            .replace('**', abnormalDeviceCount.toFixed(0)) |  |  |                            .replace('**', abnormalDeviceCount.toFixed(0)) | 
			
		
	
		
		
			
				
					|  |  |                      } |  |  |                      } | 
			
		
	
		
		
			
				
					|  |  |                      // 注1 
 |  |  |                      // 注1 
 | 
			
		
	
		
		
			
				
					
					|  |  |                      if (apMergeDeVeAnxinProjectId_.length || isDev) { |  |  |                      if (apMergeDeVeAnxinProjectId_.length) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |                         for (let a of videoAlarms) { |  |  |                         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) { |  |  |                            if (existStruc) { | 
			
		
	
		
		
			
				
					|  |  |                               apMergeDeVeAlarms[existStruc.id].video_exception.push(a) |  |  |                               apMergeDeVeAlarms[existStruc.id].video_exception.push(a) | 
			
		
	
		
		
			
				
					|  |  |                            } |  |  |                            } | 
			
		
	
	
		
		
			
				
					|  | @ -1179,7 +1177,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 +1186,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 +1208,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 +1221,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 +1246,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 +1305,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 => { | 
			
		
	
	
		
		
			
				
					|  | @ -1631,10 +1629,11 @@ module.exports = function (app, opts) { | 
			
		
	
		
		
			
				
					|  |  |                                     de.id = corSensor.sensor |  |  |                                     de.id = corSensor.sensor | 
			
		
	
		
		
			
				
					|  |  |                                  } |  |  |                                  } | 
			
		
	
		
		
			
				
					|  |  |                               } |  |  |                               } | 
			
		
	
		
		
			
				
					
					|  |  |                               let corVideoException = curStrucAlarm.video_exception.filter(v => { |  |  |                               let corVideoException = | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                                  // ! de.id 是告警信息关联查出来的测点的id 
 |  |  |                                  curStrucAlarm.video_exception ? curStrucAlarm.video_exception.filter(v => { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                                  return v.station.some(vs => vs.id == de.id) |  |  |                                     // ! de.id 是告警信息关联查出来的测点的id 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                               }) |  |  |                                     return v.station.some(vs => vs.id == de.id) | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |                                  }) : [] | 
			
		
	
		
		
			
				
					|  |  |                               if (!corVideoException.length) { |  |  |                               if (!corVideoException.length) { | 
			
		
	
		
		
			
				
					|  |  |                                  // 构造一个长度 以便在for循环里把 data_exception 放进去
 |  |  |                                  // 构造一个长度 以便在for循环里把 data_exception 放进去
 | 
			
		
	
		
		
			
				
					|  |  |                                  corVideoException.push({}) |  |  |                                  corVideoException.push({}) | 
			
		
	
	
		
		
			
				
					|  | @ -1691,7 +1690,7 @@ module.exports = function (app, opts) { | 
			
		
	
		
		
			
				
					|  |  |                               html: html |  |  |                               html: html | 
			
		
	
		
		
			
				
					|  |  |                            }) |  |  |                            }) | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |                            //存日志 存动态 socket到前端
 |  |  |                            // //存日志 存动态 socket到前端
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |                            let dataToSave = { |  |  |                            let dataToSave = { | 
			
		
	
		
		
			
				
					|  |  |                               time: moment().format(), |  |  |                               time: moment().format(), | 
			
		
	
		
		
			
				
					|  |  |                               pushConfigId: c.id, |  |  |                               pushConfigId: c.id, | 
			
		
	
	
		
		
			
				
					|  | 
 |