From f6dffd0ef3108ebdaee62b2ad0093c447bec3d24 Mon Sep 17 00:00:00 2001 From: "LAPTOP-6U09CO6D\\User" Date: Tue, 7 Feb 2023 11:55:52 +0800 Subject: [PATCH] =?UTF-8?q?change:=201.=E4=BF=AE=E6=94=B9=E6=AD=B7?= =?UTF-8?q?=E5=8F=B2=E7=B4=80=E9=8C=84=E5=B7=A6=E6=96=B9=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E9=81=B8=E5=96=AE=E5=88=A4=E6=96=B7=20device=20visible=20=3D?= =?UTF-8?q?=201=202.=E5=BE=8C=E7=AB=AF=E5=90=8C=E6=AD=A5=E5=88=A4=E6=96=B7?= =?UTF-8?q?table=20Device=20=20fullName=E7=82=BA=E7=A9=BA,=E4=BB=A5device?= =?UTF-8?q?=5Fnumber=E6=9B=BF=E4=BB=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NiagaraDataSynchronizeController.cs | 1 + .../ApiControllers/HistoryController.cs | 2 +- .../NiagaraDataSynchronizeRepository.cs | 31 ++++++++++++++++++- .../INiagaraDataSynchronizeRepository.cs | 6 ++++ 4 files changed, 38 insertions(+), 2 deletions(-) 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 ///