diff --git a/FrontendWebApi/ApiControllers/HistoryController.cs b/FrontendWebApi/ApiControllers/HistoryController.cs index 19c69af..4c240b3 100644 --- a/FrontendWebApi/ApiControllers/HistoryController.cs +++ b/FrontendWebApi/ApiControllers/HistoryController.cs @@ -956,29 +956,28 @@ namespace FrontendWebApi.ApiControllers //依據被選擇的設備找出相對應資料 var sqlDeviceItemInfo = $@"select - b.full_name as building_name, - v1.system_key as Main_system_name, - v2.system_key as Sub_system_name, - temp.device_number, - temp.device_name, - temp.full_name as item_name, - temp.points, - temp.unit - from ( - select - di.*, - d.device_building_tag, - d.device_number, - d.full_name as device_name, - d.priority - from device_item di - inner join device d on di.device_name_tag = d.device_name_tag and d.deleted = 0 - where di.deleted = 0 and di.unit is not null and d.device_number IN @Device_number - ) temp - inner join building b on temp.device_building_tag = b.building_tag and b.deleted = 0 - inner join variable v1 on temp.device_system_tag = v1.system_value and v1.deleted = 0 and v1.system_type = 'device_system_category_layer2' - inner join variable v2 on temp.device_name_tag = v2.system_value and v2.deleted = 0 and v2.system_type = 'device_system_category_layer3' - order by b.priority, v1.system_priority, v2.system_priority, temp.priority"; + b.full_name as building_name, + v1.system_key as Main_system_name, + v2.system_key as Sub_system_name, + temp.device_number, + temp.device_name, + temp.full_name as item_name, + temp.points, + temp.unit + from ( + select + di.*, + d.device_number, + d.full_name as device_name, + d.priority + from device_item di + inner join device d on di.device_name_tag = d.device_name_tag and d.deleted = 0 + where di.deleted = 0 and di.unit is not null and d.device_number IN @Device_number + ) temp + inner join building b on temp.device_building_tag COLLATE utf8mb4_unicode_ci = b.building_tag and b.deleted = 0 + inner join variable v1 on temp.device_system_tag COLLATE utf8mb4_unicode_ci = v1.system_value and v1.deleted = 0 and v1.system_type = 'device_system_category_layer2' + inner join variable v2 on temp.device_name_tag COLLATE utf8mb4_unicode_ci = v2.system_value and v2.deleted = 0 and v2.system_type = 'device_system_category_layer3' + order by b.priority, v1.system_priority, v2.system_priority, temp.priority;"; var device_item_infos = await frontendRepository.GetAllAsync(sqlDeviceItemInfo, new { Device_number = device_numbers });