[FrontendWebApi] Device 增加 GetAllDevice API 取得全部設備
This commit is contained in:
parent
35cc6a8af6
commit
c93fafb58c
@ -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
|
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
|
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
|
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 param = new { @building_tag = fd.building_tag, @floor_tag = fd.floor_tag, @sub_system_tag = fd.sub_system_tag };
|
||||||
var fl = await backendRepository.GetAllAsync<FloorList>(sqlString, param);
|
var fl = await backendRepository.GetAllAsync<FloorList>(sqlString, param);
|
||||||
|
|
||||||
@ -294,7 +294,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
from device d
|
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
|
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
|
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 };
|
var dlParam = new { @sub_system_tag = fd.sub_system_tag, @building_tag = fd.building_tag, @floor_tag = f.full_name };
|
||||||
dl = await backendRepository.GetAllAsync<DeviceLists>(sqlString, dlParam);
|
dl = await backendRepository.GetAllAsync<DeviceLists>(sqlString, dlParam);
|
||||||
|
|
||||||
@ -328,6 +328,44 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
return Ok(apiResult);
|
return Ok(apiResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 獲取全部設備資料
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fd"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("api/Device/GetAllDevice")]
|
||||||
|
public async Task<ActionResult<ApiResult<List<DeviceBaseList>>>> GetAllDevice()
|
||||||
|
{
|
||||||
|
ApiResult<List<DeviceBaseList>> apiResult = new ApiResult<List<DeviceBaseList>>();
|
||||||
|
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<DeviceBaseList>(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);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 獲取設備資料
|
/// 獲取設備資料
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -79,6 +79,17 @@ namespace FrontendWebApi.Models
|
|||||||
public List<DeviceNode> Device_nodes { get; set; }
|
public List<DeviceNode> 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 class DeviceBaseInfo
|
||||||
{
|
{
|
||||||
public string device_number { get; set; }
|
public string device_number { get; set; }
|
||||||
|
Loading…
Reference in New Issue
Block a user