[frontend] 告警系統 增加設備名稱 | 系統監控的小卡片修正
This commit is contained in:
parent
bc1b2470dd
commit
ed9add4f64
1580
Frontend/_alert.html
1580
Frontend/_alert.html
File diff suppressed because it is too large
Load Diff
@ -1410,9 +1410,9 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
|
||||
{
|
||||
"title": "發生/完成時間",
|
||||
"data": "normalTime",
|
||||
"render": function (data, type, row) {
|
||||
return row.timestamp + "<br>" + data;
|
||||
},
|
||||
//"render": function (data, type, row) {
|
||||
// return row.timestamp + "<br>" + data;
|
||||
//},
|
||||
},
|
||||
|
||||
];
|
||||
|
@ -93,20 +93,28 @@ function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, i
|
||||
var _index = 0;
|
||||
var _recoverState = isRecover ? "!= null" : "= null";
|
||||
var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
|
||||
/*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 alarmClass = '" + alarmClass + "' and timestamp.millis > " + startDate_millisecond + " and timestamp.millis < " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp asc")*/
|
||||
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 alarmClass = '" + alarmClass + "' and timestamp.millis > " + startDate_millisecond + " and timestamp.millis < " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp asc")
|
||||
require(['baja!'], function (baja) {
|
||||
baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackTime, 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) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
_sourceTmp = (record.get('alarmData').get('sourceName')).toString().split('_');
|
||||
const alarmDisplayName = record.get('alarmData').get('sourceName').split(":")[1] ?? record.get('alarmData').get('sourceName').split(":")[0]
|
||||
//console.log(alarmDisplayName)
|
||||
_sourceTmp = alarmDisplayName.split('_');
|
||||
_bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
||||
_sourceName = _sourceTmp[7] + "-" + _sourceTmp[8];
|
||||
_ss.push({ buildingFloorName_zh: _bfName, uuid: record.get('uuid'), timestamp: record.get('timestamp').$cEncStr, alarmClass: record.get('alarmClass'), sourceName_zh: _sourceName, msgText: record.get('alarmData').get('msgText'), ackState: record.get('ackState'), normalTime: record.get('normalTime'), ackedTime: record.get('ackTime').$cEncStr })
|
||||
_sourceName = _sourceTmp.slice(0, 8).join("_");
|
||||
_sourceTmp = _sourceTmp[7] + "-" + _sourceTmp[8];
|
||||
if (!_sourceTmp.includes("undefined")) {
|
||||
_ss.push({ buildingFloorName_zh: _bfName, uuid: record.get('uuid'), timestamp: record.get('timestamp').$cEncStr, alarmClass: record.get('alarmClass'), sourceName_zh: _sourceName, sourceTmp: _sourceTmp, msgText: record.get('alarmData').get('msgText'), ackState: record.get('ackState'), normalTime: record.get('normalTime'), ackedTime: record.get('ackTime').$cEncStr })
|
||||
}
|
||||
_index++
|
||||
},
|
||||
after: function () {
|
||||
_result = { count: _index, data: _ss }
|
||||
|
||||
//console.log(552, _result);
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
callback(_result);
|
||||
}
|
||||
@ -153,8 +161,8 @@ function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, i
|
||||
// });
|
||||
// }
|
||||
function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
|
||||
var _result = "";
|
||||
var _ss = "";
|
||||
var _result = {};
|
||||
var _ss = [];
|
||||
var _occurrenceTime = "";
|
||||
var _normalTime = "";
|
||||
var _index = 0;
|
||||
@ -166,28 +174,23 @@ function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
|
||||
each: function (record) {
|
||||
_occurrenceTime = "";
|
||||
_normalTime = "";
|
||||
// console.log(record.get('timestamp'),record.get('normalTime') )
|
||||
var _resultUuid = record.get('uuid').toString().split("-");//43dc7846-bd96-4be2-ab35-f11aec729c60
|
||||
|
||||
var _timestampTemp = new Date(record.get('timestamp').toString());
|
||||
_occurrenceTime += _timestampTemp.getFullYear().toString() + "-" + addzero(_timestampTemp.getMonth() + 1).toString() + "-" + addzero(_timestampTemp.getDate()).toString() + " " + addzero(_timestampTemp.getHours()).toString() + ":" + addzero(_timestampTemp.getMinutes()).toString() + ":" + addzero(_timestampTemp.getSeconds()).toString();
|
||||
var _occurrenceTime = new Date(record.get('timestamp').$cEncStr).toLocaleString('zh-tw', { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit" });
|
||||
// _occurrenceTime += _timestampTemp.getFullYear().toString() + "-" + addzero(_timestampTemp.getMonth() + 1).toString() + "-" + addzero(_timestampTemp.getDate()).toString() + " " + addzero(_timestampTemp.getHours()).toString() + ":" + addzero(_timestampTemp.getMinutes()).toString() + ":" + addzero(_timestampTemp.getSeconds()).toString();
|
||||
|
||||
//var _occurrenceTime = _timestamp.format("yyyy-MM-dd hh:mm:ss");//.toLocaleString();
|
||||
var _normaltime = new Date(record.get('normalTime').toString());
|
||||
_normalTime += _normaltime.getFullYear().toString() + "-" + addzero(_normaltime.getMonth() + 1).toString() + "-" + addzero(_normaltime.getDate()).toString() + " " + addzero(_normaltime.getHours()).toString() + ":" + addzero(_normaltime.getMinutes()).toString() + ":" + addzero(_normaltime.getSeconds()).toString();
|
||||
var _normalTime = new Date(record.get('normalTime').$cEncStr).toLocaleString('zh-tw', { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit" });
|
||||
// _normalTime += _normaltime.getFullYear().toString() + "-" + addzero(_normaltime.getMonth() + 1).toString() + "-" + addzero(_normaltime.getDate()).toString() + " " + addzero(_normaltime.getHours()).toString() + ":" + addzero(_normaltime.getMinutes()).toString() + ":" + addzero(_normaltime.getSeconds()).toString();
|
||||
|
||||
var _msgText = record.get('alarmData').get('msgText');// == 1 ? _occurrenceTime : "未確認";
|
||||
var _ackText = record.get('ackState') == 1 ? _occurrenceTime : "未確認";
|
||||
|
||||
if (_index == 0)
|
||||
_ss += '{"uuid":"' + _resultUuid[0] + '", "msgText":"' + _msgText + '", "ackState":"' + _ackText + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
|
||||
else
|
||||
_ss += ',{"uuid":"' + _resultUuid[0] + '", "msgText":"' + _msgText + '", "ackState":"' + _ackText + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
|
||||
_ss.push({ uuid: _resultUuid[0], msgText: _msgText, ackState: _ackText, timestamp: _occurrenceTime, normalTime: _normalTime })
|
||||
_index++;
|
||||
},
|
||||
after: function () {
|
||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||
_result += _ss + ']';
|
||||
_result += '}';
|
||||
_result = JSON.stringify({ count: _index, data: _ss })
|
||||
if (typeof callback === 'function') {
|
||||
callback(_result);
|
||||
}
|
||||
@ -233,7 +236,7 @@ function getOneSystemAlarmStateByBaja(systemPath, callback) {
|
||||
var _result = "";
|
||||
var _ss = "";
|
||||
var _index = 0;
|
||||
console.log("local:|foxs:|alarm:|bql:select alarmData, alarmData.sourceName, sourceState, uuid where alarmData.sourceName like '%" + systemPath + "%' order by timestamp desc")
|
||||
/* console.log("local:|foxs:|alarm:|bql:select alarmData, alarmData.sourceName, sourceState, uuid where alarmData.sourceName like '%" + systemPath + "%' order by timestamp desc")*/
|
||||
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) {
|
||||
@ -528,7 +531,7 @@ function getOneDeviceAlarmByBaja(devicePath, callback) {
|
||||
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");
|
||||
/* 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({
|
||||
@ -542,7 +545,7 @@ function getOneDeviceAlarmByBaja(devicePath, callback) {
|
||||
after: function () {
|
||||
_result = { count: _index, data: _ss }
|
||||
|
||||
console.log(552, _result);
|
||||
//console.log(552, _result);
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
callback(_result);
|
||||
@ -561,12 +564,12 @@ function getAllDeviceAlarmByBaja(startDate_millisecond, endDate_millisecond, isR
|
||||
var _recoverState = isRecover ? "!= null" : "= null";
|
||||
var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
|
||||
|
||||
let startUrl = "";
|
||||
if (startDate_millisecond) {
|
||||
startUrl = "timestamp.millis >= " + startDate_millisecond + " and ";
|
||||
}
|
||||
// console.log("local:|foxs:|alarm:|bql:select timestamp, ackTime, priority ,ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc");
|
||||
require(['baja!'], function (baja) {
|
||||
let startUrl = "";
|
||||
if (startDate_millisecond) {
|
||||
startUrl = "timestamp.millis >= " + startDate_millisecond + " and ";
|
||||
}
|
||||
// console.log("local:|foxs:|alarm:|bql:select timestamp, ackTime, priority ,ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc");
|
||||
|
||||
baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackTime, priority ,ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc").get()
|
||||
.then(function (table) {
|
||||
@ -574,30 +577,35 @@ function getAllDeviceAlarmByBaja(startDate_millisecond, endDate_millisecond, isR
|
||||
each: function (record) {
|
||||
// console.log(record,record.get('alarmData').get('sourceName').split(':'))
|
||||
let main = {};
|
||||
console.log(record.get('alarmData').get('sourceName'), record.get('timestamp').$cEncStr)
|
||||
_sourcePoint = (record.get('alarmData').get('sourceName')).toString().split(':')[0];
|
||||
_sourceTmp = _sourcePoint.split("_");
|
||||
// console.log(record.get('alarmData').get('sourceName'),record.get('timestamp').$cEncStr)
|
||||
const alarmDisplayName = record.get('alarmData').get('sourceName').split(":")[1] ?? record.get('alarmData').get('sourceName').split(":")[0]
|
||||
//console.log(alarmDisplayName)
|
||||
_sourceTmp = alarmDisplayName.split('_');
|
||||
let _bfName = _sourceTmp[1] + "-" + _sourceTmp[4]
|
||||
let _sourceName = _sourceTmp.slice(0, 8).join("_");
|
||||
_sourceTmp = _sourceTmp[7] + "-" + _sourceTmp[8];
|
||||
|
||||
let _bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
||||
let _sourceName = _sourceTmp[7] + "-" + _sourceTmp[8];
|
||||
main.buildingFloorName_zh = _bfName;
|
||||
main.sourceName_zh = _sourceName;
|
||||
main.uuid = record.get('uuid').$val;
|
||||
main.timestamp = record.get('timestamp').$cEncStr;
|
||||
main.alarmClass = record.get('alarmClass');
|
||||
main.point = _sourcePoint;
|
||||
main.devicePath = _sourceTmp.slice(0, 8).join("_");;
|
||||
main.point = _sourceTmp;
|
||||
main.sourceTmp = _sourceTmp;
|
||||
main.devicePath = _sourceName;
|
||||
main.msgText = record.get('alarmData').get('msgText');
|
||||
main.normalTime = record.get('normalTime');
|
||||
main.priority = record.get('priority');
|
||||
main.ackedTime = record.get('ackTime').$cEncStr;
|
||||
_result.data.push(main);
|
||||
if (!_sourceTmp.includes("undefined")) {
|
||||
_result.data.push(main);
|
||||
}
|
||||
_index++;
|
||||
},
|
||||
after: function () {
|
||||
_result.count = _index;
|
||||
if (typeof callback === 'function') {
|
||||
console.log(_result)
|
||||
//console.log(_result)
|
||||
callback(_result);
|
||||
}
|
||||
},
|
||||
@ -620,16 +628,16 @@ function getDeviceAlarmCardByBaja(startDate_millisecond, endDate_millisecond, is
|
||||
if (startDate_millisecond) {
|
||||
startUrl = "timestamp.millis >= " + startDate_millisecond + " and ";
|
||||
}
|
||||
console.log("local:|foxs:|alarm:|bql:select timestamp, ackTime, priority ,ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc");
|
||||
/* console.log("local:|foxs:|alarm:|bql:select timestamp, ackTime, priority ,ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc");*/
|
||||
|
||||
baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackTime, priority ,ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc").get()
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
let main = {};
|
||||
console.log(record.get('alarmData').get('sourceName'))
|
||||
//console.log(record.get('alarmData').get('sourceName'))
|
||||
_sourcePoint = (record.get('alarmData').get('sourceName')).toString().split(':')[1];
|
||||
console.log(_sourcePoint)
|
||||
//console.log(_sourcePoint)
|
||||
_sourceTmp = _sourcePoint.split("_");
|
||||
|
||||
let _bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
||||
|
Loading…
Reference in New Issue
Block a user