From c93fafb58c4824e0a2160eb8b1e9941eef8d8dae Mon Sep 17 00:00:00 2001 From: dev01 Date: Wed, 18 Jan 2023 11:12:08 +0800 Subject: [PATCH] =?UTF-8?q?[FrontendWebApi]=20Device=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=20GetAllDevice=20API=20=E5=8F=96=E5=BE=97=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E8=A8=AD=E5=82=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/DeviceManageController.cs | 42 ++++++++++++++++++- FrontendWebApi/Models/Device.cs | 11 +++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs index fa2025f..e822b4b 100644 --- a/FrontendWebApi/ApiControllers/DeviceManageController.cs +++ b/FrontendWebApi/ApiControllers/DeviceManageController.cs @@ -279,7 +279,7 @@ namespace FrontendWebApi.ApiControllers var sqlString = $@"select f.full_name, f.InitMapName as map_name, concat(f.floor_map_name,'.svg') as floor_map_name, f.urn_3D from sub_system_floor ssf join floor f on ssf.floor_tag = f.full_name and ssf.building_tag = f.building_tag and f.deleted = 0 - where ssf.deleted = 0 and ssf.building_tag = @building_tag and ssf.sub_system_tag = @sub_system_tag and ssf.floor_tag = ifnull(@floor_tag, ssf.floor_tag);"; + where ssf.deleted = 0 and ssf.building_tag = @building_tag and ssf.sub_system_tag = ifnull(@sub_system_tag and ssf.floor_tag = ifnull(@floor_tag, ssf.floor_tag);"; var param = new { @building_tag = fd.building_tag, @floor_tag = fd.floor_tag, @sub_system_tag = fd.sub_system_tag }; var fl = await backendRepository.GetAllAsync(sqlString, param); @@ -294,7 +294,7 @@ namespace FrontendWebApi.ApiControllers from device d left join device_kind dk on d.device_building_tag = dk.device_building_tag and d.device_system_tag = dk.device_system_tag and d.device_name_tag = dk.device_name_tag - where d.deleted = 0 and d.device_name_tag = @sub_system_tag and d.device_building_tag = @building_tag and d.device_floor_tag = @floor_tag"; + where d.deleted = 0 and d.device_name_tag = ifnull(@sub_system_tag,d.device_name_tag) and d.device_building_tag = ifnull(@building_tag,d.device_building_tag) and d.device_floor_tag = @floor_tag"; var dlParam = new { @sub_system_tag = fd.sub_system_tag, @building_tag = fd.building_tag, @floor_tag = f.full_name }; dl = await backendRepository.GetAllAsync(sqlString, dlParam); @@ -328,6 +328,44 @@ namespace FrontendWebApi.ApiControllers return Ok(apiResult); } + /// + /// 獲取全部設備資料 + /// + /// + /// + [HttpPost] + [Route("api/Device/GetAllDevice")] + public async Task>>> GetAllDevice() + { + ApiResult> apiResult = new ApiResult>(); + try + { + + + string sql = $@"select device_guid,device_number, full_name, device_coordinate,device_coordinate_3d,forge_dbid,priority from device where deleted = 0"; + + var device = await backendRepository.GetAllAsync(sql); + + if (device == null) + { + apiResult.Msg = "查無次設備"; + apiResult.Code = "0001"; + return apiResult; + } + + 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 2bfe850..b8eb38d 100644 --- a/FrontendWebApi/Models/Device.cs +++ b/FrontendWebApi/Models/Device.cs @@ -79,6 +79,17 @@ namespace FrontendWebApi.Models public List Device_nodes { get; set; } } + public class DeviceBaseList + { + public string device_guid { get; set; } + public string device_number { get; set; } + public string full_name { get; set; } + public string device_coordinate { get; set; } + public string device_coordinate_3d { get; set; } + public int priority { get; set; } + public string forge_dbid { get; set; } + } + public class DeviceBaseInfo { public string device_number { get; set; }