feature:根據niagara更新device_item is_show_history

This commit is contained in:
史萬澤 2023-02-09 12:07:17 +08:00
parent da2c265dd0
commit 3f718bb228
3 changed files with 36 additions and 3 deletions

View File

@ -149,6 +149,7 @@ namespace Backend.Controllers
await niagaraDataSynchronizeRepository.DeviceItemComparison();
await niagaraDataSynchronizeRepository.CheckItemDiffFullNameAndCover();
await niagaraDataSynchronizeRepository.ItemCheckFullNameEmptyReplaceByDeviceName();
await niagaraDataSynchronizeRepository.CheckItemIsShowHistory();
result = true;
apiResult.Code = "0000";

View File

@ -512,8 +512,6 @@ namespace Repository.BackendRepository.Implement
/// <returns></returns>
public async Task CheckFullNameEmptyReplaceByDeviceName()
{
using (IDbConnection conn = GetDbConnection())
{
conn.Open();
@ -534,7 +532,6 @@ namespace Repository.BackendRepository.Implement
conn.Close();
}
}
}
}
@ -637,7 +634,40 @@ namespace Repository.BackendRepository.Implement
conn.Close();
}
}
}
}
/// <summary>
/// 先將device_ite的is_show_history全部關掉
/// 根據niagara輸入資料來決定要開哪些點
/// </summary>
/// <returns></returns>
public async Task CheckItemIsShowHistory()
{
//先將所有is_show_history關閉,niagara有的才開啟
using (IDbConnection conn = GetDbConnection())
{
conn.Open();
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{
try
{
StringBuilder sb = new StringBuilder();
//先全部關閉
sb.Append("update device_item set is_show_history=0;");
sb.Append("update device_item set is_show_history= 1" +
"(select distinct device_system_tag, device_name_tag, device_point_name From import_niagara_item);");
await conn.ExecuteAsync(sb.ToString());
}
catch (Exception exception)
{
throw exception;
}
finally
{
conn.Close();
}
}
}
}
}

View File

@ -31,6 +31,8 @@ namespace Repository.BackendRepository.Interface
/// <returns></returns>
Task CheckDiffFullNameAndCover();
Task CheckItemIsShowHistory();
/// <summary>
/// 比對 device的FullName若為空則以DeviceName取代