[前台API] 增加 GetDeviceListBySystem API 專門給告警紀錄作業用的 api ,透過多筆大類與棟別取得設備列表
This commit is contained in:
parent
e234159e87
commit
9a3b098ee0
@ -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
|
||||
|
@ -375,6 +375,45 @@ namespace FrontendWebApi.ApiControllers
|
||||
return Ok(apiResult);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("api/Device/GetDeviceListBySystem")]
|
||||
public async Task<ActionResult<ApiResult<List<DeviceFullList>>>> GetDeviceListBySystem(FindDevice fd)
|
||||
{
|
||||
ApiResult<List<DeviceFullList>> apiResult = new ApiResult<List<DeviceFullList>>();
|
||||
try
|
||||
{
|
||||
|
||||
List<string> queryCollection = new List<string>();
|
||||
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<DeviceFullList>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 獲取設備資料
|
||||
/// </summary>
|
||||
|
@ -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<string> main_system_tags { get; set; } = new List<string>();
|
||||
}
|
||||
|
||||
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; }
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user