From 707ae5108023ea9826790ea51a451cb5e181a560 Mon Sep 17 00:00:00 2001 From: GiteaAdmin Date: Tue, 14 Mar 2023 13:37:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF=20API=EF=BC=9A=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20device=5Fnode.coordinate=5F3D=20=E7=B5=A6=E7=87=88?= =?UTF-8?q?=E5=85=B7=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/DeviceManageController.cs | 5 ++-- FrontendWebApi/Models/Build.cs | 1 + .../NiagaraDataSynchronizeRepository.cs | 24 ++++++++++++++----- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs index 92b8af8..e6d41fc 100644 --- a/FrontendWebApi/ApiControllers/DeviceManageController.cs +++ b/FrontendWebApi/ApiControllers/DeviceManageController.cs @@ -767,6 +767,7 @@ namespace FrontendWebApi.ApiControllers dn.device_guid, dn.full_name AS Device_node_full_name, dn.device_node_coordinate, + dn.device_node_coordinate_3d, dn.priority, dn.forge_dbid FROM device_node dn @@ -774,9 +775,7 @@ namespace FrontendWebApi.ApiControllers ORDER BY dn.priority ASC"; d.Device_nodes = await backendRepository.GetAllAsync(sql_node, new { device_guid = d.device_guid }); - } - - + } apiResult.Data = dl; apiResult.Code = "0000"; diff --git a/FrontendWebApi/Models/Build.cs b/FrontendWebApi/Models/Build.cs index aa03e7d..d642125 100644 --- a/FrontendWebApi/Models/Build.cs +++ b/FrontendWebApi/Models/Build.cs @@ -206,6 +206,7 @@ namespace FrontendWebApi.Models public string Device_guid { get; set; } public string Device_node_full_name { get; set; } public string Device_node_coordinate { get; set; } + public string Device_node_coordinate_3D { get; set; } public int Priority { get; set; } public int forge_dbid { get; set; } } diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index 77a3afd..a95c456 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -218,7 +218,7 @@ namespace Repository.BackendRepository.Implement { sb.Append($@" insert device(device_guid, deleted, status, priority, is_link, device_area_tag, device_building_tag, device_system_tag, device_name_tag, full_name, device_floor_tag, device_master, - device_last_name, device_serial_tag, device_number, device_system_category_layer3, created_at, updated_at) + device_last_name, device_serial_tag, device_number, device_system_category_layer3, visible, created_at, updated_at) values(uuid(), 0, 1, 0, 1, '" + data.device_area_tag + "', '" + data.device_building_tag + "', '" + @@ -230,7 +230,7 @@ namespace Repository.BackendRepository.Implement data.device_last_name_tag + "', '" + data.device_serial_tag + "', '" + data.niagara_tags + "', '" + - data.device_system_tag + "', now(), now() );"); + data.device_system_tag + "', 1, now(), now() );"); } foreach (var data in result2) @@ -301,7 +301,7 @@ namespace Repository.BackendRepository.Implement result = (await conn.QueryAsync(sb.ToString())).ToList(); sb.Clear(); - //新增至device, is_link = 1 +# region 新增至device, is_link = 1 if (result.Count > 0) { foreach (var data in result) @@ -334,12 +334,24 @@ namespace Repository.BackendRepository.Implement sb.Clear(); } } + #endregion + + + //device有,niagara沒有,is_link 更新成 0 + //sb.Append($@" SET SQL_SAFE_UPDATES = 0; + // UPDATE device_item d LEFT JOIN import_niagara_item m + // ON d.device_system_tag = m.device_system_tag and d.device_name_tag = m.device_name_tag and d.points = m.device_point_name + // SET d.is_link = 0, d.is_show_history = 0 + // WHERE m.device_point_name IS NULL"); + + //本次有匯入的 isLink 改為 1, 沒有的 isLink = 0 sb.Append($@" SET SQL_SAFE_UPDATES = 0; UPDATE device_item d LEFT JOIN import_niagara_item m - ON d.device_system_tag = m.device_system_tag and d.device_name_tag = m.device_name_tag and d.points = m.device_point_name - SET d.is_link = 0, d.is_show_history = 0 - WHERE m.device_point_name IS NULL"); + ON d.device_system_tag = m.device_system_tag and d.device_name_tag = m.device_name_tag and d.points = m.device_point_name + SET d.is_link = case when device_point_name is null then 0 else 1 end , + d.is_show_history = case when device_point_name is null then 0 else 1 end"); + await conn.ExecuteAsync(sb.ToString()); } catch (Exception exception)