From 3a0ead386b0814ae085dd4197e5ad5283aefcc85 Mon Sep 17 00:00:00 2001 From: dev02 Date: Tue, 14 Nov 2023 18:54:22 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9api?= =?UTF-8?q?=E6=A2=9D=E4=BB=B6,=20=E4=BF=AE=E6=94=B9=E5=90=8C=E6=AD=A5?= =?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/Controllers/DeviceManageController.cs | 1 + .../NiagaraDataSynchronizeRepository.cs | 96 ++++++++++--------- 2 files changed, 50 insertions(+), 47 deletions(-) diff --git a/Backend/Controllers/DeviceManageController.cs b/Backend/Controllers/DeviceManageController.cs index 7ca51bb..da1b5f6 100644 --- a/Backend/Controllers/DeviceManageController.cs +++ b/Backend/Controllers/DeviceManageController.cs @@ -207,6 +207,7 @@ namespace Backend.Controllers AND d.device_name_tag = @sub_system_tag AND d.device_floor_tag = @floor_tag AND d.deleted = 0 + AND d.is_link = 1 ) d JOIN building b ON d.device_building_tag = b.building_tag JOIN variable mv ON d.device_system_tag = mv.system_value AND mv.system_type = @main_system_type and mv.deleted = 0 diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index 1531883..565721d 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -290,60 +290,62 @@ namespace Repository.BackendRepository.Implement { await conn.ExecuteAsync(sb.ToString()); } + } - sb.Clear(); + sb.Clear(); - if (isDome.Contains("ibms_dome")) - { - sb.Append($@" update import_niagara_item a - join variable b on a.device_name_tag COLLATE utf8mb4_0900_ai_ci = b.system_value COLLATE utf8mb4_0900_ai_ci and b.deleted = 0 and b.system_type = 'device_system_category_layer3' - join variable v1 on b.system_parent_id = v1.id - set device_system_tag = v1.system_value - where (device_system_tag <> 'S' and device_system_tag <> 'CWB' and device_system_tag <> 'B');"); - - using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) - { - await conn.ExecuteAsync(sb.ToString()); - } - } - - sb.Clear(); - - sb.Append($@" update import_niagara_item set full_name = device_point_name where full_name = '' or full_name is null;"); - using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) - { - await conn.ExecuteAsync(sb.ToString()); - } - sb.Clear(); - - sb.Append($@"SET SQL_SAFE_UPDATES = 0; - update import_niagara_item ini - join ( - select device_building_tag, device_system_tag, device_name_tag, device_point_name - from import_niagara_item_history - group by device_building_tag, device_system_tag, device_name_tag, device_point_name - ) as inih on ini.device_building_tag = inih.device_building_tag and ini.device_system_tag = inih.device_system_tag and ini.device_name_tag = inih.device_name_tag - and ini.device_point_name = inih.device_point_name - set ini.is_history = 1"); - - using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) - { - await conn.ExecuteAsync(sb.ToString()); - } - sb.Clear(); - - sb.Append($@"SET SQL_SAFE_UPDATES = 0; - update import_niagara_item ini - join ( - select distinct device_building_tag, parent_path from import_niagara_item_history - ) inih on ini.device_building_tag = inih.device_building_tag - set ini.parent_path = inih.parent_path"); + if (isDome.Contains("ibms_dome")) + { + sb.Append($@" update import_niagara_item a + join variable b on a.device_name_tag COLLATE utf8mb4_0900_ai_ci = b.system_value COLLATE utf8mb4_0900_ai_ci and b.deleted = 0 and b.system_type = 'device_system_category_layer3' + join variable v1 on b.system_parent_id = v1.id + set device_system_tag = v1.system_value + where (device_system_tag <> 'S' and device_system_tag <> 'CWB' and device_system_tag <> 'B');"); using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { await conn.ExecuteAsync(sb.ToString()); } } + + sb.Clear(); + + sb.Append($@" update import_niagara_item set full_name = device_point_name where full_name = '' or full_name is null;"); + using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) + { + await conn.ExecuteAsync(sb.ToString()); + } + sb.Clear(); + + sb.Append($@"SET SQL_SAFE_UPDATES = 0; + update import_niagara_item ini + join ( + select device_building_tag, device_system_tag, device_name_tag, device_point_name + from import_niagara_item_history + group by device_building_tag, device_system_tag, device_name_tag, device_point_name + ) as inih on ini.device_building_tag = inih.device_building_tag and ini.device_system_tag = inih.device_system_tag and ini.device_name_tag = inih.device_name_tag + and ini.device_point_name = inih.device_point_name + set ini.is_history = 1"); + + using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) + { + await conn.ExecuteAsync(sb.ToString()); + } + sb.Clear(); + + sb.Append($@"SET SQL_SAFE_UPDATES = 0; + update import_niagara_item ini + join ( + select distinct device_building_tag, parent_path from import_niagara_item_history + ) inih on ini.device_building_tag = inih.device_building_tag + set ini.parent_path = inih.parent_path"); + + using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) + { + await conn.ExecuteAsync(sb.ToString()); + } + + await RecoverSysTag("import_niagara_item"); #endregion } catch (Exception exception) @@ -553,7 +555,7 @@ namespace Repository.BackendRepository.Implement FROM import_niagara_tag LIMIT 100000 ) i ON d.device_number = i.niagara_tags - SET d.is_link = 1"); + SET d.is_link = 1, d.deleted = 0"); using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled)) { await conn.ExecuteAsync(sb.ToString());