Merge branch 'master' of https://gitea.mjm-staging.developers-homelab.net/BIMS/BIMS
This commit is contained in:
commit
30e926f95c
Binary file not shown.
106
Frontend/js/n4js/alarmbaja.js
Normal file
106
Frontend/js/n4js/alarmbaja.js
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* 取得異常資料 by baja
|
||||||
|
* @param {any} startDate_millisecond
|
||||||
|
* @param {any} endDate_millisecond
|
||||||
|
* @param {any} isRecover
|
||||||
|
* @param {any} isAck
|
||||||
|
* @param {any} alarmClass
|
||||||
|
* @param {any} callback
|
||||||
|
*/
|
||||||
|
function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, isAck, alarmClass, callback) {
|
||||||
|
let _sourceTmp;
|
||||||
|
var _result = "";
|
||||||
|
var _ss = "";
|
||||||
|
var _bfName = "";
|
||||||
|
var _sourceName = "";
|
||||||
|
var _index = 0;
|
||||||
|
var _recoverState = isRecover ? "!= null" : "= null"
|
||||||
|
var _ackState = isAck ? "= 1" : "!= 1";
|
||||||
|
|
||||||
|
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()
|
||||||
|
.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];
|
||||||
|
_ss += ', "' + _index + '": {"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;
|
||||||
|
_result += _ss;
|
||||||
|
_result += '}';
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
callback(_result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取得單一設備最新10筆異常資料 by baja
|
||||||
|
* @param {any} devicePath
|
||||||
|
* @param {any} callback
|
||||||
|
*/
|
||||||
|
function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
|
||||||
|
var _result = "";
|
||||||
|
var _ss = "";
|
||||||
|
var _index = 0;
|
||||||
|
|
||||||
|
require(['baja!'], function (baja) {
|
||||||
|
baja.Ord.make("local:|foxs:|alarm:|bql:select top 10 timestamp, ackState, alarmData, alarmData.sourceName, sourceState, uuid, alarmData.msgText, normalTime where alarmData.sourceName like '%" + devicePath + "%' order by timestamp desc").get()
|
||||||
|
.then(function (table) {
|
||||||
|
return table.cursor({
|
||||||
|
each: function (record) {
|
||||||
|
_ss += ', "' + _index + '": {"uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "sourceName":"' + record.get('alarmData').get('sourceName') + '", "sourceState":"' + record.get('sourceState') + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||||
|
_index++;
|
||||||
|
},
|
||||||
|
after: function () {
|
||||||
|
_result += '{' + '"count": ' + _index;
|
||||||
|
_result += _ss;
|
||||||
|
_result += '}';
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
callback(_result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在單一系統下,取得各個設備的異常狀態
|
||||||
|
* @param {any} systemPath
|
||||||
|
* @param {any} callback
|
||||||
|
*/
|
||||||
|
function getOneSystemAlarmStateByBaja(systemPath, callback) {
|
||||||
|
var _result = "";
|
||||||
|
var _ss = "";
|
||||||
|
var _index = 0;
|
||||||
|
|
||||||
|
require(['baja!'], function (baja) {
|
||||||
|
baja.Ord.make("local:|foxs:|alarm:|bql:select alarmData, alarmData.sourceName, sourceState, uuid where alarmData.sourceName like '%" + systemPath + "%' order by timestamp desc").get()
|
||||||
|
.then(function (table) {
|
||||||
|
return table.cursor({
|
||||||
|
each: function (record) {
|
||||||
|
_ss += ', "' + _index + '": {"uuid":"' + record.get('uuid') + '", "sourceName":"' + record.get('alarmData').get('sourceName') + '", "sourceState":"' + record.get('sourceState') + '"}';
|
||||||
|
_index++;
|
||||||
|
},
|
||||||
|
after: function () {
|
||||||
|
_result += '{' + '"count": ' + _index;
|
||||||
|
_result += _ss;
|
||||||
|
_result += '}';
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
callback(_result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -1,79 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 取得歷史資料 by baja
|
|
||||||
* @param {any} devicePath
|
|
||||||
* @param {any} startDate_millisecond
|
|
||||||
* @param {any} endDate_millisecond
|
|
||||||
* @param {any} deviceName
|
|
||||||
* @param {any} company
|
|
||||||
* @param {any} callback
|
|
||||||
*/
|
|
||||||
function getHistoryDataByBaja(devicePath, startDate_millisecond, endDate_millisecond, deviceName, company, callback) {
|
|
||||||
var _result = "";
|
|
||||||
var _ss = "";
|
|
||||||
var _index = 0;
|
|
||||||
|
|
||||||
require(['baja!'], function (baja) {
|
|
||||||
baja.Ord.make('local:|foxs:|history:/' + company + '/' + devicePath + '|bql:select * from control:ControlPoint where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond).get()
|
|
||||||
.then(function (table) {
|
|
||||||
return table.cursor({
|
|
||||||
each: function (record) {
|
|
||||||
_ss += ', "' + _index + '": {"deviceName":"' + deviceName + '", "value":' + record.get('value') + ', "timestamp":"' + record.get('timestamp') + '"}';
|
|
||||||
_index++;
|
|
||||||
},
|
|
||||||
after: function () {
|
|
||||||
_result += '{' + '"count": ' + _index;
|
|
||||||
_result += _ss;
|
|
||||||
_result += '}';
|
|
||||||
if (typeof callback === 'function') {
|
|
||||||
callback(_result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 取得異常資料 by baja
|
|
||||||
* @param {any} startDate_millisecond
|
|
||||||
* @param {any} endDate_millisecond
|
|
||||||
* @param {any} isRecover
|
|
||||||
* @param {any} isAck
|
|
||||||
* @param {any} alarmClass
|
|
||||||
* @param {any} callback
|
|
||||||
*/
|
|
||||||
function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, isAck, alarmClass, callback) {
|
|
||||||
let _sourceTmp;
|
|
||||||
var _result = "";
|
|
||||||
var _ss = "";
|
|
||||||
var _bfName = "";
|
|
||||||
var _sourceName = "";
|
|
||||||
var _index = 0;
|
|
||||||
var _recoverState = isRecover ? "!= null" : "= null"
|
|
||||||
var _ackState = isAck ? "= 1" : "!= 1";
|
|
||||||
|
|
||||||
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()
|
|
||||||
.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];
|
|
||||||
_ss += ', "' + _index + '": {"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;
|
|
||||||
_result += _ss;
|
|
||||||
_result += '}';
|
|
||||||
if (typeof callback === 'function') {
|
|
||||||
callback(_result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
37
Frontend/js/n4js/historybaja.js
Normal file
37
Frontend/js/n4js/historybaja.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* 取得歷史資料 by baja
|
||||||
|
* @param {any} devicePath
|
||||||
|
* @param {any} startDate_millisecond
|
||||||
|
* @param {any} endDate_millisecond
|
||||||
|
* @param {any} deviceName
|
||||||
|
* @param {any} company
|
||||||
|
* @param {any} callback
|
||||||
|
*/
|
||||||
|
function getHistoryDataByBaja(devicePath, startDate_millisecond, endDate_millisecond, deviceName, company, callback) {
|
||||||
|
var _result = "";
|
||||||
|
var _ss = "";
|
||||||
|
var _index = 0;
|
||||||
|
|
||||||
|
require(['baja!'], function (baja) {
|
||||||
|
baja.Ord.make('local:|foxs:|history:/' + company + '/' + devicePath + '|bql:select * from control:ControlPoint where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond).get()
|
||||||
|
.then(function (table) {
|
||||||
|
return table.cursor({
|
||||||
|
each: function (record) {
|
||||||
|
_ss += ', "' + _index + '": {"deviceName":"' + deviceName + '", "value":' + record.get('value') + ', "timestamp":"' + record.get('timestamp') + '"}';
|
||||||
|
_index++;
|
||||||
|
},
|
||||||
|
after: function () {
|
||||||
|
_result += '{' + '"count": ' + _index;
|
||||||
|
_result += _ss;
|
||||||
|
_result += '}';
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
callback(_result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user