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());