diff --git a/FrontendWebApi/ApiControllers/OperationController.cs b/FrontendWebApi/ApiControllers/OperationController.cs
index 445851c..fb59396 100644
--- a/FrontendWebApi/ApiControllers/OperationController.cs
+++ b/FrontendWebApi/ApiControllers/OperationController.cs
@@ -96,22 +96,18 @@ namespace FrontendWebApi.ApiControllers
}
///
- /// 大樓列表
+ /// 地區列表
///
///
[HttpPost]
- public async Task>> BuiList()
+ public async Task>> AreaList()
{
ApiResult> apiResult = new ApiResult>();
List bl = new List();
try
{
- var sqlString = @$"select d.device_area_tag, d.device_building_tag, d.device_floor_tag, CONCAT(case when d.device_area_tag='TPE' then '台北市' else '新北市' end, b.full_name, d.device_floor_tag) as full_name
- from device d
- join building b on d.device_building_tag = b.building_tag
- where d.deleted = 0
- group by d.device_area_tag, d.device_building_tag, d.device_floor_tag, b.full_name";
+ var sqlString = @$"select system_key as area_name, system_value as device_area_tag from variable where deleted = 0 and system_type = 'area'";
bl = await backendRepository.GetAllAsync(sqlString);
@@ -128,6 +124,71 @@ namespace FrontendWebApi.ApiControllers
return apiResult;
}
+ ///
+ /// 大樓列表
+ ///
+ ///
+ [HttpPost]
+ public async Task>> BuiList([FromBody] BuildingList b)
+ {
+ ApiResult> apiResult = new ApiResult>();
+ List bl = new List();
+
+ try
+ {
+ var sqlString = @$"select d.device_building_tag, b.full_name as building_name
+ from device d
+ join building b on d.device_building_tag = b.building_tag
+ where d.deleted = 0 and d.device_area_tag = @device_area_tag
+ group by b.building_name, d.device_building_tag";
+
+ bl = await backendRepository.GetAllAsync(sqlString, new { @device_area_tag = b.device_area_tag });
+
+ apiResult.Code = "0000";
+ apiResult.Data = bl;
+ }
+ catch (Exception exception)
+ {
+ apiResult.Code = "9999";
+ apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
+ Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
+ }
+
+ return apiResult;
+ }
+
+ ///
+ /// 大樓列表
+ ///
+ ///
+ [HttpPost]
+ public async Task>> FloList([FromBody] BuildingList b)
+ {
+ ApiResult> apiResult = new ApiResult>();
+ List bl = new List();
+
+ try
+ {
+ var sqlString = @$"select d.device_floor_tag
+ from device d
+ where d.deleted = 0 and d.device_area_tag = @device_area_tag and d.device_building_tag = @device_building_tag
+ group by d.device_floor_tag";
+
+ bl = await backendRepository.GetAllAsync(sqlString, new { @device_area_tag = b.device_area_tag, @device_building_tag = b.device_building_tag });
+
+ apiResult.Code = "0000";
+ apiResult.Data = bl;
+ }
+ catch (Exception exception)
+ {
+ apiResult.Code = "9999";
+ apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
+ Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
+ }
+
+ return apiResult;
+ }
+
///
/// 設備列表
///
@@ -141,9 +202,9 @@ namespace FrontendWebApi.ApiControllers
try
{
var sqlString = @$"select device_number, concat(device_floor_tag, ' ', device_last_name, ' ', device_serial_tag) as device_name
- from device where deleted = 0 and device_building_tag = @device_building_tag and device_floor_tag = @device_floor_tag";
+ from device where deleted = 0 and device_area_tag = @device_area_tag and device_building_tag = @device_building_tag and device_floor_tag = @device_floor_tag";
- var param = new { @device_building_tag = bl.device_building_tag, @device_floor_tag = bl.device_floor_tag };
+ var param = new { @device_building_tag = bl.device_building_tag, @device_floor_tag = bl.device_floor_tag, @device_area_tag = bl.device_area_tag };
d = await backendRepository.GetAllAsync(sqlString, param);