From 89c2b0da8fec50bac7a43cdfe5d5c54c16b98f59 Mon Sep 17 00:00:00 2001 From: dev02 Date: Fri, 11 Nov 2022 10:12:27 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=90=9C=E5=B0=8B?= =?UTF-8?q?=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/GraphManageController.cs | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/FrontendWebApi/ApiControllers/GraphManageController.cs b/FrontendWebApi/ApiControllers/GraphManageController.cs index 7d93b4b..693c263 100644 --- a/FrontendWebApi/ApiControllers/GraphManageController.cs +++ b/FrontendWebApi/ApiControllers/GraphManageController.cs @@ -10,6 +10,7 @@ using System.Linq; using Repository.BackendRepository.Interface; using Repository.FrontendRepository.Interface; using System.IO; +using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource; namespace FrontendWebApi.ApiControllers { @@ -98,28 +99,27 @@ namespace FrontendWebApi.ApiControllers List graManList = new List(); try { - var sqlString = @$"SELECT gm.* + var param = new { @graph_manage_layer1 = graph_manage_layer1, @graph_manage_layer2 = graph_manage_layer2, @sub_system_tag = gi.sub_system_tag, @main_system_tag = gi.main_system_tag }; + if (gi.keyWord != null && !string.IsNullOrEmpty(gi.keyWord)) + { + graManList = await backendRepository.GetAllAsync(@$"SELECT gm.* + FROM graph_manage gm + JOIN variable v1 ON v1.system_value = @main_system_tag and v1.system_type = @graph_manage_layer1 and v1.deleted = 0 AND convert(v1.system_value, nchar) = gm.main_system_tag + JOIN variable v2 ON v1.id = v2.system_parent_id AND v2.system_type = @graph_manage_layer2 AND v2.deleted = 0 and convert(v2.system_value, nchar) = gm.sub_system_tag + WHERE v2.system_value in @sub_system_tag AND gm.deleted = 0 + AND (gm.code like '%{gi.keyWord}%' OR gm.name like '%{gi.keyWord}%' OR gm.oriOrgName like '%{gi.keyWord}%' OR gm.donOrgName like '%{gi.keyWord}%') + ORDER BY gm.priority, gm.created_at desc", param); + } + else + { + var sqlString = @$"SELECT gm.* FROM graph_manage gm JOIN variable v1 ON v1.system_value = @main_system_tag and v1.system_type = @graph_manage_layer1 and v1.deleted = 0 AND convert(v1.system_value, nchar) = gm.main_system_tag JOIN variable v2 ON v1.id = v2.system_parent_id AND v2.system_type = @graph_manage_layer2 AND v2.deleted = 0 AND convert(v2.system_value, nchar) = gm.sub_system_tag WHERE v2.system_value in @sub_system_tag AND gm.deleted = 0 ORDER BY gm.priority, gm.created_at desc"; - - var param = new { @graph_manage_layer1 = graph_manage_layer1, graph_manage_layer2 = graph_manage_layer2, @sub_system_tag = gi.sub_system_tag, @main_system_tag = gi.main_system_tag }; - - graManList = await backendRepository.GetAllAsync(sqlString, param); - - if (gi.keyWord != null) - { - var wParam = new { @graph_manage_layer1 = graph_manage_layer1, graph_manage_layer2 = graph_manage_layer2, @sub_system_tag = gi.sub_system_tag, @main_system_tag = gi.main_system_tag, @keyWord = gi.keyWord }; - graManList = await backendRepository.GetAllAsync(@$"SELECT gm.* - FROM graph_manage gm - JOIN variable v1 ON v1.system_value = @main_system_tag and v1.system_type = @graph_manage_layer1 and v1.deleted = 0 AND convert(v1.system_value, nchar) = gm.main_system_tag - JOIN variable v2 ON v1.id = v2.system_parent_id AND v2.system_type = @graph_manage_layer2 AND v2.deleted = 0 and convert(v2.system_value, nchar) = gm.sub_system_tag - WHERE v2.system_value in @sub_system_tag AND gm.deleted = 0 - AND (code like '%@keyWord%' OR name like '%@keyWord%' OR oriOrgName like '%@keyWord%' OR donOrgName like '%@keyWord%') - ORDER BY gm.priority, gm.created_at desc", wParam); + graManList = await backendRepository.GetAllAsync(sqlString, param); } apiResult.Code = "0000"; From ba700dab46dd85ad9717997ccfcf965a4dd73437 Mon Sep 17 00:00:00 2001 From: wanli Date: Fri, 11 Nov 2022 15:44:40 +0800 Subject: [PATCH 2/4] =?UTF-8?q?[Backend]=20=E6=9B=B4=E6=94=B9N4=E5=8F=96?= =?UTF-8?q?=E5=80=BC=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/N4v1021.xml | 96 +++++++++++++++++++ .../Services/Implement/webRequestService.cs | 23 ++++- z01_WinAPP/Service/webRequestSvc.cs | 24 ++++- 3 files changed, 137 insertions(+), 6 deletions(-) create mode 100644 Backend/N4v1021.xml diff --git a/Backend/N4v1021.xml b/Backend/N4v1021.xml new file mode 100644 index 0000000..d7b1b16 --- /dev/null +++ b/Backend/N4v1021.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Backend/Services/Implement/webRequestService.cs b/Backend/Services/Implement/webRequestService.cs index aa56566..57022a0 100644 --- a/Backend/Services/Implement/webRequestService.cs +++ b/Backend/Services/Implement/webRequestService.cs @@ -26,7 +26,7 @@ namespace Backend.Services.Implement XmlDocument xmlDoc = new XmlDocument(); //xmlDoc.LoadXml(responseString); - xmlDoc.Load("N4.xml");//N4v1021 + xmlDoc.Load("N4v1021.xml");//N4v1021 //xmlDoc.Save("N4.xml"); @@ -40,7 +40,24 @@ namespace Backend.Services.Implement string[] s1 = item.Val.Split(','); string[] s2 = s1[0].Split('/'); - foreach (var ss in s2) + row.tag_name = ""; + + for (int i = 0; i < s2.Length; i++) + { + if (i == s2.Length - 2) + { + row.point_name = s2[i]; + } + else if (i == 1) + { + row.tag_name += s2[i]; + } + else if (i > 1 && i < s2.Length - 2) + { + row.tag_name += "_" + s2[i]; + } + } + /*foreach (var ss in s2) { if (ss.Contains('_')) { @@ -52,7 +69,7 @@ namespace Backend.Services.Implement break; } } - } + }*/ result.Add(row); } diff --git a/z01_WinAPP/Service/webRequestSvc.cs b/z01_WinAPP/Service/webRequestSvc.cs index c101447..cf8da19 100644 --- a/z01_WinAPP/Service/webRequestSvc.cs +++ b/z01_WinAPP/Service/webRequestSvc.cs @@ -166,7 +166,7 @@ namespace tpDomeWinAPP.Service XmlDocument xmlDoc = new XmlDocument(); //xmlDoc.LoadXml(responseString); - xmlDoc.Load("N4.xml"); + xmlDoc.Load("N4v1021.xml");//N4v1021 //xmlDoc.Save("N4.xml"); @@ -182,9 +182,26 @@ namespace tpDomeWinAPP.Service device_value2 row = new device_value2(); row.value = item.Val; string[] s1 = item.Val.Split(','); - string[] s2 = s1[0].Split('/'); - foreach (var ss in s2) + row.tag_name = ""; + + for (int i = 0; i < s2.Length; i++) + { + if (i == s2.Length - 2) + { + row.point_name = s2[i]; + } + else if (i == 1) + { + row.tag_name += s2[i]; + } + else if (i > 1 && i < s2.Length - 2) + { + row.tag_name += "_" + s2[i]; + } + } + + /*foreach (var ss in s2) { if (ss.Contains('_')) { @@ -208,6 +225,7 @@ namespace tpDomeWinAPP.Service // //} //} } + */ result.Add(row); //row.tag_name = s2.Where( x => x.Contains("_") && // (x.Contains("H") || x.Contains("O") || x.Contains("C") || x.Contains("D") || x.Contains("M"))) From d46e6ec094e9c933a9befa5abc7cac0993fd8f48 Mon Sep 17 00:00:00 2001 From: dev02 Date: Fri, 11 Nov 2022 17:38:17 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=80=E6=9D=B1?= =?UTF-8?q?=E6=A8=93api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/OperationController.cs | 79 ++++++++++++++++--- 1 file changed, 70 insertions(+), 9 deletions(-) diff --git a/FrontendWebApi/ApiControllers/OperationController.cs b/FrontendWebApi/ApiControllers/OperationController.cs index 445851c..fb59396 100644 --- a/FrontendWebApi/ApiControllers/OperationController.cs +++ b/FrontendWebApi/ApiControllers/OperationController.cs @@ -96,22 +96,18 @@ namespace FrontendWebApi.ApiControllers } /// - /// 大樓列表 + /// 地區列表 /// /// [HttpPost] - public async Task>> BuiList() + public async Task>> AreaList() { ApiResult> apiResult = new ApiResult>(); List bl = new List(); try { - var sqlString = @$"select d.device_area_tag, d.device_building_tag, d.device_floor_tag, CONCAT(case when d.device_area_tag='TPE' then '台北市' else '新北市' end, b.full_name, d.device_floor_tag) as full_name - from device d - join building b on d.device_building_tag = b.building_tag - where d.deleted = 0 - group by d.device_area_tag, d.device_building_tag, d.device_floor_tag, b.full_name"; + var sqlString = @$"select system_key as area_name, system_value as device_area_tag from variable where deleted = 0 and system_type = 'area'"; bl = await backendRepository.GetAllAsync(sqlString); @@ -128,6 +124,71 @@ namespace FrontendWebApi.ApiControllers return apiResult; } + /// + /// 大樓列表 + /// + /// + [HttpPost] + public async Task>> BuiList([FromBody] BuildingList b) + { + ApiResult> apiResult = new ApiResult>(); + List bl = new List(); + + try + { + var sqlString = @$"select d.device_building_tag, b.full_name as building_name + from device d + join building b on d.device_building_tag = b.building_tag + where d.deleted = 0 and d.device_area_tag = @device_area_tag + group by b.building_name, d.device_building_tag"; + + bl = await backendRepository.GetAllAsync(sqlString, new { @device_area_tag = b.device_area_tag }); + + apiResult.Code = "0000"; + apiResult.Data = bl; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + return apiResult; + } + + /// + /// 大樓列表 + /// + /// + [HttpPost] + public async Task>> FloList([FromBody] BuildingList b) + { + ApiResult> apiResult = new ApiResult>(); + List bl = new List(); + + try + { + var sqlString = @$"select d.device_floor_tag + from device d + where d.deleted = 0 and d.device_area_tag = @device_area_tag and d.device_building_tag = @device_building_tag + group by d.device_floor_tag"; + + bl = await backendRepository.GetAllAsync(sqlString, new { @device_area_tag = b.device_area_tag, @device_building_tag = b.device_building_tag }); + + apiResult.Code = "0000"; + apiResult.Data = bl; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + return apiResult; + } + /// /// 設備列表 /// @@ -141,9 +202,9 @@ namespace FrontendWebApi.ApiControllers try { var sqlString = @$"select device_number, concat(device_floor_tag, ' ', device_last_name, ' ', device_serial_tag) as device_name - from device where deleted = 0 and device_building_tag = @device_building_tag and device_floor_tag = @device_floor_tag"; + from device where deleted = 0 and device_area_tag = @device_area_tag and device_building_tag = @device_building_tag and device_floor_tag = @device_floor_tag"; - var param = new { @device_building_tag = bl.device_building_tag, @device_floor_tag = bl.device_floor_tag }; + var param = new { @device_building_tag = bl.device_building_tag, @device_floor_tag = bl.device_floor_tag, @device_area_tag = bl.device_area_tag }; d = await backendRepository.GetAllAsync(sqlString, param); From 703d52283d3d5ca77ea411da16d78f9ff1ea2743 Mon Sep 17 00:00:00 2001 From: dev02 Date: Fri, 11 Nov 2022 17:38:35 +0800 Subject: [PATCH 4/4] fix problem --- FrontendWebApi/ApiControllers/OperationController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FrontendWebApi/ApiControllers/OperationController.cs b/FrontendWebApi/ApiControllers/OperationController.cs index fb59396..666d771 100644 --- a/FrontendWebApi/ApiControllers/OperationController.cs +++ b/FrontendWebApi/ApiControllers/OperationController.cs @@ -125,7 +125,7 @@ namespace FrontendWebApi.ApiControllers } /// - /// 大樓列表 + /// 東別列表 /// /// [HttpPost] @@ -158,7 +158,7 @@ namespace FrontendWebApi.ApiControllers } /// - /// 大樓列表 + /// 樓層列表 /// /// [HttpPost]