diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs
index 9ea8cdb..60ee4c7 100644
--- a/FrontendWebApi/ApiControllers/DeviceManageController.cs
+++ b/FrontendWebApi/ApiControllers/DeviceManageController.cs
@@ -910,7 +910,7 @@ namespace FrontendWebApi.ApiControllers
}
///
- /// 樓層列表
+ /// input user 所選樓層,回傳樓上那層,如果是頂樓 則回自己
///
///
///
@@ -934,8 +934,28 @@ namespace FrontendWebApi.ApiControllers
// 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 sqlString = $@" SELECT * FROM floor WHERE floor_guid = @floor_guid;";
- var param = new { @floor_guid = f.floor_guid };
+ //找出同一棟 User 所選的上一樓(要拿掉天花板),如已經是頂樓則回傳自己
+ var sqlString = $@"select * from
+ (
+ SELECT * FROM floor -- 下一樓
+ where building_tag = @building_tag and priority > (
+ select priority from floor
+ where building_tag = @building_tag and floor_guid = @floor_guid
+ )
+ order by priority limit 1
+ )a
+ union
+ select * from
+ (
+ SELECT * FROM floor -- 如果是頂樓則回傳自己
+ where building_tag = @building_tag and priority >= (
+ select priority from floor
+ where building_tag = @building_tag and floor_guid = @floor_guid
+ )
+ order by priority limit 1
+ )b
+ order by priority desc limit 1 ";
+ var param = new { @building_tag = f.building_tag, @floor_guid = f.floor_guid };
var fr = await backendRepository.GetOneAsync(sqlString, param);
apiResult.Code = "0000";
diff --git a/FrontendWebApi/Models/Build.cs b/FrontendWebApi/Models/Build.cs
index 3e87117..88e80f5 100644
--- a/FrontendWebApi/Models/Build.cs
+++ b/FrontendWebApi/Models/Build.cs
@@ -115,6 +115,8 @@ namespace FrontendWebApi.Models
public class Floor
{
public string floor_guid { get; set; }
+
+ public string building_tag { get; set; }
public string full_name { get; set; }
public string InitMapName { get; set; }
public string Floor_map_name { get; set; }