From a37224647e16fc3f59ea38813a435a7f93cfe39a Mon Sep 17 00:00:00 2001 From: dev01 Date: Mon, 30 Oct 2023 18:18:04 +0800 Subject: [PATCH] =?UTF-8?q?[WebAPI]=20GetDevice=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=BC=95=E6=95=B8=20device=5Fnumber=20=E5=8F=AF=E9=87=9D?= =?UTF-8?q?=E5=B0=8D=20device=5Fnumber=20=E9=80=B2=E8=A1=8C=20Filter=20|?= =?UTF-8?q?=20GetEmergencyDevice=20=E5=B9=B3=E9=9D=A2=E5=9C=96=E7=B6=B2?= =?UTF-8?q?=E5=9D=80=E5=8B=95=E6=85=8B=E6=8A=93=20variable=20=E5=8F=96?= =?UTF-8?q?=E5=BE=97=20website=20config=20=E7=B5=84=E8=A3=9D=20url=20|=20[?= =?UTF-8?q?View]=20=E7=B7=8A=E6=80=A5=E6=87=89=E8=AE=8A=E5=B9=B3=E9=9D=A2?= =?UTF-8?q?=E5=9C=96=E8=B7=AF=E5=BE=91=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/BuildController.cs | 14 ++++++++++---- .../EmergencyDeviceController.cs | 18 ++++++++++++++---- FrontendWebApi/Models/Build.cs | 1 + .../Views/EmergencyDeviceMenu/Index.cshtml | 2 +- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/FrontendWebApi/ApiControllers/BuildController.cs b/FrontendWebApi/ApiControllers/BuildController.cs index 68f1054..def95f1 100644 --- a/FrontendWebApi/ApiControllers/BuildController.cs +++ b/FrontendWebApi/ApiControllers/BuildController.cs @@ -474,6 +474,7 @@ namespace FrontendWebApi.ApiControllers var sub_system_guidsql = ""; var disasterjoinsql = ""; var disastersql = ""; + var devicesql = ""; var layer3sql = ""; var sWhere = ""; if (!String.IsNullOrEmpty(post.main_system_tag)) @@ -496,7 +497,9 @@ namespace FrontendWebApi.ApiControllers disasterjoinsql = " left join device_disaster dd on dd.device_guid = d.device_guid"; disastersql = $" and dd.device_system_value = '{post.device_system_value}'"; } - + if (!String.IsNullOrEmpty(post.device_number)) { + devicesql = " and d.device_number = @device_number "; + } if (!String.IsNullOrEmpty(post.show_cctv) && post.show_cctv == "1") { var str_arr = new List(); @@ -516,7 +519,10 @@ namespace FrontendWebApi.ApiControllers { str_arr.Add($@"dd.device_system_value = '{post.device_system_value}'"); } - + if (!String.IsNullOrEmpty(post.device_number)) + { + str_arr.Add($@"d.device_number = @device_number"); + } if (str_arr.Count > 0) { sWhere = $@" AND ( @@ -534,7 +540,7 @@ namespace FrontendWebApi.ApiControllers } else { - sWhere = $@"{main_system_guidsql} {sub_system_guidsql} {disastersql} {layer3sql}"; + sWhere = $@"{main_system_guidsql} {sub_system_guidsql} {disastersql} {layer3sql} {devicesql}"; } var sql = $@"select @@ -595,7 +601,7 @@ namespace FrontendWebApi.ApiControllers where d.deleted = 0 and d.is_link = 1 and d.device_building_tag = '{post.building_tag}' {sWhere} order by d.priority ASC, left(device_serial_tag, LENGTH(device_serial_tag) - 1) ASC"; - var devicelist = await backendRepository.GetAllAsync(sql); + var devicelist = await backendRepository.GetAllAsync(sql,new { device_number = post.device_number }); //抓出該設備底下的子節點 var sql_node = $@"SELECT diff --git a/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs b/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs index 3ea13d5..ea17216 100644 --- a/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs +++ b/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs @@ -132,15 +132,18 @@ namespace FrontendWebApi.ApiControllers if (selectdevice.select_disasters == null || selectdevice.select_disasters.Count == 0) selectdevice.select_disasters = new List(); + var sqlString = $@"SELECT system_key as 'Name', system_value as 'Value' FROM variable where system_type = 'website_config' AND deleted = 0"; + List webSiteConfig = await backendRepository.GetAllAsync(sqlString); + deviceQue += $" AND d.device_building_tag in @building_tag "; disasQue = " where dd.device_system_value IN @disasters "; - var sqlString = @$"select + sqlString = @$"select d.device_guid, d.device_number, d.full_name AS device_name, d.device_building_tag AS building_tag, b.full_name AS building_name, - CONCAT(b.ip_address , ':', b.ip_port) AS ip_address, + CONCAT(@niagara_http, '://',b.ip_address , ':', b.ip_port,'/file/',@niagaraRootName) AS ip_address, v.layer2, v.layer2_name, v.system_value AS layer3, @@ -173,8 +176,15 @@ namespace FrontendWebApi.ApiControllers {disasQue} ORDER BY d.device_number "; - Variable = await backendRepository.GetAllAsync(sqlString, new { disasters= selectdevice.select_disasters, building_tag = selectdevice.selectbuilding, - floor = selectdevice.select_Floors, layer3 = selectdevice.select_Layer3 }); + Variable = await backendRepository.GetAllAsync(sqlString, new + { + disasters = selectdevice.select_disasters, + building_tag = selectdevice.selectbuilding, + floor = selectdevice.select_Floors, + layer3 = selectdevice.select_Layer3, + niagaraRootName = webSiteConfig.FirstOrDefault(w => w.Name == "frontend_niagara_root_name")?.Value, + niagara_http = webSiteConfig.FirstOrDefault(w => w.Name == "frontend_http")?.Value, + }); apiResult.Code = "0000"; apiResult.Data = Variable; diff --git a/FrontendWebApi/Models/Build.cs b/FrontendWebApi/Models/Build.cs index 462563e..0ecf5e2 100644 --- a/FrontendWebApi/Models/Build.cs +++ b/FrontendWebApi/Models/Build.cs @@ -66,6 +66,7 @@ namespace FrontendWebApi.Models public string sub_system_tag { get; set; } public string building_tag { get; set; } public string device_system_value { get; set; } + public string device_number { get; set; } public string device_system_category_layer3 { get; set; } public string show_cctv { get; set; } } diff --git a/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml b/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml index 36810bb..e31a844 100644 --- a/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml +++ b/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml @@ -569,7 +569,7 @@ `;*@ var html = ` - + ${data} `;