[後端] Niagara 資料同步 修改 sql 語法DeviceComparison
This commit is contained in:
parent
5261de75e2
commit
01d0ad6db1
@ -14,6 +14,7 @@ using Microsoft.Extensions.Primitives;
|
|||||||
using System.Web;
|
using System.Web;
|
||||||
using Org.BouncyCastle.Utilities.Collections;
|
using Org.BouncyCastle.Utilities.Collections;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace Repository.BackendRepository.Implement
|
namespace Repository.BackendRepository.Implement
|
||||||
{
|
{
|
||||||
@ -326,6 +327,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
device_name_tag = x.Key.device_name_tag2
|
device_name_tag = x.Key.device_name_tag2
|
||||||
});
|
});
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
foreach (var data in result)
|
foreach (var data in result)
|
||||||
{
|
{
|
||||||
//開關控制在個別燈具(device_node層) and 小類為二線式照明系統 and tag第八段開頭不是 G
|
//開關控制在個別燈具(device_node層) and 小類為二線式照明系統 and tag第八段開頭不是 G
|
||||||
@ -350,9 +352,17 @@ namespace Repository.BackendRepository.Implement
|
|||||||
data.device_serial_tag + "', '" +
|
data.device_serial_tag + "', '" +
|
||||||
data.niagara_tags + "', '" +
|
data.niagara_tags + "', '" +
|
||||||
data.device_system_tag + "', 1, now(), now() );");
|
data.device_system_tag + "', 1, now(), now() );");
|
||||||
|
count += 1;
|
||||||
|
if (count >= 100)
|
||||||
|
{
|
||||||
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
|
sb.Clear();
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count = 0;
|
||||||
foreach (var data in result2)
|
foreach (var data in result2)
|
||||||
{
|
{
|
||||||
var sqlString = new StringBuilder();
|
var sqlString = new StringBuilder();
|
||||||
@ -366,6 +376,13 @@ namespace Repository.BackendRepository.Implement
|
|||||||
created_by, created_at)
|
created_by, created_at)
|
||||||
VALUES (uuid(), '" + data.device_building_tag + "', '" + data.device_system_tag + "', '" + data.device_name_tag +
|
VALUES (uuid(), '" + data.device_building_tag + "', '" + data.device_system_tag + "', '" + data.device_name_tag +
|
||||||
"', 0, 0, 1, 0, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now());");
|
"', 0, 0, 1, 0, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now());");
|
||||||
|
count += 1;
|
||||||
|
if (count >= 100)
|
||||||
|
{
|
||||||
|
await conn.ExecuteAsync(sb2.ToString());
|
||||||
|
sb2.Clear();
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,6 +422,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
device_name_tag = x.Key.device_name_tag2
|
device_name_tag = x.Key.device_name_tag2
|
||||||
});
|
});
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
foreach (var data in result)
|
foreach (var data in result)
|
||||||
{
|
{
|
||||||
//開關控制在個別燈具(device_node層) and 小類為二線式照明系統 and tag第八段開頭不是 G
|
//開關控制在個別燈具(device_node層) and 小類為二線式照明系統 and tag第八段開頭不是 G
|
||||||
@ -416,6 +434,13 @@ namespace Repository.BackendRepository.Implement
|
|||||||
",'" + data.niagara_tags + // device_number
|
",'" + data.niagara_tags + // device_number
|
||||||
"', '" + data.device_full_name + //full_name
|
"', '" + data.device_full_name + //full_name
|
||||||
"','B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), now());");
|
"','B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), now());");
|
||||||
|
count += 1;
|
||||||
|
if (count >= 100)
|
||||||
|
{
|
||||||
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
|
sb.Clear();
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,7 +459,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
SELECT niagara_tags
|
SELECT niagara_tags
|
||||||
FROM import_niagara_tag
|
FROM import_niagara_tag
|
||||||
LIMIT 100000
|
LIMIT 100000
|
||||||
) i ON d.device_number COLLATE utf8mb4_0900_ai_ci = i.niagara_tags COLLATE utf8mb4_0900_ai_ci
|
) i ON d.device_number = i.niagara_tags
|
||||||
SET d.is_link = 0
|
SET d.is_link = 0
|
||||||
WHERE d.is_link = 1 and i.niagara_tags is null;");
|
WHERE d.is_link = 1 and i.niagara_tags is null;");
|
||||||
await conn.ExecuteAsync(sb.ToString());
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
@ -455,7 +480,8 @@ namespace Repository.BackendRepository.Implement
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
throw exception;
|
//throw exception;
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user