[Frontend][首頁] baja 函式: 查詢異常、復歸、已確認、未確認數量

This commit is contained in:
wanli 2022-12-05 01:28:24 +08:00
parent c90e3c320d
commit aa61e210fa

View File

@ -259,3 +259,119 @@ function getOneSystemStateByBaja(systemPath, callback) {
}); });
}); });
} }
/**
* [首頁] 查詢異常數量
* @param {any} callback
*/
function getAlarmCountByBaja(callback) {
var _result = "";
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()
.then(function (table) {
return table.cursor({
each: function (record) {
_index++;
},
after: function () {
_result += '{' + '"count": ' + _index;
_result += '}';
if (typeof callback === 'function') {
callback(_result);
}
},
limit: -1,
offset: 0
});
});
});
}
/**
* [首頁] 查詢復歸數量
* @param {any} callback
*/
function getRecoverCountByBaja(callback) {
var _result = "";
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()
.then(function (table) {
return table.cursor({
each: function (record) {
_index++;
},
after: function () {
_result += '{' + '"count": ' + _index;
_result += '}';
if (typeof callback === 'function') {
callback(_result);
}
},
limit: -1,
offset: 0
});
});
});
}
/**
* [首頁] 查詢已確認異常數量
* @param {any} callback
*/
function getCheckedAckedCountByBaja(callback) {
var _result = "";
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()
.then(function (table) {
return table.cursor({
each: function (record) {
_index++;
},
after: function () {
_result += '{' + '"count": ' + _index;
_result += '}';
if (typeof callback === 'function') {
callback(_result);
}
},
limit: -1,
offset: 0
});
});
});
}
/**
* [首頁] 查詢未確認異常數量
* @param {any} callback
*/
function getUnCheckedAckedCountByBaja(callback) {
var _result = "";
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()
.then(function (table) {
return table.cursor({
each: function (record) {
_index++;
},
after: function () {
_result += '{' + '"count": ' + _index;
_result += '}';
if (typeof callback === 'function') {
callback(_result);
}
},
limit: -1,
offset: 0
});
});
});
}