diff --git a/Backend/Controllers/NiagaraDataSynchronizeController.cs b/Backend/Controllers/NiagaraDataSynchronizeController.cs index 5610f94..c175fd5 100644 --- a/Backend/Controllers/NiagaraDataSynchronizeController.cs +++ b/Backend/Controllers/NiagaraDataSynchronizeController.cs @@ -82,6 +82,7 @@ namespace Backend.Controllers var building = ds.FirstOrDefault().building; await niagaraDataSynchronizeRepository.InsertNiagaraTagList(ds, building); await niagaraDataSynchronizeRepository.DeviceComparison(); + await niagaraDataSynchronizeRepository.CheckFullNameEmptyReplaceByDeviceName(); await niagaraDataSynchronizeRepository.InsertBuildingMenu(); await niagaraDataSynchronizeRepository.InsertSubSystemFloor(); result = true; diff --git a/FrontendWebApi/ApiControllers/HistoryController.cs b/FrontendWebApi/ApiControllers/HistoryController.cs index cf8b7a6..0584e70 100644 --- a/FrontendWebApi/ApiControllers/HistoryController.cs +++ b/FrontendWebApi/ApiControllers/HistoryController.cs @@ -204,7 +204,7 @@ namespace FrontendWebApi.ApiControllers join userinfo c on c.role_guid = a.role_guid join variable v2 on b.ShowView = v2.id and v2.system_type = @sub_system_type join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type - join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0 + join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0 and d.visible = 1 where c.account = @account order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type }); var dbbuilding = await frontendRepository.GetAllAsync( diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index e14e36c..ebb1530 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using System.Transactions; using Repository.Models; using System.Data.SqlTypes; +using Microsoft.Extensions.Primitives; namespace Repository.BackendRepository.Implement { @@ -223,7 +224,7 @@ namespace Repository.BackendRepository.Implement data.device_building_tag + "', '" + data.device_system_tag + "', '" + data.device_name_tag + "', '" + - data.device_full_name + "', '" + + data.device_full_name + "', '" + data.device_floor_tag + "', '" + data.device_master_tag + "', '" + data.device_last_name_tag + "', '" + @@ -505,6 +506,34 @@ namespace Repository.BackendRepository.Implement } } } + /// + /// 檢查device內FullName為空的值,以device_Name取代 + /// + /// + public async Task CheckFullNameEmptyReplaceByDeviceName() + { + using (IDbConnection conn = GetDbConnection()) + { + conn.Open(); + using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) + { + try + { + StringBuilder sb = new StringBuilder(); + sb.Append("update bims_mitsubishi.device set full_name=device_number where full_Name='';"); + await conn.ExecuteAsync(sb.ToString()); + } + catch (Exception exception) + { + throw exception; + } + finally + { + conn.Close(); + } + } + } + } } } diff --git a/Repository/BackendRepository/Interface/INiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Interface/INiagaraDataSynchronizeRepository.cs index be4ba4e..90b440c 100644 --- a/Repository/BackendRepository/Interface/INiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Interface/INiagaraDataSynchronizeRepository.cs @@ -25,6 +25,12 @@ namespace Repository.BackendRepository.Interface /// /// Task DeviceComparison(); + + /// + /// 比對 device的FullName,若為空則以DeviceName取代 + /// + /// + Task CheckFullNameEmptyReplaceByDeviceName(); /// /// 比對 device_item ///