feature:每次同步時device .deviceItem判斷與來源niagara的full_name不同則覆蓋
This commit is contained in:
parent
0db40ce635
commit
da2c265dd0
@ -82,6 +82,7 @@ namespace Backend.Controllers
|
|||||||
var building = ds.FirstOrDefault().building;
|
var building = ds.FirstOrDefault().building;
|
||||||
await niagaraDataSynchronizeRepository.InsertNiagaraTagList(ds, building);
|
await niagaraDataSynchronizeRepository.InsertNiagaraTagList(ds, building);
|
||||||
await niagaraDataSynchronizeRepository.DeviceComparison();
|
await niagaraDataSynchronizeRepository.DeviceComparison();
|
||||||
|
await niagaraDataSynchronizeRepository.CheckDiffFullNameAndCover();
|
||||||
await niagaraDataSynchronizeRepository.CheckFullNameEmptyReplaceByDeviceName();
|
await niagaraDataSynchronizeRepository.CheckFullNameEmptyReplaceByDeviceName();
|
||||||
await niagaraDataSynchronizeRepository.InsertBuildingMenu();
|
await niagaraDataSynchronizeRepository.InsertBuildingMenu();
|
||||||
await niagaraDataSynchronizeRepository.InsertSubSystemFloor();
|
await niagaraDataSynchronizeRepository.InsertSubSystemFloor();
|
||||||
@ -146,6 +147,7 @@ namespace Backend.Controllers
|
|||||||
var building = ds.FirstOrDefault().device_building_tag;
|
var building = ds.FirstOrDefault().device_building_tag;
|
||||||
await niagaraDataSynchronizeRepository.InsertItemFromNiagara(ds, building);
|
await niagaraDataSynchronizeRepository.InsertItemFromNiagara(ds, building);
|
||||||
await niagaraDataSynchronizeRepository.DeviceItemComparison();
|
await niagaraDataSynchronizeRepository.DeviceItemComparison();
|
||||||
|
await niagaraDataSynchronizeRepository.CheckItemDiffFullNameAndCover();
|
||||||
await niagaraDataSynchronizeRepository.ItemCheckFullNameEmptyReplaceByDeviceName();
|
await niagaraDataSynchronizeRepository.ItemCheckFullNameEmptyReplaceByDeviceName();
|
||||||
result = true;
|
result = true;
|
||||||
|
|
||||||
|
@ -512,6 +512,8 @@ namespace Repository.BackendRepository.Implement
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task CheckFullNameEmptyReplaceByDeviceName()
|
public async Task CheckFullNameEmptyReplaceByDeviceName()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
using (IDbConnection conn = GetDbConnection())
|
using (IDbConnection conn = GetDbConnection())
|
||||||
{
|
{
|
||||||
conn.Open();
|
conn.Open();
|
||||||
@ -542,6 +544,8 @@ namespace Repository.BackendRepository.Implement
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task ItemCheckFullNameEmptyReplaceByDeviceName()
|
public async Task ItemCheckFullNameEmptyReplaceByDeviceName()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//檢查是否有空值
|
||||||
using (IDbConnection conn = GetDbConnection())
|
using (IDbConnection conn = GetDbConnection())
|
||||||
{
|
{
|
||||||
conn.Open();
|
conn.Open();
|
||||||
@ -565,5 +569,76 @@ namespace Repository.BackendRepository.Implement
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 檢查device的full_name與niagara device_full_name不同者 覆蓋
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 比對 device_item full_name 與 import_niagara_item full_name是否相同
|
||||||
|
/// 不同則覆蓋
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,12 @@ namespace Repository.BackendRepository.Interface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task DeviceComparison();
|
Task DeviceComparison();
|
||||||
|
/// <summary>
|
||||||
|
///檢查Device與import_niagara_tag 的Full_Name是否相同 不同則Full_Name從import_niagara_tag 覆蓋至device
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task CheckDiffFullNameAndCover();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 比對 device的FullName,若為空則以DeviceName取代
|
/// 比對 device的FullName,若為空則以DeviceName取代
|
||||||
@ -36,6 +42,12 @@ namespace Repository.BackendRepository.Interface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task DeviceItemComparison();
|
Task DeviceItemComparison();
|
||||||
|
/// <summary>
|
||||||
|
/// 比對 device_item full_name 與 import_niagara_item是否相同
|
||||||
|
/// 不同則覆蓋
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task CheckItemDiffFullNameAndCover();
|
||||||
|
|
||||||
Task ItemCheckFullNameEmptyReplaceByDeviceName();
|
Task ItemCheckFullNameEmptyReplaceByDeviceName();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user