[Frontend] baja語法: 更改與增加取得異常資料的函式
This commit is contained in:
parent
ffbefcdba7
commit
b704d183e7
@ -19,11 +19,11 @@ function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, i
|
|||||||
var _bfName = "";
|
var _bfName = "";
|
||||||
var _sourceName = "";
|
var _sourceName = "";
|
||||||
var _index = 0;
|
var _index = 0;
|
||||||
var _recoverState = isRecover ? "!= null" : "= null"
|
var _recoverState = isRecover ? "!= null" : "= null";
|
||||||
var _ackState = isAck ? "= 1" : "!= 1";
|
var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
|
||||||
|
|
||||||
require(['baja!'], function (baja) {
|
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 alarmClass = '" + alarmClass + "' and timestamp.millis > " + startDate_millisecond + " and timestamp.millis < " + endDate_millisecond + " and normalTime " + _recoverState + " order by timestamp asc").get()
|
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 alarmClass = '" + alarmClass + "' and timestamp.millis > " + startDate_millisecond + " and timestamp.millis < " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp asc").get()
|
||||||
.then(function (table) {
|
.then(function (table) {
|
||||||
return table.cursor({
|
return table.cursor({
|
||||||
each: function (record) {
|
each: function (record) {
|
||||||
@ -52,6 +52,54 @@ function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, i
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取得所有異常資料 by baja
|
||||||
|
* @param {any} startDate_millisecond
|
||||||
|
* @param {any} endDate_millisecond
|
||||||
|
* @param {any} isRecover
|
||||||
|
* @param {any} isAck
|
||||||
|
* @param {any} callback
|
||||||
|
*/
|
||||||
|
function getAllDeviceAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, isAck, callback) {
|
||||||
|
let _sourceTmp;
|
||||||
|
var _result = "";
|
||||||
|
var _ss = "";
|
||||||
|
var _bfName = "";
|
||||||
|
var _sourceName = "";
|
||||||
|
var _index = 0;
|
||||||
|
var _recoverState = isRecover ? "!= null" : "= null";
|
||||||
|
var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
|
||||||
|
|
||||||
|
require(['baja!'], function (baja) {
|
||||||
|
console.log("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 timestamp.millis >= " + startDate_millisecond + " and timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc");
|
||||||
|
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 timestamp.millis >= " + startDate_millisecond + " and timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc").get()
|
||||||
|
.then(function (table) {
|
||||||
|
return table.cursor({
|
||||||
|
each: function (record) {
|
||||||
|
_sourceTmp = (record.get('alarmData').get('sourceName')).toString().split('_');
|
||||||
|
_bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
||||||
|
_sourceName = _sourceTmp[7] + "-" + _sourceTmp[8];
|
||||||
|
if (_index == 0)
|
||||||
|
_ss += '{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||||
|
else
|
||||||
|
_ss += ',{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||||
|
_index++;
|
||||||
|
},
|
||||||
|
after: function () {
|
||||||
|
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||||
|
_result += _ss + ']';
|
||||||
|
_result += '}';
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
callback(_result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
limit: -1,
|
||||||
|
offset: 0
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取得單一設備最新10筆異常資料 by baja
|
* 取得單一設備最新10筆異常資料 by baja
|
||||||
* @param {any} devicePath
|
* @param {any} devicePath
|
||||||
@ -107,13 +155,56 @@ function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
|
|||||||
/**
|
/**
|
||||||
* 取得單一設備異常
|
* 取得單一設備異常
|
||||||
* @param {any} devicePath
|
* @param {any} devicePath
|
||||||
|
* @param {any} callback
|
||||||
|
*/
|
||||||
|
function getOneDeviceAlarmByBaja(devicePath, callback) {
|
||||||
|
let _sourceTmp;
|
||||||
|
var _result = "";
|
||||||
|
var _ss = "";
|
||||||
|
var _bfName = "";
|
||||||
|
var _sourceName = "";
|
||||||
|
var _index = 0;
|
||||||
|
|
||||||
|
require(['baja!'], function (baja) {
|
||||||
|
console.log("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 alarmData.sourceName like '%" + devicePath + "%' order by timestamp desc");
|
||||||
|
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 alarmData.sourceName like '%" + devicePath + "%' order by timestamp desc").get()
|
||||||
|
.then(function (table) {
|
||||||
|
return table.cursor({
|
||||||
|
each: function (record) {
|
||||||
|
_sourceTmp = (record.get('alarmData').get('sourceName')).toString().split('_');
|
||||||
|
_bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
||||||
|
_sourceName = _sourceTmp[7] + "-" + _sourceTmp[8];
|
||||||
|
if (_index == 0)
|
||||||
|
_ss += '{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||||
|
else
|
||||||
|
_ss += ',{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||||
|
_index++;
|
||||||
|
},
|
||||||
|
after: function () {
|
||||||
|
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||||
|
_result += _ss + ']';
|
||||||
|
_result += '}';
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
callback(_result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
limit: -1,
|
||||||
|
offset: 0
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取得單一設備異常 有時間、確認、復歸條件
|
||||||
|
* @param {any} devicePath
|
||||||
* @param {any} startDate_millisecond
|
* @param {any} startDate_millisecond
|
||||||
* @param {any} endDate_millisecond
|
* @param {any} endDate_millisecond
|
||||||
* @param {any} isRecover
|
* @param {any} isRecover
|
||||||
* @param {any} isAck
|
* @param {any} isAck
|
||||||
* @param {any} callback
|
* @param {any} callback
|
||||||
*/
|
*/
|
||||||
function getOneDeviceAlarmByBaja(devicePath, startDate_millisecond, endDate_millisecond, isRecover, isAck, callback) {
|
function getOneDeviceAlarmWithTimeByBaja(devicePath, startDate_millisecond, endDate_millisecond, isRecover, isAck, callback) {
|
||||||
let _sourceTmp;
|
let _sourceTmp;
|
||||||
var _result = "";
|
var _result = "";
|
||||||
var _ss = "";
|
var _ss = "";
|
||||||
|
Loading…
Reference in New Issue
Block a user