修改niagara 同步
This commit is contained in:
parent
4c956e3a4a
commit
4ec1f0f5bd
@ -196,6 +196,27 @@ namespace Repository.BackendRepository.Implement
|
|||||||
sql = "delete from import_niagara_item where device_building_tag = '" + building + "'";
|
sql = "delete from import_niagara_item where device_building_tag = '" + building + "'";
|
||||||
await conn.ExecuteAsync(sql);
|
await conn.ExecuteAsync(sql);
|
||||||
#endregion
|
#endregion
|
||||||
|
ds = ds.GroupBy(x => new {
|
||||||
|
device_area_tag = x.device_area_tag,
|
||||||
|
device_building_tag = x.device_building_tag,
|
||||||
|
device_system_tag = x.device_system_tag,
|
||||||
|
device_name_tag = x.device_name_tag,
|
||||||
|
device_point_name = x.device_point_name,
|
||||||
|
full_name = x.full_name,
|
||||||
|
parent_path = x.parent_path,
|
||||||
|
isHistory = x.isHistory
|
||||||
|
})
|
||||||
|
.Select(x => new ImpNiaItem
|
||||||
|
{
|
||||||
|
device_area_tag = x.Key.device_area_tag,
|
||||||
|
device_building_tag = x.Key.device_building_tag,
|
||||||
|
device_system_tag = x.Key.device_system_tag,
|
||||||
|
device_name_tag = x.Key.device_name_tag,
|
||||||
|
device_point_name = x.Key.device_point_name,
|
||||||
|
full_name = x.Key.full_name,
|
||||||
|
parent_path = x.Key.parent_path,
|
||||||
|
isHistory = x.Key.isHistory
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
#region 放入import_niagara_item資料表
|
#region 放入import_niagara_item資料表
|
||||||
@ -426,7 +447,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
result = (await conn.QueryAsync<NiagaraTagsForItem>(sb.ToString())).ToList<NiagaraTagsForItem>();
|
result = (await conn.QueryAsync<NiagaraTagsForItem>(sb.ToString())).ToList<NiagaraTagsForItem>();
|
||||||
|
|
||||||
sb.Clear();
|
sb.Clear();
|
||||||
# region 新增至device, is_link = 1
|
# region 新增至device, is_link = 1
|
||||||
if (result.Count > 0)
|
if (result.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var data in result)
|
foreach (var data in result)
|
||||||
@ -475,9 +496,11 @@ namespace Repository.BackendRepository.Implement
|
|||||||
//本次有匯入的 isLink 改為 1, 沒有的 isLink = 0
|
//本次有匯入的 isLink 改為 1, 沒有的 isLink = 0
|
||||||
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
|
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
|
||||||
UPDATE device_item d LEFT JOIN import_niagara_item m
|
UPDATE device_item d LEFT JOIN import_niagara_item m
|
||||||
ON d.device_system_tag = m.device_system_tag and d.device_name_tag = m.device_name_tag and d.points = m.device_point_name
|
ON d.device_system_tag = m.device_system_tag and d.device_name_tag = m.device_name_tag and d.points = m.device_point_name and d.full_name = m.full_name and d.is_show_history = m.is_history
|
||||||
SET d.is_link = case when device_point_name is null then 0 else 1 end ,
|
SET d.is_link = case when device_point_name is null then 0 else 1 end ,
|
||||||
d.is_show_history = case when device_point_name is null = 0 then 0 else 1 end");
|
d.is_show_history = case when device_point_name is null then 0 else 1 end
|
||||||
|
where m.is_history = 1
|
||||||
|
");
|
||||||
|
|
||||||
await conn.ExecuteAsync(sb.ToString());
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
}
|
}
|
||||||
@ -793,10 +816,10 @@ namespace Repository.BackendRepository.Implement
|
|||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
//先全部關閉
|
//先全部關閉
|
||||||
sb.Append("update device_item set is_show_history=0;");
|
//sb.Append("update device_item set is_show_history=0;");
|
||||||
sb.Append("update device_item set is_show_history = 1 " +
|
sb.Append("update device_item set is_show_history = 0 " +
|
||||||
"WHERE(device_system_tag, device_name_tag, points) IN " +
|
"WHERE(device_system_tag, device_name_tag, points, full_name, is_show_history) NOT IN " +
|
||||||
"(select distinct device_system_tag, device_name_tag, device_point_name From import_niagara_item);");
|
"(select distinct device_system_tag, device_name_tag, device_point_name, full_name, is_history From import_niagara_item where is_history = 1);");
|
||||||
await conn.ExecuteAsync(sb.ToString());
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
|
Loading…
Reference in New Issue
Block a user