51 lines
2.1 KiB
JavaScript
51 lines
2.1 KiB
JavaScript
// 首頁指定區域報警訊息(Model)
|
|
export async function getBuiAlarmStateByBaja(area_tag, building_tag) {
|
|
return new Promise((resolve) => {
|
|
let result = [];
|
|
window.require(["baja!"], function (baja) {
|
|
baja.Ord.make(
|
|
`local:|foxs:|alarm:|bql:select alarmData, alarmData.sourceName, sourceState, uuid, ackState where alarmData.sourceName like '%${area_tag}_${building_tag}%' order by timestamp desc`,
|
|
).get({
|
|
cursor: {
|
|
before: function () {
|
|
console.log("alarm before");
|
|
},
|
|
each: function () {
|
|
const { msgText, sourceName } = this.get("alarmData").$map.$map;
|
|
const { $enc: ackState } = this.get("ackState").getType();
|
|
const { $enc: sourceState } = this.get("sourceState").getType();
|
|
// 在選單上的顯示警告,只須出現在緊急的 offnormal 設備
|
|
if (sourceState !== "normal") {
|
|
result.push({
|
|
msgText,
|
|
sourceName,
|
|
ackState,
|
|
sourceState,
|
|
uuid: this.get("uuid").$val,
|
|
});
|
|
}
|
|
},
|
|
after: function () {
|
|
console.log("alarm after");
|
|
resolve(result);
|
|
},
|
|
limit: -1,
|
|
},
|
|
});
|
|
});
|
|
});
|
|
}
|
|
// 選定期間報警
|
|
export function getDeviceAlarmByBaja(
|
|
ord,
|
|
{ alarmClass, startDate_millisecond, endDate_millisecond, recoverState, ackState },
|
|
) {
|
|
var _recoverState = recoverState ? "!= null" : "= null";
|
|
var _ackState = ackState ? "= 'acked'" : "= 'unacked'";
|
|
window.requirejs(["baja!"], (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}_AlarmClass' and timestamp.millis > '${startDate_millisecond}' and timestamp.millis < '${endDate_millisecond}' and normalTime ${_recoverState} and ackState ${_ackState} order by timestamp asc`,
|
|
);
|
|
});
|
|
}
|