From 2db82f49aa4a539b65b0d8c1a000afdc4e581167 Mon Sep 17 00:00:00 2001 From: wanli Date: Tue, 6 Dec 2022 22:56:13 +0800 Subject: [PATCH] =?UTF-8?q?[Frontend]=20baja=E8=AA=9E=E6=B3=95:=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=A9=A2=E7=95=B0=E5=B8=B8=E3=80=81?= =?UTF-8?q?=E5=BE=A9=E6=AD=B8=E3=80=81=E5=B7=B2=E7=A2=BA=E8=AA=8D=E3=80=81?= =?UTF-8?q?=E6=9C=AA=E7=A2=BA=E8=AA=8D=E6=95=B8=E9=87=8F=EF=BC=9B=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=8F=96=E5=BE=97=E6=AD=A3=E5=9C=A8=E7=95=B0=E5=B8=B8?= =?UTF-8?q?=E7=9A=84=E7=B3=BB=E7=B5=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/js/n4js/alarmbaja.js | 44 +++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/Frontend/js/n4js/alarmbaja.js b/Frontend/js/n4js/alarmbaja.js index 6f031e7..46d0171 100644 --- a/Frontend/js/n4js/alarmbaja.js +++ b/Frontend/js/n4js/alarmbaja.js @@ -273,7 +273,7 @@ function getAlarmCountByBaja(callback) { var _index = 0; require(['baja!'], function (baja) { - baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmData, alarmData.sourceName, sourceState, uuid, alarmData.msgText, normalTime where sourceState = 'offnormal' order by timestamp desc").get() + baja.Ord.make("local:|foxs:|alarm:|bql:select sourceState where sourceState = 'offnormal'").get() .then(function (table) { return table.cursor({ each: function (record) { @@ -301,7 +301,7 @@ function getRecoverCountByBaja(callback) { var _index = 0; require(['baja!'], function (baja) { - baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmData, alarmData.sourceName, sourceState, uuid, alarmData.msgText, normalTime where normalTime != null order by timestamp desc").get() + baja.Ord.make("local:|foxs:|alarm:|bql:select normalTime where normalTime != null").get() .then(function (table) { return table.cursor({ each: function (record) { @@ -329,7 +329,7 @@ function getCheckedAckedCountByBaja(callback) { var _index = 0; require(['baja!'], function (baja) { - baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where ackState ='acked' order by timestamp asc").get() + baja.Ord.make("local:|foxs:|alarm:|bql:select ackState from openAlarms where ackState ='acked'").get() .then(function (table) { return table.cursor({ each: function (record) { @@ -357,7 +357,7 @@ function getUnCheckedAckedCountByBaja(callback) { var _index = 0; require(['baja!'], function (baja) { - baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where ackState ='unacked' order by timestamp asc").get() + baja.Ord.make("local:|foxs:|alarm:|bql:select ackState from openAlarms where ackState ='unacked'").get() .then(function (table) { return table.cursor({ each: function (record) { @@ -375,3 +375,39 @@ function getUnCheckedAckedCountByBaja(callback) { }); }); } + +/** + * [首頁] 取得現在是異常的系統 (較快) + * @param {any} callback + */ +function getSystemAlarmByBaja(callback) { + var _result = ""; + var _ss = ""; + var _index = 0; + + require(['baja!'], function (baja) { + //baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime where isAlarm").get() + baja.Ord.make("local:|foxs:|alarm:|bql:select alarmClass where isAlarm").get() + .then(function (table) { + return table.cursor({ + each: function (record) { + if (_index == 0) + _ss += '{"alarmClass":"' + record.get('alarmClass') + '"}'; + else + _ss += ',{"alarmClass":"' + record.get('alarmClass') + '"}'; + _index++; + }, + after: function () { + _result += '{' + '"count": ' + _index + ', "data":['; + _result += _ss; + _result += ']}'; + if (typeof callback === 'function') { + callback(_result); + } + }, + limit: -1, + offset: 0 + }); + }); + }); +}