[後端] 修改device_item獲取
This commit is contained in:
parent
16ef04ef80
commit
fb1d03c994
@ -286,16 +286,16 @@ namespace Backend.Services.Implement
|
||||
isHistory = n.isHistory
|
||||
});
|
||||
}
|
||||
else if (n.name.Split('/').Length == 11) //Arena_D2_CWB_L110_CAP_D2_CWB_L110_CAP_MET1_ER
|
||||
else if (n.name.Split('/').Length == 7) // Arena/D2/CWB/L110/CAP/D2_CWB_L110_CAP_MET1/Summery
|
||||
{
|
||||
if (n.name.Split('/')[6] == "S" || n.name.Split('/')[6] == "CWB") //for security system and CWB system
|
||||
if (n.name.Split('/')[3] == "S" || n.name.Split('/')[3] == "CWB") //for security system and CWB system
|
||||
{
|
||||
result.Add(new ImpNiaItem {
|
||||
device_building_tag = n.name.Split('/')[5],
|
||||
device_system_tag = n.name.Split('/')[6],
|
||||
device_floor_tag = n.name.Split('/')[7],
|
||||
device_name_tag = n.name.Split('/')[8],
|
||||
device_point_name = n.name.Split('/')[10],
|
||||
device_building_tag = n.name.Split('/')[1],
|
||||
device_system_tag = n.name.Split('/')[2],
|
||||
device_floor_tag = n.name.Split('/')[3],
|
||||
device_name_tag = n.name.Split('/')[4],
|
||||
device_point_name = n.name.Split('/')[6],
|
||||
full_name = n.displayName,
|
||||
parent_path = oneStationName,
|
||||
isHistory = n.isHistory
|
||||
@ -305,11 +305,11 @@ namespace Backend.Services.Implement
|
||||
{
|
||||
result.Add(new ImpNiaItem
|
||||
{
|
||||
device_building_tag = n.name.Split('/')[5],
|
||||
device_building_tag = n.name.Split('/')[1],
|
||||
//device_system_tag = n.name.Split('/')[1],
|
||||
device_floor_tag = n.name.Split('/')[7],
|
||||
device_name_tag = n.name.Split('/')[6],
|
||||
device_point_name = n.name.Split('/')[10],
|
||||
device_floor_tag = n.name.Split('/')[3],
|
||||
device_name_tag = n.name.Split('/')[2],
|
||||
device_point_name = n.name.Split('/')[6],
|
||||
full_name = n.displayName,
|
||||
parent_path = oneStationName,
|
||||
isHistory = n.isHistory
|
||||
|
@ -565,28 +565,39 @@ namespace Repository.BackendRepository.Implement
|
||||
|
||||
//本次有匯入的 isLink 改為 1, 沒有的 isLink = 0
|
||||
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
|
||||
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
|
||||
and d.full_name = m.full_name
|
||||
SET d.is_link = case when device_point_name is null then 0 else 1 end;
|
||||
|
||||
update
|
||||
device_item d
|
||||
LEFT JOIN import_niagara_item m
|
||||
UPDATE device_item d
|
||||
LEFT JOIN (
|
||||
SELECT device_system_tag, device_name_tag, device_point_name, full_name
|
||||
FROM import_niagara_item
|
||||
LIMIT 100000 -- Specify your desired limit here
|
||||
) 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
|
||||
and d.full_name = m.full_name
|
||||
and d.is_show_history = m.is_history
|
||||
SET d.is_show_history = case when device_point_name is null then 0 else 1 end
|
||||
where (m.is_history = 1 or d.is_show_history);
|
||||
AND d.device_name_tag = m.device_name_tag
|
||||
AND d.points = m.device_point_name
|
||||
AND d.full_name = m.full_name
|
||||
SET d.is_link = CASE WHEN m.device_point_name IS NULL THEN 0 ELSE 1 END;
|
||||
|
||||
");
|
||||
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
|
||||
sb.Clear();
|
||||
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
|
||||
UPDATE device_item d
|
||||
LEFT JOIN (
|
||||
SELECT m.device_system_tag, m.device_name_tag, m.device_point_name, m.full_name
|
||||
FROM import_niagara_item m
|
||||
WHERE (m.is_history = 1)
|
||||
LIMIT 100000 -- Specify your desired limit here
|
||||
) AS subquery
|
||||
ON d.device_system_tag = subquery.device_system_tag
|
||||
AND d.device_name_tag = subquery.device_name_tag
|
||||
AND d.points = subquery.device_point_name
|
||||
AND d.full_name = subquery.full_name
|
||||
SET d.is_show_history = CASE WHEN subquery.device_point_name IS NULL THEN 0 ELSE 1 END
|
||||
WHERE (d.is_show_history);");
|
||||
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -876,13 +887,18 @@ namespace Repository.BackendRepository.Implement
|
||||
try
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append($@"update device_item d
|
||||
inner JOIN import_niagara_item m ON
|
||||
m.device_system_tag = d.device_system_tag and
|
||||
m.device_name_tag = d.device_name_tag and
|
||||
m.device_point_name = d.points
|
||||
set d.full_name=m.full_name
|
||||
where d.full_name<>m.full_name;");
|
||||
sb.Append($@"UPDATE device_item d
|
||||
INNER JOIN (
|
||||
SELECT m.device_system_tag, m.device_name_tag, m.device_point_name, m.full_name
|
||||
FROM import_niagara_item m
|
||||
join device_item d
|
||||
LIMIT 100000 -- Specify your desired limit here
|
||||
) AS subquery
|
||||
ON d.device_system_tag = subquery.device_system_tag
|
||||
AND d.device_name_tag = subquery.device_name_tag
|
||||
AND d.points = subquery.device_point_name
|
||||
SET d.full_name = subquery.full_name
|
||||
WHERE d.full_name <> subquery.full_name");
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
Loading…
Reference in New Issue
Block a user