From 938a7cdb7e69027d1eca0147f8a34016b90896d7 Mon Sep 17 00:00:00 2001 From: dev02 Date: Fri, 12 May 2023 12:20:44 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9device?= =?UTF-8?q?=5Fitem=E4=BA=9Bapi=20=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=B7build?= =?UTF-8?q?ing=5Ftag,=20niagara=E5=90=8C=E6=AD=A5device=5Fitem=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0building=5Ftag=20[=E5=89=8D=E7=AB=AF]=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9api=E7=99=BC=E9=80=81=E5=A2=9E=E5=8A=A0building=5Ftag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Controllers/DeviceManageController.cs | 8 ++++---- Backend/Controllers/SystemCategoryController.cs | 6 +++--- Backend/Models/SystemCategory.cs | 6 ++++++ Backend/Views/DeviceManage/Index.cshtml | 3 ++- .../Implement/NiagaraDataSynchronizeRepository.cs | 3 ++- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Backend/Controllers/DeviceManageController.cs b/Backend/Controllers/DeviceManageController.cs index 64e9bed..c810839 100644 --- a/Backend/Controllers/DeviceManageController.cs +++ b/Backend/Controllers/DeviceManageController.cs @@ -1653,18 +1653,18 @@ namespace Backend.Controllers /// /// 取得子系統的device item /// - /// + /// /// [HttpPost] - public async Task>> GetDeviceItem(string sub_system_tag) + public async Task>> GetDeviceItem(DeviceItemInput input) { ApiResult> apiResult = new ApiResult>(); try { - string sWhere = "deleted = 0 AND device_name_tag = @Sub_system_tag"; + string sWhere = "deleted = 0 AND device_name_tag = @Sub_system_tag and device_building_tag = @device_building_tag"; - object param = new { Sub_system_tag = sub_system_tag }; + object param = new { Sub_system_tag = input.sub_system_tag, device_building_tag = input.building_tag }; var deviceItems = await backendRepository.GetAllAsync("device_item", sWhere, param); diff --git a/Backend/Controllers/SystemCategoryController.cs b/Backend/Controllers/SystemCategoryController.cs index 2509b47..641391b 100644 --- a/Backend/Controllers/SystemCategoryController.cs +++ b/Backend/Controllers/SystemCategoryController.cs @@ -581,14 +581,14 @@ namespace Backend.Controllers ApiResult> apiResult = new ApiResult>(); try { - + var building_tag = await backendRepository.GetOneAsync($@"select system_value from variable where system_type = 'project_name' and deleted = 0"); var sql = @"SELECT di.* FROM device_item di JOIN variable sv ON di.device_name_tag = sv.system_value JOIN variable mv ON sv.system_parent_id = mv.id AND di.device_system_tag = mv.system_value - WHERE sv.id = @id AND di.deleted = @Deleted"; + WHERE sv.id = @id AND di.deleted = @Deleted and di.device_building_tag = @building_tag"; - object param = new { Deleted = 0, id = id }; + object param = new { Deleted = 0, id = id, building_tag = building_tag.Split("/")[1] }; var systemSubs = await backendRepository.GetAllAsync(sql, param); diff --git a/Backend/Models/SystemCategory.cs b/Backend/Models/SystemCategory.cs index d661db9..ba54301 100644 --- a/Backend/Models/SystemCategory.cs +++ b/Backend/Models/SystemCategory.cs @@ -78,4 +78,10 @@ namespace Backend.Models public string guid { get; set; } public string subguid { get; set; } } + + public class DeviceItemInput + { + public string sub_system_tag { get; set; } + public string building_tag { get; set; } + } } diff --git a/Backend/Views/DeviceManage/Index.cshtml b/Backend/Views/DeviceManage/Index.cshtml index cb23ecf..f066639 100644 --- a/Backend/Views/DeviceManage/Index.cshtml +++ b/Backend/Views/DeviceManage/Index.cshtml @@ -1551,7 +1551,8 @@ var selectedSub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : ""; var url = "/DeviceManage/GetDeviceItem"; var send_data = { - sub_system_tag: selectedSub_system_tag + sub_system_tag: selectedSub_system_tag, + building_tag: selected_device_building_tag } $.post(url, send_data, function (rel) { diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index 193cf9e..674fef8 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -471,7 +471,7 @@ namespace Repository.BackendRepository.Implement isBool = 1; } sb.Append($@"insert device_item(deleted, points, is_show, is_show_riserDiagram, is_controll, is_bool, is_show_history, is_link, - device_system_tag, device_name_tag, full_name, parent_path, created_at, updated_at) + device_system_tag, device_name_tag, device_building_tag, full_name, parent_path, created_at, updated_at) VALUES (0, '" + data.device_point_name + "', 1, 0, " + isControll + "," + @@ -480,6 +480,7 @@ namespace Repository.BackendRepository.Implement ", 1, '" + data.device_system_tag + "', '" + data.device_name_tag + "', '" + + data.device_building_tag + "', '" + data.full_name + "', '" + data.parent_path + "', " + "now(), now());");