getting device and fulltag from the database in active alarms, but not showing in the table. using them to find the highlight the component
This commit is contained in:
parent
1b4dfeffe2
commit
729a1b6cda
@ -1,60 +1,62 @@
|
|||||||
WITH Active AS (
|
WITH Active AS (
|
||||||
SELECT
|
SELECT
|
||||||
ae.id,
|
ae.id,
|
||||||
ae.eventtime,
|
ae.eventtime,
|
||||||
ae.eventid,
|
ae.eventid,
|
||||||
ae.source,
|
ae.source,
|
||||||
ae.priority,
|
ae.priority,
|
||||||
ae.displaypath,
|
ae.displaypath,
|
||||||
TIMESTAMPDIFF(SECOND, ae.eventtime, NOW()) AS duration_seconds
|
TIMESTAMPDIFF(SECOND, ae.eventtime, NOW()) AS duration_seconds
|
||||||
FROM alarm_events ae
|
FROM alarm_events ae
|
||||||
WHERE ae.eventtype = 0
|
WHERE ae.eventtype = 0
|
||||||
AND NOT EXISTS (
|
AND NOT EXISTS (
|
||||||
SELECT 1 FROM alarm_events ae_clear
|
SELECT 1 FROM alarm_events ae_clear
|
||||||
WHERE ae_clear.eventid = ae.eventid
|
WHERE ae_clear.eventid = ae.eventid
|
||||||
AND ae_clear.eventtype = 1
|
AND ae_clear.eventtype = 1
|
||||||
)
|
)
|
||||||
AND ae.displaypath NOT LIKE '%System Startup%'
|
AND ae.displaypath NOT LIKE '%System Startup%'
|
||||||
AND ae.source NOT LIKE '%System Startup%'
|
AND ae.source NOT LIKE '%System Startup%'
|
||||||
-- Priority filter using FIND_IN_SET for comma-separated values
|
-- Priority filter using FIND_IN_SET for comma-separated values
|
||||||
AND (
|
AND (
|
||||||
:priorityList IS NULL
|
:priorityList IS NULL
|
||||||
OR :priorityList = ''
|
OR :priorityList = ''
|
||||||
OR FIND_IN_SET(ae.priority, :priorityList) > 0
|
OR FIND_IN_SET(ae.priority, :priorityList) > 0
|
||||||
)
|
)
|
||||||
GROUP BY ae.id
|
GROUP BY ae.id
|
||||||
),
|
),
|
||||||
SingleMyTag AS (
|
SingleMyTag AS (
|
||||||
SELECT aed.id, aed.strValue
|
SELECT aed.id, aed.strValue
|
||||||
FROM alarm_event_data aed
|
FROM alarm_event_data aed
|
||||||
WHERE aed.propname = 'myTag'
|
WHERE aed.propname = 'myTag'
|
||||||
GROUP BY aed.id
|
GROUP BY aed.id
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
Active.id AS ID,
|
Active.id AS ID,
|
||||||
Active.eventtime AS StartTimestamp,
|
Active.eventtime AS StartTimestamp,
|
||||||
NULL AS EndTimestamp, -- no end time since it's still active
|
NULL AS EndTimestamp, -- no end time since it's still active
|
||||||
CONCAT(
|
CONCAT(
|
||||||
LPAD(FLOOR(Active.duration_seconds / 3600), 2, '0'), ':',
|
LPAD(FLOOR(Active.duration_seconds / 3600), 2, '0'), ':',
|
||||||
LPAD(FLOOR((Active.duration_seconds % 3600) / 60), 2, '0'), ':',
|
LPAD(FLOOR((Active.duration_seconds % 3600) / 60), 2, '0'), ':',
|
||||||
LPAD(Active.duration_seconds % 60, 2, '0')
|
LPAD(Active.duration_seconds % 60, 2, '0')
|
||||||
) AS Duration,
|
) AS Duration,
|
||||||
CONCAT(Active.displaypath, ' - ', SUBSTRING_INDEX(Active.source, ':/alm:', -1)) AS Description,
|
CONCAT(Active.displaypath, ' - ', SUBSTRING_INDEX(Active.source, ':/alm:', -1)) AS Description,
|
||||||
CASE Active.priority
|
CASE Active.priority
|
||||||
WHEN 0 THEN 'Diagnostic'
|
WHEN 0 THEN 'Diagnostic'
|
||||||
WHEN 1 THEN 'Low'
|
WHEN 1 THEN 'Low'
|
||||||
WHEN 2 THEN 'Medium'
|
WHEN 2 THEN 'Medium'
|
||||||
WHEN 3 THEN 'High'
|
WHEN 3 THEN 'High'
|
||||||
WHEN 4 THEN 'Critical'
|
WHEN 4 THEN 'Critical'
|
||||||
ELSE 'Unknown'
|
ELSE 'Unknown'
|
||||||
END AS Priority,
|
END AS Priority,
|
||||||
CONCAT(
|
CONCAT(
|
||||||
Active.displaypath,
|
Active.displaypath,
|
||||||
'.HMI.',
|
'.HMI.',
|
||||||
SUBSTRING_INDEX(aed.strValue, '/', -1)
|
SUBSTRING_INDEX(aed.strValue, '/', -1)
|
||||||
) AS Tag,
|
) AS Tag,
|
||||||
SUBSTRING_INDEX(SUBSTRING_INDEX(aed.strValue, '/', 2), '/', -1) AS Location
|
SUBSTRING_INDEX(SUBSTRING_INDEX(aed.strValue, '/', 2), '/', -1) AS Location
,
|
||||||
FROM Active
|
aed.strValue AS FullTag,
|
||||||
LEFT JOIN SingleMyTag aed
|
Active.displaypath as Device
|
||||||
ON aed.id = Active.id
|
FROM Active
|
||||||
|
LEFT JOIN SingleMyTag aed
|
||||||
|
ON aed.id = Active.id
|
||||||
ORDER BY Active.eventtime DESC;
|
ORDER BY Active.eventtime DESC;
|
||||||
Loading…
x
Reference in New Issue
Block a user