ibms-dome/FrontendWebApi/ApiControllers/BuildController.cs

727 lines
32 KiB
C#
Raw Normal View History

2022-10-14 16:08:54 +08:00
using FrontendWebApi.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Repository.BackendRepository.Interface;
using Repository.FrontendRepository.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace FrontendWebApi.ApiControllers
{
public class BuildController : MyBaseApiController<BuildController>
{
private readonly IBackendRepository backendRepository;
private readonly IFrontendRepository frontendRepository;
public BuildController
(
IBackendRepository backendRepository,
IFrontendRepository frontendRepository
)
{
this.backendRepository = backendRepository;
this.frontendRepository = frontendRepository;
}
/// <summary>
/// 取得天氣資訊
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("api/GetWeateher")]
public async Task<ActionResult<ApiResult<Weateher>>> GetWeateher()
{
ApiResult<Weateher> apiResult = new ApiResult<Weateher>(jwt_str);
if (!jwtlife)
{
apiResult.Code = "5000";
return BadRequest(apiResult);
}
try
{
var sql = $@"
SELECT
(
2023-05-02 10:05:49 +08:00
SELECT w.get_value
2022-10-14 16:08:54 +08:00
FROM api_weateher w
WHERE w.weather_type = 'Wx' AND @DateNow BETWEEN w.start_time AND w.end_time ORDER BY created_at DESC
2023-05-02 10:05:49 +08:00
limit 1
2022-10-14 16:08:54 +08:00
) AS WxText,
(
2023-05-02 10:05:49 +08:00
SELECT wd.WeatherKey
2022-10-14 16:08:54 +08:00
FROM api_weateher w
LEFT JOIN weather_description wd ON w.get_value = wd.WeatherValue
WHERE w.weather_type = 'WxV' AND @DateNow BETWEEN w.start_time AND w.end_time ORDER BY created_at DESC
2023-05-02 10:05:49 +08:00
limit 1
2022-10-14 16:08:54 +08:00
) AS Wx,
(
2023-05-02 10:05:49 +08:00
SELECT w.get_value
2022-10-14 16:08:54 +08:00
FROM api_weateher w
WHERE w.weather_type = 'T' AND @DateNow < w.start_time
2023-05-02 10:05:49 +08:00
limit 1
2022-10-14 16:08:54 +08:00
) AS Temp,
(
2023-05-02 10:05:49 +08:00
SELECT w.get_value
2022-10-14 16:08:54 +08:00
FROM api_weateher w
WHERE w.weather_type = 'RH' AND @DateNow < w.start_time
2023-05-02 10:05:49 +08:00
limit 1
2022-10-14 16:08:54 +08:00
) AS RH
";
var dateNow = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00");
var weateher = await backendRepository.GetOneAsync<Weateher>(sql, new { DateNow = dateNow });
apiResult.Data = weateher;
apiResult.Code = "0000";
}
catch (Exception exception)
{
apiResult.Code = "9999";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
2022-11-05 18:18:29 +08:00
/// <summary>
/// 區域基本資料列表
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<ApiResult<List<BuildInfo>>> BuildInfoList()
{
ApiResult<List<BuildInfo>> apiResult = new ApiResult<List<BuildInfo>>();
List<BuildInfo> buildInfo = new List<BuildInfo>();
try
{
var sqlString = @$"SELECT A.priority, A.building_tag, A.full_name, A.ip_address, A.ip_port, (SELECT COUNT(*) FROM floor f WHERE f.deleted = 0 AND f.building_tag = A.building_tag) AS 'floorNum', A.created_at,
A.orgName_3D, A.extName_3D
FROM building A
WHERE A.deleted = 0
ORDER BY A.priority ASC, A.created_at DESC";
buildInfo = await backendRepository.GetAllAsync<BuildInfo>(sqlString);
apiResult.Code = "0000";
apiResult.Data = buildInfo;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return apiResult;
}
2022-10-14 16:08:54 +08:00
/// <summary>
/// 取得預設的棟別資訊
/// </summary>
/// <param name="defaultBuilding"></param>
/// <returns></returns>
[HttpPost]
[Route("api/GetDefaultBuilding")]
public async Task<ActionResult<ApiResult<Building>>> GetDefaultBuilding(DefaultBuilding defaultBuilding)
{
ApiResult<Building> apiResult = new ApiResult<Building>(jwt_str);
if (!jwtlife)
{
apiResult.Code = "5000";
return BadRequest(apiResult);
}
try
{
var sWhere = "deleted = 0 AND ip_address = @ip_address AND ip_port = @ip_port";
var building = await frontendRepository.GetOneAsync<Building>("building", sWhere, new { ip_address = defaultBuilding.ip_address, ip_port = defaultBuilding.ip_port });
apiResult.Data = building;
apiResult.Code = "0000";
}
catch (Exception exception)
{
apiResult.Code = "9999";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
/// <summary>
/// 取得L型選單資料
/// </summary>
/// <param name="account"></param>
/// <returns></returns>
[HttpPost]
[Route("api/GetMenu")]
public async Task<ActionResult<ApiResult<List<Building>>>> GetMenu(string account)
{
ApiResult<List<Building>> apiResult = new ApiResult<List<Building>>(jwt_str);
if (!jwtlife)
{
apiResult.Code = "5000";
return BadRequest(apiResult);
}
try
{
var buildmenusql = await backendRepository.GetAllAsync<BuildMenuSql>(@$"
select
2023-05-02 10:05:49 +08:00
me.* ,
b.full_name bfull_name,
b.ip_address,
b.priority bpriority,
v1.system_key mafull_name,
v1.system_priority mapriority,
v1.system_value,
v2.system_key subfull_name,
v2.system_priority subpriority
2022-10-14 16:08:54 +08:00
from building_menu me
2023-05-02 10:05:49 +08:00
left join building b on b.building_tag = me.building_tag
left join variable v1 on me.main_system_tag = v1.system_value and v1.deleted = 0 and v1.system_type = 'device_system_category_layer2'
left join variable v2 on me.sub_system_tag = v2.system_value and v2.deleted = 0 and v2.system_type = 'device_system_category_layer3'
2022-10-14 16:08:54 +08:00
inner join (
2023-05-02 10:05:49 +08:00
SELECT
ap.building_tag,
ap.ShowView
FROM
(
SELECT *
FROM role_auth ra
2023-05-02 18:07:30 +08:00
WHERE ra.role_guid = (SELECT ui.role_guid from userinfo ui where account = @Account)
2023-05-02 10:05:49 +08:00
) ra
left join auth_page ap on ra.AuthCode = ap.AuthCode
where ap.AuthType = 1
) shower on shower.building_tag = me.building_tag and shower.ShowView = v2.id
2023-05-02 10:05:49 +08:00
order by b.priority, v1.system_priority, v2.system_priority, v2.created_at DESC", new { Account = account });
2022-10-14 16:08:54 +08:00
var floorsql = await backendRepository.GetAllAsync<Floorsql>(@"
select * from (select * from sub_system_floor ssf where ssf.deleted = 0 and ssf.status = 0) a
2023-05-02 10:05:49 +08:00
left join floor on floor.full_name = a.floor_tag order by floor.priority;");
2022-10-14 16:08:54 +08:00
2023-05-02 10:05:49 +08:00
var common = await backendRepository.GetAllAsync<KeyValue>($@"select ap.building_tag Name,ap.ShowView Value from auth_page ap
2022-10-14 16:08:54 +08:00
left join role_auth ra on ra.AuthCode = ap.AuthCode
right join userinfo ui on ui.role_guid = ra.role_guid
where SUBSTRING(ap.AuthCode,1,1) = 'C' and ui.account = '{account}'
2023-05-02 10:05:49 +08:00
");
2022-10-14 16:08:54 +08:00
2023-05-05 11:10:29 +08:00
var building = buildmenusql.GroupBy(a => a.building_tag).ToList();
2022-10-14 16:08:54 +08:00
List<Building> buildingMenus = new List<Building>();
foreach (var menu in building)
{
Building building1 = new Building()
{
full_name = menu.Select(a => a.bfull_name).FirstOrDefault(),
ip_address = menu.Select(a => a.ip_address).FirstOrDefault(),
priority = menu.Select(a => a.bpriority).FirstOrDefault(),
2023-05-02 10:05:49 +08:00
building_tag = menu.Select(a => a.device_building_tag).FirstOrDefault(),
2022-10-14 16:08:54 +08:00
main_system = new List<Main_system>(),
common = new List<string>()
};
2023-05-02 10:05:49 +08:00
var commonlist = common.Where(a => a.Name == building1.building_tag).Select(a => a.Value).ToList();
2022-10-14 16:08:54 +08:00
building1.common = commonlist;
2023-05-02 10:05:49 +08:00
var mainsystem = menu.GroupBy(a => a.main_system_tag).ToList();
2022-10-14 16:08:54 +08:00
foreach (var ma in mainsystem)
{
Main_system main_System = new Main_system()
{
code = ma.Select(a => a.code).FirstOrDefault(),
2023-05-02 10:05:49 +08:00
main_system_tag = ma.Select(a => a.main_system_tag).FirstOrDefault(),
2022-10-14 16:08:54 +08:00
full_name = ma.Select(a => a.mafull_name).FirstOrDefault(),
priority = ma.Select(a => a.mapriority).FirstOrDefault(),
Sub_system = new List<Sub_systemGuid>()
};
2023-05-02 10:05:49 +08:00
var subsystem = ma.GroupBy(a => a.sub_system_tag).ToList();
2022-10-14 16:08:54 +08:00
foreach (var sub in subsystem)
{
Sub_systemGuid sub_System = new Sub_systemGuid()
{
2023-05-02 10:05:49 +08:00
sub_system_tag = sub.Select(a => a.sub_system_tag).FirstOrDefault(),
2022-10-14 16:08:54 +08:00
full_name = sub.Select(a => a.subfull_name).FirstOrDefault(),
priority = sub.Select(a => a.subpriority).FirstOrDefault(),
device_system_tag = sub.Select(a => a.device_system_tag).FirstOrDefault(),
OpenTab = sub.Select(a => a.OpenTab).FirstOrDefault(),
2023-05-05 11:45:43 +08:00
system_url = sub.Select(a => a.left_system_url).FirstOrDefault()
2022-10-14 16:08:54 +08:00
};
main_System.Sub_system.Add(sub_System);
}
building1.main_system.Add(main_System);
}
buildingMenus.Add(building1);
}
apiResult.Data = buildingMenus;
apiResult.Code = "0000";
}
catch (Exception exception)
{
apiResult.Code = "9999";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
[HttpPost]
[Route("api/GetSubSystem")]
public async Task<ActionResult<ApiResult<Sub_system>>> GetSubSystem(GetSubPost get)
{
ApiResult<Sub_system> apiResult = new ApiResult<Sub_system>(jwt_str);
if (!jwtlife)
{
apiResult.Code = "5000";
return BadRequest(apiResult);
}
if (get.building_tag == null || get.main_system_tag == null || get.sub_system_tag == null)
2022-10-14 16:08:54 +08:00
{
apiResult.Code = "9997";
return Ok(apiResult);
}
try
{
2023-05-05 09:33:47 +08:00
var sub_system = await backendRepository.GetOneAsync<BuildMenuSql>(@$"select v.system_key subfull_name,me.* from building_menu me
left join variable v on v.system_value = me.sub_system_tag and v.system_type = 'device_system_category_layer3' and v.deleted = 0
where me.building_tag = '{get.building_tag}' and me.main_system_tag = '{get.main_system_tag}' and me.sub_system_tag = '{get.sub_system_tag}' order by v.system_priority");
2022-10-14 16:08:54 +08:00
List<Floor> Floors = new List<Floor>();
var floorsql = await backendRepository.GetAllAsync<Floorsql>($@"
2023-05-05 09:33:47 +08:00
select * from (select * from sub_system_floor ssf where ssf.deleted = 0 and ssf.status = 0 and ssf.building_tag = '{get.building_tag}' and ssf.main_system_tag = '{get.main_system_tag}' and ssf.sub_system_tag = '{get.sub_system_tag}') a
left join floor on floor.full_name = a.floor_tag order by floor.priority");
2022-10-14 16:08:54 +08:00
Sub_system sub_System = new Sub_system()
{
sub_system_tag = sub_system.sub_system_tag,
2023-05-05 11:45:43 +08:00
left_system_url = sub_system.left_system_url,
left_drawing = sub_system.left_drawing,
2022-10-14 16:08:54 +08:00
Floors = new List<Floor>(),
full_name = sub_system.subfull_name,
2023-05-05 11:45:43 +08:00
left_icon_click = sub_system.left_icon_click,
left_icon_click_url = sub_system.left_icon_click_url,
left_planimetric_click = sub_system.left_planimetric_click,
left_planimetric_floor_guid = sub_system.left_planimetric_floor_guid,
left_riser_diagram_url = sub_system.left_riser_diagram_url,
2022-10-14 16:08:54 +08:00
priority = sub_system.subpriority
};
foreach (var floor in floorsql)
{
Floor floor1 = new Floor()
{
devices = null,
floor_guid = floor.floor_guid,
Floor_map_name = floor.Floor_map_name,
2022-10-14 16:08:54 +08:00
full_name = floor.full_name,
InitMapName = floor.InitMapName,
priority = floor.priority
};
Floors.Add(floor1);
}
sub_System.Floors = Floors;
apiResult.Data = sub_System;
apiResult.Code = "0000";
}
catch (Exception exception)
{
apiResult.Code = "9999";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
[HttpPost]
[Route("api/GetFloor")]
public async Task<ActionResult<ApiResult<Floor>>> GetFloor(string guid)
{
ApiResult<Floor> apiResult = new ApiResult<Floor>(jwt_str);
if (!jwtlife)
{
apiResult.Code = "5000";
return BadRequest(apiResult);
}
try
{
string sWhere = $@"deleted = 0 AND floor_guid = @Guid";
var floor = await backendRepository.GetOneAsync<Floor>("floor", sWhere, new { Guid = guid });
apiResult.Data = floor;
apiResult.Code = "0000";
}
catch (Exception exception)
{
apiResult.Code = "9999";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
/// <summary>
/// 依據過濾條件取得該棟別與系統tag name
/// </summary>
/// <param name="post"></param>
/// <returns></returns>
[HttpPost]
[Route("api/GetBuildingAndSystemTagName")]
public async Task<ActionResult<ApiResult<BuildingSystemTagName>>> GetBuildingAndSystemTagName(PostTagName post)
{
ApiResult<BuildingSystemTagName> apiResult = new ApiResult<BuildingSystemTagName>(jwt_str);
if (!jwtlife)
{
apiResult.Code = "5000";
return BadRequest(apiResult);
}
try
{
string sql = $@"
SELECT
device_building_tag,
2023-05-05 17:04:28 +08:00
sub_system_tag
2022-10-14 16:08:54 +08:00
FROM building_menu
2023-05-04 18:15:07 +08:00
WHERE building_tag = @building_tag
AND main_system_tag = @main_system_tag
AND sub_system_tag = @sub_system_tag
2022-10-14 16:08:54 +08:00
";
var tagName = await backendRepository.GetOneAsync<BuildingSystemTagName>(sql, post);
apiResult.Data = tagName;
apiResult.Code = "0000";
}
catch (Exception exception)
{
apiResult.Code = "9999";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
/// <summary>
/// 透過過濾條件,取得設備
/// </summary>
/// <param name="post"></param>
/// <returns></returns>
[HttpPost]
[Route("api/GetDevice")]
public async Task<ActionResult<ApiResult<List<DeviceList>>>> GetDevice(GetSubPost post)
{
ApiResult<List<DeviceList>> apiResult = new ApiResult<List<DeviceList>>();
if (!jwtlife)
{
apiResult.Code = "5000";
return BadRequest(apiResult);
}
2022-11-01 11:58:02 +08:00
if (post.building_tag == null)
2022-10-14 16:08:54 +08:00
{
apiResult.Code = "9997";
return Ok(apiResult);
}
try
{
var main_system_guidsql = "";
var sub_system_guidsql = "";
var disasterjoinsql = "";
var disastersql = "";
var layer3sql = "";
var sWhere = "";
2022-11-01 11:58:02 +08:00
if (!String.IsNullOrEmpty(post.main_system_tag))
2022-10-14 16:08:54 +08:00
{
2022-11-01 11:58:02 +08:00
main_system_guidsql = $" and d.device_system_tag = '{post.main_system_tag}'";
2022-10-14 16:08:54 +08:00
}
2022-11-01 11:58:02 +08:00
if (!String.IsNullOrEmpty(post.sub_system_tag))
2022-10-14 16:08:54 +08:00
{
2022-11-01 11:58:02 +08:00
sub_system_guidsql = $" and d.device_name_tag = '{post.sub_system_tag}'";
2022-10-14 16:08:54 +08:00
}
if (!String.IsNullOrEmpty(post.device_system_category_layer3))
{
layer3sql = $" and d.device_system_category_layer3 = '{post.device_system_category_layer3}'";
}
if (!String.IsNullOrEmpty(post.device_system_value))
{
disasterjoinsql = " left join device_disaster dd on dd.device_guid = d.device_guid";
disastersql = $" and dd.device_system_value = '{post.device_system_value}'";
}
if (!String.IsNullOrEmpty(post.show_cctv) && post.show_cctv == "1")
{
var str_arr = new List<string>();
2022-11-01 11:58:02 +08:00
if (!String.IsNullOrEmpty(post.main_system_tag))
2022-10-14 16:08:54 +08:00
{
2022-11-01 11:58:02 +08:00
str_arr.Add($@"d.device_system_tag = '{post.main_system_tag}'");
2022-10-14 16:08:54 +08:00
}
2022-11-01 11:58:02 +08:00
if (!String.IsNullOrEmpty(post.sub_system_tag))
2022-10-14 16:08:54 +08:00
{
2022-11-01 11:58:02 +08:00
str_arr.Add($@"d.device_name_tag = '{post.sub_system_tag}'");
2022-10-14 16:08:54 +08:00
}
if (!String.IsNullOrEmpty(post.device_system_category_layer3))
{
str_arr.Add($@"d.device_system_category_layer3 = '{post.device_system_category_layer3}'");
}
if (!String.IsNullOrEmpty(post.device_system_value))
{
str_arr.Add($@"dd.device_system_value = '{post.device_system_value}'");
}
if (str_arr.Count > 0)
{
sWhere = $@" AND (
(
{string.Join(" AND ", str_arr)}
) OR
d.device_system_category_layer3 = 'C'
)";
}
else
{
sWhere = $@" AND d.device_system_category_layer3 = 'C'";
}
}
else
{
sWhere = $@"{main_system_guidsql} {sub_system_guidsql} {disastersql} {layer3sql}";
}
var sql = $@"select
d.*,
dk.device_image,
dk.device_normal_text,
dk.device_normal_point_name,
dk.device_normal_point_col,
dk.device_normal_point_value,
dk.device_normal_color,
dk.device_normal_flashing,
dk.device_close_text,
dk.device_close_point_name,
dk.device_close_point_col,
dk.device_close_point_value,
dk.device_close_color,
dk.device_close_flashing,
dk.device_error_text,
dk.device_error_point_name,
dk.device_error_point_col,
dk.device_error_point_value,
dk.device_error_color,
dk.device_error_flashing,
dk.device_error_independent,
CASE WHEN dm.device_master_number IS NOT NULL THEN dm.device_master_number
ELSE CONCAT(d.device_building_tag, '_', d.device_name_tag)
END AS device_master_number,
dm.device_master_full_name,
dm.device_master_icon,
2023-05-05 15:08:30 +08:00
bm.left_icon_click,
bm.left_icon_click_url,
bm.left_icon_click_url_width,
bm.left_icon_click_url_height,
2022-10-14 16:08:54 +08:00
di.full_name as point_name,
di.points,
2023-05-05 16:45:07 +08:00
di.is_bool as points_is_bool,
f.floor_guid
2022-10-14 16:08:54 +08:00
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
-- and d.device_floor_tag = dk.device_floor_tag
and d.device_name_tag = dk.device_name_tag
left join device_master dm ON d.device_building_tag = dm.device_building_tag
AND d.device_name_tag = dm.device_name_tag
2022-11-01 11:58:02 +08:00
left join device_item di ON d.device_name_tag = di.device_name_tag
2022-10-14 16:08:54 +08:00
AND di.deleted = 0
AND di.is_show_riserDiagram = 1
2023-05-05 16:45:07 +08:00
left join floor f on d.device_floor_tag = f.full_name and f.deleted = 0
2022-10-14 16:08:54 +08:00
{disasterjoinsql}
2022-11-01 11:58:02 +08:00
LEFT JOIN building_menu bm ON d.device_building_tag = bm.building_tag AND d.device_system_tag = bm.main_system_tag AND d.device_name_tag = bm.sub_system_tag
where d.deleted = 0 and d.device_building_tag = '{post.building_tag}' {sWhere}
2022-10-14 16:08:54 +08:00
order by d.priority ASC, d.device_number ASC";
var devicelist = await backendRepository.GetAllAsync<DeviceFloor>(sql);
//抓出該設備底下的子節點
var sql_node = $@"SELECT
dn.device_node_guid,
dn.device_guid,
dn.full_name AS Device_node_full_name,
dn.device_node_coordinate,
dn.priority
FROM device_node dn
WHERE dn.deleted = 0 AND dn.device_guid = @device_guid
ORDER BY dn.priority ASC";
foreach (var device in devicelist)
{
device.Device_nodes = await backendRepository.GetAllAsync<DeviceNode>(sql_node, new { device_guid = device.device_guid });
}
//抓出該設備所需要的顯示的即時資料(平面圖)
2022-11-01 11:58:02 +08:00
var sql_tips = $@"SELECT di.* FROM device_item di WHERE di.deleted = 0 AND is_show = 1 AND device_name_tag = @sub_system_tag";
2022-10-14 16:08:54 +08:00
2022-11-01 11:58:02 +08:00
var device_item_floormap = await backendRepository.GetAllAsync<DeviceItem>(sql_tips, new { sub_system_tag = post.sub_system_tag });
2022-10-14 16:08:54 +08:00
foreach (var device in devicelist)
{
device.deviceItems = device_item_floormap;
}
var dev = devicelist.GroupBy(a => a.floor_guid).ToList();
apiResult.Data = new List<DeviceList>();
foreach (var one in dev)
{
DeviceList afloor = new DeviceList()
{
floor_guid = one.Key,
device = new List<Device>()
};
foreach (var de in one)
{
var device_url = string.Empty;
if (((de.icon_click & 1) > 0) && !string.IsNullOrEmpty(de.icon_click_url))
{
device_url = de.icon_click_url;
//點擊顯示系統圖
if (de.icon_click_url.Contains("[device_building_tag]"))
{
device_url = device_url.Replace("[device_building_tag]", de.device_building_tag);
}
if (de.icon_click_url.Contains("[device_system_tag]"))
{
device_url = device_url.Replace("[device_system_tag]", de.device_system_tag);
}
if (de.icon_click_url.Contains("[device_floor_tag]"))
{
device_url = device_url.Replace("[device_floor_tag]", de.device_floor_tag);
}
if (de.icon_click_url.Contains("[device_name_tag]"))
{
device_url = device_url.Replace("[device_name_tag]", de.device_name_tag);
}
if (de.icon_click_url.Contains("[device_serial_tag]"))
{
device_url = device_url.Replace("[device_serial_tag]", de.device_serial_tag);
}
if (de.icon_click_url.Contains("[tag_name]"))
{
device_url = device_url.Replace("[tag_name]", de.device_number);
}
de.icon_click_url = null;
de.DeviceURL = device_url;
}
afloor.device.Add(de);
//Device device = new Device()
//{
// device_building_tag = de.device_building_tag,
// device_close_color =de.device_close_color,
// device_coordinate = de.device_coordinate,
// device_error_color = de.device_error_color,
// device_flashing = de.device_flashing,
// device_floor_tag = de.device_floor_tag,
// device_guid = de.device_guid ,
// device_image = de.device_image,
// device_model = de.device_model,
// device_name_tag = de.device_name_tag,
// device_normal_color = de.device_normal_color,
// device_number = de.device_number,
// device_serial_tag= de.device_serial_tag,
// device_system_tag= de.device_system_tag,
// full_name = de.full_name,
// priority = de.priority,
// status = de.status,
// DeviceURL = device_url,
// icon_click = de.icon_click
//};
//afloor.device.Add(device);
}
apiResult.Data.Add(afloor);
}
apiResult.Code = "0000";
}
catch (Exception exception)
{
apiResult.Code = "9999";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
[HttpPost]
[Route("api/GetAllfloorSVG")]
public async Task<ActionResult<ApiResult<List<string>>>> GetAllfloorSVG(string guid)
{
ApiResult<List<string>> apiResult = new ApiResult<List<string>>(jwt_str);
if (!jwtlife)
{
apiResult.Code = "5000";
return BadRequest(apiResult);
}
try
{
string sWhere = $@"
SELECT
floor_map_name
FROM floor
where building_guid = @Guid and deleted = 0";
var floor = await backendRepository.GetAllAsync<string>(sWhere, new { Guid = guid });
apiResult.Data = floor;
apiResult.Code = "0000";
}
catch (Exception exception)
{
apiResult.Code = "9999";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
2023-05-11 17:01:45 +08:00
[HttpPost]
[Route("api/GetAllfloor")]
public async Task<ActionResult<ApiResult<List<Floor>>>> GetAllfloor(string building_tag)
2023-05-11 17:01:45 +08:00
{
ApiResult<List<Floor>> apiResult = new ApiResult<List<Floor>>(jwt_str);
2023-05-11 17:01:45 +08:00
if (!jwtlife)
{
apiResult.Code = "5000";
return BadRequest(apiResult);
}
try
{
string sWhere = $@"
SELECT
floor_guid,full_name,building_tag
2023-05-11 17:01:45 +08:00
FROM floor
where building_tag = @building_tag and deleted = 0 order by priority";
var floor = await backendRepository.GetAllAsync<Floor>(sWhere, new { building_tag = building_tag });
2023-05-11 17:01:45 +08:00
apiResult.Data = floor;
apiResult.Code = "0000";
}
catch (Exception exception)
{
apiResult.Code = "9999";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
2022-10-14 16:08:54 +08:00
}
}