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)