From 3dcc506236b741ba2b9e7bfa20f8306a28c17b02 Mon Sep 17 00:00:00 2001 From: keke Date: Fri, 18 Aug 2023 17:33:53 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E5=A5=BD?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=8A=9F=E8=83=BD=20[FE=20API]=20=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E9=A1=AF=E7=A4=BA=E5=A4=A7=E5=85=AC=E5=8D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Controllers/NiagaraDataSynchronizeController.cs | 2 +- FrontendWebApi/ApiControllers/BuildController.cs | 9 ++++++--- .../Implement/NiagaraDataSynchronizeRepository.cs | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Backend/Controllers/NiagaraDataSynchronizeController.cs b/Backend/Controllers/NiagaraDataSynchronizeController.cs index 42c316b..ebe5cd4 100644 --- a/Backend/Controllers/NiagaraDataSynchronizeController.cs +++ b/Backend/Controllers/NiagaraDataSynchronizeController.cs @@ -116,7 +116,7 @@ namespace Backend.Controllers string LightSwitchLevel = await niagaraDataSynchronizeRepository.getLightSwitchLevel(); //獲取照明開關 是否在 device or device_node await niagaraDataSynchronizeRepository.InsertNiagaraTagList(ds, building, tag_quantity); // 匯入 MySQL table: import_niagara_tag await niagaraDataSynchronizeRepository.DeviceComparison(LightSwitchLevel); - await niagaraDataSynchronizeRepository.CheckDiffFullNameAndCover(); + await niagaraDataSynchronizeRepository.CheckDiffFullNameAndCover(); // * await niagaraDataSynchronizeRepository.CheckFullNameEmptyReplaceByDeviceName(); await niagaraDataSynchronizeRepository.InsertBuildingMenu(); await niagaraDataSynchronizeRepository.InsertSubSystemFloor(); diff --git a/FrontendWebApi/ApiControllers/BuildController.cs b/FrontendWebApi/ApiControllers/BuildController.cs index e9b72fb..76f78ef 100644 --- a/FrontendWebApi/ApiControllers/BuildController.cs +++ b/FrontendWebApi/ApiControllers/BuildController.cs @@ -285,9 +285,12 @@ namespace FrontendWebApi.ApiControllers foreach(var bm in buildingMenus) { var safeSystem = bm.main_system.Where(x => x.main_system_tag == "S").FirstOrDefault(); - var EmerBuckle = safeSystem.Sub_system.Where(x => x.sub_system_tag == "P").ToList(); - EmerBuckle.AddRange(safeSystem.Sub_system.Where(x => x.sub_system_tag == "B").ToList()); - safeSystem.Sub_system.RemoveAll(x => x.sub_system_tag == "B"); + if (safeSystem != null) + { + var EmerBuckle = safeSystem.Sub_system.Where(x => x.sub_system_tag == "P").ToList(); + EmerBuckle.AddRange(safeSystem.Sub_system.Where(x => x.sub_system_tag == "B").ToList()); + safeSystem.Sub_system.RemoveAll(x => x.sub_system_tag == "B"); + } } } apiResult.Data = buildingMenus; diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index 77df0d3..e5ddbd8 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -795,12 +795,12 @@ namespace Repository.BackendRepository.Implement update device d JOIN ( select niagara_tags, device_full_name from import_niagara_tag limit 100000 - ) m ON m.niagara_tags COLLATE utf8mb4_0900_ai_ci = d.device_number COLLATE utf8mb4_0900_ai_ci + ) m ON m.niagara_tags = d.device_number LEFT JOIN ( SELECT niagara_tags, device_full_name FROM import_niagara_tag LIMIT 100000 - ) m2 ON m2.niagara_tags COLLATE utf8mb4_0900_ai_ci = d.device_number COLLATE utf8mb4_0900_ai_ci AND m2.device_full_name COLLATE utf8mb4_0900_ai_ci = d.full_name COLLATE utf8mb4_0900_ai_ci + ) m2 ON m2.niagara_tags = d.device_number AND m2.device_full_name = d.full_name SET d.full_name = m.device_full_name WHERE m2.niagara_tags IS NULL;"); await conn.ExecuteAsync(sb.ToString());