/History/GetDevice、 /History/LookRealTime、 /History/GetMainSub 即時趨勢 API SQL調整
This commit is contained in:
parent
8c8030cb03
commit
0811ba816b
@ -210,7 +210,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
where c.account = @account
|
where c.account = @account
|
||||||
order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type });
|
order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type });
|
||||||
var dbbuilding = await frontendRepository.GetAllAsync<History_Build>(
|
var dbbuilding = await frontendRepository.GetAllAsync<History_Build>(
|
||||||
@$"select distinct d.building_guid,d.full_name,d.priority from role_auth a
|
@$"select distinct d.building_tag,d.full_name,d.priority from role_auth a
|
||||||
join auth_page b on a.AuthCode = b.AuthCode
|
join auth_page b on a.AuthCode = b.AuthCode
|
||||||
join userinfo c on c.role_guid = a.role_guid
|
join userinfo c on c.role_guid = a.role_guid
|
||||||
join building d on d.building_tag = b.building_tag
|
join building d on d.building_tag = b.building_tag
|
||||||
@ -335,7 +335,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
wheres.Add("d.deleted = 0");
|
wheres.Add("d.deleted = 0");
|
||||||
if (postDevice.SelectBuildings != null && postDevice.SelectBuildings.Count() > 0)
|
if (postDevice.SelectBuildings != null && postDevice.SelectBuildings.Count() > 0)
|
||||||
{
|
{
|
||||||
wheres.Add("d.building_tag in @builds");
|
wheres.Add("d.device_building_tag in @builds");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (postDevice.SelectFloors != null && postDevice.SelectFloors.Count() > 0)
|
if (postDevice.SelectFloors != null && postDevice.SelectFloors.Count() > 0)
|
||||||
@ -360,15 +360,14 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
b.full_name building_name,
|
b.full_name building_name,
|
||||||
v1.system_key main_name,
|
v1.system_key main_name,
|
||||||
v2.system_key sub_name,
|
v2.system_key sub_name,
|
||||||
d.full_name sub_name,
|
|
||||||
a.full_name device_name,
|
a.full_name device_name,
|
||||||
a.device_number
|
a.device_number
|
||||||
from (SELECT *
|
from (SELECT *
|
||||||
FROM device d
|
FROM device d
|
||||||
WHERE {wheres_str}) a
|
WHERE {wheres_str}) a
|
||||||
join building b on b.building_tag = a.building_tag
|
join building b on b.building_tag = a.device_building_tag
|
||||||
join variable v1 on v1.system_value = a.device_system_tag and v1.deleted = 0 and v1.system_type = 'device_system_category_layer2'
|
join variable v1 on v1.system_value = a.device_system_tag and v1.deleted = 0 and v1.system_type = 'device_system_category_layer2'
|
||||||
join variable v2 on v2.system_value = a.device_system_tag and v2.deleted = 0 and v2.system_type = 'device_system_category_layer3'
|
join variable v2 on v2.system_value = a.device_name_tag and v2.deleted = 0 and v2.system_type = 'device_system_category_layer3'
|
||||||
order by b.priority,v1.system_priority,v2.system_priority,a.priority";
|
order by b.priority,v1.system_priority,v2.system_priority,a.priority";
|
||||||
|
|
||||||
var dbDevice = await backendRepository.GetAllAsync<History_GetDevice>(sql, new { builds = postDevice.SelectBuildings, floor_guid = postDevice.SelectFloors, syss = postDevice.SelectSub, device_name = postDevice.Device_name });
|
var dbDevice = await backendRepository.GetAllAsync<History_GetDevice>(sql, new { builds = postDevice.SelectBuildings, floor_guid = postDevice.SelectFloors, syss = postDevice.SelectSub, device_name = postDevice.Device_name });
|
||||||
@ -405,9 +404,9 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
@$"select c.full_name building_name,b.device_number,b.full_name device_name,a.full_name item_name,a.points,a.unit
|
@$"select c.full_name building_name,b.device_number,b.full_name device_name,a.full_name item_name,a.points,a.unit
|
||||||
from device_item a
|
from device_item a
|
||||||
join device b on a.device_system_tag = b.device_system_tag
|
join device b on a.device_system_tag = b.device_system_tag
|
||||||
join building c on c.building_tag = b.building_tag
|
join building c on c.building_tag = b.device_building_tag
|
||||||
join variable v1 on v1.system_value = b.device_system_tag and v1.deleted = 0 and v1.system_type = 'device_system_category_layer2'
|
join variable v1 on v1.system_value = b.device_system_tag and v1.deleted = 0 and v1.system_type = 'device_system_category_layer2'
|
||||||
join variable v2 on v2.system_value = b.device_system_tag and v2.deleted = 0 and v2.system_type = 'device_system_category_layer3'
|
join variable v2 on v2.system_value = b.device_name_tag and v2.deleted = 0 and v2.system_type = 'device_system_category_layer3'
|
||||||
where a.deleted = 0 and b.deleted = 0 and v2.deleted = 0 and v1.deleted = 0
|
where a.deleted = 0 and b.deleted = 0 and v2.deleted = 0 and v1.deleted = 0
|
||||||
and a.unit is not null and b.device_number in @Device_number
|
and a.unit is not null and b.device_number in @Device_number
|
||||||
order by c.priority,b.priority
|
order by c.priority,b.priority
|
||||||
|
Loading…
Reference in New Issue
Block a user