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/FrontendWebApi/ApiControllers/GraphManageController.cs b/FrontendWebApi/ApiControllers/GraphManageController.cs index 8d701f8..9c08634 100644 --- a/FrontendWebApi/ApiControllers/GraphManageController.cs +++ b/FrontendWebApi/ApiControllers/GraphManageController.cs @@ -11,6 +11,7 @@ using System.Web; using Repository.BackendRepository.Interface; using Repository.FrontendRepository.Interface; using System.IO; +using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource; namespace FrontendWebApi.ApiControllers { @@ -99,28 +100,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"; diff --git a/FrontendWebApi/ApiControllers/OperationController.cs b/FrontendWebApi/ApiControllers/OperationController.cs index edc9e26..4672c78 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); 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")))