diff --git a/FrontendWebApi/ApiControllers/AlarmRecordController.cs b/FrontendWebApi/ApiControllers/AlarmRecordController.cs index 9739835..d25ba3c 100644 --- a/FrontendWebApi/ApiControllers/AlarmRecordController.cs +++ b/FrontendWebApi/ApiControllers/AlarmRecordController.cs @@ -51,7 +51,8 @@ namespace FrontendWebApi.ApiControllers b.full_name AS building_name, v1.system_value, v1.system_key - FROM building_menu bm + FROM + (SELECT * FROM building_menu ORDER BY priority) bm INNER JOIN ( SELECT ap.building_tag, ap.ShowView diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs index 3f1f677..70b3dab 100644 --- a/FrontendWebApi/ApiControllers/DeviceManageController.cs +++ b/FrontendWebApi/ApiControllers/DeviceManageController.cs @@ -375,6 +375,45 @@ namespace FrontendWebApi.ApiControllers return Ok(apiResult); } + [HttpPost] + [Route("api/Device/GetDeviceListBySystem")] + public async Task>>> GetDeviceListBySystem(FindDevice fd) + { + ApiResult> apiResult = new ApiResult>(); + try + { + + List queryCollection = new List(); + if (!string.IsNullOrEmpty(fd.building_tag)) { + queryCollection.Add("device_building_tag = @building_tag"); + } + if (fd.main_system_tags != null && fd.main_system_tags.Count() > 0) + { + queryCollection.Add("device_system_tag IN @system_tags"); + } + queryCollection.Add("deleted = 0"); + + string query = string.Join(" AND ", queryCollection); + string sql = $@"SELECT * + FROM device + Where {query}"; + + var device = await backendRepository.GetAllAsync(sql, + new { building_tag = fd.building_tag , system_tags = fd.main_system_tags }); + + apiResult.Data = device; + apiResult.Code = "0000"; + } + catch (Exception exception) + { + + apiResult.Code = "9999"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + return Ok(apiResult); + } + return Ok(apiResult); + } + /// /// 獲取設備資料 /// diff --git a/FrontendWebApi/Models/Device.cs b/FrontendWebApi/Models/Device.cs index d17498a..21137de 100644 --- a/FrontendWebApi/Models/Device.cs +++ b/FrontendWebApi/Models/Device.cs @@ -12,6 +12,8 @@ namespace FrontendWebApi.Models public string floor_tag { get; set; } public string device_guid { get; set; } public string device_number { get; set; } + + public List main_system_tags { get; set; } = new List(); } public class BuildList @@ -194,5 +196,11 @@ namespace FrontendWebApi.Models } + public class DeviceFullList : DeviceBaseList + { + public string device_building_tag { get; set; } + public string device_system_tag { get; set; } + public string device_name_tag { get; set; } + } }