From ddb1db6da0d3e12ece2cd79600529bff100bea2e Mon Sep 17 00:00:00 2001 From: "jay.chang" Date: Wed, 24 Apr 2024 17:49:10 +0800 Subject: [PATCH] =?UTF-8?q?[WebApi]=E4=BF=AE=E6=AD=A3=E6=AD=B7=E5=8F=B2?= =?UTF-8?q?=E8=B3=87=E6=96=99=E6=9F=A5=E8=A9=A2=E8=A8=AD=E5=82=99=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=AF=A9=E9=81=B8=E6=A2=9D=E4=BB=B6=EF=BC=8C=E6=B2=92?= =?UTF-8?q?=E6=9C=89=E5=B0=8D=E6=87=89=E9=BB=9E=E4=BD=8D=E5=B0=B1=E4=B8=8D?= =?UTF-8?q?=E6=9C=83=E5=87=BA=E7=8F=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/HistoryController.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/FrontendWebApi/ApiControllers/HistoryController.cs b/FrontendWebApi/ApiControllers/HistoryController.cs index 718a374..884e997 100644 --- a/FrontendWebApi/ApiControllers/HistoryController.cs +++ b/FrontendWebApi/ApiControllers/HistoryController.cs @@ -516,21 +516,25 @@ namespace FrontendWebApi.ApiControllers var wheres_str = string.Join(" AND ", wheres); - var sql = $@"SELECT + var sql = $@"SELECT DISTINCT a.device_guid, - b.full_name building_name, + c.full_name building_name, v1.system_key main_name, v2.system_key sub_name, a.full_name device_name, a.device_number from (SELECT * FROM device d - WHERE {wheres_str} - ) a - join building b on b.building_tag = a.device_building_tag + WHERE {wheres_str} + ) a + join device_item b on b.device_system_tag = a.device_system_tag + and b.device_building_tag COLLATE utf8mb4_unicode_ci = a.device_building_tag + and b.device_name_tag COLLATE utf8mb4_unicode_ci = a.device_name_tag + join building c on c.building_tag = a.device_building_tag join variable v1 on v1.system_value = a.device_system_tag and v1.deleted = 0 and v1.system_type = 'device_system_category_layer2' join variable v2 on v2.system_value = a.device_name_tag and v2.deleted = 0 and v2.system_type = 'device_system_category_layer3' - order by b.priority,v1.system_priority,v2.system_priority,a.priority"; + where a.deleted = 0 and b.deleted = 0 and v2.deleted = 0 and v1.deleted = 0 and b.is_link = 1 and b.is_show_history = 1 + order by c.priority,v1.system_priority,v2.system_priority,a.priority"; var dbDevice = await backendRepository.GetAllAsync(sql, new { builds = postDevice.SelectBuildings, floor_tag = postDevice.SelectFloors, syss = postDevice.SelectSub, device_name = postDevice.Device_name }); apiResult.Data = dbDevice; @@ -572,7 +576,7 @@ namespace FrontendWebApi.ApiControllers join variable v1 on v1.system_value = b.device_system_tag and v1.deleted = 0 and v1.system_type = 'device_system_category_layer2' join variable v2 on v2.system_value = b.device_name_tag and v2.deleted = 0 and v2.system_type = 'device_system_category_layer3' where a.deleted = 0 and b.deleted = 0 and v2.deleted = 0 and v1.deleted = 0 - and a.unit is not null and b.device_number in @Device_number and a.is_link = 1 and a.is_show_history = 1 + and b.device_number in @Device_number and a.is_link = 1 and a.is_show_history = 1 order by c.priority,b.priority;" , new { Device_number = postDevice.select_data.Select(a => a.device_number).ToList() } );