[後端] 修改緊急應變api alarmRecord
This commit is contained in:
parent
aa61f21354
commit
9b639ae44d
@ -47,41 +47,41 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sqlBuildingMain = $@"SELECT
|
var sqlBuildingMain = $@"SELECT
|
||||||
b.building_guid,
|
b.building_tag,
|
||||||
b.full_name AS building_name,
|
b.full_name AS building_name,
|
||||||
ms.main_system_guid,
|
v1.system_value,
|
||||||
ms.full_name AS main_system_name
|
v1.system_key AS main_system_name
|
||||||
FROM building_menu bm
|
FROM building_menu bm
|
||||||
INNER JOIN (
|
INNER JOIN (
|
||||||
SELECT
|
SELECT
|
||||||
ap.building_guid, ap.ShowView
|
ap.building_tag, ap.ShowView
|
||||||
FROM role_auth ra
|
FROM role_auth ra
|
||||||
JOIN auth_page ap ON ra.AuthCode = ap.AuthCode
|
JOIN auth_page ap ON ra.AuthCode = ap.AuthCode
|
||||||
JOIN userinfo u ON u.role_guid = ra.role_guid WHERE u.account = @Account
|
JOIN userinfo u ON u.role_guid = ra.role_guid WHERE u.account = 'Bajascript'
|
||||||
AND ap.building_guid IS NOT NULL
|
AND ap.building_tag IS NOT NULL
|
||||||
) ap ON bm.building_guid = ap.building_guid AND bm.sub_system_guid = ap.ShowView
|
) ap ON bm.building_tag = ap.building_tag
|
||||||
LEFT JOIN building b ON bm.building_guid = b.building_guid
|
LEFT JOIN building b ON bm.building_tag = b.building_tag
|
||||||
LEFT JOIN main_system ms ON bm.main_system_guid = ms.main_system_guid
|
left join variable v2 on ap.ShowView = v2.id and v2.deleted = 0
|
||||||
GROUP BY bm.building_guid, bm.main_system_guid
|
left join variable v1 on v2.system_parent_id = v1.id
|
||||||
ORDER BY b.priority, ms.priority";
|
GROUP BY b.building_tag, b.full_name, v1.system_value, v1.system_key";
|
||||||
|
|
||||||
var alarmRecordPanelRawDatas = await frontendRepository.GetAllAsync<AlarmRecordPanelRawData>(sqlBuildingMain, new { Account = account });
|
var alarmRecordPanelRawDatas = await frontendRepository.GetAllAsync<AlarmRecordPanelRawData>(sqlBuildingMain, new { Account = account });
|
||||||
|
|
||||||
List<AlarmRecordPanel> alarmRecordPanels = new List<AlarmRecordPanel>();
|
List<AlarmRecordPanel> alarmRecordPanels = new List<AlarmRecordPanel>();
|
||||||
|
|
||||||
var alarmRecordPanelRawDatas_GroupBy = alarmRecordPanelRawDatas.GroupBy(x => x.building_guid);
|
var alarmRecordPanelRawDatas_GroupBy = alarmRecordPanelRawDatas.GroupBy(x => x.building_tag);
|
||||||
|
|
||||||
foreach (var building in alarmRecordPanelRawDatas_GroupBy)
|
foreach (var building in alarmRecordPanelRawDatas_GroupBy)
|
||||||
{
|
{
|
||||||
AlarmRecordPanel alarmRecordPanel = new AlarmRecordPanel();
|
AlarmRecordPanel alarmRecordPanel = new AlarmRecordPanel();
|
||||||
alarmRecordPanel.building_guid = building.Key;
|
alarmRecordPanel.building_tag = building.Key;
|
||||||
alarmRecordPanel.building_name = building.First().building_name;
|
alarmRecordPanel.building_name = building.First().building_name;
|
||||||
alarmRecordPanel.mainSystemPanels = new List<MainSystemPanel>();
|
alarmRecordPanel.mainSystemPanels = new List<MainSystemPanel>();
|
||||||
foreach (var tempData in building)
|
foreach (var tempData in building)
|
||||||
{
|
{
|
||||||
MainSystemPanel mainSystemPanel = new MainSystemPanel();
|
MainSystemPanel mainSystemPanel = new MainSystemPanel();
|
||||||
mainSystemPanel.main_system_guid = tempData.main_system_guid;
|
mainSystemPanel.system_value = tempData.system_value;
|
||||||
mainSystemPanel.main_system_name = tempData.main_system_name;
|
mainSystemPanel.system_key = tempData.system_key;
|
||||||
|
|
||||||
alarmRecordPanel.mainSystemPanels.Add(mainSystemPanel);
|
alarmRecordPanel.mainSystemPanels.Add(mainSystemPanel);
|
||||||
}
|
}
|
||||||
@ -115,31 +115,31 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sql = $@"SELECT
|
var sql = $@"SELECT
|
||||||
temp_path.source AS alarm_path,
|
temp_path.source AS alarm_path,
|
||||||
temp_msg.source_msg AS msgText,
|
temp_msg.source_msg AS msgText,
|
||||||
from_unixtime(record.timestamp/1000,'%Y-%m-%d %H:%i:%s') alarm_timestamp,
|
from_unixtime(record.timestamp/1000,'%Y-%m-%d %H:%i:%s') alarm_timestamp,
|
||||||
record.priority,
|
record.priority,
|
||||||
CASE WHEN record.normalTime > 0 THEN from_unixtime(record.normalTime/1000,'%Y-%m-%d %H:%i:%s')
|
CASE WHEN record.normalTime > 0 THEN from_unixtime(record.normalTime/1000,'%Y-%m-%d %H:%i:%s')
|
||||||
ELSE NULL
|
ELSE NULL
|
||||||
END AS normal_timestamp,
|
END AS normal_timestamp,
|
||||||
record.sourceState AS ackState,
|
record.sourceState AS ackState,
|
||||||
class.alarmclass AS alarm_className,
|
class.alarmclass AS alarm_className,
|
||||||
record.userAccount
|
record.userAccount
|
||||||
|
|
||||||
FROM alarmorion_orionalarmrecord record
|
FROM alarmOrion_OrionAlarmRecord record
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT sourceorder.* ,temp_source.source
|
SELECT sourceorder.* ,temp_source.source
|
||||||
FROM alarmorion_orionalarmsourceorder sourceorder
|
FROM alarmOrion_OrionAlarmSourceOrder sourceorder
|
||||||
JOIN alarmorion_orionalarmsource temp_source ON sourceorder.alarmSource = temp_source.id
|
JOIN alarmOrion_OrionAlarmSource temp_source ON sourceorder.alarmSource = temp_source.id
|
||||||
) temp_path ON record.id = temp_path.alarm
|
) temp_path ON record.id = temp_path.alarm
|
||||||
JOIN(
|
JOIN(
|
||||||
SELECT
|
SELECT
|
||||||
val.alarm,
|
val.alarm,
|
||||||
val.value AS source_msg
|
val.value AS source_msg
|
||||||
FROM alarmorion_orionalarmfacetvalue val
|
FROM alarmOrion_OrionAlarmFacetValue val
|
||||||
JOIN alarmorion_orionalarmfacetname nam ON val.facetName = nam.id AND nam.facetName = 'msgText'
|
JOIN alarmOrion_OrionAlarmFacetName nam ON val.facetName = nam.id AND nam.facetName = 'msgText'
|
||||||
) temp_msg ON record.id = temp_msg.alarm
|
) 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";
|
WHERE from_unixtime(record.timestamp/1000,'%Y-%m-%d %H:%i:%s') BETWEEN @StartTimestamp AND @EndTimeStamp";
|
||||||
|
|
||||||
if (post.IsSolve != 0)
|
if (post.IsSolve != 0)
|
||||||
@ -183,8 +183,8 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
var sql_device = $@"SELECT *
|
var sql_device = $@"SELECT *
|
||||||
FROM device d
|
FROM device d
|
||||||
WHERE d.deleted = 0
|
WHERE d.deleted = 0
|
||||||
AND d.building_guid = @building_guid
|
AND d.device_building_tag = @building_tag
|
||||||
AND d.main_system_guid IN @main_system_guids";
|
AND d.device_system_tag IN @main_system_tag";
|
||||||
|
|
||||||
var devices = await frontendRepository.GetAllAsync<Device>(sql_device, post);
|
var devices = await frontendRepository.GetAllAsync<Device>(sql_device, post);
|
||||||
|
|
||||||
|
@ -8,23 +8,23 @@ namespace FrontendWebApi.Models
|
|||||||
{
|
{
|
||||||
public class AlarmRecordPanelRawData
|
public class AlarmRecordPanelRawData
|
||||||
{
|
{
|
||||||
public string building_guid { get; set; }
|
public string building_tag { get; set; }
|
||||||
public string building_name { get; set; }
|
public string building_name { get; set; }
|
||||||
public string main_system_guid { get; set; }
|
public string system_key { get; set; }
|
||||||
public string main_system_name { get; set; }
|
public string system_value { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
public class AlarmRecordPanel
|
public class AlarmRecordPanel
|
||||||
{
|
{
|
||||||
public string building_guid { get; set; }
|
public string building_tag { get; set; }
|
||||||
public string building_name { get; set; }
|
public string building_name { get; set; }
|
||||||
public List<MainSystemPanel> mainSystemPanels { get; set; }
|
public List<MainSystemPanel> mainSystemPanels { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MainSystemPanel
|
public class MainSystemPanel
|
||||||
{
|
{
|
||||||
public string main_system_guid { get; set; }
|
public string system_key { get; set; }
|
||||||
public string main_system_name { get; set; }
|
public string system_value { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AlarmRecord
|
public class AlarmRecord
|
||||||
@ -52,8 +52,8 @@ namespace FrontendWebApi.Models
|
|||||||
{
|
{
|
||||||
public string StartTimestamp { get; set; }
|
public string StartTimestamp { get; set; }
|
||||||
public string EndTimestamp { get; set; }
|
public string EndTimestamp { get; set; }
|
||||||
public string Building_guid { get; set; }
|
public string Building_tag { get; set; }
|
||||||
public List<string> Main_system_guids { get; set; }
|
public List<string> Main_system_tag { get; set; }
|
||||||
public byte IsSolve { get;set;}
|
public byte IsSolve { get;set;}
|
||||||
public byte IsAck { get;set;}
|
public byte IsAck { get;set;}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user