[後端] 修改api條件, 修改同步問題

This commit is contained in:
dev02 2023-11-14 18:54:22 +08:00
parent 9ad73b749b
commit 3a0ead386b
2 changed files with 50 additions and 47 deletions

View File

@ -207,6 +207,7 @@ namespace Backend.Controllers
AND d.device_name_tag = @sub_system_tag AND d.device_name_tag = @sub_system_tag
AND d.device_floor_tag = @floor_tag AND d.device_floor_tag = @floor_tag
AND d.deleted = 0 AND d.deleted = 0
AND d.is_link = 1
) d ) d
JOIN building b ON d.device_building_tag = b.building_tag JOIN building b ON d.device_building_tag = b.building_tag
JOIN variable mv ON d.device_system_tag = mv.system_value AND mv.system_type = @main_system_type and mv.deleted = 0 JOIN variable mv ON d.device_system_tag = mv.system_value AND mv.system_type = @main_system_type and mv.deleted = 0

View File

@ -290,60 +290,62 @@ namespace Repository.BackendRepository.Implement
{ {
await conn.ExecuteAsync(sb.ToString()); await conn.ExecuteAsync(sb.ToString());
} }
}
sb.Clear(); sb.Clear();
if (isDome.Contains("ibms_dome")) if (isDome.Contains("ibms_dome"))
{ {
sb.Append($@" update import_niagara_item a sb.Append($@" update import_niagara_item a
join variable b on a.device_name_tag COLLATE utf8mb4_0900_ai_ci = b.system_value COLLATE utf8mb4_0900_ai_ci and b.deleted = 0 and b.system_type = 'device_system_category_layer3' join variable b on a.device_name_tag COLLATE utf8mb4_0900_ai_ci = b.system_value COLLATE utf8mb4_0900_ai_ci and b.deleted = 0 and b.system_type = 'device_system_category_layer3'
join variable v1 on b.system_parent_id = v1.id join variable v1 on b.system_parent_id = v1.id
set device_system_tag = v1.system_value set device_system_tag = v1.system_value
where (device_system_tag <> 'S' and device_system_tag <> 'CWB' and device_system_tag <> 'B');"); where (device_system_tag <> 'S' and device_system_tag <> 'CWB' and device_system_tag <> 'B');");
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{
await conn.ExecuteAsync(sb.ToString());
}
}
sb.Clear();
sb.Append($@" update import_niagara_item set full_name = device_point_name where full_name = '' or full_name is null;");
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{
await conn.ExecuteAsync(sb.ToString());
}
sb.Clear();
sb.Append($@"SET SQL_SAFE_UPDATES = 0;
update import_niagara_item ini
join (
select device_building_tag, device_system_tag, device_name_tag, device_point_name
from import_niagara_item_history
group by device_building_tag, device_system_tag, device_name_tag, device_point_name
) as inih on ini.device_building_tag = inih.device_building_tag and ini.device_system_tag = inih.device_system_tag and ini.device_name_tag = inih.device_name_tag
and ini.device_point_name = inih.device_point_name
set ini.is_history = 1");
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{
await conn.ExecuteAsync(sb.ToString());
}
sb.Clear();
sb.Append($@"SET SQL_SAFE_UPDATES = 0;
update import_niagara_item ini
join (
select distinct device_building_tag, parent_path from import_niagara_item_history
) inih on ini.device_building_tag = inih.device_building_tag
set ini.parent_path = inih.parent_path");
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{ {
await conn.ExecuteAsync(sb.ToString()); await conn.ExecuteAsync(sb.ToString());
} }
} }
sb.Clear();
sb.Append($@" update import_niagara_item set full_name = device_point_name where full_name = '' or full_name is null;");
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{
await conn.ExecuteAsync(sb.ToString());
}
sb.Clear();
sb.Append($@"SET SQL_SAFE_UPDATES = 0;
update import_niagara_item ini
join (
select device_building_tag, device_system_tag, device_name_tag, device_point_name
from import_niagara_item_history
group by device_building_tag, device_system_tag, device_name_tag, device_point_name
) as inih on ini.device_building_tag = inih.device_building_tag and ini.device_system_tag = inih.device_system_tag and ini.device_name_tag = inih.device_name_tag
and ini.device_point_name = inih.device_point_name
set ini.is_history = 1");
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{
await conn.ExecuteAsync(sb.ToString());
}
sb.Clear();
sb.Append($@"SET SQL_SAFE_UPDATES = 0;
update import_niagara_item ini
join (
select distinct device_building_tag, parent_path from import_niagara_item_history
) inih on ini.device_building_tag = inih.device_building_tag
set ini.parent_path = inih.parent_path");
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{
await conn.ExecuteAsync(sb.ToString());
}
await RecoverSysTag("import_niagara_item");
#endregion #endregion
} }
catch (Exception exception) catch (Exception exception)
@ -553,7 +555,7 @@ namespace Repository.BackendRepository.Implement
FROM import_niagara_tag FROM import_niagara_tag
LIMIT 100000 LIMIT 100000
) i ON d.device_number = i.niagara_tags ) i ON d.device_number = i.niagara_tags
SET d.is_link = 1"); SET d.is_link = 1, d.deleted = 0");
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled)) using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
{ {
await conn.ExecuteAsync(sb.ToString()); await conn.ExecuteAsync(sb.ToString());