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)