調整同步問題
This commit is contained in:
parent
b97828ca6a
commit
4365516598
@ -511,7 +511,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
sb.Append($@" insert device(device_guid, deleted, status, priority, is_link, device_area_tag,
|
sb.Append($@" insert device(device_guid, deleted, status, priority, is_link, device_area_tag,
|
||||||
device_building_tag, device_system_tag, device_name_tag, full_name, device_floor_tag, device_master,
|
device_building_tag, device_system_tag, device_name_tag, full_name, device_floor_tag, device_master,
|
||||||
device_last_name, device_serial_tag, device_model_tag, device_number, device_system_category_layer3, visible, created_at, updated_at)
|
device_last_name, device_serial_tag, device_model_tag, device_number, device_system_category_layer3, visible, created_at, updated_at)
|
||||||
values(uuid(), 0, 1, 0, 1, '" +
|
select uuid(), 0, 1, 0, 1, '" +
|
||||||
data.device_area_tag + "', '" +
|
data.device_area_tag + "', '" +
|
||||||
data.device_building_tag + "', '" +
|
data.device_building_tag + "', '" +
|
||||||
data.device_system_tag + "', '" +
|
data.device_system_tag + "', '" +
|
||||||
@ -523,7 +523,8 @@ namespace Repository.BackendRepository.Implement
|
|||||||
data.device_serial_tag + "', '" +
|
data.device_serial_tag + "', '" +
|
||||||
data.device_model_tag + "', '" +
|
data.device_model_tag + "', '" +
|
||||||
data.niagara_tags + "', '" +
|
data.niagara_tags + "', '" +
|
||||||
data.device_system_tag + "', 1, now(), now() );");
|
data.device_system_tag + "', 1, now(), now() " +
|
||||||
|
$@"WHERE NOT EXISTS ( SELECT 1 FROM device WHERE device_number = '{data.niagara_tags}'); ");
|
||||||
count += 1;
|
count += 1;
|
||||||
if (count >= 100)
|
if (count >= 100)
|
||||||
{
|
{
|
||||||
@ -1425,17 +1426,13 @@ namespace Repository.BackendRepository.Implement
|
|||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.Append(@"SET SQL_SAFE_UPDATES = 0;
|
sb.Append(@"SET SQL_SAFE_UPDATES = 0;
|
||||||
update device d
|
UPDATE device d
|
||||||
JOIN (
|
JOIN (
|
||||||
select niagara_tags, device_full_name from import_niagara_tag limit 100000
|
SELECT niagara_tags, device_full_name
|
||||||
) m ON m.niagara_tags = d.device_number
|
FROM import_niagara_tag
|
||||||
LEFT JOIN (
|
) m ON m.niagara_tags = d.device_number
|
||||||
SELECT niagara_tags, device_full_name
|
|
||||||
FROM import_niagara_tag
|
|
||||||
LIMIT 100000
|
|
||||||
) m2 ON m2.niagara_tags = d.device_number AND m2.device_full_name = d.full_name
|
|
||||||
SET d.full_name = m.device_full_name
|
SET d.full_name = m.device_full_name
|
||||||
WHERE m2.niagara_tags IS NULL;");
|
WHERE d.full_name != m.device_full_name;");
|
||||||
await conn.ExecuteAsync(sb.ToString());
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
|
Loading…
Reference in New Issue
Block a user