From a3a0a0c963120117f6ad777ff6861e7dfb02ad80 Mon Sep 17 00:00:00 2001 From: dev01 Date: Sat, 31 Dec 2022 11:13:35 +0800 Subject: [PATCH] =?UTF-8?q?[FrontendWebApi]=20GetNextFloor=20=E5=8F=96?= =?UTF-8?q?=E5=BE=97=20=E7=9B=AE=E6=A8=99=E6=A8=93=E5=B1=A4=E4=B9=8B?= =?UTF-8?q?=E4=B8=8B=E4=B8=80=E6=A8=93=E5=B1=A4=20API=20=E5=BB=BA=E7=BD=AE?= =?UTF-8?q?=20|=20GetFloor=20=E4=B8=9F=E5=87=BA=20Floor=5Fguid=20=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E8=AA=BF=E6=95=B4=20|=20forge=20=E5=8B=95=E6=85=8B?= =?UTF-8?q?=E6=8A=93=E5=8F=96=20node=20id=20=20forge=5Fnode=5Fname=5Fsyste?= =?UTF-8?q?m=5Ftype=20=E6=94=B9=E7=82=BA=20forge=5Fcheck=5Ftag=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/DeviceManageController.cs | 42 ++++++++++++++++++- .../ApiControllers/MyBaseApiController.cs | 4 +- FrontendWebApi/Models/Device.cs | 1 + 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs index 4e2b2aa..08eed00 100644 --- a/FrontendWebApi/ApiControllers/DeviceManageController.cs +++ b/FrontendWebApi/ApiControllers/DeviceManageController.cs @@ -219,7 +219,7 @@ namespace FrontendWebApi.ApiControllers try { - var sqlString = $@"select f.full_name as floor_tag + var sqlString = $@"select f.full_name as floor_tag, f.floor_guid 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 f.building_tag = @building_tag and sub_system_tag = @sub_system_tag order by f.priority"; @@ -789,5 +789,45 @@ namespace FrontendWebApi.ApiControllers } return Ok(apiResult); } + + /// + /// 樓層列表 + /// + /// + /// + [HttpPost] + [Route("api/Device/GetNextFloor")] + public async Task>> GetNextFloor([FromBody] Floor f) + { + ApiResult apiResult = new ApiResult(); + + if (string.IsNullOrEmpty(f.floor_guid)) + { + apiResult.Code = "0002"; + apiResult.Msg = "需傳入樓層guid"; + return apiResult; + } + + try + { + var sqlString = $@" SELECT * FROM floor WHERE + priority = (SELECT MIN(priority) FROM floor WHERE priority > (SELECT priority FROM floor WHERE floor_guid = @floor_guid) + AND building_tag = (SELECT building_tag FROM floor WHERE floor_guid = @floor_guid)) + AND building_tag = (SELECT building_tag FROM floor WHERE floor_guid = @floor_guid)"; + var param = new { @floor_guid = f.floor_guid }; + var fr = await backendRepository.GetOneAsync(sqlString, param); + + apiResult.Code = "0000"; + apiResult.Data = fr; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + return Ok(apiResult); + } + return Ok(apiResult); + } } } \ No newline at end of file diff --git a/FrontendWebApi/ApiControllers/MyBaseApiController.cs b/FrontendWebApi/ApiControllers/MyBaseApiController.cs index f347c2c..e7a966b 100644 --- a/FrontendWebApi/ApiControllers/MyBaseApiController.cs +++ b/FrontendWebApi/ApiControllers/MyBaseApiController.cs @@ -35,14 +35,14 @@ namespace FrontendWebApi.ApiControllers public string actionName; public string main_system_type = "device_system_category_layer2"; public string sub_system_type = "device_system_category_layer3"; - public string forge_node_name_system_type = "forge_check_node_name"; + public string forge_node_name_system_type = "forge_check_tag_id"; public ErrorCode errorCode = new ErrorCode(); [Authorize] public override void OnActionExecuting(ActionExecutingContext filterContext) { controllerName = ControllerContext.RouteData.Values["controller"].ToString(); //controller名稱 actionName = ControllerContext.RouteData.Values["action"].ToString(); //action名稱 - + var ctx = filterContext.HttpContext; ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*"); ctx.Response.Headers.Add("Access-Control-Allow-Headers", "*"); diff --git a/FrontendWebApi/Models/Device.cs b/FrontendWebApi/Models/Device.cs index 0c67ea5..c854265 100644 --- a/FrontendWebApi/Models/Device.cs +++ b/FrontendWebApi/Models/Device.cs @@ -24,6 +24,7 @@ namespace FrontendWebApi.Models { public string full_name { get; set; } public string floor_tag { get; set; } + public string floor_guid { get; set; } public string map_name { get; set; } public string floor_map_name { get; set; } public string urn_3D { get; set; }