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 + }); + }); + }); +}