From 0a111767c12a6684c817ecc2b8f2a69682a58c8b Mon Sep 17 00:00:00 2001 From: Gigi Mamaladze Date: Tue, 13 May 2025 13:57:46 +0400 Subject: [PATCH] Fix induct detailes sqls --- .../views/Windows/Statistics/view.json | 12 +++--- .../Statistics/Induct Details/query.sql | 10 +---- .../Statistics/Induct Details_graph/query.sql | 42 ++++++++----------- 3 files changed, 25 insertions(+), 39 deletions(-) diff --git a/MTN6_SCADA/com.inductiveautomation.perspective/views/Windows/Statistics/view.json b/MTN6_SCADA/com.inductiveautomation.perspective/views/Windows/Statistics/view.json index 00c81bc..da95654 100644 --- a/MTN6_SCADA/com.inductiveautomation.perspective/views/Windows/Statistics/view.json +++ b/MTN6_SCADA/com.inductiveautomation.perspective/views/Windows/Statistics/view.json @@ -32168,7 +32168,7 @@ }, "props": { "dismissOnSelect": false, - "formattedValue": "May 7, 2025 12:11 PM", + "formattedValue": "May 13, 2025 11:34 AM", "formattedValues": { "date": "Mar 26, 2021", "datetime": "Mar 26, 2021 12:00 AM", @@ -32178,9 +32178,9 @@ "$": [ "ts", 192, - 1746609088108 + 1747125250352 ], - "$ts": 1746605488000 + "$ts": 1747121650000 } }, "type": "ia.input.date-time-input" @@ -32328,7 +32328,7 @@ }, "props": { "dismissOnSelect": false, - "formattedValue": "May 7, 2025 1:11 PM", + "formattedValue": "May 13, 2025 12:34 PM", "formattedValues": { "date": "Mar 29, 2021", "datetime": "Mar 29, 2021 1:37 PM", @@ -32338,9 +32338,9 @@ "$": [ "ts", 192, - 1746609088104 + 1747125250351 ], - "$ts": 1746609088000 + "$ts": 1747125250000 } }, "type": "ia.input.date-time-input" diff --git a/MTN6_SCADA/ignition/named-query/Statistics/Induct Details/query.sql b/MTN6_SCADA/ignition/named-query/Statistics/Induct Details/query.sql index 5fd8616..4b0fb80 100644 --- a/MTN6_SCADA/ignition/named-query/Statistics/Induct Details/query.sql +++ b/MTN6_SCADA/ignition/named-query/Statistics/Induct Details/query.sql @@ -1,18 +1,12 @@ Select - SorterName,InductName,Total_count,singlecarrier_count,doublecarrier_count,Startstamp,Endtstamp, + SorterName,InductName,Total_count,Startstamp,Endtstamp, Total_count/Total_count as Total_perc, - singlecarrier_count/Total_count as SingleCarrier_perc, - doublecarrier_count/Total_count as DoubleCarrier_perc, - Total_count*3600/TIMESTAMPDIFF(second, Startstamp, Endtstamp) as Total_rate, - singlecarrier_count*3600/TIMESTAMPDIFF(second, Startstamp, Endtstamp) as SingleCarrier_rate, - doublecarrier_count*3600/TIMESTAMPDIFF(second, Startstamp, Endtstamp) as DoubleCarrier_rate + Total_count*3600/TIMESTAMPDIFF(second, Startstamp, Endtstamp) as Total_rate FROM (SELECT 'S03' as SorterName, 'Induct 1' as InductName, COUNT(*) AS Total_count, - SUM(alltable.ParcelHistory_TupelLength = 1) AS singlecarrier_count, - SUM(alltable.ParcelHistory_TupelLength = 2) AS doublecarrier_count, MIN(alltable.t_stamp) AS Startstamp, Max(alltable.t_stamp) AS Endtstamp diff --git a/MTN6_SCADA/ignition/named-query/Statistics/Induct Details_graph/query.sql b/MTN6_SCADA/ignition/named-query/Statistics/Induct Details_graph/query.sql index 63fa707..afe266b 100644 --- a/MTN6_SCADA/ignition/named-query/Statistics/Induct Details_graph/query.sql +++ b/MTN6_SCADA/ignition/named-query/Statistics/Induct Details_graph/query.sql @@ -1,25 +1,17 @@ - Select - roundtime, - Total_count,singlecarrier_count,doublecarrier_count, - Total_count/Total_count as Total_perc, - singlecarrier_count/Total_count as SingleCarrier_perc, - doublecarrier_count/Total_count as DoubleCarrier_perc, - Total_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as Total_rate, - singlecarrier_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as SingleCarrier_rate, - doublecarrier_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as DoubleCarrier_rate - - FROM - - (Select - COUNT(*) AS Total_count, - SUM(alltable.ParcelHistory_TupelLength = 1) AS singlecarrier_count, - SUM(alltable.ParcelHistory_TupelLength = 2) AS doublecarrier_count, - - FROM_UNIXTIME(CEIL(UNIX_TIMESTAMP(alltable.t_stamp) / 60) * 60) roundtime - - FROM alltable - Where (alltable.t_stamp BETWEEN :starttime AND :endtime) and ('Induct 1' = :Induct) - - Group BY FROM_UNIXTIME(CEIL(UNIX_TIMESTAMP(alltable.t_stamp) / 60) * 60) - /***Order By alltable.t_stamp ASC ***/ - ) okey \ No newline at end of file +SELECT + okey.roundtime, + okey.Total_count, + okey.Total_count / okey.Total_count AS Total_perc, + okey.Total_count * 3600 + / TIMESTAMPDIFF(SECOND, :starttime, :endtime) AS Total_rate +FROM ( + SELECT + FROM_UNIXTIME( + CEIL(UNIX_TIMESTAMP(alltable.t_stamp) / 60) * 60 + ) AS roundtime, + COUNT(*) AS Total_count + FROM alltable + WHERE (alltable.t_stamp BETWEEN :starttime AND :endtime) and ('Induct 1' = :Induct) + GROUP BY roundtime +) AS okey +ORDER BY okey.roundtime;