Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sterlite_custom_reports
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
suryakant
sterlite_custom_reports
Commits
848762b9
Commit
848762b9
authored
Oct 30, 2023
by
mohammed.akhib
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UPDATED CCPP QUERIES and CCPC
parent
cf93420f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
249 additions
and
85 deletions
+249
-85
scripts/core/db/postgres/custom_report_query.py
scripts/core/db/postgres/custom_report_query.py
+222
-81
scripts/template/ccpc_report_template.py
scripts/template/ccpc_report_template.py
+23
-0
scripts/template/ccpp_report_template.py
scripts/template/ccpp_report_template.py
+4
-4
No files found.
scripts/core/db/postgres/custom_report_query.py
View file @
848762b9
...
@@ -4191,6 +4191,44 @@ class SterliteCCPCQuery:
...
@@ -4191,6 +4191,44 @@ class SterliteCCPCQuery:
CCPC report queries
CCPC report queries
"""
"""
class
Lpg
:
QUERY_1
=
"""
select tbl2.kpi as particulars, tbl2.unit, sum(lpg_consumption)/sum(production) as on_date from
(select 'Production' as kpi, 'MT' as unit, a.date, (sum(anode_wt)*sum(total_anode))/1000 as production from
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpc_production_plan
where lower(trim(production_anode))='anode weighment') a
inner join
(select date(date) as date, total_anode_accepted_a+total_anode_accepted_b+total_anode_accepted_c as total_anode
from semantic_prod.ccpc_actual_production_data) b
on a.date=b.date
group by 1,2,3
) tbl1
inner join
(select 'LPG' as kpi, 'KG/MT' as unit, date(date) as date, lpg_consumption
from semantic_prod.ccpc_actual_production_2) tbl2
on tbl1.date=tbl2.date
where tbl1.date BETWEEN '{day_start_date}' AND '{day_end_date}'
group by 1,2
;"""
QUERY_2
=
"""
select tbl2.kpi as particulars, tbl2.unit, sum(lpg_consumption)/sum(production) as mtd from
(select 'Production' as kpi, 'MT' as unit, a.date, (sum(anode_wt)*sum(total_anode))/1000 as production from
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpc_production_plan
where lower(trim(production_anode))='anode weighment') a
inner join
(select date(date) as date, total_anode_accepted_a+total_anode_accepted_b+total_anode_accepted_c as total_anode
from semantic_prod.ccpc_actual_production_data) b
on a.date=b.date
group by 1,2,3
) tbl1
inner join
(select 'LPG' as kpi, 'KG/MT' as unit, date(date) as date, lpg_consumption
from semantic_prod.ccpc_actual_production_2) tbl2
on tbl1.date=tbl2.date
where tbl1.date BETWEEN '{month_start_date}' AND '{month_end_date}'
group by 1,2
;"""
class
Production
:
class
Production
:
QUERY_1
=
"""
QUERY_1
=
"""
select
select
...
@@ -4393,6 +4431,42 @@ class SterliteCCPCQuery:
...
@@ -4393,6 +4431,42 @@ class SterliteCCPCQuery:
group by 1,2;
group by 1,2;
"""
"""
class
Power1
:
QUERY_1
=
"""
select tbl2.kpi as particulars, tbl2.unit, sum(power_consumption1)/sum(production) as on_date from
(select 'Production' as kpi, 'MT' as unit, a.date, (sum(anode_wt)*sum(total_anode))/1000 as production from
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpc_production_plan
where lower(trim(production_anode))='anode weighment') a
inner join
(select date(date) as date, total_anode_accepted_a+total_anode_accepted_b+total_anode_accepted_c as total_anode
from semantic_prod.ccpc_actual_production_data) b
on a.date=b.date
group by 1,2,3
) tbl1
inner join
(select 'power' as kpi, 'KWH/MT' as unit, date(date) as date, power_consumption1
from semantic_prod.ccpc_actual_production_2) tbl2
on tbl1.date=tbl2.date
where tbl1.date BETWEEN '{day_start_date}' AND '{day_end_date}'
group by 1,2"""
QUERY_2
=
"""
select tbl2.kpi as particulars, tbl2.unit, sum(power_consumption1)/sum(production) as mtd from
(select 'Production' as kpi, 'MT' as unit, a.date, (sum(anode_wt)*sum(total_anode))/1000 as production from
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpc_production_plan
where lower(trim(production_anode))='anode weighment') a
inner join
(select date(date) as date, total_anode_accepted_a+total_anode_accepted_b+total_anode_accepted_c as total_anode
from semantic_prod.ccpc_actual_production_data) b
on a.date=b.date
group by 1,2,3
) tbl1
inner join
(select 'power' as kpi, 'KWH/MT' as unit, date(date) as date, power_consumption1
from semantic_prod.ccpc_actual_production_2) tbl2
on tbl1.date=tbl2.date
where tbl1.date BETWEEN '{month_start_date}' AND '{month_end_date}'
group by 1,2"""
class
BLISTER
:
class
BLISTER
:
""" PARTICULARS """
""" PARTICULARS """
QUERY_1
=
""" SELECT
QUERY_1
=
""" SELECT
...
@@ -5514,7 +5588,6 @@ class SterliteCCPCQuery:
...
@@ -5514,7 +5588,6 @@ class SterliteCCPCQuery:
WHERE
WHERE
LOWER(shift) = 'shift c'
LOWER(shift) = 'shift c'
) foo WHERE DATE BETWEEN '{month_start_date}' AND '{month_end_date}'
) foo WHERE DATE BETWEEN '{month_start_date}' AND '{month_end_date}'
GROUP BY
GROUP BY
1;"""
1;"""
...
@@ -5598,84 +5671,152 @@ class SterliteCCPCQuery:
...
@@ -5598,84 +5671,152 @@ class SterliteCCPCQuery:
1;"""
1;"""
class
ANODEREJECTION
:
class
ANODEREJECTION
:
QUERY_1
=
"""SELECT
QUERY_1
=
"""
kpi as particulars,
select tbl2.kpi as particulars, tbl2.unit, (sum(rejection)/sum(production))*100 as on_date from
ROUND(SUM(CAST(metric_value AS NUMERIC)), 2) AS ondate,
(select 'Production' as kpi, 'MT' as unit, a.date, (sum(anode_wt)*sum(total_anode))/1000 as production from
'MT' as unit
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpc_production_plan
FROM
where lower(trim(production_anode))='anode weighment') a
inner join
(select date(date) as date, total_anode_accepted_a+total_anode_accepted_b+total_anode_accepted_c as total_anode
from semantic_prod.ccpc_actual_production_data) b
on a.date=b.date
group by 1,2,3
) tbl1
left join
(
(
SELECT
SELECT kpi, '
%
' as unit, date, SUM(CAST(metric_value AS NUMERIC)) AS rejection
date,
FROM (
'Anode rejection' AS kpi,
SELECT date(date) as date, 'Anode rejection' AS kpi, shift, COALESCE(internal_reject_a, '0') AS metric_value
shift,
FROM semantic_prod.charging_details_ccpc_new
COALESCE(acp_reject_a, '0') AS metric_value
WHERE LOWER(shift) = 'shift a'
FROM
semantic_prod.charging_details_ccpc_new
WHERE
LOWER(shift) = 'shift a'
UNION ALL
UNION ALL
SELECT
SELECT date(date) as date, 'Anode rejection' AS kpi, shift, COALESCE(internal_reject_b, '0') AS metric_value
date,
FROM semantic_prod.charging_details_ccpc_new
'Anode rejection' AS kpi,
WHERE LOWER(shift) = 'shift b'
shift,
COALESCE(acp_reject_b, '0') AS metric_value
FROM
semantic_prod.charging_details_ccpc_new
WHERE
LOWER(shift) = 'shift b'
UNION ALL
UNION ALL
SELECT
SELECT date(date) as date, 'Anode rejection' AS kpi, shift, COALESCE(internal_reject_c, '0') AS metric_value
date,
FROM semantic_prod.charging_details_ccpc_new
'Anode rejection' AS kpi,
WHERE LOWER(shift) = 'shift c'
shift,
) foo group by 1,2,3) tbl2
COALESCE(acp_reject_c, '0') AS metric_value
on tbl1.date=tbl2.date
FROM
where tbl1.date BETWEEN '{day_start_date}' AND '{day_end_date}'
semantic_prod.charging_details_ccpc_new
GROUP BY 1,2;"""
WHERE
QUERY_2
=
"""
LOWER(shift) = 'shift c'
select tbl2.kpi as particulars, tbl2.unit, (sum(rejection)/sum(production))*100 as mtd from
) foo WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
(select 'Production' as kpi, 'MT' as unit, a.date, (sum(anode_wt)*sum(total_anode))/1000 as production from
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpc_production_plan
GROUP BY
where lower(trim(production_anode))='anode weighment') a
1;"""
inner join
QUERY_2
=
"""SELECT
(select date(date) as date, total_anode_accepted_a+total_anode_accepted_b+total_anode_accepted_c as total_anode
kpi as particulars,
from semantic_prod.ccpc_actual_production_data) b
ROUND(SUM(CAST(metric_value AS NUMERIC)), 2) AS mtd,
on a.date=b.date
'MT' as unit
group by 1,2,3
FROM
) tbl1
left join
(
(
SELECT
SELECT kpi, '
%
' as unit, date, SUM(CAST(metric_value AS NUMERIC)) AS rejection
date,
FROM (
'Anode rejection' AS kpi,
SELECT date(date) as date, 'Anode rejection' AS kpi, shift, COALESCE(internal_reject_a, '0') AS metric_value
shift,
FROM semantic_prod.charging_details_ccpc_new
COALESCE(acp_reject_a, '0') AS metric_value
WHERE LOWER(shift) = 'shift a'
FROM
semantic_prod.charging_details_ccpc_new
WHERE
LOWER(shift) = 'shift a'
UNION ALL
UNION ALL
SELECT
SELECT date(date) as date, 'Anode rejection' AS kpi, shift, COALESCE(internal_reject_b, '0') AS metric_value
date,
FROM semantic_prod.charging_details_ccpc_new
'Anode rejection' AS kpi,
WHERE LOWER(shift) = 'shift b'
shift,
COALESCE(acp_reject_b, '0') AS metric_value
FROM
semantic_prod.charging_details_ccpc_new
WHERE
LOWER(shift) = 'shift b'
UNION ALL
UNION ALL
SELECT
SELECT date(date) as date, 'Anode rejection' AS kpi, shift, COALESCE(internal_reject_c, '0') AS metric_value
date,
FROM semantic_prod.charging_details_ccpc_new
'Anode rejection' AS kpi,
WHERE LOWER(shift) = 'shift c'
shift,
) foo group by 1,2,3) tbl2
COALESCE(acp_reject_c, '0') AS metric_value
on tbl1.date=tbl2.date
FROM
where tbl1.date BETWEEN '{month_start_date}' AND '{month_end_date}'
semantic_prod.charging_details_ccpc_new
GROUP BY 1,2; """
WHERE
LOWER(shift) = 'shift c'
) foo WHERE DATE BETWEEN '{month_start_date}' AND '{month_end_date}'
GROUP BY
class
AnodeInCCPCYard
:
1;"""
QUERY_1
=
"""
select
'Anodes in CCPC Yard' as particulars,
'MT' as unit,
sum(bookedanode_a) as on_date
from
semantic_prod.ccpc_daily_data_prod_3
where
date(date) BETWEEN '{day_start_date}' AND '{day_end_date}'
group by
1,
2;
"""
QUERY_2
=
"""
select
'Anodes in CCPC Yard' as particulars,
'MT' as unit,
sum(bookedanode_a) as mtd
from
semantic_prod.ccpc_daily_data_prod_3
where
date(date) BETWEEN '{month_start_date}' AND '{month_end_date}'
group by
1,
2;
"""
class
Day02
:
QUERY_1
=
"""
select
'Day O2' as particulars,
'ppm' as unit,
sum(refinary_labdata_oxygen) as on_date
from
semantic_prod.anode_refinery_lab
where
lower(trim(refinary_labdata_plant)) = 'ccpc'
and date(date) BETWEEN '{day_start_date}' AND '{day_end_date}'
group by
1,
2;"""
QUERY_2
=
"""
select
'Day O2' as particulars,
'ppm' as unit,
sum(refinary_labdata_oxygen) as mtd
from
semantic_prod.anode_refinery_lab
where
lower(trim(refinary_labdata_plant)) = 'ccpc'
and date(date) BETWEEN '{month_start_date}' AND '{month_end_date}'
group by
1,
2;"""
class
DayAs
:
QUERY_1
=
"""
select
'Day As' as particulars,
'ppm' as unit,
sum(refinary_labdata_arsenic) as on_date
from
semantic_prod.anode_refinery_lab
where
lower(trim(refinary_labdata_plant)) = 'ccpc'
and date(date) BETWEEN '{day_start_date}' AND '{day_end_date}'
group by
1,
2;
"""
QUERY_2
=
"""
select
'Day As' as particulars,
'ppm' as unit,
sum(refinary_labdata_arsenic) as mtd
from
semantic_prod.anode_refinery_lab
where
lower(trim(refinary_labdata_plant)) = 'ccpc'
and date(date) BETWEEN '{month_start_date}' AND '{month_end_date}'
group by
1,
2;
"""
class
TotalBreakdownDetails
:
class
TotalBreakdownDetails
:
""" TOTAL BREAKDOWN DETAILS """
""" TOTAL BREAKDOWN DETAILS """
...
@@ -6178,7 +6319,7 @@ class SterliteCCPPQuery:
...
@@ -6178,7 +6319,7 @@ class SterliteCCPPQuery:
(select 'LPG' as kpi, 'KG/MT' as unit, date(date) as date, lpg_consumption_total
(select 'LPG' as kpi, 'KG/MT' as unit, date(date) as date, lpg_consumption_total
from semantic_prod.ccpp_actual_production_2) tbl2
from semantic_prod.ccpp_actual_production_2) tbl2
on tbl1.date=tbl2.date
on tbl1.date=tbl2.date
where
a
.date between '{day_start_date}' AND '{day_end_date}'
where
tbl1.date
.date between '{day_start_date}' AND '{day_end_date}'
group by 1,2;
group by 1,2;
"""
"""
QUERY_2
=
"""
QUERY_2
=
"""
...
@@ -6196,7 +6337,7 @@ class SterliteCCPPQuery:
...
@@ -6196,7 +6337,7 @@ class SterliteCCPPQuery:
(select 'LPG' as kpi, 'KG/MT' as unit, date(date) as date, lpg_consumption_total
(select 'LPG' as kpi, 'KG/MT' as unit, date(date) as date, lpg_consumption_total
from semantic_prod.ccpp_actual_production_2) tbl2
from semantic_prod.ccpp_actual_production_2) tbl2
on tbl1.date=tbl2.date
on tbl1.date=tbl2.date
where
a
.date between '{month_start_date}' AND '{month_end_date}'
where
tbl1.date
.date between '{month_start_date}' AND '{month_end_date}'
group by 1,2;
group by 1,2;
"""
"""
...
@@ -6282,7 +6423,7 @@ class SterliteCCPPQuery:
...
@@ -6282,7 +6423,7 @@ class SterliteCCPPQuery:
(select 'power' as parameters, 'KWH/MT' as unit, date(date) as date, power_consumption_total
(select 'power' as parameters, 'KWH/MT' as unit, date(date) as date, power_consumption_total
from semantic_prod.ccpp_actual_production_2) tbl2
from semantic_prod.ccpp_actual_production_2) tbl2
on tbl1.date=tbl2.date
on tbl1.date=tbl2.date
WHERE
a
.date BETWEEN '{day_start_date}' AND '{day_end_date}'
WHERE
tbl1.date
.date BETWEEN '{day_start_date}' AND '{day_end_date}'
group by 1,2;
group by 1,2;
"""
"""
...
@@ -6301,7 +6442,7 @@ class SterliteCCPPQuery:
...
@@ -6301,7 +6442,7 @@ class SterliteCCPPQuery:
(select 'power' as parameters, 'KWH/MT' as unit, date(date) as date, power_consumption_total
(select 'power' as parameters, 'KWH/MT' as unit, date(date) as date, power_consumption_total
from semantic_prod.ccpp_actual_production_2) tbl2
from semantic_prod.ccpp_actual_production_2) tbl2
on tbl1.date=tbl2.date
on tbl1.date=tbl2.date
WHERE
a
.date BETWEEN '{month_start_date}' AND '{month_end_date}'
WHERE
tbl1.date
.date BETWEEN '{month_start_date}' AND '{month_end_date}'
group by 1,2;
group by 1,2;
"""
"""
...
...
scripts/template/ccpc_report_template.py
View file @
848762b9
...
@@ -25,10 +25,15 @@ class CCPCReportTemplate:
...
@@ -25,10 +25,15 @@ class CCPCReportTemplate:
"MTD"
,
"MTD"
,
],
],
"query"
:
{
"query"
:
{
"Production"
:[
"Production"
:[
SterliteCCPCQuery
.
Production
.
QUERY_1
,
SterliteCCPCQuery
.
Production
.
QUERY_1
,
SterliteCCPCQuery
.
Production
.
QUERY_2
SterliteCCPCQuery
.
Production
.
QUERY_2
],
],
"Lpg"
:
[
SterliteCCPCQuery
.
Lpg
.
QUERY_1
,
SterliteCCPCQuery
.
Lpg
.
QUERY_2
],
"BariumSulphateP"
:[
"BariumSulphateP"
:[
SterliteCCPCQuery
.
BariumSulphateP
.
QUERY_1
,
SterliteCCPCQuery
.
BariumSulphateP
.
QUERY_1
,
SterliteCCPCQuery
.
BariumSulphateP
.
QUERY_2
SterliteCCPCQuery
.
BariumSulphateP
.
QUERY_2
...
@@ -37,6 +42,10 @@ class CCPCReportTemplate:
...
@@ -37,6 +42,10 @@ class CCPCReportTemplate:
SterliteCCPCQuery
.
Sodiumsilicate
.
QUERY_1
,
SterliteCCPCQuery
.
Sodiumsilicate
.
QUERY_1
,
SterliteCCPCQuery
.
Sodiumsilicate
.
QUERY_2
SterliteCCPCQuery
.
Sodiumsilicate
.
QUERY_2
],
],
"Power"
:[
SterliteCCPCQuery
.
Power1
.
QUERY_1
,
SterliteCCPCQuery
.
Power1
.
QUERY_2
],
"BLISTER"
:
[
"BLISTER"
:
[
SterliteCCPCQuery
.
BLISTER
.
QUERY_1
,
SterliteCCPCQuery
.
BLISTER
.
QUERY_1
,
SterliteCCPCQuery
.
BLISTER
.
QUERY_2
,
SterliteCCPCQuery
.
BLISTER
.
QUERY_2
,
...
@@ -109,6 +118,18 @@ class CCPCReportTemplate:
...
@@ -109,6 +118,18 @@ class CCPCReportTemplate:
SterliteCCPCQuery
.
ANODEREJECTION
.
QUERY_1
,
SterliteCCPCQuery
.
ANODEREJECTION
.
QUERY_1
,
SterliteCCPCQuery
.
ANODEREJECTION
.
QUERY_2
,
SterliteCCPCQuery
.
ANODEREJECTION
.
QUERY_2
,
],
],
"AnodeInCCPCYard"
:[
SterliteCCPCQuery
.
AnodeInCCPCYard
.
QUERY_1
,
SterliteCCPCQuery
.
AnodeInCCPCYard
.
QUERY_2
],
"Day02"
:[
SterliteCCPCQuery
.
Day02
.
QUERY_1
,
SterliteCCPCQuery
.
Day02
.
QUERY_2
],
"DayAs"
:[
SterliteCCPCQuery
.
DayAs
.
QUERY_1
,
SterliteCCPCQuery
.
DayAs
.
QUERY_2
]
},
},
"data"
:
[],
"data"
:
[],
"data_column"
:
[
"particulars"
,
"unit"
,
"on_date"
,
"mtd"
,
"data_column"
:
[
"particulars"
,
"unit"
,
"on_date"
,
"mtd"
,
...
@@ -408,6 +429,8 @@ class CCPCReportTemplate:
...
@@ -408,6 +429,8 @@ class CCPCReportTemplate:
"REASON FOR STOPAGE"
"REASON FOR STOPAGE"
],
],
"query"
:
{
"query"
:
{
"ActivityTime"
:[
SterliteCCPCQuery
.
ActivityTime
.
QUERY_1
]
},
},
"data"
:
[],
"data"
:
[],
"data_column"
:
[
"data_column"
:
[
...
...
scripts/template/ccpp_report_template.py
View file @
848762b9
...
@@ -32,8 +32,8 @@ class CCPPReportTemplate:
...
@@ -32,8 +32,8 @@ class CCPPReportTemplate:
SterliteCCPPQuery
.
Production
.
QUERY_2
SterliteCCPPQuery
.
Production
.
QUERY_2
],
],
"Lpg"
:
[
"Lpg"
:
[
#
SterliteCCPPQuery.Lpg.QUERY_1,
SterliteCCPPQuery
.
Lpg
.
QUERY_1
,
#
SterliteCCPPQuery.Lpg.QUERY_2,
SterliteCCPPQuery
.
Lpg
.
QUERY_2
,
],
],
"BariumSulphate"
:
[
"BariumSulphate"
:
[
SterliteCCPPQuery
.
BariumSulphate
.
QUERY_1
,
SterliteCCPPQuery
.
BariumSulphate
.
QUERY_1
,
...
@@ -45,8 +45,8 @@ class CCPPReportTemplate:
...
@@ -45,8 +45,8 @@ class CCPPReportTemplate:
SterliteCCPPQuery
.
SodiumSilicate
.
QUERY_2
,
SterliteCCPPQuery
.
SodiumSilicate
.
QUERY_2
,
],
],
"Power"
:
[
"Power"
:
[
#
SterliteCCPPQuery.Power.QUERY_1,
SterliteCCPPQuery
.
Power
.
QUERY_1
,
#
SterliteCCPPQuery.Power.QUERY_2,
SterliteCCPPQuery
.
Power
.
QUERY_2
,
],
],
"KanshakiBlister"
:
[
"KanshakiBlister"
:
[
SterliteCCPPQuery
.
KanshakiBlister
.
QUERY_1
,
SterliteCCPPQuery
.
KanshakiBlister
.
QUERY_1
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment