From 343681e1f15926c9424775538c23349a042a6620 Mon Sep 17 00:00:00 2001 From: dev01 Date: Wed, 20 Sep 2023 17:32:03 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=85=A8=E5=9F=9F]=20Jwt=20token=20=E7=B6=93?= =?UTF-8?q?=E9=81=8E=20base=20=E5=88=B7=E6=96=B0=20token=20=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=20|=20GetAlarm=20=E5=8E=9F=E6=9C=AC=E5=BE=9E=E8=B3=87?= =?UTF-8?q?=E6=96=99=E5=BA=AB=E5=8F=96=E5=BE=97=E8=AD=A6=E5=A0=B1=E6=94=B9?= =?UTF-8?q?=E6=88=90=E5=BE=9E=20Niagara=20Obix=20=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E5=8F=96=E5=BE=97=E8=B3=87=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/AlarmController.cs | 158 ++++++++++++++ .../ApiControllers/MyBaseApiController.cs | 55 ++--- .../ApiControllers/WarningValueController.cs | 1 - .../Controllers/MyBaseController.cs | 13 +- FrontendWebApi/Jwt/JwtHelpers.cs | 4 +- FrontendWebApi/Models/Alarm.cs | 17 ++ FrontendWebApi/Models/EmergencyDevice.cs | 2 +- .../Views/EmergencyDeviceMenu/Index.cshtml | 205 ++++++++++-------- FrontendWebApi/Views/Login/Index.cshtml | 3 + FrontendWebApi/Views/Shared/_Layout.cshtml | 33 ++- 10 files changed, 347 insertions(+), 144 deletions(-) create mode 100644 FrontendWebApi/ApiControllers/AlarmController.cs create mode 100644 FrontendWebApi/Models/Alarm.cs diff --git a/FrontendWebApi/ApiControllers/AlarmController.cs b/FrontendWebApi/ApiControllers/AlarmController.cs new file mode 100644 index 0000000..7179149 --- /dev/null +++ b/FrontendWebApi/ApiControllers/AlarmController.cs @@ -0,0 +1,158 @@ +using FrontendWebApi.Models; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using NPOI.SS.UserModel; +using NPOI.XSSF.UserModel; +using Repository.FrontendRepository.Interface; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; +using System.Xml; +using System.Xml.Linq; + +namespace FrontendWebApi.ApiControllers +{ + /// + /// 告警紀錄 + /// + public class AlarmController : MyBaseApiController + { + private readonly IFrontendRepository frontendRepository; + + public AlarmController + ( + IFrontendRepository frontendRepository + ) + { + this.frontendRepository = frontendRepository; + } + + [HttpPost] + [Route("api/Alarm/GetAlarmFromObix")] + public async Task>> GetAlarmFromObix() + { + ApiResult apiResult = new ApiResult(jwt_str); + if (!jwtlife) + { + apiResult.Code = "5000"; + return BadRequest(apiResult); + } + try + { + var sqlString = $@"SELECT system_value FROM variable WHERE system_type = 'obixConfig' AND system_key = 'ApiBase' AND deleted = 0"; + string baseApiUrl = await frontendRepository.GetOneAsync(sqlString); + + if (string.IsNullOrEmpty(baseApiUrl)) + { + apiResult.Code = "9998"; + apiResult.Msg = "未找到 obixConfig baseAPI,請聯絡管理者。"; + return BadRequest(apiResult); + } + + string apiUrl = Path.Combine(baseApiUrl, "obix/config/Services/AlarmService/~alarmQuery/"); + + using (HttpClient client = new HttpClient()) + { + string username = "stanGG"; + string password = "St12345678"; + string encoded = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password)); + + client.DefaultRequestHeaders.Add("Authorization", "Basic " + encoded); + // 建構 XML 數據 + string xmlData = @$" + + + "; + HttpContent content = new StringContent(xmlData, Encoding.UTF8, "application/xml"); + + var response = await client.PostAsync(apiUrl, content); + var resString = (await response.Content.ReadAsStringAsync()).ToString(); + + XDocument xmlDoc = XDocument.Parse(resString); + + /* 回傳結果範例 + + + + + + .... + + + .... + + + .... + + + .... + + + + */ + + var list = xmlDoc.Descendants().Where(d => d.Name?.LocalName == "list").FirstOrDefault(); + var objs = list.Descendants().Where(d => d.Name?.LocalName == "obj" && (d.Attribute("is")?.Value?.Contains("obix:Alarm") ?? false)).ToList(); + + // 宣告要丟出去的資料容器 + AlarmObj alarmObj = new AlarmObj() + { + alarmorion = new List(), + buildingAlarmDeviceAmount = new List() + }; + + // 篩選 toState != normal + objs = objs.Where(d => d.Descendants().Any(dd => dd?.Name?.LocalName == "str" && dd?.Attribute("name")?.Value == "toState" && dd?.Attribute("val")?.Value != "normal")).ToList(); + // + // + alarmObj.alarmorion = objs.Select(obj => new AlarmorionString() + { + alarm_timestamp = obj.Descendants().Where(d => d.Name.LocalName == "abstime" && d.Attribute("name").Value == "timestamp") + .Select(d => + { + DateTime valid; + if (DateTime.TryParse(d.Attribute("val").Value, out valid)) + { + return DateTime.Parse(d.Attribute("val").Value).ToString("yyyy-MM-dd HH:mm:ss.fff"); + } + else + { + return null; + } + }).FirstOrDefault(), + device_number = obj.Descendants().Where(d => d.Name.LocalName == "str" && d.Attribute("name").Value == "sourceName") + .Select(d => d.Attribute("val").Value).Select(d => string.Join("_", d.Split("_").Take(5))).FirstOrDefault(), + }).ToList(); + + // obix alarm 回傳 device_number + point 取出棟別分組 + alarmObj.buildingAlarmDeviceAmount = alarmObj.alarmorion.Where(a => a.device_number?.Contains("_") ?? false) + .GroupBy(g => g.device_number.Split("_")[0]).Select(g => new BuildingAlarmDeviceAmount() + { + building_tag = g.Key, + device_amount = g.Count() + }).ToList(); + + apiResult.Data = alarmObj; + + } + + apiResult.Msg = "讀取成功"; + apiResult.Code = "0000"; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + return Ok(apiResult); + } + return Ok(apiResult); + } + } +} + diff --git a/FrontendWebApi/ApiControllers/MyBaseApiController.cs b/FrontendWebApi/ApiControllers/MyBaseApiController.cs index 891da48..7e2b0f5 100644 --- a/FrontendWebApi/ApiControllers/MyBaseApiController.cs +++ b/FrontendWebApi/ApiControllers/MyBaseApiController.cs @@ -17,6 +17,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using System.IdentityModel.Tokens.Jwt; using System.Net; +using Newtonsoft.Json; namespace FrontendWebApi.ApiControllers { @@ -58,39 +59,29 @@ namespace FrontendWebApi.ApiControllers userinfo_guid = User.Claims.Where(a => a.Type == "userinfo_guid").Select(e => e.Value).FirstOrDefault(), }; - if (myUser.exp == 0) + Logger.LogError("MyBaseApi - 61 : " + JsonConvert.SerializeObject(myUser) + "---" + DateTime.Now.AddHours(-8).AddMinutes(10).Subtract(new DateTime(1970, 1, 1)).TotalSeconds); + + //if (myUser.exp == 0) + //{ + // jwt_str = "Jwt Token不合法"; + // jwtlife = false; + // filterContext.Result = new JsonResult(new { HttpStatusCode.Unauthorized }); + //} + + //if (myUser.exp <= DateTime.Now.AddHours(-8).AddMinutes(10).Subtract(new DateTime(1970, 1, 1)).TotalSeconds) + //{ + jwtlife = true; + JwtLogin jwtLoing = new JwtLogin() { - jwt_str = "Jwt Token不合法"; - jwtlife = false; - filterContext.Result = new JsonResult(new { HttpStatusCode.Unauthorized }); - } - else - { - if (myUser.exp <= DateTime.Now.AddHours(-8).AddMinutes(10).Subtract(new DateTime(1970, 1, 1)).TotalSeconds) - { - jwtlife = true; - JwtLogin jwtLoing = new JwtLogin() - { - account = myUser.account, - email = myUser.email, - full_name = myUser.full_name, - userinfo_guid = myUser.userinfo_guid - }; - jwt_str = jwt.GenerateToken(jwtLoing).token; - } - } - if (myUser.exp <= DateTime.Now.AddHours(-8).AddMinutes(10).Subtract(new DateTime(1970, 1, 1)).TotalSeconds) - { - jwtlife = true; - JwtLogin jwtLoing = new JwtLogin() - { - account = "webUser", - email = "webUser@gmail.com", - full_name = "webUser", - userinfo_guid = "6ac24708-3a40-4199-88c5-22df310cd1a8" - }; - jwt_str = jwt.GenerateToken(jwtLoing).token; - } + account = myUser.account, + email = myUser.email, + full_name = myUser.full_name, + userinfo_guid = myUser.userinfo_guid + }; + jwt_str = jwt.GenerateToken(jwtLoing).token; + //} + + Logger.LogError("MyBaseApi - 98 : " + JsonConvert.SerializeObject(myUser)); base.OnActionExecuting(filterContext); } } diff --git a/FrontendWebApi/ApiControllers/WarningValueController.cs b/FrontendWebApi/ApiControllers/WarningValueController.cs index 031e3df..46faf27 100644 --- a/FrontendWebApi/ApiControllers/WarningValueController.cs +++ b/FrontendWebApi/ApiControllers/WarningValueController.cs @@ -93,7 +93,6 @@ namespace FrontendWebApi.ApiControllers XDocument xmlDoc = XDocument.Parse(resString); - Logger.LogError("【" + controllerName + "/" + actionName + "】" + JsonConvert.SerializeXNode(xmlDoc)); if (xmlDoc?.Root?.Name?.LocalName == "str") { result.targetValue = xmlDoc.Root.Attribute("val").Value; diff --git a/FrontendWebApi/Controllers/MyBaseController.cs b/FrontendWebApi/Controllers/MyBaseController.cs index b86f965..e48ba23 100644 --- a/FrontendWebApi/Controllers/MyBaseController.cs +++ b/FrontendWebApi/Controllers/MyBaseController.cs @@ -50,7 +50,7 @@ namespace FrontendWebApi.Controllers updateProcess.Add("@system_value", currentProcess.Id.ToString()); frontendRepository.UpdateProcessPID(updateProcess, "variable", "system_type = 'watchDogCongfig' AND system_key = 'AlarmPID'"); - + bool isAjaxCall = filterContext.HttpContext.Request.Headers["x-requested-with"] == "XMLHttpRequest"; if (string.IsNullOrEmpty(myAccount)) { @@ -83,7 +83,6 @@ namespace FrontendWebApi.Controllers myUserInfo.ShowView = showview.Result; ViewBag.myUserInfo = myUserInfo; ViewBag.role = showview.Result; - ViewBag.WarningValuePxPath = GetWarningValuePxPath().Result; //var showviewt = new List() @@ -165,15 +164,5 @@ namespace FrontendWebApi.Controllers base.OnActionExecuting(filterContext); } - public async Task GetWarningValuePxPath() { - var pxPath = await frontendRepository.GetOneAsync($@" - SELECT system_value FROM `variable` where system_type = 'pxPath' and system_key = 'warningValue' and deleted = '0'"); - var frontendPath = await frontendRepository.GetOneAsync($@" - SELECT system_value FROM `variable` where system_type = 'obixConfig' and system_key = 'ApiBase' and deleted = '0'"); - pxPath = frontendPath + pxPath; - - return pxPath; - } - } } diff --git a/FrontendWebApi/Jwt/JwtHelpers.cs b/FrontendWebApi/Jwt/JwtHelpers.cs index 1aa1ddf..093feab 100644 --- a/FrontendWebApi/Jwt/JwtHelpers.cs +++ b/FrontendWebApi/Jwt/JwtHelpers.cs @@ -61,8 +61,8 @@ namespace FrontendWebApi.Jwt // https://stackoverflow.com/questions/47279947/idx10603-the-algorithm-hs256-requires-the-securitykey-keysize-to-be-greater var signingCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256Signature); - var now = DateTime.Now; - var expires = DateTime.Now.AddSeconds(lifeseconds); + var now = DateTime.UtcNow; + var expires = DateTime.UtcNow.AddSeconds(lifeseconds); // 產出所需要的 JWT securityToken 物件,並取得序列化後的 Token 結果(字串格式) var tokenHandler = new JwtSecurityTokenHandler(); diff --git a/FrontendWebApi/Models/Alarm.cs b/FrontendWebApi/Models/Alarm.cs new file mode 100644 index 0000000..501d140 --- /dev/null +++ b/FrontendWebApi/Models/Alarm.cs @@ -0,0 +1,17 @@ +using NPOI.Util; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace FrontendWebApi.Models +{ + public class AlarmObixResult + { + public string alarm_timestamp { get; set; } + public string device_number { get; set; } + + public List buildingAlarmDeviceAmount { get; set; } = new List(); + } + +} 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..a814352 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) { + data.buildingAlarmDeviceAmount.forEach(function (item) { $(`#${item.building_tag}_device_amount`).html(item.device_amount); }); ResetDeviceTable(); } - } - }, 'json'); + }) + + }, 3000); //#endregion @@ -643,92 +633,100 @@ 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; + } - 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; + } + + + 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 +847,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'); 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";