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
cf93420f
Commit
cf93420f
authored
Oct 27, 2023
by
mohammed.akhib
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UPDATED CCPP QUERIES and CCPC
parent
e6c166f7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1108 additions
and
706 deletions
+1108
-706
scripts/core/db/postgres/custom_report_query.py
scripts/core/db/postgres/custom_report_query.py
+665
-333
scripts/core/handler/event_handler.py
scripts/core/handler/event_handler.py
+5
-4
scripts/template/ccpc_report_template.py
scripts/template/ccpc_report_template.py
+24
-2
scripts/template/ccpp_report_template.py
scripts/template/ccpp_report_template.py
+414
-367
No files found.
scripts/core/db/postgres/custom_report_query.py
View file @
cf93420f
...
@@ -4191,6 +4191,208 @@ class SterliteCCPCQuery:
...
@@ -4191,6 +4191,208 @@ class SterliteCCPCQuery:
CCPC report queries
CCPC report queries
"""
"""
class
Production
:
QUERY_1
=
"""
select
'Production' as particulars,
'MT' as unit,
(sum(anode_wt) * sum(total_anode)) / 1000 as on_date
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
where
a.date BETWEEN '{day_start_date}' AND '{day_end_date}';
"""
QUERY_2
=
"""
select
'Production' as particulars,
'MT' as unit,
(sum(anode_wt) * sum(total_anode)) / 1000 as mtd
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
WHERE a.date BETWEEN '{month_start_date}' AND '{month_end_date}'
GROUP BY
1;
"""
class
BariumSulphate
:
QUERY_1
=
""" SELECT
kpi as particulars,
'MT' as unit,
ROUND(SUM(CAST(metric_value AS NUMERIC)),2) AS on_date
FROM
(
SELECT
date,
'Blister' AS kpi,
shift,
COALESCE(blister_a, '0') AS metric_value
FROM
semantic_prod.charging_details_ccpc_new
WHERE
LOWER(shift) = 'shift a'
UNION ALL
SELECT
date,
'Blister' AS kpi,
shift,
COALESCE(blister_b, '0') AS metric_value
FROM
semantic_prod.charging_details_ccpc_new
WHERE
LOWER(shift) = 'shift b'
UNION ALL
SELECT
date,
'Blister' AS kpi,
shift,
COALESCE(blister_c, '0') AS metric_value
FROM
semantic_prod.charging_details_ccpc_new
WHERE
LOWER(shift) = 'shift c'
) foo
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
GROUP BY
1;
"""
QUERY_2
=
"""
SELECT
kpi as particulars,
'MT' as unit,
ROUND(SUM(CAST(metric_value AS NUMERIC)),2) AS mtd
FROM
(
SELECT
date,
'Blister' AS kpi,
shift,
COALESCE(blister_a, '0') AS metric_value
FROM
semantic_prod.charging_details_ccpc_new
WHERE
LOWER(shift) = 'shift a'
UNION ALL
SELECT
date,
'Blister' AS kpi,
shift,
COALESCE(blister_b, '0') AS metric_value
FROM
semantic_prod.charging_details_ccpc_new
WHERE
LOWER(shift) = 'shift b'
UNION ALL
SELECT
date,
'Blister' AS kpi,
shift,
COALESCE(blister_c, '0') AS metric_value
FROM
semantic_prod.charging_details_ccpc_new
WHERE
LOWER(shift) = 'shift c'
) foo
WHERE DATE BETWEEN '{month_start_date}' AND '{month_end_date}'
GROUP BY
1;
"""
class
Sodiumsilicate
:
QUERY_1
=
"""
select tbl2.kpi as particulars, tbl2.unit, sum(sodium_silicate)/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
left join
(SELECT kpi, 'KG/MT' as unit, date(date) as date, SUM(CAST(metric_value AS NUMERIC)) AS sodium_silicate
FROM (
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_a, '0') AS metric_value
FROM semantic_prod.ccpc_actual_production_data
WHERE LOWER(shift) = 'shift a' and sodium_silicate_a != ''
UNION ALL
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_b, '0') AS metric_value
FROM semantic_prod.ccpc_actual_production_data
WHERE LOWER(shift) = 'shift b' and sodium_silicate_b != ''
UNION ALL
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_c, '0') AS metric_value
FROM semantic_prod.ccpc_actual_production_data
WHERE LOWER(shift) = 'shift c' and sodium_silicate_c != ''
) foo GROUP BY 1,2,3
) 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(sodium_silicate)/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
left join
(SELECT kpi, 'KG/MT' as unit, date(date) as date, SUM(CAST(metric_value AS NUMERIC)) AS sodium_silicate
FROM (
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_a, '0') AS metric_value
FROM semantic_prod.ccpc_actual_production_data
WHERE LOWER(shift) = 'shift a' and sodium_silicate_a != ''
UNION ALL
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_b, '0') AS metric_value
FROM semantic_prod.ccpc_actual_production_data
WHERE LOWER(shift) = 'shift b' and sodium_silicate_b != ''
UNION ALL
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_c, '0') AS metric_value
FROM semantic_prod.ccpc_actual_production_data
WHERE LOWER(shift) = 'shift c' and sodium_silicate_c != ''
) foo GROUP BY 1,2,3
) 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
...
@@ -5353,7 +5555,6 @@ class SterliteCCPCQuery:
...
@@ -5353,7 +5555,6 @@ class SterliteCCPCQuery:
WHERE
WHERE
LOWER(shift) = 'shift c'
LOWER(shift) = 'shift c'
) foo WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
) foo WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
GROUP BY
GROUP BY
1;"""
1;"""
QUERY_2
=
"""SELECT
QUERY_2
=
"""SELECT
...
@@ -5526,6 +5727,64 @@ class SterliteCCPCQuery:
...
@@ -5526,6 +5727,64 @@ class SterliteCCPCQuery:
semantic_prod.ccpc_shift_manpower;
semantic_prod.ccpc_shift_manpower;
"""
"""
class
MonthWiseData
:
QUERY_1
=
"""
select TO_CHAR(TO_DATE(month::text, 'MM'),'Mon') as nos, max(target) as target, max(production) as production from
(select month,
case when lower(kpi)='production plan' then sum(value) else 0 end as target,
case when lower(kpi)='production actual' then sum(value) else 0 end as production
from semantic_prod.acp_ccpc_ccpp_view
where lower(kpi) in('production actual','production plan')
and lower(category) = 'ccpc' and DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
group by 1,kpi) foo group by 1;"""
class
ProductionDetails1
:
QUERY1
=
"""
select kpi, max(Shift_A) as a_shift, max(Shift_B) as b_shift, max(Shift_C) as ac_shift,
max(Shift_A) + max(Shift_B) + max(Shift_C) as total,
max(Prdn_A) as a_shift_prdn, max(Prdn_B) as b_shift_prdn, max(Prdn_C) as c_shift_prdn,
max(Prdn_A) + max(Prdn_B) + max(Prdn_C) as od_prodn
from (
select 'No of Anode' as kpi, date(tbl1.date) as date,
case when lower(shift)='shift a' then sum(total_anode_accepted_a) else 0 end as shift_A,
case when lower(shift)='shift b' then sum(total_anode_accepted_b) else 0 end as shift_B,
case when lower(shift)='shift c' then sum(total_anode_accepted_c) else 0 end as shift_C,
case when lower(shift)='shift a' then (sum(total_anode_accepted_a)*sum(anode_wt))/1000 else 0 end as Prdn_A,
case when lower(shift)='shift b' then (sum(total_anode_accepted_b)*sum(anode_wt))/1000 else 0 end as Prdn_B,
case when lower(shift)='shift c' then (sum(total_anode_accepted_c)*sum(anode_wt))/1000 else 0 end as Prdn_C
from
(select * from semantic_prod.ccpc_actual_production_data) tbl1
left join
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpc_production_plan
where lower(trim(production_anode))='anode weighment') tbl2
on date(tbl1.date)=date(tbl2.date)
group by 1,2,shift) foo where DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
group by 1"""
class
ProductionDetails2
:
QUERY_1
=
"""
select kpi, max(Shift_A) as a_shift, max(Shift_B) as b_shift, max(Shift_C) as c_shift,
max(Shift_A) + max(Shift_B) + max(Shift_C) as total,
max(Prdn_A) as a_shift_prdn, max(Prdn_B) as b_shift_prdn, max(Prdn_C) as c_shift_prdn,
max(Prdn_A) + max(Prdn_B) + max(Prdn_C) as od_prodn
from (
select 'Revert generation in Shift' as kpi, date(tbl1.date) as date,
case when lower(shift)='shift a' then sum(total_anode_rejected_a) else 0 end as shift_A,
case when lower(shift)='shift b' then sum(total_anode_rejected_b) else 0 end as shift_B,
case when lower(shift)='shift c' then sum(total_anode_rejected_c) else 0 end as shift_C,
case when lower(shift)='shift a' then (sum(total_anode_rejected_a)*sum(anode_wt))/1000 else 0 end as Prdn_A,
case when lower(shift)='shift b' then (sum(total_anode_rejected_b)*sum(anode_wt))/1000 else 0 end as Prdn_B,
case when lower(shift)='shift c' then (sum(total_anode_rejected_c)*sum(anode_wt))/1000 else 0 end as Prdn_C
from
(select * from semantic_prod.ccpc_actual_production_data) tbl1
left join
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpc_production_plan
where lower(trim(production_anode))='anode weighment') tbl2
on date(tbl1.date)=date(tbl2.date)
group by 1,2,shift) foo where DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
group by 1;
"""
class
ChargingDetails
:
class
ChargingDetails
:
QUERY_1
=
"""
QUERY_1
=
"""
select
select
...
@@ -5561,93 +5820,68 @@ class SterliteCCPCQuery:
...
@@ -5561,93 +5820,68 @@ class SterliteCCPCQuery:
total DESC;
total DESC;
"""
"""
class
BariumSulphate
:
class
BariumSulphateP
:
QUERY_1
=
"""SELECT
QUERY_1
=
"""
kpi AS consumption_items,
select tbl2.kpi as particulars, tbl2.unit, sum(barium_sulphate)/sum(production) as on_date from
'KG/MT' as unit,
(select 'Production' as kpi, 'MT' as unit, a.date, (sum(anode_wt)*sum(total_anode))/1000 as production from
ROUND(SUM(CAST(metric_value AS NUMERIC)), 2) AS on_date
(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
(select date(date) as date, total_anode_accepted_a+total_anode_accepted_b+total_anode_accepted_c as total_anode
date,
from semantic_prod.ccpc_actual_production_data) b
'BARIUM SULPHATE' AS kpi,
on a.date=b.date
shift,
group by 1,2,3
COALESCE(barium_sulphate_a, '0') AS metric_value
) tbl1
FROM
left join
semantic_prod.ccpc_actual_production_data
(SELECT kpi, 'KG/MT' as unit, date(date) as date, SUM(CAST(metric_value AS NUMERIC)) AS barium_sulphate
WHERE
FROM (
LOWER(shift) = 'shift a'
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_a, '0') AS metric_value
and barium_sulphate_a != ''
FROM semantic_prod.ccpc_actual_production_data
UNION ALL
WHERE LOWER(shift) = 'shift a' and barium_sulphate_a != ''
SELECT
UNION ALL
date,
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_b, '0') AS metric_value
'BARIUM SULPHATE' AS kpi,
FROM semantic_prod.ccpc_actual_production_data
shift,
WHERE LOWER(shift) = 'shift b' and barium_sulphate_b != ''
COALESCE(barium_sulphate_b, '0') AS metric_value
UNION ALL
FROM
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_c, '0') AS metric_value
semantic_prod.ccpc_actual_production_data
FROM semantic_prod.ccpc_actual_production_data
WHERE
WHERE LOWER(shift) = 'shift c' and barium_sulphate_c != ''
LOWER(shift) = 'shift b'
)foo GROUP BY 1,2,3
and barium_sulphate_b != ''
) tbl2
UNION ALL
on tbl1.date=tbl2.date
SELECT
where tbl1.date BETWEEN '{day_start_date}' AND '{day_end_date}'
date,
group by 1,2;
'BARIUM SULPHATE' AS kpi,
shift,
COALESCE(barium_sulphate_c, '0') AS metric_value
FROM
semantic_prod.ccpc_actual_production_data
WHERE
LOWER(shift) = 'shift c'
and barium_sulphate_c != ''
) foo
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
GROUP BY
1;
"""
"""
QUERY_2
=
"""SELECT
QUERY_2
=
"""
kpi AS consumption_items,
select tbl2.kpi as particulars, tbl2.unit, sum(barium_sulphate)/sum(production) as mtd from
'KG/MT' as unit,
(select 'Production' as kpi, 'MT' as unit, a.date, (sum(anode_wt)*sum(total_anode))/1000 as production from
ROUND(SUM(CAST(metric_value AS NUMERIC)), 2) AS mtd
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpc_production_plan
where lower(trim(production_anode))='anode weighment') a
FROM
inner join
(
(select date(date) as date, total_anode_accepted_a+total_anode_accepted_b+total_anode_accepted_c as total_anode
SELECT
from semantic_prod.ccpc_actual_production_data) b
date,
on a.date=b.date
'BARIUM SULPHATE' AS kpi,
group by 1,2,3
shift,
) tbl1
COALESCE(barium_sulphate_a, '0') AS metric_value
left join
FROM
(SELECT kpi, 'KG/MT' as unit, date(date) as date, SUM(CAST(metric_value AS NUMERIC)) AS barium_sulphate
semantic_prod.ccpc_actual_production_data
FROM (
WHERE
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_a, '0') AS metric_value
LOWER(shift) = 'shift a'
FROM semantic_prod.ccpc_actual_production_data
and barium_sulphate_a != ''
WHERE LOWER(shift) = 'shift a' and barium_sulphate_a != ''
UNION ALL
UNION ALL
SELECT
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_b, '0') AS metric_value
date,
FROM semantic_prod.ccpc_actual_production_data
'BARIUM SULPHATE' AS kpi,
WHERE LOWER(shift) = 'shift b' and barium_sulphate_b != ''
shift,
UNION ALL
COALESCE(barium_sulphate_b, '0') AS metric_value
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_c, '0') AS metric_value
FROM
FROM semantic_prod.ccpc_actual_production_data
semantic_prod.ccpc_actual_production_data
WHERE LOWER(shift) = 'shift c' and barium_sulphate_c != ''
WHERE
)foo GROUP BY 1,2,3
LOWER(shift) = 'shift b'
) tbl2
and barium_sulphate_b != ''
on tbl1.date=tbl2.date
UNION ALL
where tbl1.date BETWEEN '{month_start_date}' AND '{month_end_date}'
SELECT
group by 1,2;
date,
'BARIUM SULPHATE' AS kpi,
shift,
COALESCE(barium_sulphate_c, '0') AS metric_value
FROM
semantic_prod.ccpc_actual_production_data
WHERE
LOWER(shift) = 'shift c'
and barium_sulphate_c != ''
) foo
WHERE DATE BETWEEN '{month_start_date}' AND '{month_end_date}'
GROUP BY
1;
"""
"""
class
SodiumSulphate
:
class
SodiumSulphate
:
...
@@ -5930,7 +6164,7 @@ class SterliteCCPPQuery:
...
@@ -5930,7 +6164,7 @@ class SterliteCCPPQuery:
class
Lpg
:
class
Lpg
:
QUERY_1
=
"""
QUERY_1
=
"""
select tbl2.kpi
, tbl2.unit, sum(lpg_consumption_total/production) as metric_valu
e from
select tbl2.kpi
as particulars, tbl2.unit, sum(lpg_consumption_total/production) as on_dat
e from
(select 'Production' as kpi, 'MT' as unit, a.date, (sum(anode_wt)*sum(total_anode))/1000 as production 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.ccpp_production_plan
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpp_production_plan
where lower(trim(production_anode))='anode weighment') a
where lower(trim(production_anode))='anode weighment') a
...
@@ -5944,11 +6178,11 @@ class SterliteCCPPQuery:
...
@@ -5944,11 +6178,11 @@ 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 a.date between '{day_start_date}' AND '{day_end_date}'
group by 1,2;
group by 1,2;
"""
"""
QUERY_2
=
"""
QUERY_2
=
"""
select tbl2.kpi
, tbl2.unit, sum(lpg_consumption_total/production) as metric_value
from
select tbl2.kpi
as particulars, tbl2.unit, sum(lpg_consumption_total/production) as mtd
from
(select 'Production' as kpi, 'MT' as unit, a.date, (sum(anode_wt)*sum(total_anode))/1000 as production 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.ccpp_production_plan
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpp_production_plan
where lower(trim(production_anode))='anode weighment') a
where lower(trim(production_anode))='anode weighment') a
...
@@ -5962,118 +6196,114 @@ class SterliteCCPPQuery:
...
@@ -5962,118 +6196,114 @@ 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 a.date between '{month_start_date}' AND '{month_end_date}'
group by 1,2;
group by 1,2;
"""
"""
class
SodiumSilicate
:
class
SodiumSilicate
:
QUERY_1
=
"""
QUERY_1
=
"""
SELECT
select tbl2.parameters as particulars, tbl2.unit, sum(sodium_silicate)/sum(production) as on_date from
kpi as particulars,
(select 'Production' as kpi, 'MT' as unit, a.date, (sum(anode_wt)*sum(total_anode))/1000 as production from
'KG/MT' as unit,
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpp_production_plan
SUM(CAST(metric_value AS NUMERIC)) AS on_date
where lower(trim(production_anode))='anode weighment') a
FROM
inner join
(
(select date(date) as date, total_anode_accepted_a+total_anode_accepted_b+total_anode_accepted_c as total_anode
SELECT
from semantic_prod.ccpp_actual_production_new) b
date,
on a.date=b.date
'SODIUM SILICATE' AS kpi,
group by 1,2,3
shift,
) tbl1
COALESCE(sodium_silicate_a, '0') AS metric_value
left join
FROM
(SELECT kpi as parameters, 'KG/MT' as unit, date(date) as date, SUM(CAST(metric_value AS NUMERIC)) AS sodium_silicate
semantic_prod.actual_production_data_shiftwise_ccpp
FROM (
WHERE
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_a, '0') AS metric_value
LOWER(shift) = 'shift a'
FROM semantic_prod.ccpp_actual_production_new
and sodium_silicate_a != ''
WHERE LOWER(shift) = 'shift a' and sodium_silicate_a != ''
UNION ALL
UNION ALL
SELECT
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_b, '0') AS metric_value
date,
FROM semantic_prod.ccpp_actual_production_new
'SODIUM SILICATE' AS kpi,
WHERE LOWER(shift) = 'shift b' and sodium_silicate_b != ''
shift,
UNION ALL
COALESCE(sodium_silicate_b, '0') AS metric_value
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_c, '0') AS metric_value
FROM
FROM semantic_prod.ccpp_actual_production_new
semantic_prod.actual_production_data_shiftwise_ccpp
WHERE LOWER(shift) = 'shift c' and sodium_silicate_c != ''
WHERE
) foo GROUP BY 1,2,3
LOWER(shift) = 'shift b'
) tbl2
and sodium_silicate_b != ''
on tbl1.date=tbl2.date
UNION ALL
where tbl1.date between '{day_start_date}' AND '{day_end_date}'
SELECT
group by 1,2;
date,
'SODIUM SILICATE' AS kpi,
shift,
COALESCE(sodium_silicate_c, '0') AS metric_value
FROM
semantic_prod.actual_production_data_shiftwise_ccpp
WHERE
LOWER(shift) = 'shift c'
and sodium_silicate_c != ''
) foo WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
GROUP BY
1;
"""
"""
QUERY_2
=
"""
QUERY_2
=
"""
SELECT
select tbl2.parameters as particulars, tbl2.unit, sum(sodium_silicate)/sum(production) as mtd from
kpi as particulars,
(select 'Production' as kpi, 'MT' as unit, a.date, (sum(anode_wt)*sum(total_anode))/1000 as production from
'KG/MT' as unit,
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpp_production_plan
SUM(CAST(metric_value AS NUMERIC)) AS mtd
where lower(trim(production_anode))='anode weighment') a
inner join
FROM
(select date(date) as date, total_anode_accepted_a+total_anode_accepted_b+total_anode_accepted_c as total_anode
(
from semantic_prod.ccpp_actual_production_new) b
SELECT
on a.date=b.date
date,
group by 1,2,3
'SODIUM SILICATE' AS kpi,
) tbl1
shift,
left join
COALESCE(sodium_silicate_a, '0') AS metric_value
(SELECT kpi as parameters, 'KG/MT' as unit, date(date) as date, SUM(CAST(metric_value AS NUMERIC)) AS sodium_silicate
FROM
FROM (
semantic_prod.actual_production_data_shiftwise_ccpp
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_a, '0') AS metric_value
WHERE
FROM semantic_prod.ccpp_actual_production_new
LOWER(shift) = 'shift a'
WHERE LOWER(shift) = 'shift a' and sodium_silicate_a != ''
and sodium_silicate_a != ''
UNION ALL
UNION ALL
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_b, '0') AS metric_value
SELECT
FROM semantic_prod.ccpp_actual_production_new
date,
WHERE LOWER(shift) = 'shift b' and sodium_silicate_b != ''
'SODIUM SILICATE' AS kpi,
UNION ALL
shift,
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_c, '0') AS metric_value
COALESCE(sodium_silicate_b, '0') AS metric_value
FROM semantic_prod.ccpp_actual_production_new
FROM
WHERE LOWER(shift) = 'shift c' and sodium_silicate_c != ''
semantic_prod.actual_production_data_shiftwise_ccpp
) foo GROUP BY 1,2,3
WHERE
) tbl2
LOWER(shift) = 'shift b'
on tbl1.date=tbl2.date
and sodium_silicate_b != ''
where tbl1.date between '{month_start_date}' AND '{month_end_date}'
UNION ALL
group by 1,2;
SELECT
date,
'SODIUM SILICATE' AS kpi,
shift,
COALESCE(sodium_silicate_c, '0') AS metric_value
FROM
semantic_prod.actual_production_data_shiftwise_ccpp
WHERE
LOWER(shift) = 'shift c'
and sodium_silicate_c != ''
) foo
WHERE DATE BETWEEN '{month_start_date}' AND '{month_end_date}'
GROUP BY
1;
"""
"""
class
Power
:
class
Power
:
QUERY_1
=
"""
QUERY_1
=
"""
select
select tbl2.particulars , tbl2.unit, sum(power_consumption_total)/sum(production) as on_date from
'power' as particulars,
(select 'Production' as particulars, 'MT' as unit, a.date, (sum(anode_wt)*sum(total_anode))/1000 as production from
'KWH/MT' as unit,
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpp_production_plan
power_consumption_total as on_date
where lower(trim(production_anode))='anode weighment') a
from
inner join
semantic_prod.ccpp_actual_production_2
(select date(date) as date, total_anode_accepted_a+total_anode_accepted_b+total_anode_accepted_c as total_anode
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}';
from semantic_prod.ccpp_actual_production_new) b
on a.date=b.date
group by 1,2,3
) tbl1
inner join
(select 'power' as parameters, 'KWH/MT' as unit, date(date) as date, power_consumption_total
from semantic_prod.ccpp_actual_production_2) tbl2
on tbl1.date=tbl2.date
WHERE a.date BETWEEN '{day_start_date}' AND '{day_end_date}'
group by 1,2;
"""
"""
QUERY_2
=
"""
QUERY_2
=
"""
select
select tbl2.particulars, tbl2.unit, sum(power_consumption_total)/sum(production) as mtd from
'power' as particulars,
(select 'Production' as particulars, 'MT' as unit, a.date, (sum(anode_wt)*sum(total_anode))/1000 as production from
'KWH/MT' as unit,
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpp_production_plan
power_consumption_total as mtd
where lower(trim(production_anode))='anode weighment') a
from
inner join
semantic_prod.ccpp_actual_production_2
(select date(date) as date, total_anode_accepted_a+total_anode_accepted_b+total_anode_accepted_c as total_anode
WHERE DATE BETWEEN '{month_start_date}' AND '{month_end_date}';
from semantic_prod.ccpp_actual_production_new) b
on a.date=b.date
group by 1,2,3
) tbl1
inner join
(select 'power' as parameters, 'KWH/MT' as unit, date(date) as date, power_consumption_total
from semantic_prod.ccpp_actual_production_2) tbl2
on tbl1.date=tbl2.date
WHERE a.date BETWEEN '{month_start_date}' AND '{month_end_date}'
group by 1,2;
"""
"""
class
KanshakiBlister
:
class
KanshakiBlister
:
...
@@ -6593,8 +6823,8 @@ class SterliteCCPPQuery:
...
@@ -6593,8 +6823,8 @@ class SterliteCCPPQuery:
class
TotalBreakdownDetails
:
class
TotalBreakdownDetails
:
QUERY_1
=
"""
QUERY_1
=
"""
select
select
type_of_breakdown as
kpi
,
type_of_breakdown as
total_breakdown
,
sum(breakdown_duration_hours * 60) as
breakdown_duration_mins
sum(breakdown_duration_hours * 60) as
"on_date"
from
from
semantic_prod.ccpp_downtime_kpi_view
semantic_prod.ccpp_downtime_kpi_view
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
...
@@ -6605,8 +6835,8 @@ class SterliteCCPPQuery:
...
@@ -6605,8 +6835,8 @@ class SterliteCCPPQuery:
class
TotalBreakdownDetails1
:
class
TotalBreakdownDetails1
:
QUERY_1
=
"""
QUERY_1
=
"""
select
select
'Total(Mins)' as
kpi
,
'Total(Mins)' as
total_breakdown
,
sum(breakdown_duration_hours * 60) as
breakdown_duration_mins
sum(breakdown_duration_hours * 60) as
"on_date"
from
from
semantic_prod.ccpp_downtime_kpi_view
semantic_prod.ccpp_downtime_kpi_view
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
...
@@ -6617,10 +6847,10 @@ class SterliteCCPPQuery:
...
@@ -6617,10 +6847,10 @@ class SterliteCCPPQuery:
class
ChargingDetails
:
class
ChargingDetails
:
QUERY_1
=
"""
QUERY_1
=
"""
select
select
kpi,
kpi
as charging_detail
,
shift_a,
shift_a
as a_shift
,
shift_b,
shift_b
as b_shift
,
shift_c,
shift_c
as c_shift
,
total
total
from
from
semantic_prod.ccpp_custom_rprt_charging_details
semantic_prod.ccpp_custom_rprt_charging_details
...
@@ -6630,7 +6860,7 @@ class SterliteCCPPQuery:
...
@@ -6630,7 +6860,7 @@ class SterliteCCPPQuery:
class
MonthwiseProductionDetails
:
class
MonthwiseProductionDetails
:
QUERY_1
=
"""
QUERY_1
=
"""
select TO_CHAR(TO_DATE(month::text, 'MM'),'Mon') as
month
, max(target) as target, max(production) as production from
select TO_CHAR(TO_DATE(month::text, 'MM'),'Mon') as
nos
, max(target) as target, max(production) as production from
(select month,
(select month,
case when lower(kpi)='production plan' then sum(value) else 0 end as target,
case when lower(kpi)='production plan' then sum(value) else 0 end as target,
case when lower(kpi)='production actual' then sum(value) else 0 end as production
case when lower(kpi)='production actual' then sum(value) else 0 end as production
...
@@ -6644,9 +6874,9 @@ class SterliteCCPPQuery:
...
@@ -6644,9 +6874,9 @@ class SterliteCCPPQuery:
class
Paticulars
:
class
Paticulars
:
QUERY_1
=
"""
QUERY_1
=
"""
select
select
select_ccpp as
kpi
,
select_ccpp as
particulars
,
uom_ccpp as uom,
uom_ccpp as uom,
avg(value_ccpp) as
metric_value
avg(value_ccpp) as
ftd
from
from
semantic_prod.ccpp_ctp_new
semantic_prod.ccpp_ctp_new
where
where
...
@@ -6661,89 +6891,108 @@ class SterliteCCPPQuery:
...
@@ -6661,89 +6891,108 @@ class SterliteCCPPQuery:
class
LugThickness
:
class
LugThickness
:
QUERY_1
=
"""
QUERY_1
=
"""
select
select
select_ccpp as
kpi
,
select_ccpp as
particulars
,
uom_ccpp as uom,
uom_ccpp as uom,
avg(value_ccpp) as
metric_value
avg(value_ccpp) as
ftd
from
from
semantic_prod.ccpp_ctq_new
semantic_prod.ccpp_ctq_new
where
where
lower(select_ccpp) in (
lower(select_ccpp) in (
'anode dimension- body thickness ',
'anode dimension- body thickness ',
'anode dimension- lug thickness '
'anode dimension- lug thickness '
)
) and
DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
group by
group by
1,
1,
2;
2;
"""
"""
class
ElectricalVapor
:
class
Tbc
:
QUERY_1
=
"""
QUERY_1
=
"""
select kpi, shift, water_temp,water_level, water_valve_condition, status from(
SELECT kpi, shift, value, CAST(date AS TIME) AS time
select date, electrical_a as kpi,shift, coalesce(water_temp_a,'0') as water_temp, coalesce(water_level_a,'0') as water_level,
FROM (
coalesce(water_valve_condition_a,'0') as water_valve_condition,status_a as status from
SELECT date, lpg_param AS kpi, shift, COALESCE(lpg_value, '0') AS value
semantic_prod.ccpp_electrical_vapouriser where lower(shift) = 'shift a'
FROM semantic_prod.ccpp_lpg_vapouriser
union all
WHERE LOWER(shift) = 'shift a'
select date, electrical_b as kpi,shift, coalesce(water_temp_b,'0') as water_temp, coalesce(water_level_b,'0') as water_level,
coalesce(water_valve_condition_b,'0') as water_valve_condition,status_b as status from
UNION ALL
semantic_prod.ccpp_electrical_vapouriser where lower(shift) = 'shift b'
union all
SELECT date, lpg_param2 AS kpi, shift, COALESCE(lpg_value2, '0') AS value
select date, electrical_c as kpi,shift, coalesce(water_temp_c,'0') as water_temp, coalesce(water_level_c,'0') as water_level,
FROM semantic_prod.ccpp_lpg_vapouriser
coalesce(water_valve_condition_c,'0') as water_valve_condition,status_c as status from
WHERE LOWER(shift) = 'shift b'
semantic_prod.ccpp_electrical_vapouriser where lower(shift) = 'shift c')foo
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
UNION ALL
"""
SELECT date, lpg_param3 AS kpi, shift, COALESCE(lpg_value3, '0') AS value
FROM semantic_prod.ccpp_lpg_vapouriser
WHERE LOWER(shift) = 'shift c'
) foo
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
"""
QUERY_2
=
"""
select kpi, shift, water_temp,water_level, water_valve_condition, status from(
select date, electrical_a as kpi,shift, coalesce(water_temp_a,'0') as water_temp, coalesce(water_level_a,'0') as water_level,
coalesce(water_valve_condition_a,'0') as water_valve_condition,status_a as status from
semantic_prod.ccpp_electrical_vapouriser where lower(shift) = 'shift a'
union all
select date, electrical_b as kpi,shift, coalesce(water_temp_b,'0') as water_temp, coalesce(water_level_b,'0') as water_level,
coalesce(water_valve_condition_b,'0') as water_valve_condition,status_b as status from
semantic_prod.ccpp_electrical_vapouriser where lower(shift) = 'shift b'
union all
select date, electrical_c as kpi,shift, coalesce(water_temp_c,'0') as water_temp, coalesce(water_level_c,'0') as water_level,
coalesce(water_valve_condition_c,'0') as water_valve_condition,status_c as status from
semantic_prod.ccpp_electrical_vapouriser where lower(shift) = 'shift c')foo
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
"""
class
PersonOnDuty
:
class
PersonOnDuty
:
QUERY_1
=
"""
QUERY_1
=
"""
select
select
persons_on_duty,
persons_on_duty,
a_shift,
a_shift,
b_shift,
b_shift,
c_shift
c_shift
from
from
semantic_prod.ccpp_shift_manpower
semantic_prod.ccpp_shift_manpower
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
"""
"""
class
ConsumptionItem1
:
class
ConsumptionItem1
:
QUERY_1
=
"""
QUERY_1
=
"""
SELECT kpi, SUM(CAST(metric_value AS NUMERIC)) AS metric_value, 'KG/MT' as unit
SELECT kpi as consumption_item, 'KG/MT' as unit, SUM(CAST(metric_value AS NUMERIC)) AS on_date
FROM (
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_a, '0') AS metric_value
FROM semantic_prod.actual_production_data_shiftwise_ccpp
WHERE LOWER(shift) = 'shift a' and barium_sulphate_a != ''
UNION ALL
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_b, '0') AS metric_value
FROM semantic_prod.actual_production_data_shiftwise_ccpp
WHERE LOWER(shift) = 'shift b' and barium_sulphate_b != ''
UNION ALL
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_c, '0') AS metric_value
FROM semantic_prod.actual_production_data_shiftwise_ccpp
WHERE LOWER(shift) = 'shift c' and barium_sulphate_c != ''
) foo WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
GROUP BY 1 ;
"""
QUERY_2
=
"""
SELECT kpi, SUM(CAST(metric_value AS NUMERIC)) AS metric_value, 'KG/MT' as unit
FROM (
FROM (
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_a, '0') AS metric_value
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_a, '0') AS metric_value
FROM semantic_prod.
actual_production_data_shiftwise_ccpp
FROM semantic_prod.
ccpp_actual_production_new
WHERE LOWER(shift) = 'shift a' and barium_sulphate_a != ''
WHERE LOWER(shift) = 'shift a' and barium_sulphate_a != ''
UNION ALL
UNION ALL
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_b, '0') AS metric_value
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_b, '0') AS metric_value
FROM semantic_prod.
actual_production_data_shiftwise_ccpp
FROM semantic_prod.
ccpp_actual_production_new
WHERE LOWER(shift) = 'shift b' and barium_sulphate_b != ''
WHERE LOWER(shift) = 'shift b' and barium_sulphate_b != ''
UNION ALL
UNION ALL
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_c, '0') AS metric_value
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_c, '0') AS metric_value
FROM semantic_prod.actual_production_data_shiftwise_ccpp
FROM semantic_prod.ccpp_actual_production_new
WHERE LOWER(shift) = 'shift c' and barium_sulphate_c != ''
) foo WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
GROUP BY 1 ;
"""
QUERY_2
=
"""
SELECT kpi as consumption_item, 'KG/MT' as unit, SUM(CAST(metric_value AS NUMERIC)) AS mtd
FROM (
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_a, '0') AS metric_value
FROM semantic_prod.ccpp_actual_production_new
WHERE LOWER(shift) = 'shift a' and barium_sulphate_a != ''
UNION ALL
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_b, '0') AS metric_value
FROM semantic_prod.ccpp_actual_production_new
WHERE LOWER(shift) = 'shift b' and barium_sulphate_b != ''
UNION ALL
SELECT date, 'BARIUM SULPHATE' AS kpi, shift, COALESCE(barium_sulphate_c, '0') AS metric_value
FROM semantic_prod.ccpp_actual_production_new
WHERE LOWER(shift) = 'shift c' and barium_sulphate_c != ''
WHERE LOWER(shift) = 'shift c' and barium_sulphate_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 1 ;
GROUP BY 1 ;
...
@@ -6751,45 +7000,37 @@ class SterliteCCPPQuery:
...
@@ -6751,45 +7000,37 @@ class SterliteCCPPQuery:
class
ConsumptionItem2
:
class
ConsumptionItem2
:
QUERY_1
=
"""
QUERY_1
=
"""
SELECT kpi, SUM(CAST(metric_value AS NUMERIC)) AS metric_value, 'KG/MT' as unit
SELECT kpi as consumption_item, 'KG/MT' as unit, SUM(CAST(metric_value AS NUMERIC)) AS on_date
FROM (
FROM (
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_a, '0') AS metric_value
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_a, '0') AS metric_value
FROM semantic_prod.actual_production_data_shiftwise_ccpp
FROM semantic_prod.ccpp_actual_production_new
WHERE LOWER(shift) = 'shift a' and sodium_silicate_a != ''
WHERE LOWER(shift) = 'shift a' and sodium_silicate_a != ''
UNION ALL
UNION ALL
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_b, '0') AS metric_value
FROM semantic_prod.ccpp_actual_production_new
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_b, '0') AS metric_value
WHERE LOWER(shift) = 'shift b' and sodium_silicate_b != ''
FROM semantic_prod.actual_production_data_shiftwise_ccpp
UNION ALL
WHERE LOWER(shift) = 'shift b' and sodium_silicate_b != ''
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_c, '0') AS metric_value
FROM semantic_prod.ccpp_actual_production_new
UNION ALL
WHERE LOWER(shift) = 'shift c' and sodium_silicate_c != ''
) foo
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_c, '0') AS metric_value
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
FROM semantic_prod.actual_production_data_shiftwise_ccpp
GROUP BY 1 ;
WHERE LOWER(shift) = 'shift c' and sodium_silicate_c != ''
"""
) foo
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
GROUP BY 1 ;
"""
QUERY_2
=
"""
QUERY_2
=
"""
SELECT kpi
, SUM(CAST(metric_value AS NUMERIC)) AS metric_value, 'KG/MT' as unit
SELECT kpi
as consumption_item, 'KG/MT' as unit, SUM(CAST(metric_value AS NUMERIC)) AS mtd
FROM (
FROM (
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_a, '0') AS metric_value
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_a, '0') AS metric_value
FROM semantic_prod.actual_production_data_shiftwise_ccpp
FROM semantic_prod.ccpp_actual_production_new
WHERE LOWER(shift) = 'shift a' and sodium_silicate_a != ''
WHERE LOWER(shift) = 'shift a' and sodium_silicate_a != ''
UNION ALL
UNION ALL
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_b, '0') AS metric_value
FROM semantic_prod.ccpp_actual_production_new
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_b, '0') AS metric_value
WHERE LOWER(shift) = 'shift b' and sodium_silicate_b != ''
FROM semantic_prod.actual_production_data_shiftwise_ccpp
UNION ALL
WHERE LOWER(shift) = 'shift b' and sodium_silicate_b != ''
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_c, '0') AS metric_value
FROM semantic_prod.ccpp_actual_production_new
UNION ALL
WHERE LOWER(shift) = 'shift c' and sodium_silicate_c != ''
SELECT date, 'SODIUM SILICATE' AS kpi, shift, COALESCE(sodium_silicate_c, '0') AS metric_value
FROM semantic_prod.actual_production_data_shiftwise_ccpp
WHERE LOWER(shift) = 'shift c' and sodium_silicate_c != ''
) foo
) foo
WHERE DATE BETWEEN '{month_start_date}' AND '{month_end_date}'
WHERE DATE BETWEEN '{month_start_date}' AND '{month_end_date}'
GROUP BY 1 ;
GROUP BY 1 ;
...
@@ -6797,51 +7038,28 @@ class SterliteCCPPQuery:
...
@@ -6797,51 +7038,28 @@ class SterliteCCPPQuery:
class
ConsumptionItem3
:
class
ConsumptionItem3
:
QUERY_1
=
"""
QUERY_1
=
"""
select
select
'power' as kpi
,
'power' as consumption_item
,
'KWH/MT' as unit,
'KWH/MT' as unit,
power_consumption_total as metric_valu
e
power_consumption_total as on_dat
e
from
from
semantic_prod.ccpp_actual_production_2
semantic_prod.ccpp_actual_production_2
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
"""
"""
QUERY_2
=
"""
QUERY_2
=
"""
select
select
'power' as
kpi
,
'power' as
consumption_item
,
'KWH/MT' as unit,
'KWH/MT' as unit,
power_consumption_total as m
etric_value
power_consumption_total as m
td
from
from
semantic_prod.ccpp_actual_production_2
semantic_prod.ccpp_actual_production_2
WHERE DATE BETWEEN '{month_start_date}' AND '{month_end_date}'
WHERE DATE BETWEEN '{month_start_date}' AND '{month_end_date}'
"""
"""
class
Tbc
:
QUERY_1
=
"""
SELECT kpi, shift, value, CAST(date AS TIME) AS time
FROM (
SELECT date, lpg_param AS kpi, shift, COALESCE(lpg_value, '0') AS value
FROM semantic_prod.ccpp_lpg_vapouriser
WHERE LOWER(shift) = 'shift a'
UNION ALL
SELECT date, lpg_param2 AS kpi, shift, COALESCE(lpg_value2, '0') AS value
FROM semantic_prod.ccpp_lpg_vapouriser
WHERE LOWER(shift) = 'shift b'
UNION ALL
SELECT date, lpg_param3 AS kpi, shift, COALESCE(lpg_value3, '0') AS value
FROM semantic_prod.ccpp_lpg_vapouriser
WHERE LOWER(shift) = 'shift c'
) foo
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
"""
class
Production
:
class
Production
:
QUERY_1
=
"""
QUERY_1
=
"""
select
select
'Production' as par
amete
rs,
'Production' as par
ticula
rs,
'MT' as unit,
'MT' as unit,
(sum(anode_wt) * sum(total_anode)) / 1000 as on_date
(sum(anode_wt) * sum(total_anode)) / 1000 as on_date
from
from
...
@@ -6866,7 +7084,7 @@ class SterliteCCPPQuery:
...
@@ -6866,7 +7084,7 @@ class SterliteCCPPQuery:
"""
"""
QUERY_2
=
"""
QUERY_2
=
"""
select
select
'Production' as par
amete
rs,
'Production' as par
ticula
rs,
'MT' as unit,
'MT' as unit,
(sum(anode_wt) * sum(total_anode)) / 1000 as mtd
(sum(anode_wt) * sum(total_anode)) / 1000 as mtd
from
from
...
@@ -6892,7 +7110,7 @@ class SterliteCCPPQuery:
...
@@ -6892,7 +7110,7 @@ class SterliteCCPPQuery:
class
BariumSulphate
:
class
BariumSulphate
:
QUERY_1
=
"""
QUERY_1
=
"""
select tbl2.parameters, tbl2.unit, sum(barium_sulphate/production) as on_date from
select tbl2.parameters
as particulars
, tbl2.unit, sum(barium_sulphate/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 '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.ccpp_production_plan
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpp_production_plan
where lower(trim(production_anode))='anode weighment') a
where lower(trim(production_anode))='anode weighment') a
...
@@ -6919,13 +7137,13 @@ class SterliteCCPPQuery:
...
@@ -6919,13 +7137,13 @@ class SterliteCCPPQuery:
)foo GROUP BY 1,2,3
)foo GROUP BY 1,2,3
) tbl2
) tbl2
on tbl1.date=tbl2.date
on tbl1.date=tbl2.date
tbl1.date between '{day_start_date}' and '{day_end_date}'
where
tbl1.date between '{day_start_date}' and '{day_end_date}'
group by 1,2
group by 1,2
;
;
"""
"""
QUERY_2
=
"""
QUERY_2
=
"""
select tbl2.parameters, tbl2.unit, sum(barium_sulphate/production) as mtd from
select tbl2.parameters
as particulars
, tbl2.unit, sum(barium_sulphate/production) as mtd from
(select 'Production' as kpi, 'MT' as unit, a.date, (sum(anode_wt)*sum(total_anode))/1000 as production 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.ccpp_production_plan
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpp_production_plan
where lower(trim(production_anode))='anode weighment') a
where lower(trim(production_anode))='anode weighment') a
...
@@ -6952,7 +7170,121 @@ class SterliteCCPPQuery:
...
@@ -6952,7 +7170,121 @@ class SterliteCCPPQuery:
)foo GROUP BY 1,2,3
)foo GROUP BY 1,2,3
) tbl2
) tbl2
on tbl1.date=tbl2.date
on tbl1.date=tbl2.date
tbl1.date between '{month_start_date}' and '{month_end_date}'
where
tbl1.date between '{month_start_date}' and '{month_end_date}'
group by 1,2
group by 1,2
;
;
"""
"""
class
AnodesBookingPending
:
QUERY_1
=
"""
select 'Anode Booking Pending' as particulars,
'MT' as unit, sum(unbooked_anode) as on_date
from semantic_prod.ccpp_daily_production_3
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}' ;"""
QUERY_2
=
"""
select 'Anode Booking Pending' as particulars, 'MT' as unit, sum(unbooked_anode) as mtd from semantic_prod.ccpp_daily_production_3
WHERE DATE BETWEEN '{month_start_date}' AND '{month_end_date}';
"""
class
AnodeInCCPPYard
:
QUERY_1
=
"""
select
'Anode in CCPP Yard' as particulars,
'MT' as unit,
sum(booked_anode) as on_date
from
semantic_prod.ccpp_daily_production_3
WHERE DATE BETWEEN '{day_start_date}' AND '{day_end_date}';"""
QUERY_2
=
"""
select
'Anode in CCPP Yard' as particulars,
'MT' as unit,
sum(booked_anode) as mtd
from
semantic_prod.ccpp_daily_production_3
WHERE DATE BETWEEN '{month_start_date}' AND '{month_end_date}'
"""
class
InternalAnodeRejection
:
QUERY_1
=
"""
SELECT kpi as internal_anode_rejection, SUM(CAST(metric_value AS NUMERIC)) AS ccpp_anode_rejection
FROM (
SELECT date, 'Shift A' AS kpi, COALESCE(values_shift_a_ccpp, '0') AS metric_value
FROM semantic_prod.anode_rejection_ccpp
UNION ALL
SELECT date, 'Shift B' AS kpi, COALESCE(values_shift_b_ccpp, '0') AS metric_value
FROM semantic_prod.anode_rejection_ccpp
UNION ALL
SELECT date, 'Shift C' AS kpi, COALESCE(values_shift_c_ccpp, '0') AS metric_value
FROM semantic_prod.anode_rejection_ccpp
UNION ALL
SELECT date, 'Total' AS kpi, COALESCE(values_shift_a_ccpp, '0') + COALESCE(values_shift_b_ccpp, '0') + COALESCE(values_shift_c_ccpp, '0') AS metric_value
FROM semantic_prod.anode_rejection_ccpp
) foo
where Date(date) BETWEEN '{day_start_date}' AND '{day_end_date}'
GROUP BY 1
ORDER by 1;
"""
class
ProductionDetails1
:
QUERY_1
=
"""
select kpi as production_detail, max(Shift_A) as a_shift, max(Shift_B) as b_shift, max(Shift_C) as c_shift,
max(Shift_A) + max(Shift_B) + max(Shift_C) as total_anode,
max(Prdn_A) as a_shift_production, max(Prdn_B) as b_shift_production, max(Prdn_C) as c_shift_production,
max(Prdn_A) + max(Prdn_B) + max(Prdn_C) as od_production
from (
select 'No of Anode' as kpi, date(tbl1.date) as date,
case when lower(shift)='shift a' then sum(total_anode_accepted_a) else 0 end as shift_A,
case when lower(shift)='shift b' then sum(total_anode_accepted_b) else 0 end as shift_B,
case when lower(shift)='shift c' then sum(total_anode_accepted_c) else 0 end as shift_C,
case when lower(shift)='shift a' then (sum(total_anode_accepted_a)*sum(anode_wt))/1000 else 0 end as Prdn_A,
case when lower(shift)='shift b' then (sum(total_anode_accepted_b)*sum(anode_wt))/1000 else 0 end as Prdn_B,
case when lower(shift)='shift c' then (sum(total_anode_accepted_c)*sum(anode_wt))/1000 else 0 end as Prdn_C
from
(select * from semantic_prod.ccpp_actual_production_new) tbl1
left join
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpp_production_plan
where lower(trim(production_anode))='anode weighment') tbl2
on date(tbl1.date)=date(tbl2.date)
group by 1,2,shift) foo where Date(date) BETWEEN '{day_start_date}' AND '{day_end_date}'
group by 1;
"""
class
ProductionDetails2
:
QUERY_1
=
"""
select kpi as production_detail, max(Shift_A) as a_shift, max(Shift_B) as b_shift, max(Shift_C) as c_shift,
max(Shift_A) + max(Shift_B) + max(Shift_C) as total_anode,
max(Prdn_A) as a_shift_production, max(Prdn_B) as b_shift_production, max(Prdn_C) as c_shift_production,
max(Prdn_A) + max(Prdn_B) + max(Prdn_C) as od_production
from (
select 'Revert generation in Shift' as kpi, date(tbl1.date) as date,
case when lower(shift)='shift a' then sum(total_anode_rejected_a) else 0 end as shift_A,
case when lower(shift)='shift b' then sum(total_anode_rejected_b) else 0 end as shift_B,
case when lower(shift)='shift c' then sum(total_anode_rejected_c) else 0 end as shift_C,
case when lower(shift)='shift a' then (sum(total_anode_rejected_a)*sum(anode_wt))/1000 else 0 end as Prdn_A,
case when lower(shift)='shift b' then (sum(total_anode_rejected_b)*sum(anode_wt))/1000 else 0 end as Prdn_B,
case when lower(shift)='shift c' then (sum(total_anode_rejected_c)*sum(anode_wt))/1000 else 0 end as Prdn_C
from
(select * from semantic_prod.ccpp_actual_production_new) tbl1
left join
(select date(date) as date, production_value as anode_wt from semantic_prod.ccpp_production_plan
where lower(trim(production_anode))='anode weighment') tbl2
on date(tbl1.date)=date(tbl2.date)
group by 1,2,shift) foo where Date(date) BETWEEN '{day_start_date}' AND '{day_end_date}'
group by 1;
"""
class
ActivityTime
:
QUERY_1
=
"""
select
from_time as start_tm,
to_time as end_tm,
loss_in_minutes as total_tm,
stoppage_details as reason_for_stopage
from
semantic_prod.ccpp_plant_stoppage
where
date(date) BETWEEN '{day_start_date}' AND '{day_end_date}';
"""
scripts/core/handler/event_handler.py
View file @
cf93420f
...
@@ -4,6 +4,7 @@ import pandas as pd
...
@@ -4,6 +4,7 @@ import pandas as pd
from
datetime
import
datetime
from
datetime
import
datetime
from
scripts.constants
import
ReportType
,
CommonConstants
,
PostgresConstant
from
scripts.constants
import
ReportType
,
CommonConstants
,
PostgresConstant
from
scripts.template.ccpc_report_template
import
CCPCReportTemplate
from
scripts.template.ccpc_report_template
import
CCPCReportTemplate
from
scripts.template.ccpp_report_template
import
CCPPReportTemplate
from
scripts.template.refinery_report_template
import
SterliteRefineryTemplate
from
scripts.template.refinery_report_template
import
SterliteRefineryTemplate
from
scripts.template.acp_report_template
import
ACPReportTemplate
from
scripts.template.acp_report_template
import
ACPReportTemplate
from
scripts.core.logging.application_logging
import
logger
from
scripts.core.logging.application_logging
import
logger
...
@@ -631,7 +632,7 @@ class CustomReportHandler:
...
@@ -631,7 +632,7 @@ class CustomReportHandler:
logger
.
info
(
f
"date filter: {each_date_range}"
)
logger
.
info
(
f
"date filter: {each_date_range}"
)
report_template
=
copy
.
deepcopy
(
report_template
=
copy
.
deepcopy
(
ACPReportTemplate
.
REPORT_TEMPLATE
CCPPReportTemplate
.
CCPP_
REPORT_TEMPLATE
)
)
start_col
=
CommonConstants
.
START_COLUMN
start_col
=
CommonConstants
.
START_COLUMN
start_row
=
CommonConstants
.
START_ROW
start_row
=
CommonConstants
.
START_ROW
...
@@ -658,9 +659,9 @@ class CustomReportHandler:
...
@@ -658,9 +659,9 @@ class CustomReportHandler:
input_json
=
each_blocks
,
writer
=
writer
,
input_json
=
each_blocks
,
writer
=
writer
,
workbook
=
workbook
,
sheet_name
=
sheet_name
,
workbook
=
workbook
,
sheet_name
=
sheet_name
,
start_col
=
start_col
,
start_row
=
start_row
,
start_col
=
start_col
,
start_row
=
start_row
,
header_merge_format
=
AC
PReportTemplate
.
COLUMN_HEADER_FORMAT
,
header_merge_format
=
CCP
PReportTemplate
.
COLUMN_HEADER_FORMAT
,
column_merge_format
=
AC
PReportTemplate
.
COLUMN_HEADER_FORMAT
,
column_merge_format
=
CCP
PReportTemplate
.
COLUMN_HEADER_FORMAT
,
blank_merge_format
=
AC
PReportTemplate
.
BLANK_COLUMN_HEADER_FORMAT
blank_merge_format
=
CCP
PReportTemplate
.
BLANK_COLUMN_HEADER_FORMAT
)
)
if
total_column
<
shape
[
1
]:
if
total_column
<
shape
[
1
]:
...
...
scripts/template/ccpc_report_template.py
View file @
cf93420f
...
@@ -25,6 +25,18 @@ class CCPCReportTemplate:
...
@@ -25,6 +25,18 @@ class CCPCReportTemplate:
"MTD"
,
"MTD"
,
],
],
"query"
:
{
"query"
:
{
"Production"
:[
SterliteCCPCQuery
.
Production
.
QUERY_1
,
SterliteCCPCQuery
.
Production
.
QUERY_2
],
"BariumSulphateP"
:[
SterliteCCPCQuery
.
BariumSulphateP
.
QUERY_1
,
SterliteCCPCQuery
.
BariumSulphateP
.
QUERY_2
],
"Sodiumsilicate"
:[
SterliteCCPCQuery
.
Sodiumsilicate
.
QUERY_1
,
SterliteCCPCQuery
.
Sodiumsilicate
.
QUERY_2
],
"BLISTER"
:
[
"BLISTER"
:
[
SterliteCCPCQuery
.
BLISTER
.
QUERY_1
,
SterliteCCPCQuery
.
BLISTER
.
QUERY_1
,
SterliteCCPCQuery
.
BLISTER
.
QUERY_2
,
SterliteCCPCQuery
.
BLISTER
.
QUERY_2
,
...
@@ -295,7 +307,11 @@ class CCPCReportTemplate:
...
@@ -295,7 +307,11 @@ class CCPCReportTemplate:
},
},
"MONTHWISE PRODUCTION DETAILS (MT)"
:
{
"MONTHWISE PRODUCTION DETAILS (MT)"
:
{
"columns"
:
[
"NOS"
,
"TARGET"
,
"PRODUCTION"
],
"columns"
:
[
"NOS"
,
"TARGET"
,
"PRODUCTION"
],
"query"
:
{},
"query"
:
{
"MonthWiseData"
:[
SterliteCCPCQuery
.
MonthWiseData
.
QUERY_1
]
},
"data"
:
[],
"data"
:
[],
"data_column"
:
[
"nos"
,
"target"
,
"production"
],
"data_column"
:
[
"nos"
,
"target"
,
"production"
],
"addition"
:
{
"addition"
:
{
...
@@ -317,11 +333,17 @@ class CCPCReportTemplate:
...
@@ -317,11 +333,17 @@ class CCPCReportTemplate:
"OD PRODN (MT) ="
"OD PRODN (MT) ="
],
],
"query"
:
{
"query"
:
{
"ProductionDetails1"
:[
SterliteCCPCQuery
.
ProductionDetails1
.
QUERY1
],
"ProductionDetails2"
:
[
SterliteCCPCQuery
.
ProductionDetails2
.
QUERY_1
]
},
},
"data"
:
[],
"data"
:
[],
"data_column"
:
[
"data_column"
:
[
"
production details-no. of anodes
"
,
"
kpi
"
,
"a_shift"
,
"a_shift"
,
"b_shift"
,
"b_shift"
,
"c_shift"
,
"c_shift"
,
...
...
scripts/template/ccpp_report_template.py
View file @
cf93420f
...
@@ -2,15 +2,17 @@ from scripts.constants import PostgresConstant
...
@@ -2,15 +2,17 @@ from scripts.constants import PostgresConstant
from
scripts.core.db.postgres.custom_report_query
import
SterliteCCPPQuery
from
scripts.core.db.postgres.custom_report_query
import
SterliteCCPPQuery
class
CCP
C
ReportTemplate
:
class
CCP
P
ReportTemplate
:
CCP
C
_REPORT_TEMPLATE
=
[
CCP
P
_REPORT_TEMPLATE
=
[
{
{
"BLANK0"
:
{
"BLANK0"
:
{
"columns"
:
[
"columns"
:
[
None
None
],
],
"data"
:
[],
"data"
:
[],
"query"
:
{},
"query"
:
{
},
"data_column"
:
[
"data_column"
:
[
None
None
]
]
...
@@ -24,7 +26,85 @@ class CCPCReportTemplate:
...
@@ -24,7 +26,85 @@ class CCPCReportTemplate:
"ON DATE"
,
"ON DATE"
,
"MTD"
,
"MTD"
,
],
],
"query"
:
{},
"query"
:
{
"Production"
:
[
SterliteCCPPQuery
.
Production
.
QUERY_1
,
SterliteCCPPQuery
.
Production
.
QUERY_2
],
"Lpg"
:
[
# SterliteCCPPQuery.Lpg.QUERY_1,
# SterliteCCPPQuery.Lpg.QUERY_2,
],
"BariumSulphate"
:
[
SterliteCCPPQuery
.
BariumSulphate
.
QUERY_1
,
SterliteCCPPQuery
.
BariumSulphate
.
QUERY_2
],
"SodiumSilicate"
:
[
SterliteCCPPQuery
.
SodiumSilicate
.
QUERY_1
,
SterliteCCPPQuery
.
SodiumSilicate
.
QUERY_2
,
],
"Power"
:
[
# SterliteCCPPQuery.Power.QUERY_1,
# SterliteCCPPQuery.Power.QUERY_2,
],
"KanshakiBlister"
:
[
SterliteCCPPQuery
.
KanshakiBlister
.
QUERY_1
,
SterliteCCPPQuery
.
KanshakiBlister
.
QUERY_2
,
],
"RejectedCoil"
:
[
SterliteCCPPQuery
.
RejectedCoil
.
QUERY_1
,
SterliteCCPPQuery
.
RejectedCoil
.
QUERY_2
,
],
"MasterAlloy"
:
[
SterliteCCPPQuery
.
MasterAlloy
.
QUERY_1
,
SterliteCCPPQuery
.
MasterAlloy
.
QUERY_2
,
],
"CssBlister"
:
[
SterliteCCPPQuery
.
CssBlister
.
QUERY_1
,
SterliteCCPPQuery
.
CssBlister
.
QUERY_2
,
],
"InternalRejectionAnode"
:
[
SterliteCCPPQuery
.
InternalRejectionAnode
.
QUERY_1
,
SterliteCCPPQuery
.
InternalRejectionAnode
.
QUERY_2
,
],
"RefinerySpentAnode"
:
[
SterliteCCPPQuery
.
RefinerySpentAnode
.
QUERY_1
,
SterliteCCPPQuery
.
RefinerySpentAnode
.
QUERY_2
,
],
"SapProduction"
:
[
SterliteCCPPQuery
.
SapProduction
.
QUERY_1
,
SterliteCCPPQuery
.
SapProduction
.
QUERY_2
,
],
"Dingot"
:
[
SterliteCCPPQuery
.
Dingot
.
QUERY_1
,
SterliteCCPPQuery
.
Dingot
.
QUERY_2
,
],
"KcmAnode"
:
[
SterliteCCPPQuery
.
KcmAnode
.
QUERY_1
,
SterliteCCPPQuery
.
KcmAnode
.
QUERY_2
,
],
"CuLumps"
:
[
SterliteCCPPQuery
.
CuLumps
.
QUERY_1
,
SterliteCCPPQuery
.
CuLumps
.
QUERY_2
,
],
"AcpRejectAnode"
:
[
SterliteCCPPQuery
.
AcpRejectAnode
.
QUERY_1
,
SterliteCCPPQuery
.
AcpRejectAnode
.
QUERY_2
,
],
"ChargingVariation"
:
[
SterliteCCPPQuery
.
ChargingVariation
.
QUERY_1
,
SterliteCCPPQuery
.
ChargingVariation
.
QUERY_2
,
],
"AnodesBookingPending"
:
[
SterliteCCPPQuery
.
AnodesBookingPending
.
QUERY_1
,
SterliteCCPPQuery
.
AnodesBookingPending
.
QUERY_2
],
"AnodeInCCPPYard"
:
[
SterliteCCPPQuery
.
AnodeInCCPPYard
.
QUERY_1
,
SterliteCCPPQuery
.
AnodeInCCPPYard
.
QUERY_2
]
},
"data"
:
[],
"data"
:
[],
"data_column"
:
[
"particulars"
,
"unit"
,
"on_date"
,
"mtd"
,
"data_column"
:
[
"particulars"
,
"unit"
,
"on_date"
,
"mtd"
,
],
],
...
@@ -57,12 +137,13 @@ class CCPCReportTemplate:
...
@@ -57,12 +137,13 @@ class CCPCReportTemplate:
]
]
},
},
"TOTAL BREAKDOWN DETAILS"
:
{
"TOTAL BREAKDOWN DETAILS"
:
{
"columns"
:
[
"T
EMP
"
,
"ON DATE"
],
"columns"
:
[
"T
OTAL BREAKDOWN DETAILS(MINS)
"
,
"ON DATE"
],
"query"
:
{
"query"
:
{
"TotalBreakdownDetails"
:
[
SterliteCCPPQuery
.
TotalBreakdownDetails
.
QUERY_1
],
"TotalBreakdownDetails1"
:
[
SterliteCCPPQuery
.
TotalBreakdownDetails1
.
QUERY_1
]
},
},
"data"
:
[],
"data"
:
[],
"data_column"
:
[
"t
emp
"
,
"on_date"
],
"data_column"
:
[
"t
otal_breakdown
"
,
"on_date"
],
},
},
"BLANK2"
:
{
"BLANK2"
:
{
"columns"
:
[
"columns"
:
[
...
@@ -75,13 +156,14 @@ class CCPCReportTemplate:
...
@@ -75,13 +156,14 @@ class CCPCReportTemplate:
]
]
},
},
"MONTH WISE PRODUCTION"
:
{
"MONTH WISE PRODUCTION"
:
{
"columns"
:
[
"
POSITION"
,
"SHIFT"
,
"AVG-TEMP
"
],
"columns"
:
[
"
NOS"
,
"SHIFT"
,
"PRODUCTION
"
],
"query"
:
{
"query"
:
{
"MonthwiseProductionDetails"
:
[
SterliteCCPPQuery
.
MonthwiseProductionDetails
.
QUERY_1
]
},
},
"data"
:
[],
"data"
:
[],
"data_column"
:
[
"
position"
,
"shift"
,
"avg-temp
"
],
"data_column"
:
[
"
nos"
,
"target"
,
"production
"
],
"addition"
:
{
"addition"
:
{
"merge_header"
:
"
Furnace Shell Temp DCS - Data to be fetched shiftwise
"
,
"merge_header"
:
"
Monthwise Production details (MT)
"
,
}
}
},
},
...
@@ -90,27 +172,23 @@ class CCPCReportTemplate:
...
@@ -90,27 +172,23 @@ class CCPCReportTemplate:
{
{
"CHARGING DETAILS"
:
{
"CHARGING DETAILS"
:
{
"columns"
:
[
"columns"
:
[
"DCS - DATA TO BE FETCHED SHIFTWISE"
,
"CHARGING_DETAIL"
,
""
,
"A-SHIFT"
,
"6AM"
,
"B-SHIFT"
,
"7AM"
,
"C-SHIFT"
,
"8AM"
,
"TOTAL"
"1PM"
],
],
"query"
:
{
"query"
:
{
"ChargingDetails"
:
[
SterliteCCPPQuery
.
ChargingDetails
.
QUERY_1
]
},
},
"data"
:
[],
"data"
:
[],
"data_column"
:
[
"data_column"
:
[
"dcs_data_to_be_fetched_shiftwise"
,
"charging_detail"
,
""
,
"a_shift"
,
"6am"
,
"b_shift"
,
"7am"
,
"c_shift"
,
"8am"
,
"total"
"1pm"
]
],
"addition"
:
{
"merge_header"
:
"SHIFT-A"
,
}
},
},
"BLANK0"
:
{
"BLANK0"
:
{
"columns"
:
[
"columns"
:
[
...
@@ -124,27 +202,19 @@ class CCPCReportTemplate:
...
@@ -124,27 +202,19 @@ class CCPCReportTemplate:
},
},
"INTERNAL ANODE REJECTION"
:
{
"INTERNAL ANODE REJECTION"
:
{
"columns"
:
[
"columns"
:
[
"DCS - DATA TO BE FETCHED SHIFTWISE"
,
"INTERNAL ANODE REJECTION"
,
""
,
"CCPP ANODE REJECTION"
"6AM"
,
"7AM"
,
"8AM"
,
"1PM"
],
],
"query"
:
{
"query"
:
{
"InternalAnodeRejection"
:
[
SterliteCCPPQuery
.
InternalAnodeRejection
.
QUERY_1
]
},
},
"data"
:
[],
"data"
:
[],
"data_column"
:
[
"data_column"
:
[
"dcs - data to be fetched shiftwise"
,
"internal_anode_rejection"
,
""
,
"ccpp_anode_rejection"
"6am"
,
"7am"
,
"8am"
,
"1pm"
],
],
"addition"
:
{
"merge_header"
:
"SHIFT-B"
,
}
},
},
"BLANK1"
:
{
"BLANK1"
:
{
"columns"
:
[
"columns"
:
[
...
@@ -158,12 +228,19 @@ class CCPCReportTemplate:
...
@@ -158,12 +228,19 @@ class CCPCReportTemplate:
},
},
"PARTICULAR TEMP"
:
{
"PARTICULAR TEMP"
:
{
"columns"
:
[
"columns"
:
[
None
"PARTICULARS"
,
"UOM"
,
"FTD"
],
],
"data"
:
[],
"data"
:
[],
"query"
:
{},
"query"
:
{
"Paticulars"
:
[
SterliteCCPPQuery
.
Paticulars
.
QUERY_1
],
"LugThickness"
:
[
SterliteCCPPQuery
.
LugThickness
.
QUERY_1
]
},
"data_column"
:
[
"data_column"
:
[
None
"particulars"
,
"uom"
,
"ftd"
]
]
}
}
...
@@ -171,375 +248,345 @@ class CCPCReportTemplate:
...
@@ -171,375 +248,345 @@ class CCPCReportTemplate:
{
{
"TBC"
:
{
"TBC"
:
{
"columns"
:
[
"columns"
:
[
"DCS - DATA TO BE FETCHED SHIFTWISE"
,
""
,
"6AM"
,
"7AM"
,
"8AM"
,
"1PM"
],
],
"query"
:
{
"query"
:
{
"Tbc"
:
[
SterliteCCPPQuery
.
Tbc
.
QUERY_1
,
SterliteCCPPQuery
.
Tbc
.
QUERY_2
]
},
},
"data"
:
[],
"data"
:
[],
"data_column"
:
[
"data_column"
:
[
"dcs - data to be fetched shiftwise"
,
""
,
"6am"
,
"7am"
,
"8am"
,
"1pm"
],
],
"addition"
:
{
"merge_header"
:
"SHIFT-C"
,
}
}
}
},
},
{
{
"PERSON ON DUTY"
:
{
"PERSON ON DUTY"
:
{
"columns"
:
[
"SHIFT"
,
"TIME"
,
"TANK OUTLET PRESSURE"
,
"VAP. OUTLET PRESSURE"
,
"LINE. OUTLET PRESSURE"
,
"columns"
:
[
"PERSONS ON DUTY"
,
"A SHIFT"
,
"B SHIFT"
,
"C SHIFT"
],
"LINE. TEM "
],
"query"
:
{
"query"
:
{
"PersonOnDuty"
:
[
SterliteCCPPQuery
.
PersonOnDuty
.
QUERY_1
]
},
},
"data"
:
[],
"data"
:
[],
"data_column"
:
[
"shift"
,
"time"
,
"tank outlet pressure"
,
"vap. outlet pressure"
,
"data_column"
:
[
"persons_on_duty"
,
"a_shift"
,
"b_shift"
,
"c_shift"
],
"line. outlet pressure"
,
"line. tem "
],
},
},
},
},
{
{
"PRODUCTION DETAILS"
:
{
"PRODUCTION DETAILS"
:
{
"columns"
:
[
"PARAMATER"
,
"AVG VALUE"
],
"columns"
:
[
"PRODUCTION_DETAIL"
,
"A_SHIFT"
,
"B_SHIFT"
,
"C_SHIFT"
,
"TOTAL_ANODE"
,
"A_SHIFT_PRODUCTION"
,
"B_SHIFT_PRODUCTION"
,
"C_SHIFT_PRODUCTION"
,
"OD_PRODUCTION"
],
"query"
:
{
"query"
:
{
"ProductionDetails1"
:
[
SterliteCCPPQuery
.
ProductionDetails1
.
QUERY_1
],
"ProductionDetails2"
:
[
SterliteCCPPQuery
.
ProductionDetails2
.
QUERY_1
]
},
},
"data"
:
[],
"data"
:
[],
"data_column"
:
[
"parameter"
,
"avg_value"
]
"data_column"
:
[
"production_detail"
,
"a_shift"
,
"b_shift"
,
"c_shift"
,
"total_anode"
,
"a_shift_production"
,
"b_shift_production"
,
"c_shift_production"
,
"od_production"
]
},
},
},
},
{
{
"CONSUMPTION ITEMS"
:
{
"CONSUMPTION ITEMS"
:
{
"columns"
:
[
"C
HARGING DETAILS"
,
"A SHIFT"
,
"B SHIFT"
,
"C SHIFT"
,
"TOTAL
"
],
"columns"
:
[
"C
ONSUMPTION ITEM"
,
"UNIT"
,
"ON DATE"
,
"MTD
"
],
"query"
:
{
"query"
:
{
"ConsumptionItem1"
:
[
SterliteCCPPQuery
.
ConsumptionItem1
.
QUERY_1
,
SterliteCCPPQuery
.
ConsumptionItem1
.
QUERY_2
],
"ConsumptionItem2"
:
[
SterliteCCPPQuery
.
ConsumptionItem2
.
QUERY_1
,
SterliteCCPPQuery
.
ConsumptionItem2
.
QUERY_2
],
"ConsumptionItem3"
:
[
SterliteCCPPQuery
.
ConsumptionItem3
.
QUERY_1
,
SterliteCCPPQuery
.
ConsumptionItem3
.
QUERY_2
]
},
},
"data"
:
[],
"data"
:
[],
"data_column"
:
[
"c
harging_details"
,
"shift_a"
,
"shift_b"
,
"shift_c"
,
"total
"
],
"data_column"
:
[
"c
onsumption_item"
,
"unit"
,
"on_date"
,
"mtd
"
],
}
}
},
},
{
{
"ACTIVITY TIME"
:
{
"ACTIVITY TIME"
:
{
"columns"
:
[
"columns"
:
[
"PRODUCTION DETAILS-NO. OF ANODES"
,
"ACTIVITY TIME"
,
"A SHIFT"
,
"SHIFT TIME"
,
"B SHIFT"
,
"C SHIFT"
,
"TOTAL"
,
"A-SHIFT PRDN"
,
"B-SHIFT PRDN"
,
"C-SHIFT PRDN"
,
"OD PRODN (MT) ="
],
"query"
:
{
},
"data"
:
[],
"data_column"
:
[
"production details-no. of anodes"
,
"a_shift"
,
"b_shift"
,
"c_shift"
,
"total"
,
"a_shift_prdn"
,
"b_shift_prdn"
,
"c_shift_prdn"
,
"od_prodn"
],
}
},
{
"A-SHIFT"
:
{
"columns"
:
[
"CONSUMPTION ITEMS"
,
"UNIT"
,
"ON DATE"
,
"MTD"
,
],
"query"
:
{
},
"data"
:
[],
"data_column"
:
[
"consumption_items"
,
"unit"
,
"on_date"
,
"mtd"
,
],
},
"BLANK0"
:
{
"columns"
:
[
None
],
"data"
:
[],
"query"
:
{},
"data_column"
:
[
None
]
},
"LINEAR CASTING"
:
{
"columns"
:
[
None
],
"data"
:
[],
"query"
:
{},
"data_column"
:
[
None
]
},
},
{
"A-SHIFT"
:
{
"columns"
:
[
"CONSUMPTION ITEMS"
,
"UNIT"
,
"ON DATE"
,
"MTD"
,
],
"query"
:
{
},
"data"
:
[],
"data_column"
:
[
"consumption_items"
,
"unit"
,
"on_date"
,
"mtd"
,
],
},
"BLANK0"
:
{
"columns"
:
[
None
],
"data"
:
[],
"query"
:
{},
"data_column"
:
[
None
]
},
"LINEAR CASTING"
:
{
"columns"
:
[
None
],
"data"
:
[],
"query"
:
{},
"data_column"
:
[
None
]
},
},
{
"SHIFT ACTIVITY"
:
{
"columns"
:
[
"ACTIVITY-TIME"
,
"SHIFT"
,
"START TIME"
,
"END TIME"
,
"END TIME"
,
"TOTAL TIME (MINUTES)"
,
"TOTAL TIME (MINUTES)"
,
"REASON FOR STOPAGE"
"REASON FOR STOPAGE"
],
],
"query"
:
{
"query"
:
{
# "ActivityTime":[
# # SterliteCCPPQuery.ActivityTime.QUERY_1
# ]
},
},
"data"
:
[],
"data"
:
[],
"data_column"
:
[
"data_column"
:
[
"activity_time"
,
"activity_time"
,
"shift"
,
"shift_time"
,
"start_time"
,
"end_time"
,
"end_time"
,
"total_time"
,
"total_time"
,
"reason_for_stopage"
"reason_for_stopage"
],
],
},
}
"BLANK"
:
{
"columns"
:
[
None
],
"data"
:
[],
"query"
:
{},
"data_column"
:
[
None
]
},
"CIRCULAR CASTING"
:
{
"columns"
:
[
None
],
"data"
:
[],
"query"
:
{},
"data_column"
:
[
None
]
},
},
{
"B-SHIFT"
:
{
"columns"
:
[
"CONSUMPTION ITEMS"
,
"UNIT"
,
"ON DATE"
,
"MTD"
,
],
"query"
:
{
},
"data"
:
[],
"data_column"
:
[
"consumption_items"
,
"unit"
,
"on_date"
,
"mtd"
,
],
},
"BLANK0"
:
{
"columns"
:
[
None
],
"data"
:
[],
"query"
:
{},
"data_column"
:
[
None
]
},
"LINEAR CASTING"
:
{
"columns"
:
[
None
],
"data"
:
[],
"query"
:
{},
"data_column"
:
[
None
]
},
},
{
"SHIFT ACTIVITY"
:
{
"columns"
:
[
"ACTIVITY-TIME"
,
"SHIFT"
,
"START TIME"
,
"END TIME"
,
"TOTAL TIME (MINUTES)"
,
"REASON FOR STOPAGE"
],
"query"
:
{
},
"data"
:
[],
"data_column"
:
[
"activity_time"
,
"shift"
,
"start_time"
,
"end_time"
,
"total_time"
,
"reason_for_stopage"
],
},
"BLANK"
:
{
"columns"
:
[
None
],
"data"
:
[],
"query"
:
{},
"data_column"
:
[
None
]
},
"CIRCULAR CASTING"
:
{
"columns"
:
[
None
],
"data"
:
[],
"query"
:
{},
"data_column"
:
[
None
]
},
},
{
"C-SHIFT"
:
{
"columns"
:
[
"CONSUMPTION ITEMS"
,
"UNIT"
,
"ON DATE"
,
"MTD"
,
],
"query"
:
{
},
"data"
:
[],
"data_column"
:
[
"consumption_items"
,
"unit"
,
"on_date"
,
"mtd"
,
],
},
"BLANK0"
:
{
"columns"
:
[
None
],
"data"
:
[],
"query"
:
{},
"data_column"
:
[
None
]
},
"LINEAR CASTING"
:
{
"columns"
:
[
None
],
"data"
:
[],
"query"
:
{},
"data_column"
:
[
None
]
},
},
},
{
# {
"SHIFT ACTIVITY"
:
{
# "A-SHIFT": {
"columns"
:
[
# "columns": ["",""
"ACTIVITY-TIME"
,
# ],
"SHIFT"
,
# "query": {
"START TIME"
,
# },
"END TIME"
,
# "data": [],
"TOTAL TIME (MINUTES)"
,
# "data_column": ["",""
"REASON FOR STOPAGE"
#
],
# ],
"query"
:
{
# "addition": {
},
# "merge_header": "A-SHIFT",
"data"
:
[],
# }
"data_column"
:
[
# },
"activity_time"
,
# "BLANK0": {
"shift"
,
# "columns": [
"start_time"
,
# None
"end_time"
,
# ],
"total_time"
,
# "data": [],
"reason_for_stopage"
# "query": {},
],
# "data_column": [
},
# None
"BLANK"
:
{
# ]
"columns"
:
[
# },
None
# "LINEAR CASTING": {
],
# "columns": [
"data"
:
[],
# "",""
"query"
:
{},
# ],
"data_column"
:
[
# "data": [],
None
# "query": {},
]
# "data_column": [
},
# "",""
"CIRCULAR CASTING"
:
{
# ],
"columns"
:
[
# "addition": {
None
# "merge_header": "LINEAR CASTING",
],
# }
"data"
:
[],
# },
"query"
:
{},
# },
"data_column"
:
[
# {
None
# "A-SHIFT": {
]
# "columns": [
},
# "",""
}
# ],
# "query": {
# },
# "data": [],
# "data_column": [
# "",""
# ],
# },
# "BLANK0": {
# "columns": [
# None
# ],
# "data": [],
# "query": {},
# "data_column": [
# None
# ]
# },
# "CIRCULAR CASTING": {
# "columns": [
# "",""
# ],
# "data": [],
# "query": {},
# "data_column": [
# "",""
# ],
# "addition": {
# "merge_header": "CIRCULAR CASTING",
# }
# },
# },
# {
# "SHIFT ACTIVITY": {
# "columns": [
# "",""
# ],
# "query": {
# },
# "data": [],
# "data_column": [
# "",""
# ],
# },
# "BLANK": {
# "columns": [
# None
# ],
# "data": [],
# "query": {},
# "data_column": [
# None
# ]
# },
# "CIRCULAR CASTING": {
# "columns": [
# "",""
# ],
# "data": [],
# "query": {},
# "data_column": [
# "",""
# ],
# "addition": {
# "merge_header": "CIRCULAR CASTING",
# }
# },
# },
# {
# "B-SHIFT": {
# "columns": [
# "", ""
# ],
# "query": {
# },
# "data": [],
# "data_column": [
# "",""
# ],
# },
# "BLANK0": {
# "columns": [
# None
# ],
# "data": [],
# "query": {},
# "data_column": [
# None
# ]
# },
# "LINEAR CASTING": {
# "columns": [
# "",""
# ],
# "data": [],
# "query": {},
# "data_column": [
# "",""
# ],
# "addition": {
# "merge_header": "LINEAR CASTING",
# }
# },
# },
# {
# "SHIFT ACTIVITY": {
# "columns": [
# "ACTIVITY-TIME",
# "SHIFT",
# "START TIME",
# "END TIME",
# "TOTAL TIME (MINUTES)",
# "REASON FOR STOPAGE"
# ],
# "query": {
# },
# "data": [],
# "data_column": [
# "activity_time",
# "shift",
# "start_time",
# "end_time",
# "total_time",
# "reason_for_stopage"
# ],
# },
# "BLANK": {
# "columns": [
# None
# ],
# "data": [],
# "query": {},
# "data_column": [
# None
# ]
# },
# "CIRCULAR CASTING": {
# "columns": [
# "",""
# ],
# "data": [],
# "query": {},
# "data_column": [
# "",""
# ],
# "addition": {
# "merge_header": "CIRCULAR CASTING",
# }
# },
# },
# {
# "C-SHIFT": {
# "columns": ["",""
#
# ],
# "query": {
# },
# "data": [],
# "data_column": ["",""
#
# ],
# },
# "BLANK0": {
# "columns": [
# None
# ],
# "data": [],
# "query": {},
# "data_column": [
# None
# ]
# },
# "LINEAR CASTING": {
# "columns": [
# "",""
# ],
# "data": [],
# "query": {},
# "data_column": [
# "",""
# ],
# "addition": {
# "merge_header": "LINEAR CASTING",
# }
# },
# },
# {
# "SHIFT ACTIVITY": {
# "columns": ["",""
# ],
# "query": {
# },
# "data": [],
# "data_column": ["",""
#
# ],
# },
# "BLANK": {
# "columns": [
# None
# ],
# "data": [],
# "query": {},
# "data_column": [
# None
# ]
# },
# "CIRCULAR CASTING": {
# "columns": [
# "",""
# ],
# "data": [],
# "query": {},
# "data_column": [
# "",""
# ],
# "addition": {
# "merge_header": "CIRCULAR CASTING",
# }
# },
# }
]
]
WORKSHEET_HEADER_FORMAT
=
{
WORKSHEET_HEADER_FORMAT
=
{
"bold"
:
True
,
"bold"
:
True
,
...
...
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