();
+ }
+
+}
diff --git a/FrontendWebApi/Models/EmergencyDevice.cs b/FrontendWebApi/Models/EmergencyDevice.cs
index fe5c076..a7ffe41 100644
--- a/FrontendWebApi/Models/EmergencyDevice.cs
+++ b/FrontendWebApi/Models/EmergencyDevice.cs
@@ -199,7 +199,7 @@ namespace FrontendWebApi.Models
public class BuildingAlarmDeviceAmount
{
- public string building_guid { get; set; }
+ public string building_tag { get; set; }
public int device_amount { get; set; }
}
diff --git a/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml b/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml
index 2f8519a..951d24f 100644
--- a/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml
+++ b/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml
@@ -365,26 +365,15 @@
if (!enable_alarm_timer) {
return;
}
- var url = "/api/Device/Getalarm";
- $.post(url, null, function (rel) {
- if (rel.code != "0000") {
- if (rel.code == "9999") {
- toast_error(rel.msg);
- }
- else {
- toast_warning(rel.msg);
- }
- return;
- }
- else {
-
- var is_diff = false;
- if (Object.keys(temp_alarm_device).length == Object.keys(rel.data.alarmorion).length) {
- for (var i = 0; i < Object.keys(rel.data.alarmorion).length; i++) {
+ GetAlarmFromObix((data) => {
+ var is_diff = false;
+ if (Object.keys(temp_alarm_device).length == Object.keys(data.alarmorion).length) {
- var index = temp_alarm_device.findIndex(x => x.alarm_timestamp == rel.data.alarmorion[i].alarm_timestamp
- && x.device_number == rel.data.alarmorion[i].device_number)
+ for (var i = 0; i < Object.keys(data.alarmorion).length; i++) {
+
+ var index = temp_alarm_device.findIndex(x => x.alarm_timestamp == data.alarmorion[i].alarm_timestamp
+ && x.device_number == data.alarmorion[i].device_number)
if (index > -1) {
is_diff = false;
@@ -397,19 +386,20 @@
is_diff = true;
}
- temp_alarm_device = rel.data.alarmorion;
+ temp_alarm_device = data.alarmorion;
if (show_mode == "alarm" && (is_need_reload || is_diff)) {
enable_alarm_timer = false; //關閉查詢異常設備,避免重複呼叫
- $("#building").find(".building_device_amount").html(0);
- rel.data.buildingAlarmDeviceAmount.forEach(function (item) {
- $(`#${item.building_tag}_device_amount`).html(item.device_amount);
- });
+ //$("#building").find(".building_device_amount").html(0);
+ //data.buildingAlarmDeviceAmount.forEach(function (item) {
+ // $(`#${item.building_tag}_device_amount`).html(item.device_amount);
+ //});
ResetDeviceTable();
}
- }
- }, 'json');
+ })
+
+
}, 3000);
//#endregion
@@ -643,92 +633,101 @@
data = rel.data;
- if (data == null || data.length == 0) {
- this.data = [];
- is_need_reload = true;
- }
+ try {
+ if (data == null || data.length == 0) {
+ this.data = [];
+ is_need_reload = true;
+ }
+ $(`button[id^=buildingBtn]`).removeClass("btn-danger").addClass("btn-secondary");
- enable_alarm_timer = true;
- is_need_reload = false;
+ enable_alarm_timer = true;
+ is_need_reload = false;
- if (show_mode == 'alarm') {
- backfill_building_alarm_device_amount = [];
- backfill_layer2_alarm_device_amount = [];
- backfill_layer3_alarm_device_amount = [];
+ if (show_mode == 'alarm') {
+ backfill_building_alarm_device_amount = [];
+ backfill_layer2_alarm_device_amount = [];
+ backfill_layer3_alarm_device_amount = [];
- var alarm_data = [];
- temp_alarm_device.forEach(function (alarm_device) {
- var temp_device = data.filter(x => x.device_number == alarm_device.device_number)[0];
+ var alarm_data = [];
+ temp_alarm_device.forEach(function (alarm_device) {
+ var temp_device = data.filter(x => x.device_number == alarm_device.device_number)[0];
- if (temp_device != undefined && temp_device != null) {
- var obj = {
- device_guid: temp_device.device_guid,
- device_number: temp_device.device_number,
- device_name: temp_device.device_name,
- building_name: temp_device.building_name,
- building_tag: temp_device.building_tag,
- ip_address: temp_device.ip_address,
- disaster: temp_device.disaster,
- disaster_name: temp_device.disaster_name,
- layer2: temp_device.layer2,
- layer2_name: temp_device.layer2_name,
- layer3: temp_device.layer3,
- layer3_name: temp_device.layer3_name,
- floorname: temp_device.floorname,
- floorguid: temp_device.floorguid,
- alarm_timestamp: alarm_device.alarm_timestamp,
- }
-
- var temp_building_index = backfill_building_alarm_device_amount.findIndex(x => x.building_tag == temp_device.building_tag);
- if (temp_building_index < 0) {
- var building_obj = {
- building_tag: temp_device.building_tag,
- device_amount: 1
- }
-
- backfill_building_alarm_device_amount.push(building_obj);
- } else {
- backfill_building_alarm_device_amount[temp_building_index].device_amount += 1;
- }
-
- var temp_layer2_index = backfill_layer2_alarm_device_amount.findIndex(x => x.value == temp_device.layer2 && x.building_tag == temp_device.building_tag)
- if (temp_layer2_index < 0) {
- var layer2_obj = {
- building_tag: temp_device.building_tag,
- value: temp_device.layer2,
- device_amount: 1
- }
-
- backfill_layer2_alarm_device_amount.push(layer2_obj);
- } else {
- backfill_layer2_alarm_device_amount[temp_layer2_index].device_amount += 1;
- }
-
- var temp_layer3_index = backfill_layer3_alarm_device_amount.findIndex(x => x.layer3 == temp_device.layer3 && x.layer2 == temp_device.layer2 && x.building_tag == temp_device.building_tag)
- if (temp_layer3_index < 0) {
- var layer3_obj = {
+ if (temp_device != undefined && temp_device != null) {
+ var obj = {
+ device_guid: temp_device.device_guid,
+ device_number: temp_device.device_number,
+ device_name: temp_device.device_name,
+ building_name: temp_device.building_name,
building_tag: temp_device.building_tag,
+ ip_address: temp_device.ip_address,
+ disaster: temp_device.disaster,
+ disaster_name: temp_device.disaster_name,
layer2: temp_device.layer2,
+ layer2_name: temp_device.layer2_name,
layer3: temp_device.layer3,
- device_amount: 1
+ layer3_name: temp_device.layer3_name,
+ floorname: temp_device.floorname,
+ floorguid: temp_device.floorguid,
+ alarm_timestamp: alarm_device.alarm_timestamp,
}
- backfill_layer3_alarm_device_amount.push(layer3_obj);
- } else {
- backfill_layer3_alarm_device_amount[temp_layer3_index].device_amount += 1;
+ var temp_building_index = backfill_building_alarm_device_amount.findIndex(x => x.building_tag == temp_device.building_tag);
+ if (temp_building_index < 0) {
+ var building_obj = {
+ building_tag: temp_device.building_tag,
+ device_amount: 1
+ }
+
+ backfill_building_alarm_device_amount.push(building_obj);
+ } else {
+ backfill_building_alarm_device_amount[temp_building_index].device_amount += 1;
+ }
+
+ var temp_layer2_index = backfill_layer2_alarm_device_amount.findIndex(x => x.value == temp_device.layer2 && x.building_tag == temp_device.building_tag)
+ if (temp_layer2_index < 0) {
+ var layer2_obj = {
+ building_tag: temp_device.building_tag,
+ value: temp_device.layer2,
+ device_amount: 1
+ }
+
+ backfill_layer2_alarm_device_amount.push(layer2_obj);
+ } else {
+ backfill_layer2_alarm_device_amount[temp_layer2_index].device_amount += 1;
+ }
+
+ var temp_layer3_index = backfill_layer3_alarm_device_amount.findIndex(x => x.layer3 == temp_device.layer3 && x.layer2 == temp_device.layer2 && x.building_tag == temp_device.building_tag)
+ if (temp_layer3_index < 0) {
+ var layer3_obj = {
+ building_tag: temp_device.building_tag,
+ layer2: temp_device.layer2,
+ layer3: temp_device.layer3,
+ device_amount: 1
+ }
+
+ backfill_layer3_alarm_device_amount.push(layer3_obj);
+ } else {
+ backfill_layer3_alarm_device_amount[temp_layer3_index].device_amount += 1;
+ }
+
+ $(`#buildingBtn${temp_device.building_tag}`).removeClass("btn-secondary").addClass("btn-danger");
+ alarm_data.push(obj);
}
+ });
+ UpdateDeviceAmount();
- alarm_data.push(obj);
- }
- });
-
- UpdateDeviceAmount();
-
- data = alarm_data;
+ data = alarm_data;
+ }
+ }
+ catch(e) {
+ console.error(e);
+ return [];
}
+
+
return data;
}
}
@@ -849,6 +848,27 @@
});
//#endregion
+ function GetAlarmFromObix(callback = null){
+ let url = "/api/Alarm/GetAlarmFromObix"
+ $.ajax({
+ url: url,
+ data: null,
+ type: 'POST',
+ dataType: 'json',
+ success: function (rel) {
+ if(rel && rel.code == "0000") {
+ console.log(rel);
+ callback ? callback(rel.data ?? []) : "";
+ } else {
+ toast_error(rel?.msg || "取得警報發生錯誤,請通知資訊相關人員。");
+ }
+ },
+ });
+
+
+
+ }
+
//#region 變更查詢內容
function ChangeMode(mode, e) {
$('#show-mode').find('button').removeClass('btn-success').addClass('btn-secondary');
@@ -930,8 +950,7 @@
`;*@
html += `
-
-
+
`;
});
$('#building').append(``);
diff --git a/FrontendWebApi/Views/Login/Index.cshtml b/FrontendWebApi/Views/Login/Index.cshtml
index 994097b..93d06a3 100644
--- a/FrontendWebApi/Views/Login/Index.cshtml
+++ b/FrontendWebApi/Views/Login/Index.cshtml
@@ -78,7 +78,10 @@
async: false,
dataType: 'json',
success: function (rel) {
+
window.location = "/EmergencyDeviceMenu";
+
+
},
error: function (xhr, textStatus, thrownError) {
alert(textStatus);
diff --git a/FrontendWebApi/Views/Shared/_Layout.cshtml b/FrontendWebApi/Views/Shared/_Layout.cshtml
index ea05022..b7f8d76 100644
--- a/FrontendWebApi/Views/Shared/_Layout.cshtml
+++ b/FrontendWebApi/Views/Shared/_Layout.cshtml
@@ -883,7 +883,7 @@
- 24小時累積雨量達80毫米以上,或時雨量達40毫米以上之降雨現象 |
+ 24小時累積雨量達80毫米以上,或時雨量達40毫米以上之降雨現象 |
|
@@ -915,7 +915,7 @@
- 幾乎所有家俱都大幅移動或翻倒,部分耐震較強建築物可能損壞或倒塌。 |
+ 幾乎所有家俱都大幅移動或翻倒,部分耐震較強建築物可能損壞或倒塌。 |
@@ -936,6 +936,7 @@
+
@@ -959,7 +960,7 @@
-
+
@*各頁面的JavaScript*@
@RenderSection("Scripts", required: false)
@@ -981,6 +982,32 @@
$("body").on("show.bs.modal","#warning-value-modal",getWarningValue);
+ $("body").on("change","input[name=rainRadio]",onRainRadioChange);
+ $("body").on("change","input[name=eqRadio]",onEqRadioChange);
+
+ function onRainRadioChange(e) {
+ let rainDecDict = {
+ 1:"24小時累積雨量達80毫米以上,或時雨量達40毫米以上之降雨現象。",
+ 2:"24小時累積雨量達200毫米以上,或3小時累積雨量達100毫米以上之降雨現象。",
+ 3:"24小時累積雨量達350毫米以上之降雨現象。",
+ 4:"24小時累積雨量達500毫米以上之降雨現象。",
+ };
+
+ $("#rainDesc").text(rainDecDict[e.target.value] || "");
+ }
+
+ function onEqRadioChange(){
+ let eqDecDict = {
+ 3:"房屋震動,碗盤門窗發出聲音,懸掛物搖擺。",
+ 4:"房屋搖動甚烈,少數未固定物品可能傾倒掉落,少數傢俱移動,可能有輕微災害。",
+ 5:"部分未固定物品傾倒掉落,少數傢俱可能移動或翻倒,少數門窗可能變形,部分牆壁產生裂痕。",
+ 6:"大量傢俱大幅移動或翻倒,門窗扭曲變形,部分耐震能力較差房屋可能損壞或倒塌。",
+ 7:"幾乎所有傢俱都大幅移動或翻倒,部分耐震較強建築物可能損壞或倒塌。",
+ }
+
+ $("#eqDesc").text(eqDecDict[e.target.value] || "");
+ }
+
function getWarningValue(){
let url = "api/WarningValue/GetWarningValue";