From 8914bb7ac20c891a06e9f51e0e97e226eb4c71fa Mon Sep 17 00:00:00 2001 From: dev02 Date: Mon, 4 Mar 2024 16:17:45 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E9=87=8D=E8=A4=87=E5=95=8F=E9=A1=8C,=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=89=8D=E5=8F=B0api=E6=96=B0=E9=9C=80?= =?UTF-8?q?=E6=B1=82,=20=E4=BF=AE=E6=94=B9model=20=E8=A1=9D=E7=AA=81?= =?UTF-8?q?=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Models/Device.cs | 1 - .../ApiControllers/BuildController.cs | 2 +- .../NiagaraDataSynchronizeRepository.cs | 23 +++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Backend/Models/Device.cs b/Backend/Models/Device.cs index 6f8bad7..9825929 100644 --- a/Backend/Models/Device.cs +++ b/Backend/Models/Device.cs @@ -82,7 +82,6 @@ namespace Backend.Models public List Device_disasters { get; set; } //防災類型 public List Device_nodes { get; set; } //設備子節點 - public System.DateTime created_at { get; set; } /// /// 前次成功日期;下次重新歸檔日期 /// diff --git a/FrontendWebApi/ApiControllers/BuildController.cs b/FrontendWebApi/ApiControllers/BuildController.cs index 2d0d5a8..c9482fa 100644 --- a/FrontendWebApi/ApiControllers/BuildController.cs +++ b/FrontendWebApi/ApiControllers/BuildController.cs @@ -520,7 +520,7 @@ namespace FrontendWebApi.ApiControllers { if (!string.IsNullOrEmpty(projectName) && projectName.Contains("ibms_dome") && (post.main_system_tag == "S" && post.sub_system_tag == "P")) { - sub_system_guidsql = $@" and (d.device_name_tag = '{post.sub_system_tag}' or d.device_name_tag = 'B')"; + sub_system_guidsql = $@" and (d.device_name_tag = '{post.sub_system_tag}' or d.device_name_tag = 'B') and d.device_number not like '%ATS%'"; singleSubSql = $"and (di.device_name_tag = '{post.sub_system_tag}' or di.device_name_tag = 'B')"; } else diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index ef24e0b..184c25b 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -407,11 +407,34 @@ namespace Repository.BackendRepository.Implement { await conn.ExecuteAsync(sb.ToString()); } + stopwatchSection.Stop(); await KeepTimeLog("update device_item parent_path", stopwatchSection.ElapsedMilliseconds); stopwatch.Stop(); await KeepTimeLog("InsertItemFromNiagara", stopwatch.ElapsedMilliseconds); + + //delete the same point in + await conn.ExecuteAsync(@"DELETE ini1 + FROM import_niagara_item ini1 + JOIN ( + SELECT DISTINCT ini1.id + FROM import_niagara_item ini1 + JOIN import_niagara_item ini2 ON ini1.id != ini2.id + AND ini1.device_building_tag = ini2.device_building_tag + AND ini1.device_system_tag = ini2.device_system_tag + AND ini1.device_name_tag = ini2.device_name_tag + AND ini1.device_point_name = ini2.device_point_name + AND ini1.full_name = ini2.full_name + AND ini1.parent_path = ini2.parent_path + AND ini1.is_history = ini2.is_history + WHERE ini1.id NOT IN ( + SELECT MIN(id) + FROM import_niagara_item + GROUP BY device_building_tag, device_system_tag, device_name_tag, device_point_name, full_name + HAVING COUNT(device_point_name) > 1 + ) + ) AS to_delete ON ini1.id = to_delete.id;"); #endregion } catch (Exception exception)