diff --git a/Backend/Controllers/NiagaraDataSynchronizeController.cs b/Backend/Controllers/NiagaraDataSynchronizeController.cs
index 77e2cdb..b1f5206 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.CheckDiffFullNameAndCover();
await niagaraDataSynchronizeRepository.CheckFullNameEmptyReplaceByDeviceName();
await niagaraDataSynchronizeRepository.InsertBuildingMenu();
await niagaraDataSynchronizeRepository.InsertSubSystemFloor();
@@ -146,6 +147,7 @@ namespace Backend.Controllers
var building = ds.FirstOrDefault().device_building_tag;
await niagaraDataSynchronizeRepository.InsertItemFromNiagara(ds, building);
await niagaraDataSynchronizeRepository.DeviceItemComparison();
+ await niagaraDataSynchronizeRepository.CheckItemDiffFullNameAndCover();
await niagaraDataSynchronizeRepository.ItemCheckFullNameEmptyReplaceByDeviceName();
result = true;
diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs
index 116ec37..dddc9da 100644
--- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs
+++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs
@@ -512,6 +512,8 @@ namespace Repository.BackendRepository.Implement
///
public async Task CheckFullNameEmptyReplaceByDeviceName()
{
+
+
using (IDbConnection conn = GetDbConnection())
{
conn.Open();
@@ -542,6 +544,8 @@ namespace Repository.BackendRepository.Implement
///
public async Task ItemCheckFullNameEmptyReplaceByDeviceName()
{
+
+ //檢查是否有空值
using (IDbConnection conn = GetDbConnection())
{
conn.Open();
@@ -565,5 +569,76 @@ namespace Repository.BackendRepository.Implement
}
}
+
+ ///
+ /// 檢查device的full_name與niagara device_full_name不同者 覆蓋
+ ///
+ ///
+ public async Task CheckDiffFullNameAndCover()
+ {
+ using (IDbConnection conn = GetDbConnection())
+ {
+ conn.Open();
+ using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
+ {
+ try
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append("update device d inner JOIN import_niagara_tag m ON m.niagara_tags = d.device_number " +
+ "set d.full_name=m.device_full_name " +
+ "where m.device_full_name<>d.full_name;");
+ await conn.ExecuteAsync(sb.ToString());
+ }
+ catch (Exception exception)
+ {
+ throw exception;
+ }
+ finally
+ {
+ conn.Close();
+ }
+ }
+
+ }
+ }
+
+
+ ///
+ /// 比對 device_item full_name 與 import_niagara_item full_name是否相同
+ /// 不同則覆蓋
+ ///
+ ///
+ public async Task CheckItemDiffFullNameAndCover()
+ {
+ //檢查
+ using (IDbConnection conn = GetDbConnection())
+ {
+ conn.Open();
+ using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
+ {
+ try
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append("update device_item d " +
+ "inner JOIN import_niagara_item m ON " +
+ "m.device_system_tag = d.device_system_tag and " +
+ "m.device_name_tag = d.device_name_tag and " +
+ "m.device_point_name = d.points " +
+ "set d.full_name=m.full_name " +
+ "where d.full_name<>m.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 f079975..5629b9c 100644
--- a/Repository/BackendRepository/Interface/INiagaraDataSynchronizeRepository.cs
+++ b/Repository/BackendRepository/Interface/INiagaraDataSynchronizeRepository.cs
@@ -25,6 +25,12 @@ namespace Repository.BackendRepository.Interface
///
///
Task DeviceComparison();
+ ///
+ ///檢查Device與import_niagara_tag 的Full_Name是否相同 不同則Full_Name從import_niagara_tag 覆蓋至device
+ ///
+ ///
+ Task CheckDiffFullNameAndCover();
+
///
/// 比對 device的FullName,若為空則以DeviceName取代
@@ -36,6 +42,12 @@ namespace Repository.BackendRepository.Interface
///
///
Task DeviceItemComparison();
+ ///
+ /// 比對 device_item full_name 與 import_niagara_item是否相同
+ /// 不同則覆蓋
+ ///
+ ///
+ Task CheckItemDiffFullNameAndCover();
Task ItemCheckFullNameEmptyReplaceByDeviceName();
///