[後端] 前台修改sql
This commit is contained in:
parent
ce792c2a5c
commit
412a8ec909
@ -17,8 +17,8 @@
|
||||
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
|
||||
"Port": "js2LutKe+rdjzdxMPQUrvQ==",
|
||||
//"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30
|
||||
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
|
||||
"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
|
||||
"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
|
||||
//"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
|
||||
//"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
|
||||
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
|
||||
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
|
||||
|
@ -44,25 +44,29 @@ namespace FrontendWebApi.ApiControllers
|
||||
var sql = $@"
|
||||
SELECT
|
||||
(
|
||||
SELECT TOP(1) w.get_value
|
||||
SELECT w.get_value
|
||||
FROM api_weateher w
|
||||
WHERE w.weather_type = 'Wx' AND @DateNow BETWEEN w.start_time AND w.end_time ORDER BY created_at DESC
|
||||
limit 1
|
||||
) AS WxText,
|
||||
(
|
||||
SELECT TOP(1) wd.WeatherKey
|
||||
SELECT wd.WeatherKey
|
||||
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
|
||||
limit 1
|
||||
) AS Wx,
|
||||
(
|
||||
SELECT TOP(1) w.get_value
|
||||
SELECT w.get_value
|
||||
FROM api_weateher w
|
||||
WHERE w.weather_type = 'T' AND @DateNow < w.start_time
|
||||
limit 1
|
||||
) AS Temp,
|
||||
(
|
||||
SELECT TOP(1) w.get_value
|
||||
SELECT w.get_value
|
||||
FROM api_weateher w
|
||||
WHERE w.weather_type = 'RH' AND @DateNow < w.start_time
|
||||
limit 1
|
||||
) AS RH
|
||||
";
|
||||
var dateNow = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00");
|
||||
@ -170,74 +174,73 @@ namespace FrontendWebApi.ApiControllers
|
||||
b.full_name bfull_name,
|
||||
b.ip_address,
|
||||
b.priority bpriority,
|
||||
ma.full_name mafull_name,
|
||||
ma.priority mapriority,
|
||||
ma.code,
|
||||
sub.full_name subfull_name,
|
||||
sub.priority subpriority
|
||||
v1.system_key mafull_name,
|
||||
v1.system_priority mapriority,
|
||||
v1.system_value,
|
||||
v2.system_key subfull_name,
|
||||
v2.system_priority subpriority
|
||||
from building_menu me
|
||||
left join building b on b.building_guid = me.building_guid
|
||||
left join main_system ma on ma.main_system_guid = me.main_system_guid
|
||||
left join sub_system sub on sub.sub_system_guid = me.sub_system_guid
|
||||
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'
|
||||
inner join (
|
||||
SELECT
|
||||
ap.building_guid,
|
||||
ap.building_tag,
|
||||
ap.ShowView
|
||||
FROM
|
||||
(
|
||||
SELECT *
|
||||
FROM role_auth ra
|
||||
WHERE ra.role_guid = (SELECT ui.role_guid from userinfo ui where account = @Account)
|
||||
WHERE ra.role_guid = (SELECT ui.role_guid from userinfo ui where account = '@Account')
|
||||
) ra
|
||||
left join auth_page ap on ra.AuthCode = ap.AuthCode
|
||||
where ap.AuthType = 1
|
||||
) shower on shower.building_guid = me.building_guid and shower.ShowView = me.sub_system_guid
|
||||
order by b.priority, ma.priority,sub.priority, sub.created_at DESC", new { Account = account });
|
||||
) shower on shower.building_tag = me.building_tag and shower.ShowView = v2.id
|
||||
order by b.priority, v1.system_priority, v2.system_priority, v2.created_at DESC", new { Account = account });
|
||||
|
||||
var floorsql = await backendRepository.GetAllAsync<Floorsql>(@"
|
||||
select * from (select * from sub_system_floor ssf where ssf.deleted = 0 and ssf.status = 0) a
|
||||
left join floor on floor.floor_guid = a.floor_guid order by floor.priority");
|
||||
left join floor on floor.full_name = a.floor_tag order by floor.priority;");
|
||||
|
||||
var common = await backendRepository.GetAllAsync<KeyValue>($@"select ap.building_guid Name,ap.ShowView Value from auth_page ap
|
||||
var common = await backendRepository.GetAllAsync<KeyValue>($@"select ap.building_tag Name,ap.ShowView Value from auth_page ap
|
||||
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}'
|
||||
");
|
||||
|
||||
var building = buildmenusql.GroupBy(a => a.building_guid).ToList();
|
||||
var building = buildmenusql.GroupBy(a => a.main_system_tag).ToList();
|
||||
|
||||
List<Building> buildingMenus = new List<Building>();
|
||||
foreach (var menu in building)
|
||||
{
|
||||
Building building1 = new Building()
|
||||
{
|
||||
building_guid = menu.Select(a => a.building_guid).FirstOrDefault(),
|
||||
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(),
|
||||
device_building_tag = menu.Select(a => a.device_building_tag).FirstOrDefault(),
|
||||
building_tag = menu.Select(a => a.device_building_tag).FirstOrDefault(),
|
||||
main_system = new List<Main_system>(),
|
||||
common = new List<string>()
|
||||
};
|
||||
var commonlist = common.Where(a => a.Name == building1.building_guid).Select(a => a.Value).ToList();
|
||||
var commonlist = common.Where(a => a.Name == building1.building_tag).Select(a => a.Value).ToList();
|
||||
building1.common = commonlist;
|
||||
var mainsystem = menu.GroupBy(a => a.main_system_guid).ToList();
|
||||
var mainsystem = menu.GroupBy(a => a.main_system_tag).ToList();
|
||||
foreach (var ma in mainsystem)
|
||||
{
|
||||
Main_system main_System = new Main_system()
|
||||
{
|
||||
code = ma.Select(a => a.code).FirstOrDefault(),
|
||||
main_system_guid = ma.Select(a => a.main_system_guid).FirstOrDefault(),
|
||||
main_system_tag = ma.Select(a => a.main_system_tag).FirstOrDefault(),
|
||||
full_name = ma.Select(a => a.mafull_name).FirstOrDefault(),
|
||||
priority = ma.Select(a => a.mapriority).FirstOrDefault(),
|
||||
Sub_system = new List<Sub_systemGuid>()
|
||||
};
|
||||
var subsystem = ma.GroupBy(a => a.sub_system_guid).ToList();
|
||||
var subsystem = ma.GroupBy(a => a.sub_system_tag).ToList();
|
||||
foreach (var sub in subsystem)
|
||||
{
|
||||
Sub_systemGuid sub_System = new Sub_systemGuid()
|
||||
{
|
||||
sub_system_guid = sub.Select(a => a.sub_system_guid).FirstOrDefault(),
|
||||
sub_system_tag = sub.Select(a => a.sub_system_tag).FirstOrDefault(),
|
||||
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(),
|
||||
@ -289,7 +292,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
left join floor on floor.floor_guid = a.floor_guid order by floor.priority");
|
||||
Sub_system sub_System = new Sub_system()
|
||||
{
|
||||
sub_system_guid = sub_system.sub_system_guid,
|
||||
sub_system_guid = sub_system.sub_system_tag,
|
||||
system_url = sub_system.system_url,
|
||||
drawing = sub_system.drawing,
|
||||
Floors = new List<Floor>(),
|
||||
|
@ -206,7 +206,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type
|
||||
join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0 and d.visible = 1
|
||||
join device_item di on d.device_system_tag=di.device_system_tag and d.device_name_tag=di.device_name_tag
|
||||
and di.is_link = 1
|
||||
and di.is_link = 1 and di.is_show_history = 1
|
||||
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 });
|
||||
var dbbuilding = await frontendRepository.GetAllAsync<History_Build>(
|
||||
|
@ -21,15 +21,15 @@ namespace FrontendWebApi.Models
|
||||
|
||||
public class Buildingsql
|
||||
{
|
||||
public string building_guid { get; set; }
|
||||
public string building_tag { get; set; }
|
||||
public string bfull_name { get; set; }
|
||||
public string ip_address { get; set; }
|
||||
public int bpriority { get; set; }
|
||||
}
|
||||
public class BuildMenuSql : Buildingsql
|
||||
{
|
||||
public string main_system_guid { get; set; }
|
||||
public string sub_system_guid { get; set; }
|
||||
public string main_system_tag { get; set; }
|
||||
public string sub_system_tag { get; set; }
|
||||
public byte drawing { get; set; }
|
||||
public byte icon_click { get; set; }
|
||||
public string icon_click_url { get; set; }
|
||||
@ -48,9 +48,8 @@ namespace FrontendWebApi.Models
|
||||
}
|
||||
public class Floorsql : Floor
|
||||
{
|
||||
public string main_system_guid { get; set; }
|
||||
public string sub_system_guid { get; set; }
|
||||
public string building_guid { get; set; }
|
||||
public string main_system_tag { get; set; }
|
||||
public string sub_system_tag { get; set; }
|
||||
}
|
||||
public class Devicesql : Device
|
||||
{
|
||||
@ -72,17 +71,16 @@ namespace FrontendWebApi.Models
|
||||
|
||||
public class Building
|
||||
{
|
||||
public string building_guid { get; set; }
|
||||
public string building_tag { get; set; }
|
||||
public string full_name { get; set; }
|
||||
public string ip_address { get; set; }
|
||||
public int priority { get; set; }
|
||||
public string device_building_tag { get; set; }
|
||||
public List<Main_system> main_system { get; set; }
|
||||
public List<string> common { get; set; }
|
||||
}
|
||||
public class Main_system
|
||||
{
|
||||
public string main_system_guid { get; set; }
|
||||
public string main_system_tag { get; set; }
|
||||
public string full_name { get; set; }
|
||||
public int priority { get; set; }
|
||||
public string code { get; set; }
|
||||
@ -90,7 +88,7 @@ namespace FrontendWebApi.Models
|
||||
}
|
||||
public class Sub_systemGuid
|
||||
{
|
||||
public string sub_system_guid { get; set; }
|
||||
public string sub_system_tag { get; set; }
|
||||
public string full_name { get; set; }
|
||||
public int priority { get; set; }
|
||||
public string device_system_tag { get; set; }
|
||||
@ -115,7 +113,6 @@ namespace FrontendWebApi.Models
|
||||
public class Floor
|
||||
{
|
||||
public string floor_guid { get; set; }
|
||||
|
||||
public string building_tag { get; set; }
|
||||
public string full_name { get; set; }
|
||||
public string InitMapName { get; set; }
|
||||
|
Loading…
Reference in New Issue
Block a user