From 01d0ad6db1a5b6fe25fbf3032f2b3b4330922c45 Mon Sep 17 00:00:00 2001 From: keke Date: Tue, 22 Aug 2023 12:29:40 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20Niagara=20=E8=B3=87?= =?UTF-8?q?=E6=96=99=E5=90=8C=E6=AD=A5=20=E4=BF=AE=E6=94=B9=20sql=20?= =?UTF-8?q?=E8=AA=9E=E6=B3=95DeviceComparison?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NiagaraDataSynchronizeRepository.cs | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index 9800fce..14761d4 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -14,6 +14,7 @@ using Microsoft.Extensions.Primitives; using System.Web; using Org.BouncyCastle.Utilities.Collections; using System.Reflection; +using System.Drawing; namespace Repository.BackendRepository.Implement { @@ -326,6 +327,7 @@ namespace Repository.BackendRepository.Implement device_name_tag = x.Key.device_name_tag2 }); + int count = 0; foreach (var data in result) { //開關控制在個別燈具(device_node層) and 小類為二線式照明系統 and tag第八段開頭不是 G @@ -350,9 +352,17 @@ namespace Repository.BackendRepository.Implement data.device_serial_tag + "', '" + data.niagara_tags + "', '" + data.device_system_tag + "', 1, now(), now() );"); + count += 1; + if (count >= 100) + { + await conn.ExecuteAsync(sb.ToString()); + sb.Clear(); + count = 0; + } } } + count = 0; foreach (var data in result2) { var sqlString = new StringBuilder(); @@ -366,6 +376,13 @@ namespace Repository.BackendRepository.Implement created_by, created_at) VALUES (uuid(), '" + data.device_building_tag + "', '" + data.device_system_tag + "', '" + data.device_name_tag + "', 0, 0, 1, 0, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now());"); + count += 1; + if (count >= 100) + { + await conn.ExecuteAsync(sb2.ToString()); + sb2.Clear(); + count = 0; + } } } @@ -405,6 +422,7 @@ namespace Repository.BackendRepository.Implement device_name_tag = x.Key.device_name_tag2 }); + int count = 0; foreach (var data in result) { //開關控制在個別燈具(device_node層) and 小類為二線式照明系統 and tag第八段開頭不是 G @@ -416,6 +434,13 @@ namespace Repository.BackendRepository.Implement ",'" + data.niagara_tags + // device_number "', '" + data.device_full_name + //full_name "','B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), now());"); + count += 1; + if (count >= 100) + { + await conn.ExecuteAsync(sb.ToString()); + sb.Clear(); + count = 0; + } } } @@ -434,7 +459,7 @@ namespace Repository.BackendRepository.Implement SELECT niagara_tags FROM import_niagara_tag LIMIT 100000 - ) i ON d.device_number COLLATE utf8mb4_0900_ai_ci = i.niagara_tags COLLATE utf8mb4_0900_ai_ci + ) i ON d.device_number = i.niagara_tags SET d.is_link = 0 WHERE d.is_link = 1 and i.niagara_tags is null;"); await conn.ExecuteAsync(sb.ToString()); @@ -455,7 +480,8 @@ namespace Repository.BackendRepository.Implement } catch (Exception exception) { - throw exception; + //throw exception; + throw; } finally {