Compare commits

...

1 Commits
main ... guga1

2 changed files with 428 additions and 3341 deletions

View File

@ -1,17 +1,15 @@
SELECT SELECT
Active.id AS ID, Active.id AS ID,
Active.eventtime AS `StartTimestamp`, Active.eventtime AS StartTimestamp,
Clear.eventtime AS `EndTimestamp`, Clear.eventtime AS EndTimestamp,
CONCAT( CONCAT(
LPAD(FLOOR(duration_seconds / 3600), 2, '0'), ':', LPAD(FLOOR(Active.duration_seconds / 3600), 2, '0'), ':',
LPAD(FLOOR((duration_seconds % 3600) / 60), 2, '0'), ':', LPAD(FLOOR((Active.duration_seconds % 3600) / 60), 2, '0'), ':',
LPAD(duration_seconds % 60, 2, '0') LPAD(Active.duration_seconds % 60, 2, '0')
) AS Duration, ) AS Duration,
CONCAT(
SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(Active.source, '/HMI/ALARMST', 1), ':/tag:', -1), '/', -1), CONCAT(Active.displaypath, ' - ', SUBSTRING_INDEX(Active.source, ':/alm:', -1)) AS Description,
' - ',
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'
@ -20,8 +18,15 @@ SELECT
WHEN 4 THEN 'Critical' WHEN 4 THEN 'Critical'
ELSE 'Unknown' ELSE 'Unknown'
END AS Priority, END AS Priority,
SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(Active.source, '/HMI/ALARMST', 1), ':/tag:', -1), '/', -1) AS Tag,
SUBSTRING_INDEX(SUBSTRING_INDEX(Active.source, '/tag:', -1), '/', 1) AS MCM CONCAT(
Active.displaypath,
'.HMI.',
SUBSTRING_INDEX(aed.strValue, '/', -1)
) AS Tag,
Active.displaypath AS MCM
FROM ( FROM (
SELECT SELECT
ae.id, ae.id,
@ -29,12 +34,18 @@ FROM (
ae.eventid, ae.eventid,
ae.source, ae.source,
ae.priority, ae.priority,
ae.displaypath,
TIMESTAMPDIFF(SECOND, ae.eventtime, COALESCE(ae_clear.eventtime, NOW())) AS duration_seconds TIMESTAMPDIFF(SECOND, ae.eventtime, COALESCE(ae_clear.eventtime, NOW())) AS duration_seconds
FROM alarm_events ae FROM alarm_events ae
LEFT JOIN alarm_events ae_clear LEFT JOIN alarm_events ae_clear
ON ae.eventid = ae_clear.eventid AND ae_clear.eventtype = 1 ON ae.eventid = ae_clear.eventid AND ae_clear.eventtype = 1
WHERE ae.eventtype = 0 WHERE ae.eventtype = 0
) AS Active ) AS Active
LEFT JOIN alarm_events Clear LEFT JOIN alarm_events Clear
ON Active.eventid = Clear.eventid AND Clear.eventtype = 1 ON Active.eventid = Clear.eventid AND Clear.eventtype = 1
LEFT JOIN alarm_event_data aed
ON aed.id = Active.id AND aed.propname = 'myTag'
ORDER BY Active.eventtime DESC; ORDER BY Active.eventtime DESC;