diff --git a/FrontendWebApi/ApiControllers/AlarmRecordController.cs b/FrontendWebApi/ApiControllers/AlarmRecordController.cs index 5ef95d6..033a8ca 100644 --- a/FrontendWebApi/ApiControllers/AlarmRecordController.cs +++ b/FrontendWebApi/ApiControllers/AlarmRecordController.cs @@ -20,7 +20,7 @@ namespace FrontendWebApi.ApiControllers public class AlarmRecordController : MyBaseApiController { private readonly IFrontendRepository frontendRepository; - + public AlarmRecordController ( IFrontendRepository frontendRepository @@ -47,41 +47,41 @@ namespace FrontendWebApi.ApiControllers try { var sqlBuildingMain = $@"SELECT - b.building_guid, + b.building_tag, b.full_name AS building_name, - ms.main_system_guid, - ms.full_name AS main_system_name + v1.system_value, + v1.system_key AS main_system_name FROM building_menu bm INNER JOIN ( SELECT - ap.building_guid, ap.ShowView + ap.building_tag, ap.ShowView FROM role_auth ra JOIN auth_page ap ON ra.AuthCode = ap.AuthCode - JOIN userinfo u ON u.role_guid = ra.role_guid WHERE u.account = @Account - AND ap.building_guid IS NOT NULL - ) ap ON bm.building_guid = ap.building_guid AND bm.sub_system_guid = ap.ShowView - LEFT JOIN building b ON bm.building_guid = b.building_guid - LEFT JOIN main_system ms ON bm.main_system_guid = ms.main_system_guid - GROUP BY bm.building_guid, bm.main_system_guid - ORDER BY b.priority, ms.priority"; + JOIN userinfo u ON u.role_guid = ra.role_guid WHERE u.account = 'Bajascript' + AND ap.building_tag IS NOT NULL + ) ap ON bm.building_tag = ap.building_tag + LEFT JOIN building b ON bm.building_tag = b.building_tag + left join variable v2 on ap.ShowView = v2.id and v2.deleted = 0 + left join variable v1 on v2.system_parent_id = v1.id + GROUP BY b.building_tag, b.full_name, v1.system_value, v1.system_key"; var alarmRecordPanelRawDatas = await frontendRepository.GetAllAsync(sqlBuildingMain, new { Account = account }); List alarmRecordPanels = new List(); - var alarmRecordPanelRawDatas_GroupBy = alarmRecordPanelRawDatas.GroupBy(x => x.building_guid); + var alarmRecordPanelRawDatas_GroupBy = alarmRecordPanelRawDatas.GroupBy(x => x.building_tag); foreach (var building in alarmRecordPanelRawDatas_GroupBy) { AlarmRecordPanel alarmRecordPanel = new AlarmRecordPanel(); - alarmRecordPanel.building_guid = building.Key; + alarmRecordPanel.building_tag = building.Key; alarmRecordPanel.building_name = building.First().building_name; alarmRecordPanel.mainSystemPanels = new List(); foreach (var tempData in building) { MainSystemPanel mainSystemPanel = new MainSystemPanel(); - mainSystemPanel.main_system_guid = tempData.main_system_guid; - mainSystemPanel.main_system_name = tempData.main_system_name; + mainSystemPanel.system_value = tempData.system_value; + mainSystemPanel.system_key = tempData.system_key; alarmRecordPanel.mainSystemPanels.Add(mainSystemPanel); } @@ -115,31 +115,31 @@ namespace FrontendWebApi.ApiControllers try { var sql = $@"SELECT - temp_path.source AS alarm_path, - temp_msg.source_msg AS msgText, - from_unixtime(record.timestamp/1000,'%Y-%m-%d %H:%i:%s') alarm_timestamp, - record.priority, - CASE WHEN record.normalTime > 0 THEN from_unixtime(record.normalTime/1000,'%Y-%m-%d %H:%i:%s') - ELSE NULL - END AS normal_timestamp, - record.sourceState AS ackState, - class.alarmclass AS alarm_className, - record.userAccount - - FROM alarmorion_orionalarmrecord record + temp_path.source AS alarm_path, + temp_msg.source_msg AS msgText, + from_unixtime(record.timestamp/1000,'%Y-%m-%d %H:%i:%s') alarm_timestamp, + record.priority, + CASE WHEN record.normalTime > 0 THEN from_unixtime(record.normalTime/1000,'%Y-%m-%d %H:%i:%s') + ELSE NULL + END AS normal_timestamp, + record.sourceState AS ackState, + class.alarmclass AS alarm_className, + record.userAccount + + FROM alarmOrion_OrionAlarmRecord record JOIN ( - SELECT sourceorder.* ,temp_source.source - FROM alarmorion_orionalarmsourceorder sourceorder - JOIN alarmorion_orionalarmsource temp_source ON sourceorder.alarmSource = temp_source.id + SELECT sourceorder.* ,temp_source.source + FROM alarmOrion_OrionAlarmSourceOrder sourceorder + JOIN alarmOrion_OrionAlarmSource temp_source ON sourceorder.alarmSource = temp_source.id ) temp_path ON record.id = temp_path.alarm JOIN( - SELECT - val.alarm, - val.value AS source_msg - FROM alarmorion_orionalarmfacetvalue val - JOIN alarmorion_orionalarmfacetname nam ON val.facetName = nam.id AND nam.facetName = 'msgText' + SELECT + val.alarm, + val.value AS source_msg + FROM alarmOrion_OrionAlarmFacetValue val + JOIN alarmOrion_OrionAlarmFacetName nam ON val.facetName = nam.id AND nam.facetName = 'msgText' ) temp_msg ON record.id = temp_msg.alarm - JOIN alarmorion_orionalarmclass class ON record.alarmClass = class.id + JOIN alarmOrion_OrionAlarmClass class ON record.alarmClass = class.id WHERE from_unixtime(record.timestamp/1000,'%Y-%m-%d %H:%i:%s') BETWEEN @StartTimestamp AND @EndTimeStamp"; if (post.IsSolve != 0) @@ -183,8 +183,8 @@ namespace FrontendWebApi.ApiControllers var sql_device = $@"SELECT * FROM device d WHERE d.deleted = 0 - AND d.building_guid = @building_guid - AND d.main_system_guid IN @main_system_guids"; + AND d.device_building_tag = @building_tag + AND d.device_system_tag IN @main_system_tag"; var devices = await frontendRepository.GetAllAsync(sql_device, post); diff --git a/FrontendWebApi/Models/AlarmRecord.cs b/FrontendWebApi/Models/AlarmRecord.cs index b00e0f5..49dd2e1 100644 --- a/FrontendWebApi/Models/AlarmRecord.cs +++ b/FrontendWebApi/Models/AlarmRecord.cs @@ -8,23 +8,23 @@ namespace FrontendWebApi.Models { public class AlarmRecordPanelRawData { - public string building_guid { get; set; } + public string building_tag { get; set; } public string building_name { get; set; } - public string main_system_guid { get; set; } - public string main_system_name { get; set; } + public string system_key { get; set; } + public string system_value { get; set; } } public class AlarmRecordPanel { - public string building_guid { get; set; } + public string building_tag { get; set; } public string building_name { get; set; } public List mainSystemPanels { get; set; } } public class MainSystemPanel { - public string main_system_guid { get; set; } - public string main_system_name { get; set; } + public string system_key { get; set; } + public string system_value { get; set; } } public class AlarmRecord @@ -52,8 +52,8 @@ namespace FrontendWebApi.Models { public string StartTimestamp { get; set; } public string EndTimestamp { get; set; } - public string Building_guid { get; set; } - public List Main_system_guids { get; set; } + public string Building_tag { get; set; } + public List Main_system_tag { get; set; } public byte IsSolve { get;set;} public byte IsAck { get;set;} }