This commit is contained in:
GiteaAdmin 2023-06-06 10:58:35 +08:00
commit ad0449eb52
8 changed files with 3114 additions and 2832 deletions

View File

@ -170,12 +170,12 @@ namespace Backend
); );
#endregion #endregion
#region API //#region 定時取得氣象API
services.AddSingleton<WeatherAPIJob>(); //services.AddSingleton<WeatherAPIJob>();
services.AddSingleton( //services.AddSingleton(
new JobSchedule(jobType: typeof(WeatherAPIJob), cronExpression: Configuration.GetValue<string>("BackgroundServiceCron:WeatherAPIJob")) //new JobSchedule(jobType: typeof(WeatherAPIJob), cronExpression: Configuration.GetValue<string>("BackgroundServiceCron:WeatherAPIJob"))
); //);
#endregion //#endregion
double loginExpireMinute = this.Configuration.GetValue<double>("LoginExpireMinute"); double loginExpireMinute = this.Configuration.GetValue<double>("LoginExpireMinute");
services.AddSession(options => services.AddSession(options =>

View File

@ -89,7 +89,7 @@
<span aria-hidden="true"><i class="fal fa-times"></i></span> <span aria-hidden="true"><i class="fal fa-times"></i></span>
</button> </button>
</div> </div>
<form id="opeRecForm"> <form id="alr_opeRecForm">
<div class="modal-body"> <div class="modal-body">
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
@ -200,8 +200,8 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" id="OpeRecCanBtn" data-dismiss="modal">關閉</button> <button type="button" class="btn btn-secondary" id="alr_OpeRecCanBtn" data-dismiss="modal">關閉</button>
<button type="button" class="btn btn-primary" id="OpeRecSendBtn" e-prevent>儲存</button> <button type="button" class="btn btn-primary" id="alr_OpeRecSendBtn" e-prevent>儲存</button>
</div> </div>
</form> </form>
</div> </div>
@ -218,7 +218,7 @@
pageAct.alrSelSysSub = []; pageAct.alrSelSysSub = [];
pageAct.selAllSysSub = false; pageAct.selAllSysSub = false;
first = true; first = true;
let dataAlarm = []; // let dataAlarm = [];
var historyTable = null; var historyTable = null;
var elemIndex = 0; var elemIndex = 0;
var index = 0; var index = 0;
@ -386,8 +386,8 @@
$('#inpFixDoCode').val(alr_fixDoCode); $('#inpFixDoCode').val(alr_fixDoCode);
}); });
onEvent('click', '#OpeRecSendBtn', function () { onEvent('click', '#alr_OpeRecSendBtn', function () {
let form = $("#opeRecForm"); let form = $("#alr_opeRecForm");
$(form).validate({ $(form).validate({
rules: { rules: {
inpWorTyp: { required: true }, inpWorTyp: { required: true },
@ -441,7 +441,7 @@
} else { } else {
//toast_ok(common.AddSuc); //toast_ok(common.AddSuc);
//$("#opeFirmModal").modal("hide"); //$("#opeFirmModal").modal("hide");
$("#OpeRecCanBtn").click(); $("#alr_OpeRecCanBtn").click();
getData(); getData();
} }
} }

View File

@ -144,6 +144,7 @@
var uploadFiles = {}; var uploadFiles = {};
var curActGraid = 0; var curActGraid = 0;
var cookies = new YourTeam.Utility.Cookie(); var cookies = new YourTeam.Utility.Cookie();
var token = cookies.get("JWT-Authorization"); var token = cookies.get("JWT-Authorization");
$(function () { $(function () {
initList(); initList();
@ -343,9 +344,9 @@
if (!res || res.code != "0000" || !res.data) { if (!res || res.code != "0000" || !res.data) {
} else { } else {
res.data.forEach(x => x.parent = x.system_parent_id); res.data.forEach(x => x.parent = x.parent_id);
res.data.forEach(x => x.text = x.system_key); res.data.forEach(x => x.text = x.name);
res.data.forEach(x => x.parent = x.parent); // res.data.forEach(x => x.parent = x.parent);
callback ? callback(res.data) : ""; callback ? callback(res.data) : "";
} }
}, null, "POST").send(); }, null, "POST").send();
@ -454,12 +455,12 @@
}) })
$("#graTree").on('create_node.jstree', function (e, data) { $("#graTree").on('create_node.jstree', function (e, data) {
let main = {}; let main = {};
main.system_key = data.node.text; main.name = data.node.text;
main.system_parent_id = parseInt(data.node.parent); main.parent_id = parseInt(data.node.parent);
objSendData.Data = main; objSendData.Data = main;
ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/SaveVar", objSendData, function (res) { ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/SaveGraphManageTree", objSendData, function (res) {
if (!res || res.code != "0000") { if (!res || res.code != "0000") {
data.instance.delete_node(data.node); data.instance.delete_node(data.node);
toast_error(res.msg || common.SysErr); toast_error(res.msg || common.SysErr);
@ -475,10 +476,10 @@
let main = {} let main = {}
main.id = parseInt(data.node.id); main.id = parseInt(data.node.id);
main.system_key = data.node.text; main.name = data.node.text;
objSendData.Data = main; objSendData.Data = main;
ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/EditVar", objSendData, function (res) { ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/EditGraphManageTree", objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) { if (!res || res.code != "0000" || !res.data) {
toast_error(res.msg || common.SysErr); toast_error(res.msg || common.SysErr);
} else { } else {
@ -495,7 +496,7 @@
if (!isNaN(parseInt(data.node.id))) { if (!isNaN(parseInt(data.node.id))) {
main.id = parseInt(data.node.id); main.id = parseInt(data.node.id);
objSendData.Data = main; objSendData.Data = main;
ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/DelVar", objSendData, function (res) { ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/DelGraphManageTree", objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) { if (!res || res.code != "0000" || !res.data) {
toast_error(res.msg || common.SysErr); toast_error(res.msg || common.SysErr);
} else { } else {

View File

@ -198,7 +198,7 @@
if ( if (
data.point_name == norDevPoiName && data.point_name == norDevPoiName &&
data.value == matchDevice.device_normal_point_value && (data.value == matchDevice.device_normal_point_value || norDevPoiName === errDevPoiName) &&
!deviceNormalArr.some( !deviceNormalArr.some(
({ device_number }) => device_number === matchDevice.device_number ({ device_number }) => device_number === matchDevice.device_number
) )

View File

@ -624,7 +624,7 @@
if ( if (
data.point_name == norDevPoiName && data.point_name == norDevPoiName &&
data.value == matchDevice.device_normal_point_value && (data.value == matchDevice.device_normal_point_value || norDevPoiName === errDevPoiName) &&
!deviceScatterNormalArr.some( !deviceScatterNormalArr.some(
({ device_number }) => data.device_number_full === device_number ({ device_number }) => data.device_number_full === device_number
) )

View File

@ -1152,7 +1152,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
getAlarmSub(data); getAlarmSub(data);
} }
alarmIconBlink(); alarmIconBlink(data);
}); });
getAlarm(); getAlarm();
}); });

View File

@ -1,6 +1,5 @@
function addzero(num) { function addzero(num) {
return num < 10 ? '0' + num : num; return num < 10 ? "0" + num : num;
} }
/** /**
@ -84,44 +83,76 @@ function addzero(num) {
// }); // });
// }); // });
// } // }
function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, isAck, alarmClass, callback) { function getAlarmByBaja(
startDate_millisecond,
endDate_millisecond,
isRecover,
isAck,
alarmClass,
callback
) {
let _sourceTmp; let _sourceTmp;
var _result = ""; var _result = "";
var _ss = []; var _ss = [];
var _bfName = ""; var _bfName = "";
var _sourceName = ""; var _sourceName = "";
var _index = 0; var _index = 0;
var _recoverState = isRecover ? "!= null" : "= null"; var _recoverState = isRecover ? "= 'normal'" : "= 'offnormal'";
var _ackState = isAck ? "= 'acked'" : "= 'unacked'"; 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 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 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) { 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 where alarmClass = '" + alarmClass + "' and timestamp.millis > " + startDate_millisecond + " and timestamp.millis < " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp asc").get() 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 where alarmClass = '" +
alarmClass +
"' and timestamp.millis > " +
startDate_millisecond +
" and timestamp.millis < " +
endDate_millisecond +
" and sourceState " +
_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) {
// console.log(record) const alarmDisplayName =
const alarmDisplayName = record.get('alarmData').get('sourceName').split(":")[1] ?? record.get('alarmData').get('sourceName').split(":")[0] record.get("alarmData").get("sourceName").split(":")[1] ??
record.get("alarmData").get("sourceName").split(":")[0];
//console.log(alarmDisplayName) //console.log(alarmDisplayName)
_sourceTmp = alarmDisplayName.split('_'); _sourceTmp = alarmDisplayName.split("_");
_bfName = _sourceTmp[1] + "-" + _sourceTmp[4]; _bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
_sourceName = _sourceTmp.slice(0, 8).join("_"); _sourceName = _sourceTmp.slice(0, 8).join("_");
_sourceTmp = _sourceTmp[7] + "-" + _sourceTmp[8]; _sourceTmp = _sourceTmp[7] + "-" + _sourceTmp[8];
if (!_sourceTmp.includes("undefined")) { 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 }) _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++ _index++;
}, },
after: function () { after: function () {
_result = { count: _index, data: _ss } _result = { count: _index, data: _ss };
//console.log(552, _result); //console.log(552, _result);
if (typeof callback === 'function') { if (typeof callback === "function") {
callback(_result); callback(_result);
} }
}, },
limit: -1, limit: -1,
offset: 0 offset: 0,
}); });
}); });
}); });
@ -168,36 +199,64 @@ function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
var _normalTime = ""; var _normalTime = "";
var _index = 0; var _index = 0;
//{ "count":2,"data": [{ "time": "2022/11/14 15:00:00", "errId": "0001", "ackCheck": "未確認", "errReason": "燈泡故障" }, { "time": "2022/11/14 15:00:00", "errId": "0002", "ackCheck": "未確認", "errReason": "燈泡故障" }]} //{ "count":2,"data": [{ "time": "2022/11/14 15:00:00", "errId": "0001", "ackCheck": "未確認", "errReason": "燈泡故障" }, { "time": "2022/11/14 15:00:00", "errId": "0002", "ackCheck": "未確認", "errReason": "燈泡故障" }]}
require(['baja!'], function (baja) { 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() 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) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
_occurrenceTime = ""; _occurrenceTime = "";
_normalTime = ""; _normalTime = "";
// console.log(record.get('timestamp'),record.get('normalTime') ) // console.log(record.get('timestamp'),record.get('normalTime') )
var _resultUuid = record.get('uuid').toString().split("-");//43dc7846-bd96-4be2-ab35-f11aec729c60 var _resultUuid = record.get("uuid").toString().split("-"); //43dc7846-bd96-4be2-ab35-f11aec729c60
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" }); 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(); // _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 _occurrenceTime = _timestamp.format("yyyy-MM-dd hh:mm:ss");//.toLocaleString();
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" }); 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(); // _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 _msgText = record.get("alarmData").get("msgText"); // == 1 ? _occurrenceTime : "未確認";
var _ackText = record.get('ackState') == 1 ? _occurrenceTime : "未確認"; var _ackText =
_ss.push({ uuid: _resultUuid[0], msgText: _msgText, ackState: _ackText, timestamp: _occurrenceTime, normalTime: _normalTime }) record.get("ackState") == 1 ? _occurrenceTime : "未確認";
_ss.push({
uuid: _resultUuid[0],
msgText: _msgText,
ackState: _ackText,
timestamp: _occurrenceTime,
normalTime: _normalTime,
});
_index++; _index++;
}, },
after: function () { after: function () {
_result = JSON.stringify({ count: _index, data: _ss }) _result = JSON.stringify({ count: _index, data: _ss });
if (typeof callback === 'function') { if (typeof callback === "function") {
callback(_result); callback(_result);
} }
}, },
limit: -1, limit: -1,
offset: 0 offset: 0,
}); });
}); });
}); });
@ -238,27 +297,46 @@ function getOneSystemAlarmStateByBaja(systemPath, callback) {
var _ss = ""; var _ss = "";
var _index = 0; 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) { 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() 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) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
if (_index == 0) if (_index == 0)
_ss += '{"uuid":"' + record.get('uuid') + '", "sourceName":"' + record.get('alarmData').get('sourceName') + '", "sourceState":"' + record.get('sourceState') + '"}'; _ss +=
'{"uuid":"' +
record.get("uuid") +
'", "sourceName":"' +
record.get("alarmData").get("sourceName") +
'", "sourceState":"' +
record.get("sourceState") +
'"}';
else else
_ss += ',{"uuid":"' + record.get('uuid') + '", "sourceName":"' + record.get('alarmData').get('sourceName') + '", "sourceState":"' + record.get('sourceState') + '"}'; _ss +=
',{"uuid":"' +
record.get("uuid") +
'", "sourceName":"' +
record.get("alarmData").get("sourceName") +
'", "sourceState":"' +
record.get("sourceState") +
'"}';
_index++; _index++;
}, },
after: function () { after: function () {
_result += '{' + '"count": ' + _index + ', "data":['; _result += "{" + '"count": ' + _index + ', "data":[';
_result += _ss; _result += _ss;
_result += ']}'; _result += "]}";
if (typeof callback === 'function') { if (typeof callback === "function") {
callback(_result); callback(_result);
} }
}, },
limit: -1, limit: -1,
offset: 0 offset: 0,
}); });
}); });
}); });
@ -274,8 +352,15 @@ function getOneSystemStateByBaja(systemPath, callback) {
var _ss = ""; var _ss = "";
var _index = 0; var _index = 0;
require(['baja!'], function (baja) { require(["baja!"], function (baja) {
baja.Ord.make("local:|foxs:|alarm:|bql:select top 1 alarmData, alarmData.sourceName, sourceState where alarmData.sourceName like '%" + systemPath + "%' order by timestamp desc").get() baja.Ord.make(
"local:|foxs:" +
port +
"|alarm:|bql:select top 1 alarmData, alarmData.sourceName, sourceState where alarmData.sourceName like '%" +
systemPath +
"%' order by timestamp desc"
)
.get()
.then(function (table) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
@ -283,19 +368,19 @@ function getOneSystemStateByBaja(systemPath, callback) {
// _ss += '{"sourceState":"' + record.get('sourceState') + '"}'; // _ss += '{"sourceState":"' + record.get('sourceState') + '"}';
//else //else
// _ss += '{"sourceState":"' + record.get('sourceState') + '"}'; // _ss += '{"sourceState":"' + record.get('sourceState') + '"}';
_ss += '{"sourceState":"' + record.get('sourceState') + '"}'; _ss += '{"sourceState":"' + record.get("sourceState") + '"}';
_index++; _index++;
}, },
after: function () { after: function () {
_result += '{' + '"count": ' + _index + ', "data":['; _result += "{" + '"count": ' + _index + ', "data":[';
_result += _ss; _result += _ss;
_result += ']}'; _result += "]}";
if (typeof callback === 'function') { if (typeof callback === "function") {
callback(_result); callback(_result);
} }
}, },
limit: -1, limit: -1,
offset: 0 offset: 0,
}); });
}); });
}); });
@ -309,21 +394,41 @@ function getAlarmCountByBaja(callback) {
var _result = { count: 0 }; var _result = { count: 0 };
var _index = 0; var _index = 0;
require(['baja!'], function (baja) { // require(['baja!'], function (baja) {
baja.Ord.make("local:|foxs:|alarm:|bql:select sourceState where sourceState = 'offnormal'").get() // baja.Ord.make("local:|foxs:"+port+"|alarm:|bql:select sourceState where sourceState = 'offnormal'").get()
// .then(function (table) {
// return table.cursor({
// each: function (record) {
// _index++;
// },
// after: function () {
// _result.count = _index;
// if (typeof callback === 'function') {
// callback(_result);
// }
// },
// limit: -1,
// offset: 0
// });
// });
// });
require(["baja!"], function (baja) {
baja.Ord.make(
"local:|foxs:" +
port +
"|alarm:|bql:select COUNT(*) where sourceState = 'offnormal'"
)
.get()
.then(function (table) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
_index++; if (typeof callback === "function") {
}, // console.log("@@@@@@@@@", record.get("COUNT$28toString$29").$val)
after: function () { callback(record.get("COUNT$28toString$29").$val);
_result.count = _index;
if (typeof callback === 'function') {
callback(_result);
} }
}, },
limit: -1, limit: -1,
offset: 0 offset: 0,
}); });
}); });
}); });
@ -337,21 +442,40 @@ function getRecoverCountByBaja(callback) {
var _result = { count: 0 }; var _result = { count: 0 };
var _index = 0; var _index = 0;
require(['baja!'], function (baja) { // require(['baja!'], function (baja) {
baja.Ord.make("local:|foxs:|alarm:|bql:select normalTime where normalTime != null").get() // baja.Ord.make("local:|foxs:"+port+"|alarm:|bql:select normalTime where normalTime != null").get()
// .then(function (table) {
// return table.cursor({
// each: function (record) {
// _index++;
// },
// after: function () {
// _result.count = _index;
// if (typeof callback === 'function') {
// callback(_result);
// }
// },
// limit: -1,
// offset: 0
// });
// });
// });
require(["baja!"], function (baja) {
baja.Ord.make(
"local:|foxs:" +
port +
"|alarm:|bql:select COUNT(*) where normalTime != null"
)
.get()
.then(function (table) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
_index++; if (typeof callback === "function") {
}, callback(record.get("COUNT$28toString$29").$val);
after: function () {
_result.count = _index;
if (typeof callback === 'function') {
callback(_result);
} }
}, },
limit: -1, limit: -1,
offset: 0 offset: 0,
}); });
}); });
}); });
@ -365,21 +489,40 @@ function getCheckedAckedCountByBaja(callback) {
var _result = { count: 0 }; var _result = { count: 0 };
var _index = 0; var _index = 0;
require(['baja!'], function (baja) { // require(['baja!'], function (baja) {
baja.Ord.make("local:|foxs:|alarm:|bql:select ackState where ackState ='acked'").get() // baja.Ord.make("local:|foxs:"+port+"|alarm:|bql:select ackState where ackState ='acked'").get()
// .then(function (table) {
// return table.cursor({
// each: function (record) {
// _index++;
// },
// after: function () {
// _result.count = _index;
// if (typeof callback === 'function') {
// callback(_result);
// }
// },
// limit: -1,
// offset: 0
// });
// });
// });
require(["baja!"], function (baja) {
baja.Ord.make(
"local:|foxs:" +
port +
"|alarm:|bql:select COUNT(*) where ackState='acked'"
)
.get()
.then(function (table) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
_index++; if (typeof callback === "function") {
}, callback(record.get("COUNT$28toString$29").$val);
after: function () {
_result.count = _index;
if (typeof callback === 'function') {
callback(_result);
} }
}, },
limit: -1, limit: -1,
offset: 0 offset: 0,
}); });
}); });
}); });
@ -392,22 +535,41 @@ function getCheckedAckedCountByBaja(callback) {
function getUnCheckedAckedCountByBaja(callback) { function getUnCheckedAckedCountByBaja(callback) {
var _result = { count: 0 }; var _result = { count: 0 };
var _index = 0; var _index = 0;
// console.log("######getUnCheckedAckedCountByBaja#######");
require(['baja!'], function (baja) { // require(['baja!'], function (baja) {
baja.Ord.make("local:|foxs:|alarm:|bql:select ackState where ackState ='unacked'").get() // baja.Ord.make("local:|foxs:"+port+"|alarm:|bql:select ackState where ackState ='unacked'").get()
// .then(function (table) {
// return table.cursor({
// each: function (record) {
// _index++;
// },
// after: function () {
// _result.count = _index;
// if (typeof callback === 'function') {
// callback(_result);
// }
// },
// limit: -1,
// offset: 0
// });
// });
// });
require(["baja!"], function (baja) {
baja.Ord.make(
"local:|foxs:" +
port +
"|alarm:|bql:select COUNT(*) where ackState='unacked'"
)
.get()
.then(function (table) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
_index++; if (typeof callback === "function") {
}, callback(record.get("COUNT$28toString$29").$val);
after: function () {
_result.count = _index;
if (typeof callback === 'function') {
callback(_result);
} }
}, },
limit: -1, limit: -1,
offset: 0 offset: 0,
}); });
}); });
}); });
@ -421,28 +583,33 @@ function getSystemAlarmByBaja(callback) {
var _result = { count: 0, data: [] }; var _result = { count: 0, data: [] };
var _index = 0; var _index = 0;
require(['baja!'], function (baja) { require(["baja!"], function (baja) {
// console.log("ip:202.39.218.221|foxs:4912|alarm:|bql:select alarmClass where isAlarm") // console.log("local:|foxs:"+ port +"|alarm:|bql:select alarmClass where isAlarm")
//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 where isAlarm").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 where isAlarm").get()
baja.Ord.make("local:|foxs:|alarm:|bql:select alarmClass where isAlarm").get() baja.Ord.make(
"local:|foxs:" +
port +
"|alarm:|bql:select alarmClass where sourceState = 'offnormal'"
)
.get()
.then(function (table) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
// console.log(record) // console.log(record)
let main = {}; let main = {};
main.alarmClass = record.get('alarmClass'); main.alarmClass = record.get("alarmClass");
_result.data.push(main); _result.data.push(main);
_index++; _index++;
}, },
after: function () { after: function () {
_result.count = _index; _result.count = _index;
if (typeof callback === 'function') { if (typeof callback === "function") {
callback(_result); callback(_result);
} }
}, },
limit: -1, limit: -1,
offset: 0 offset: 0,
}); });
}); });
}); });
@ -533,79 +700,130 @@ function getOneDeviceAlarmByBaja(devicePath, callback) {
var _sourceName = ""; var _sourceName = "";
var _index = 0; var _index = 0;
require(['baja!'], function (baja) { 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 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 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 where alarmData.sourceName like '%" + devicePath + "%' order by timestamp desc").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 where alarmData.sourceName like '%" +
devicePath +
"%' order by timestamp desc"
)
.get()
.then(function (table) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
_sourceTmp = (record.get('alarmData').get('sourceName')).toString().split('_'); _sourceTmp = record
.get("alarmData")
.get("sourceName")
.toString()
.split("_");
_bfName = _sourceTmp[1] + "-" + _sourceTmp[4]; _bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
_sourceName = _sourceTmp[7] + "-" + _sourceTmp[8]; _sourceName = _sourceTmp[7] + "-" + _sourceTmp[8];
_ss.push({ 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') }) _ss.push({
_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 () { after: function () {
_result = { count: _index, data: _ss } _result = { count: _index, data: _ss };
//console.log(552, _result); //console.log(552, _result);
if (typeof callback === 'function') { if (typeof callback === "function") {
callback(_result); callback(_result);
} }
}, },
limit: -1, limit: -1,
offset: 0 offset: 0,
}); });
}); });
}); });
} }
function getOtherAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, isAck, callback) { function getOtherAlarmByBaja(
startDate_millisecond,
endDate_millisecond,
isRecover,
isAck,
callback
) {
var _result = { count: 0, data: [] }; var _result = { count: 0, data: [] };
var _index = 0; var _index = 0;
var _recoverState = isRecover ? "!= null" : "= null"; var _recoverState = isRecover ? "= 'normal'" : "= 'offnormal'";
var _ackState = isAck ? "= 'acked'" : "= 'unacked'"; var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
let startUrl = ""; let startUrl = "";
if (startDate_millisecond) { if (startDate_millisecond) {
startUrl = "timestamp.millis >= " + startDate_millisecond + " and "; startUrl = "timestamp.millis >= " + startDate_millisecond + " and ";
} }
console.log("告警2", "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 where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc"); console.log(
require(['baja!'], function (baja) { "告警2",
"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 where " +
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 where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc").get() startUrl +
"timestamp.millis <= " +
endDate_millisecond +
" and sourceState " +
_recoverState +
" and ackState " +
_ackState +
" order by timestamp desc"
);
require(["baja!"], function (baja) {
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 where " +
startUrl +
"timestamp.millis <= " +
endDate_millisecond +
" and sourceState " +
_recoverState +
" and ackState " +
_ackState +
" order by timestamp desc"
)
.get()
.then(function (table) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
// console.log(record) // console.log(record)
let main = {}; let main = {};
// const alarmDisplayName = record.get('alarmData').get('sourceName').split(":")[1] ?? record.get('alarmData').get('sourceName').split(":")[0] // const alarmDisplayName = record.get('alarmData').get('sourceName').split(":")[1] ?? record.get('alarmData').get('sourceName').split(":")[0]
const alarmDisplayName = record.get('alarmData').get('sourceName').split(":")[1] ?? record.get('alarmData').get('sourceName') const alarmDisplayName =
_sourceTmp = alarmDisplayName.split('_'); record.get("alarmData").get("sourceName").split(":")[1] ??
let _bfName = _sourceTmp[1] + "-" + _sourceTmp[4] record.get("alarmData").get("sourceName");
_sourceTmp = alarmDisplayName.split("_");
let _bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
let _sourceName = _sourceTmp.slice(0, 8).join("_"); let _sourceName = _sourceTmp.slice(0, 8).join("_");
_sourceTmp = _sourceTmp[7] + "-" + _sourceTmp[8]; _sourceTmp = _sourceTmp[7] + "-" + _sourceTmp[8];
console.log(record.get('alarmData').get('sourceName'), _bfName, _sourceName) console.log(
record.get("alarmData").get("sourceName"),
_bfName,
_sourceName
);
main.buildingFloorName_zh = _bfName; main.buildingFloorName_zh = _bfName;
main.sourceName_zh = _sourceName; main.sourceName_zh = _sourceName;
main.uuid = record.get('uuid').$val; main.uuid = record.get("uuid").$val;
main.timestamp = record.get('timestamp').$cEncStr; main.timestamp = record.get("timestamp").$cEncStr;
main.alarmClass = record.get('alarmClass'); main.alarmClass = record.get("alarmClass");
main.point = _sourceTmp; main.point = _sourceTmp;
main.sourceTmp = _sourceTmp; main.sourceTmp = _sourceTmp;
main.devicePath = _sourceName; main.devicePath = _sourceName;
main.msgText = record.get('alarmData').get('msgText'); main.msgText = record.get("alarmData").get("msgText");
main.normalTime = record.get('normalTime'); main.normalTime = record.get("normalTime");
main.priority = record.get('priority'); main.priority = record.get("priority");
main.ackedTime = record.get('ackTime').$cEncStr; main.ackedTime = record.get("ackTime").$cEncStr;
main.ackState = record.get('ackState').$ordinal main.ackState = record.get("ackState").$ordinal;
if (_sourceTmp.includes("undefined")) { if (_sourceTmp.includes("undefined")) {
main.buildingFloorName_zh = ""; main.buildingFloorName_zh = "";
main.alarmClass = "系統異常"; //main.alarmClass = "系統異常";
main.sourceTmp = ""; main.sourceTmp = "";
main.msgText = ""; //main.msgText = "";
_result.data.push(main); _result.data.push(main);
} }
@ -613,22 +831,28 @@ function getOtherAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecov
}, },
after: function () { after: function () {
_result.count = _index; _result.count = _index;
if (typeof callback === 'function') { if (typeof callback === "function") {
//console.log(_result) //console.log(_result)
callback(_result); callback(_result);
} }
}, },
limit: -1, limit: -1,
offset: 0 offset: 0,
}); });
}); });
}); });
} }
function getAllDeviceAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, isAck, callback) { function getAllDeviceAlarmByBaja(
startDate_millisecond,
endDate_millisecond,
isRecover,
isAck,
callback
) {
var _result = { count: 0, data: [] }; var _result = { count: 0, data: [] };
var _index = 0; var _index = 0;
var _recoverState = isRecover ? "!= null" : "= null"; var _recoverState = isRecover ? "= 'normal'" : "= 'offnormal'";
var _ackState = isAck ? "= 'acked'" : "= 'unacked'"; var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
let startUrl = ""; let startUrl = "";
@ -636,63 +860,79 @@ function getAllDeviceAlarmByBaja(startDate_millisecond, endDate_millisecond, isR
startUrl = "timestamp.millis >= " + startDate_millisecond + " and "; 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 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 where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc");
require(['baja!'], function (baja) { require(["baja!"], function (baja) {
baja.Ord.make(
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 where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc").get() "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 where " +
startUrl +
"timestamp.millis <= " +
endDate_millisecond +
" and sourceState " +
_recoverState +
" and ackState " +
_ackState +
" order by timestamp desc"
)
.get()
.then(function (table) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
// console.log(record)
let main = {}; let main = {};
// const alarmDisplayName = record.get('alarmData').get('sourceName').split(":")[1] ?? record.get('alarmData').get('sourceName').split(":")[0] // const alarmDisplayName = record.get('alarmData').get('sourceName').split(":")[1] ?? record.get('alarmData').get('sourceName').split(":")[0]
const alarmDisplayName = record.get('alarmData').get('sourceName').split(":")[1] ?? record.get('alarmData').get('sourceName') const alarmDisplayName =
_sourceTmp = alarmDisplayName.split('_'); record.get("alarmData").get("sourceName").split(":")[1] ??
let _bfName = _sourceTmp[1] + "-" + _sourceTmp[4] record.get("alarmData").get("sourceName");
_sourceTmp = alarmDisplayName.split("_");
let _bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
let _sourceName = _sourceTmp.slice(0, 8).join("_"); let _sourceName = _sourceTmp.slice(0, 8).join("_");
_sourceTmp = _sourceTmp[7] + "-" + _sourceTmp[8]; _sourceTmp = _sourceTmp[7] + "-" + _sourceTmp[8];
main.buildingFloorName_zh = _bfName; main.buildingFloorName_zh = _bfName;
main.sourceName_zh = _sourceName; main.sourceName_zh = _sourceName;
main.uuid = record.get('uuid').$val; main.uuid = record.get("uuid").$val;
main.timestamp = record.get('timestamp').$cEncStr; main.timestamp = record.get("timestamp").$cEncStr;
main.alarmClass = record.get('alarmClass'); main.alarmClass = record.get("alarmClass");
main.point = _sourceTmp; main.point = _sourceTmp;
main.sourceTmp = _sourceTmp; main.sourceTmp = _sourceTmp;
main.devicePath = _sourceName; main.devicePath = _sourceName;
main.msgText = record.get('alarmData').get('msgText'); main.msgText = record.get("alarmData").get("msgText");
main.normalTime = record.get('normalTime'); main.normalTime = record.get("normalTime");
main.priority = record.get('priority'); main.priority = record.get("priority");
main.ackedTime = record.get('ackTime').$cEncStr; main.ackedTime = record.get("ackTime").$cEncStr;
main.ackState = record.get('ackState').$ordinal main.ackState = record.get("ackState").$ordinal;
if (_sourceTmp.includes("undefined")) { if (_sourceTmp.includes("undefined")) {
// console.log(main.ackState) // console.log(main.ackState)
main.buildingFloorName_zh = ""; main.buildingFloorName_zh = "";
main.alarmClass = "系統異常"; //main.alarmClass = "系統異常";
main.sourceTmp = ""; main.sourceTmp = "";
main.msgText = ""; //main.msgText = "";
} }
_result.data.push(main); _result.data.push(main);
_index++; _index++;
}, },
after: function () { after: function () {
_result.count = _index; _result.count = _index;
if (typeof callback === 'function') { if (typeof callback === "function") {
//console.log(_result) //console.log(_result)
callback(_result); callback(_result);
} }
}, },
limit: -1, limit: -1,
offset: 0 offset: 0,
}); });
}); });
}); });
} }
function getDeviceAlarmCardByBaja(
function getDeviceAlarmCardByBaja(startDate_millisecond, endDate_millisecond, isRecover, isAck, callback) { startDate_millisecond,
endDate_millisecond,
isRecover,
isAck,
callback
) {
var _result = { count: 0, data: [] }; var _result = { count: 0, data: [] };
var _index = 0; var _index = 0;
var _recoverState = isRecover ? "!= null" : "= null"; var _recoverState = isRecover ? "= 'normal'" : "= 'offnormal'";
var _ackState = isAck ? "= 'acked'" : "= 'unacked'"; var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
let startUrl = ""; let startUrl = "";
@ -700,35 +940,47 @@ function getDeviceAlarmCardByBaja(startDate_millisecond, endDate_millisecond, is
startUrl = "timestamp.millis >= " + startDate_millisecond + " and "; 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");
require(['baja!'], function (baja) { require(["baja!"], function (baja) {
baja.Ord.make(
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 where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc").get() "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 where " +
startUrl +
"timestamp.millis <= " +
endDate_millisecond +
" and sourceState " +
_recoverState +
" and ackState " +
_ackState +
" order by timestamp desc"
)
.get()
.then(function (table) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
// console.log(record) // console.log("%%%%%%%%%%%%%%%%", record.get('alarmData').get('alarmClassDisplayName'))
let main = {}; let main = {};
// console.log(record.get('alarmData').get('sourceName'),record.get('timestamp').$cEncStr) // 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] const alarmDisplayName =
record.get("alarmData").get("sourceName").split(":")[1] ??
record.get("alarmData").get("sourceName").split(":")[0];
//console.log(alarmDisplayName) //console.log(alarmDisplayName)
_sourceTmp = alarmDisplayName.split('_'); _sourceTmp = alarmDisplayName.split("_");
let _bfName = _sourceTmp[1] + "-" + _sourceTmp[4] let _bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
let _sourceName = _sourceTmp.slice(0, 8).join("_"); let _sourceName = _sourceTmp.slice(0, 8).join("_");
_sourceTmp = _sourceTmp[7] + "-" + _sourceTmp[8]; _sourceTmp = _sourceTmp[7] + "-" + _sourceTmp[8];
main.buildingFloorName_zh = _bfName; main.buildingFloorName_zh = _bfName;
main.sourceName_zh = _sourceName; main.sourceName_zh = _sourceName;
main.uuid = record.get('uuid').$val; main.uuid = record.get("uuid").$val;
main.timestamp = record.get('timestamp').$cEncStr; main.timestamp = record.get("timestamp").$cEncStr;
main.alarmClass = record.get('alarmClass'); main.alarmClass = record.get("alarmClass");
main.point = _sourceTmp; main.point = _sourceTmp;
main.sourceTmp = _sourceTmp; main.sourceTmp = _sourceTmp;
main.devicePath = _sourceName; main.devicePath = _sourceName;
main.msgText = record.get('alarmData').get('msgText'); main.msgText = record.get("alarmData").get("msgText");
main.normalTime = record.get('normalTime'); main.normalTime = record.get("normalTime");
main.priority = record.get('priority'); main.priority = record.get("priority");
main.ackedTime = record.get('ackTime').$cEncStr; main.ackedTime = record.get("ackTime").$cEncStr;
main.ackState = record.get('ackState').$ordinal main.ackState = record.get("ackState").$ordinal;
// if (!_sourceTmp.includes("undefined")) { // if (!_sourceTmp.includes("undefined")) {
// // console.log(main.ackState) // // console.log(main.ackState)
// } // }
@ -737,13 +989,13 @@ function getDeviceAlarmCardByBaja(startDate_millisecond, endDate_millisecond, is
}, },
after: function () { after: function () {
_result.count = _index; _result.count = _index;
if (typeof callback === 'function') { if (typeof callback === "function") {
//console.log(_result) //console.log(_result)
callback(_result); callback(_result);
} }
}, },
limit: -1, limit: -1,
offset: 0 offset: 0,
}); });
}); });
}); });
@ -758,27 +1010,42 @@ function getAlarmForChartDataByBaja(callback) {
var _ss = ""; var _ss = "";
var _index = 0; var _index = 0;
require(['baja!'], function (baja) { require(["baja!"], function (baja) {
baja.Ord.make("local:|foxs:|alarm:|bql:select *").get() baja.Ord.make("local:|foxs:|alarm:|bql:select *")
.get()
.then(function (table) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
if (_index == 0) if (_index == 0)
_ss += '{"alarmClass":"' + record.get('alarmClass') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}'; _ss +=
'{"alarmClass":"' +
record.get("alarmClass") +
'", "ackState":"' +
record.get("ackState") +
'", "normalTime":"' +
record.get("normalTime") +
'"}';
else else
_ss += ',{"alarmClass":"' + record.get('alarmClass') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}'; _ss +=
',{"alarmClass":"' +
record.get("alarmClass") +
'", "ackState":"' +
record.get("ackState") +
'", "normalTime":"' +
record.get("normalTime") +
'"}';
_index++; _index++;
}, },
after: function () { after: function () {
//_result += '{' + '"count": ' + _index + ', "data":['; //_result += '{' + '"count": ' + _index + ', "data":[';
//_result += _ss; //_result += _ss;
//_result += ']}'; //_result += ']}';
if (typeof callback === 'function') { if (typeof callback === "function") {
callback(_index); callback(_index);
} }
}, },
limit: -1, limit: -1,
offset: 0 offset: 0,
}); });
}); });
}); });

View File

@ -506,11 +506,25 @@ namespace Repository.BackendRepository.Implement
//本次有匯入的 isLink 改為 1, 沒有的 isLink = 0 //本次有匯入的 isLink 改為 1, 沒有的 isLink = 0
sb.Append($@" SET SQL_SAFE_UPDATES = 0; sb.Append($@" SET SQL_SAFE_UPDATES = 0;
UPDATE device_item d LEFT JOIN import_niagara_item m update
ON d.device_system_tag = m.device_system_tag and d.device_name_tag = m.device_name_tag and d.points = m.device_point_name and d.full_name = m.full_name and d.is_show_history = m.is_history device_item d
SET d.is_link = case when device_point_name is null then 0 else 1 end , LEFT JOIN import_niagara_item m
d.is_show_history = case when device_point_name is null then 0 else 1 end ON d.device_system_tag = m.device_system_tag
where m.is_history = 1 and d.device_name_tag = m.device_name_tag
and d.points = m.device_point_name
and d.full_name = m.full_name
SET d.is_link = case when device_point_name is null then 0 else 1 end;
update
device_item d
LEFT JOIN import_niagara_item m
ON d.device_system_tag = m.device_system_tag
and d.device_name_tag = m.device_name_tag
and d.points = m.device_point_name
and d.full_name = m.full_name
and d.is_show_history = m.is_history
SET d.is_show_history = case when device_point_name is null then 0 else 1 end
where (m.is_history = 1 or d.is_show_history);
"); ");
await conn.ExecuteAsync(sb.ToString()); await conn.ExecuteAsync(sb.ToString());