[WebAPI] GetDevice 增加引數 device_number 可針對 device_number 進行 Filter | GetEmergencyDevice 平面圖網址動態抓 variable 取得 website config 組裝 url | [View] 緊急應變平面圖路徑調整

This commit is contained in:
dev01 2023-10-30 18:18:04 +08:00
parent 3bbdfb2913
commit a37224647e
4 changed files with 26 additions and 9 deletions

View File

@ -474,6 +474,7 @@ namespace FrontendWebApi.ApiControllers
var sub_system_guidsql = ""; var sub_system_guidsql = "";
var disasterjoinsql = ""; var disasterjoinsql = "";
var disastersql = ""; var disastersql = "";
var devicesql = "";
var layer3sql = ""; var layer3sql = "";
var sWhere = ""; var sWhere = "";
if (!String.IsNullOrEmpty(post.main_system_tag)) if (!String.IsNullOrEmpty(post.main_system_tag))
@ -496,7 +497,9 @@ namespace FrontendWebApi.ApiControllers
disasterjoinsql = " left join device_disaster dd on dd.device_guid = d.device_guid"; disasterjoinsql = " left join device_disaster dd on dd.device_guid = d.device_guid";
disastersql = $" and dd.device_system_value = '{post.device_system_value}'"; disastersql = $" and dd.device_system_value = '{post.device_system_value}'";
} }
if (!String.IsNullOrEmpty(post.device_number)) {
devicesql = " and d.device_number = @device_number ";
}
if (!String.IsNullOrEmpty(post.show_cctv) && post.show_cctv == "1") if (!String.IsNullOrEmpty(post.show_cctv) && post.show_cctv == "1")
{ {
var str_arr = new List<string>(); var str_arr = new List<string>();
@ -516,7 +519,10 @@ namespace FrontendWebApi.ApiControllers
{ {
str_arr.Add($@"dd.device_system_value = '{post.device_system_value}'"); str_arr.Add($@"dd.device_system_value = '{post.device_system_value}'");
} }
if (!String.IsNullOrEmpty(post.device_number))
{
str_arr.Add($@"d.device_number = @device_number");
}
if (str_arr.Count > 0) if (str_arr.Count > 0)
{ {
sWhere = $@" AND ( sWhere = $@" AND (
@ -534,7 +540,7 @@ namespace FrontendWebApi.ApiControllers
} }
else else
{ {
sWhere = $@"{main_system_guidsql} {sub_system_guidsql} {disastersql} {layer3sql}"; sWhere = $@"{main_system_guidsql} {sub_system_guidsql} {disastersql} {layer3sql} {devicesql}";
} }
var sql = $@"select var sql = $@"select
@ -595,7 +601,7 @@ namespace FrontendWebApi.ApiControllers
where d.deleted = 0 and d.is_link = 1 and d.device_building_tag = '{post.building_tag}' {sWhere} where d.deleted = 0 and d.is_link = 1 and d.device_building_tag = '{post.building_tag}' {sWhere}
order by d.priority ASC, left(device_serial_tag, LENGTH(device_serial_tag) - 1) ASC"; order by d.priority ASC, left(device_serial_tag, LENGTH(device_serial_tag) - 1) ASC";
var devicelist = await backendRepository.GetAllAsync<DeviceFloor>(sql); var devicelist = await backendRepository.GetAllAsync<DeviceFloor>(sql,new { device_number = post.device_number });
//抓出該設備底下的子節點 //抓出該設備底下的子節點
var sql_node = $@"SELECT var sql_node = $@"SELECT

View File

@ -132,15 +132,18 @@ namespace FrontendWebApi.ApiControllers
if (selectdevice.select_disasters == null || selectdevice.select_disasters.Count == 0) if (selectdevice.select_disasters == null || selectdevice.select_disasters.Count == 0)
selectdevice.select_disasters = new List<int>(); selectdevice.select_disasters = new List<int>();
var sqlString = $@"SELECT system_key as 'Name', system_value as 'Value' FROM variable where system_type = 'website_config' AND deleted = 0";
List<KeyValue> webSiteConfig = await backendRepository.GetAllAsync<KeyValue>(sqlString);
deviceQue += $" AND d.device_building_tag in @building_tag "; deviceQue += $" AND d.device_building_tag in @building_tag ";
disasQue = " where dd.device_system_value IN @disasters "; disasQue = " where dd.device_system_value IN @disasters ";
var sqlString = @$"select sqlString = @$"select
d.device_guid, d.device_guid,
d.device_number, d.device_number,
d.full_name AS device_name, d.full_name AS device_name,
d.device_building_tag AS building_tag, d.device_building_tag AS building_tag,
b.full_name AS building_name, b.full_name AS building_name,
CONCAT(b.ip_address , ':', b.ip_port) AS ip_address, CONCAT(@niagara_http, '://',b.ip_address , ':', b.ip_port,'/file/',@niagaraRootName) AS ip_address,
v.layer2, v.layer2,
v.layer2_name, v.layer2_name,
v.system_value AS layer3, v.system_value AS layer3,
@ -173,8 +176,15 @@ namespace FrontendWebApi.ApiControllers
{disasQue} {disasQue}
ORDER BY d.device_number ORDER BY d.device_number
"; ";
Variable = await backendRepository.GetAllAsync<deviceMenu>(sqlString, new { disasters= selectdevice.select_disasters, building_tag = selectdevice.selectbuilding, Variable = await backendRepository.GetAllAsync<deviceMenu>(sqlString, new
floor = selectdevice.select_Floors, layer3 = selectdevice.select_Layer3 }); {
disasters = selectdevice.select_disasters,
building_tag = selectdevice.selectbuilding,
floor = selectdevice.select_Floors,
layer3 = selectdevice.select_Layer3,
niagaraRootName = webSiteConfig.FirstOrDefault(w => w.Name == "frontend_niagara_root_name")?.Value,
niagara_http = webSiteConfig.FirstOrDefault(w => w.Name == "frontend_http")?.Value,
});
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Data = Variable; apiResult.Data = Variable;

View File

@ -66,6 +66,7 @@ namespace FrontendWebApi.Models
public string sub_system_tag { get; set; } public string sub_system_tag { get; set; }
public string building_tag { get; set; } public string building_tag { get; set; }
public string device_system_value { get; set; } public string device_system_value { get; set; }
public string device_number { get; set; }
public string device_system_category_layer3 { get; set; } public string device_system_category_layer3 { get; set; }
public string show_cctv { get; set; } public string show_cctv { get; set; }
} }

View File

@ -569,7 +569,7 @@
`;*@ `;*@
var html = ` var html = `
<a href="https://${row.ip_address}/file/BajascriptTest/_FloorMap.html?building_tag=${row.building_tag}&main_system_tag=${row.layer2}&floor_guid=${row.floorguid}&sub_system_tag=${row.layer3}&device_number=${data}&show_cctv=1&jwt=${localStorage.getItem('JWT-Authorization')}" target="_blank"> <a href="${row.ip_address}/_FloorMap.html?building_tag=${row.building_tag}&main_system_tag=${row.layer2}&floor_guid=${row.floorguid}&sub_system_tag=${row.layer3}&device_number=${data}&show_cctv=1&isFromEmergency=1&jwt=${localStorage.getItem('JWT-Authorization')}" target="_blank">
${data} ${data}
</a> </a>
`; `;