wenlele 2 years ago
parent
commit
f717b10ada
  1. 39
      api/app/lib/schedule/alarms_push.js
  2. 2
      api/app/lib/utils/alarmHandle.js
  3. 4
      web/client/src/sections/facility/containers/monitor.jsx
  4. 5
      web/client/src/sections/service/containers/reportManagement.jsx

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

@ -4,7 +4,7 @@ let isDev = false
// isDev = true
let proDebug = false
// proDebug = true
proDebug = true
module.exports = function (app, opts) {
const alarmsPush = app.fs.scheduleInit(
@ -681,7 +681,9 @@ module.exports = function (app, opts) {
console.log(`pomsStrucFactorId:`, pomsStrucFactorId);
}
let deviceIds = new Set()
for (let d of dataAlarms) {
d = { ...d, stationId: d.id }
/** 按监测因素筛选 且为测点告警 */
// if (pomsStrucFactorId && d.SourceTypeId == 2) {
@ -718,6 +720,11 @@ module.exports = function (app, opts) {
apMergeDeVeAnxinProjectId_.some(pid => pid == (strucMap[d.StructureId] || {}).projectId)
)
) {
// SourceTypeId 0: 'DTU' / 1: '传感器' / 2: '测点'
if (d.SourceTypeId != 2) {
deviceIds.add(d.SourceId)
}
if (apMergeDeVeAlarms[d.StructureId]) {
apMergeDeVeAlarms[d.StructureId].data_exception.push(d)
} else {
@ -886,6 +893,27 @@ module.exports = function (app, opts) {
}
if (Object.keys(apMergeDeVeAlarms).length) {
if (proDebug) {
console.log(`查得数据异常、视频异常合并の告警:`);
console.log(apMergeDeVeAlarms);
}
let deviceSensorRes = []
if (deviceIds.size) {
const device4Search = [...deviceIds]
.map(id => "'" + id + "'")
deviceSensorRes = await clickHouse.anxinyun.query(`
SELECT
iota_device_id, sensor
FROM t_device_sensor
WHERE iota_device_id
${device4Search.length > 1 ? `IN (${device4Search.join(',')})` : `= ${device4Search[0]}`}
`).toPromise()
}
if (proDebug) {
console.log(`相关设备及测点信息:`);
console.log(deviceSensorRes);
}
let alarmTitle = dataAlarmTitle.concat(
videoAlarmTitle.slice(2).map(v => {
return {
@ -900,9 +928,16 @@ module.exports = function (app, opts) {
let alarmData = []
for (let aKey in apMergeDeVeAlarms) {
let curStrucAlarm = apMergeDeVeAlarms[aKey]
for (let de of curStrucAlarm.data_exception) {
if (!de.id) {
let corSensor = deviceSensorRes.find(ds => ds.iota_device_id == de.SourceId)
if (corSensor) {
de.id = corSensor.sensor
}
}
let corVideoException = curStrucAlarm.video_exception.filter(v => {
// ! de.id 是告警的关联查出来的测点的id
// ! de.id 是告警信息关联查出来的测点的id
return v.station.some(vs => vs.id == de.id)
})
if (!corVideoException.length) {

2
api/app/lib/utils/alarmHandle.js

@ -110,7 +110,7 @@ module.exports = function (app, opts) {
}
let pepProjects = pepPojectIds.size ? await clickHouse.projectManage.query(`
SELECT id, project_name FROM t_pim_project WHERE id IN (${[...pepPojectIds]}, -1)`
SELECT id, project_name FROM t_pim_project WHERE id IN (${[...pepPojectIds].join(',')}, -1)`
).toPromise() : [];
return { projects, pepProjects };

4
web/client/src/sections/facility/containers/monitor.jsx

@ -14,7 +14,9 @@ const Server = (props) => {
return (
<>
<div>
<img src="/assets/images/install/watting.png" alt="" style={{ width: 'calc(100% + 16px)', position: "relative", top: -12, left: -8, }} />
{/* <img src="/assets/images/install/watting.png" alt="" style={{ width: 'calc(100% + 16px)', position: "relative", top: -12, left: -8, }} /> */}
{/* <iframe frameborder="0" src={`/_api/https://monitor.anxinyun.cn/login`} style={{height: '100%', width: '100%'}} /> */}
<iframe frameBorder="0" src={`https://monitor.anxinyun.cn`} style={{height: 'calc(100vh - 30px)', width: 'calc(100%)'}} />
</div>
</>
)

5
web/client/src/sections/service/containers/reportManagement.jsx

@ -13,8 +13,9 @@ const Rest = (props) => {
return (
<>
<div>
<img src="/assets/images/install/watting.png" alt="" style={{ width: 'calc(100% + 16px)', position: "relative", top: -12, left: -8, }} />
{/* style={{height: '100%', width: '100%',margin: '8px 12px', padding: '20px 20px 0px 20px'}} */}
<div >
<iframe frameBorder="0" src={`https://fsiot-oamss.anxinyun.cn/dataService/download?pcode=`} style={{height: 'calc(100vh - 30px)', width: 'calc(100%)'}} />
</div>
</>
)

Loading…
Cancel
Save