Commit cf9fc25f authored by suryakant's avatar suryakant

Sterlite Custom Report Updates

parent 9f037fcb
...@@ -4,8 +4,6 @@ class SterliteRefineryQuery: ...@@ -4,8 +4,6 @@ class SterliteRefineryQuery:
""" """
class AnodeAvailability: class AnodeAvailability:
# Query for ANODE_AVAILABILITY
# ANODE_AVAILABILITY, UOM, NORMS, ON_DATE
QUERY_1 = """ QUERY_1 = """
SELECT SELECT
'Cell House Anode Availability' AS ANODE_AVAILABILITY, 'Cell House Anode Availability' AS ANODE_AVAILABILITY,
...@@ -135,8 +133,6 @@ class SterliteRefineryQuery: ...@@ -135,8 +133,6 @@ class SterliteRefineryQuery:
""" """
class DOCellsInOperation: class DOCellsInOperation:
# Query for DO Cells Operation
# ANODE_AVAILABILITY, UOM, NORMS, ON_DATE
QUERY_1 = """ QUERY_1 = """
SELECT SELECT
'DO Cells In Operation' AS ANODE_AVAILABILITY, 'DO Cells In Operation' AS ANODE_AVAILABILITY,
...@@ -162,8 +158,6 @@ class SterliteRefineryQuery: ...@@ -162,8 +158,6 @@ class SterliteRefineryQuery:
""" """
class TotalCellsInOperation: class TotalCellsInOperation:
# Query for Total Cell In Operations
# ANODE_AVAILABILITY, UOM, NORMS, ON_DATE
QUERY_1 = """ QUERY_1 = """
SELECT SELECT
'Total Cells In Operation' AS ANODE_AVAILABILITY, 'Total Cells In Operation' AS ANODE_AVAILABILITY,
...@@ -342,7 +336,7 @@ class SterliteRefineryQuery: ...@@ -342,7 +336,7 @@ class SterliteRefineryQuery:
QUERY_1 = """ QUERY_1 = """
SELECT SELECT
'Cir-1 40 KA Rectifier Avg. Current' AS power_availability, 'Cir-1 40 KA Rectifier Avg. Current' AS power_availability,
'%' AS uom, 'KAmp' AS uom,
AVG(PLAN_METRIC_VALUE) AS norms, AVG(PLAN_METRIC_VALUE) AS norms,
SUM(ACTUAL_METRIC_VALUE) / COALESCE(NULLIF(COUNT( SUM(ACTUAL_METRIC_VALUE) / COALESCE(NULLIF(COUNT(
CASE CASE
...@@ -357,7 +351,7 @@ class SterliteRefineryQuery: ...@@ -357,7 +351,7 @@ class SterliteRefineryQuery:
QUERY_2 = """ QUERY_2 = """
SELECT SELECT
'Cir-1 40 KA Rectifier Avg. Current' AS power_availability, 'Cir-1 40 KA Rectifier Avg. Current' AS power_availability,
'%' AS uom, 'KAmp' AS uom,
SUM(ACTUAL_METRIC_VALUE) / COALESCE(NULLIF(COUNT( SUM(ACTUAL_METRIC_VALUE) / COALESCE(NULLIF(COUNT(
CASE CASE
WHEN ACTUAL_METRIC_VALUE <> 0 THEN 1 WHEN ACTUAL_METRIC_VALUE <> 0 THEN 1
...@@ -371,7 +365,7 @@ class SterliteRefineryQuery: ...@@ -371,7 +365,7 @@ class SterliteRefineryQuery:
QUERY_3 = """ QUERY_3 = """
SELECT SELECT
'Cir-1 40 KA Rectifier Avg. Current' AS power_availability, 'Cir-1 40 KA Rectifier Avg. Current' AS power_availability,
'%' AS uom, 'KAmp' AS uom,
SUM(ACTUAL_METRIC_VALUE) / COALESCE(NULLIF(COUNT( SUM(ACTUAL_METRIC_VALUE) / COALESCE(NULLIF(COUNT(
CASE CASE
WHEN ACTUAL_METRIC_VALUE <> 0 THEN 1 WHEN ACTUAL_METRIC_VALUE <> 0 THEN 1
...@@ -382,3 +376,135 @@ class SterliteRefineryQuery: ...@@ -382,3 +376,135 @@ class SterliteRefineryQuery:
AND DATE BETWEEN '{year_start_date}' AND '{year_end_date}' AND DATE BETWEEN '{year_start_date}' AND '{year_end_date}'
GROUP BY 1,2 GROUP BY 1,2
""" """
class Cir235KARectifierAvgCurrent:
QUERY_1 = """
SELECT
'Cir-2 35 KA Rectifier Avg. Current' AS power_availability,
'KAmp' AS uom,
AVG(PLAN_METRIC_VALUE) AS norms,
SUM(ACTUAL_METRIC_VALUE) / COALESCE(NULLIF(COUNT(
CASE
WHEN ACTUAL_METRIC_VALUE <> 0
THEN 1 ELSE NULL END), 0), 1)
AS on_date
FROM SEMANTIC_PROD.RECTIFIER_KPI_VIEW
WHERE LOWER(TRIM(KPI)) = '35ka_rectifier_current'
AND DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
GROUP BY 1,2
"""
QUERY_2 = """
SELECT
'Cir-2 35 KA Rectifier Avg. Current' AS power_availability,
'KAmp' AS uom,
SUM(ACTUAL_METRIC_VALUE) / COALESCE(NULLIF(COUNT(
CASE
WHEN ACTUAL_METRIC_VALUE <> 0
THEN 1 ELSE NULL END), 0), 1)
AS mtd
FROM SEMANTIC_PROD.RECTIFIER_KPI_VIEW
WHERE LOWER(TRIM(KPI)) = '35ka_rectifier_current'
AND DATE BETWEEN '{month_start_date}' AND '{month_end_date}'
GROUP BY 1,2
"""
QUERY_3 = """
SELECT
'Cir-2 35 KA Rectifier Avg. Current' AS power_availability,
'KAmp' AS uom,
SUM(ACTUAL_METRIC_VALUE) / COALESCE(NULLIF(COUNT(
CASE
WHEN ACTUAL_METRIC_VALUE <> 0
THEN 1 ELSE NULL END), 0), 1)
AS ytd
FROM SEMANTIC_PROD.RECTIFIER_KPI_VIEW
WHERE LOWER(TRIM(KPI)) = '35ka_rectifier_current'
AND DATE BETWEEN '{year_start_date}' AND '{year_end_date}'
GROUP BY 1,2
"""
class TotalAvgCurrent:
QUERY_1 = """
SELECT
'Total Avg. Current' AS power_availability,
'KAmp' AS uom,
AVG(PLAN_METRIC_VALUE) AS norms,
SUM(ACTUAL_METRIC_VALUE) / COALESCE(NULLIF(COUNT(
CASE WHEN ACTUAL_METRIC_VALUE <> 0 THEN 1
ELSE NULL END), 0), 1) AS on_date
FROM SEMANTIC_PROD.RECTIFIER_KPI_VIEW
WHERE LOWER(TRIM(KPI)) in
('40ka_rectifier_current', '35ka_rectifier_current')
AND DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
GROUP BY 1,2
"""
QUERY_2 = """
SELECT
'Total Avg. Current' AS power_availability,
'KAmp' AS uom,
SUM(ACTUAL_METRIC_VALUE) / COALESCE(NULLIF(COUNT(
CASE WHEN ACTUAL_METRIC_VALUE <> 0 THEN 1
ELSE NULL END), 0), 1) AS mtd
FROM SEMANTIC_PROD.RECTIFIER_KPI_VIEW
WHERE LOWER(TRIM(KPI)) in
('40ka_rectifier_current', '35ka_rectifier_current')
AND DATE BETWEEN '{month_start_date}' AND '{month_end_date}'
GROUP BY 1,2
"""
QUERY_3 = """
SELECT
'Total Avg. Current' AS power_availability,
'KAmp' AS uom,
SUM(ACTUAL_METRIC_VALUE) / COALESCE(NULLIF(COUNT(
CASE WHEN ACTUAL_METRIC_VALUE <> 0 THEN 1
ELSE NULL END), 0), 1) AS ytd
FROM SEMANTIC_PROD.RECTIFIER_KPI_VIEW
WHERE LOWER(TRIM(KPI)) in
('40ka_rectifier_current', '35ka_rectifier_current')
AND DATE BETWEEN '{year_start_date}' AND '{year_end_date}'
GROUP BY 1,2
"""
class CurrentDensity:
QUERY_1 = """
SELECT
'Current Density' AS power_availability,
'Amp / m2' AS uom,
AVG(NUMO_PLAN) AS norms,
AVG(NUMO_ACTUAL) AS on_date
FROM SEMANTIC_PROD.CE_CD_TE_DETAILED_VIEW CCTDV2
WHERE
LOWER(TRIM(CATEGORY)) = 'cd'
AND DATE BETWEEN '{day_start_date}' AND '{day_end_date}'
"""
QUERY_2 = """
SELECT
'Current Density' AS power_availability,
'Amp / m2' AS uom,
AVG(NUMO_ACTUAL) AS mtd
FROM SEMANTIC_PROD.CE_CD_TE_DETAILED_VIEW CCTDV2
WHERE
LOWER(TRIM(CATEGORY)) = 'cd'
AND DATE BETWEEN '{month_start_date}' AND '{month_end_date}'
"""
QUERY_3 = """
SELECT
'Current Density' AS power_availability,
'Amp / m2' AS uom,
AVG(NUMO_ACTUAL) AS ytd
FROM SEMANTIC_PROD.CE_CD_TE_DETAILED_VIEW CCTDV2
WHERE
LOWER(TRIM(CATEGORY)) = 'cd'
AND DATE BETWEEN '{year_start_date}' AND '{year_end_date}'
"""
...@@ -32,7 +32,6 @@ class SterliteRefineryTemplate: ...@@ -32,7 +32,6 @@ class SterliteRefineryTemplate:
"data_column": [ "data_column": [
"anode_availability", "uom", "norms", "anode_availability", "uom", "norms",
"on_date", "mtd", "ytd"], "on_date", "mtd", "ytd"],
"description": "",
"format": "", "format": "",
}, },
"SAFETY REPORT": { "SAFETY REPORT": {
...@@ -52,8 +51,6 @@ class SterliteRefineryTemplate: ...@@ -52,8 +51,6 @@ class SterliteRefineryTemplate:
"data": [], "data": [],
"data_column": ["safety_report", "uom", "norms", "data_column": ["safety_report", "uom", "norms",
"on_date", "mtd", "ytd"], "on_date", "mtd", "ytd"],
"additions": [],
"description": "",
"format": "", "format": "",
}, },
}, },
...@@ -79,16 +76,27 @@ class SterliteRefineryTemplate: ...@@ -79,16 +76,27 @@ class SterliteRefineryTemplate:
SterliteRefineryQuery.Cir140KARectifierAvgCurrent.QUERY_2, SterliteRefineryQuery.Cir140KARectifierAvgCurrent.QUERY_2,
SterliteRefineryQuery.Cir140KARectifierAvgCurrent.QUERY_3, SterliteRefineryQuery.Cir140KARectifierAvgCurrent.QUERY_3,
], ],
"Cir-2 35 KA Rectifier Avg. Current": [], "Cir-2 35 KA Rectifier Avg. Current": [
"Total Avg. Current": [], SterliteRefineryQuery.Cir235KARectifierAvgCurrent.QUERY_1,
"Current Density": [] SterliteRefineryQuery.Cir235KARectifierAvgCurrent.QUERY_2,
SterliteRefineryQuery.Cir235KARectifierAvgCurrent.QUERY_3,
],
"Total Avg. Current": [
SterliteRefineryQuery.TotalAvgCurrent.QUERY_1,
SterliteRefineryQuery.TotalAvgCurrent.QUERY_2,
SterliteRefineryQuery.TotalAvgCurrent.QUERY_3,
],
"Current Density": [
SterliteRefineryQuery.CurrentDensity.QUERY_1,
SterliteRefineryQuery.CurrentDensity.QUERY_2,
SterliteRefineryQuery.CurrentDensity.QUERY_3,
]
}, },
"data": [], "data": [],
"data_column": ["power_availability", "uom", "data_column": ["power_availability", "uom",
"norms", "on_date", "mtd", "norms", "on_date", "mtd",
"ytd"], "ytd"],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
}, },
"RM ANODE RECEIPT DETAILS": { "RM ANODE RECEIPT DETAILS": {
...@@ -105,7 +113,6 @@ class SterliteRefineryTemplate: ...@@ -105,7 +113,6 @@ class SterliteRefineryTemplate:
"data_column": ["rm_anode_receipt_details", "on_date", "data_column": ["rm_anode_receipt_details", "on_date",
"mtd", "ytd", "material", "opening_stock"], "mtd", "ytd", "material", "opening_stock"],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
}, },
}, },
...@@ -117,7 +124,7 @@ class SterliteRefineryTemplate: ...@@ -117,7 +124,7 @@ class SterliteRefineryTemplate:
"data_column": ["efficiencies", "uom", "norms", "data_column": ["efficiencies", "uom", "norms",
"on_date", "mtd", "ytd"], "on_date", "mtd", "ytd"],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
}, },
"BANK / CROP": { "BANK / CROP": {
...@@ -133,7 +140,7 @@ class SterliteRefineryTemplate: ...@@ -133,7 +140,7 @@ class SterliteRefineryTemplate:
"data_column": ["bank_crop", "ce(%)", "theor_weight", "data_column": ["bank_crop", "ce(%)", "theor_weight",
"actual_weight", "stripping_time"], "actual_weight", "stripping_time"],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
}, },
}, },
...@@ -145,7 +152,7 @@ class SterliteRefineryTemplate: ...@@ -145,7 +152,7 @@ class SterliteRefineryTemplate:
"data_column": ["production", "uom", "norms", "data_column": ["production", "uom", "norms",
"on_date", "mtd", "ytd"], "on_date", "mtd", "ytd"],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
}, },
"CIRCULATION": { "CIRCULATION": {
...@@ -154,7 +161,7 @@ class SterliteRefineryTemplate: ...@@ -154,7 +161,7 @@ class SterliteRefineryTemplate:
"data": [], "data": [],
"data_column": ["circulation", "ce", "theor_weight", "actual_weight"], "data_column": ["circulation", "ce", "theor_weight", "actual_weight"],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
}, },
}, },
...@@ -165,7 +172,7 @@ class SterliteRefineryTemplate: ...@@ -165,7 +172,7 @@ class SterliteRefineryTemplate:
"data": [], "data": [],
"data_column": ["fg_inventory", "on_date", "mtd", "ytd"], "data_column": ["fg_inventory", "on_date", "mtd", "ytd"],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
}, },
"PRODUCTION": { "PRODUCTION": {
...@@ -174,7 +181,7 @@ class SterliteRefineryTemplate: ...@@ -174,7 +181,7 @@ class SterliteRefineryTemplate:
"data": [], "data": [],
"data_column": ["production", "on_date", "mtd", "ytd"], "data_column": ["production", "on_date", "mtd", "ytd"],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
}, },
}, },
...@@ -192,7 +199,7 @@ class SterliteRefineryTemplate: ...@@ -192,7 +199,7 @@ class SterliteRefineryTemplate:
"data_column": ["crop", "banks", "total_cells", "data_column": ["crop", "banks", "total_cells",
"cell_voltage", "t_shorts"], "cell_voltage", "t_shorts"],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
} }
}, },
...@@ -217,7 +224,7 @@ class SterliteRefineryTemplate: ...@@ -217,7 +224,7 @@ class SterliteRefineryTemplate:
"csm_plate_rejection" "csm_plate_rejection"
], ],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
} }
}, },
...@@ -238,7 +245,7 @@ class SterliteRefineryTemplate: ...@@ -238,7 +245,7 @@ class SterliteRefineryTemplate:
"total_volume_refinery", "on_date" "total_volume_refinery", "on_date"
], ],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
} }
}, },
...@@ -263,7 +270,7 @@ class SterliteRefineryTemplate: ...@@ -263,7 +270,7 @@ class SterliteRefineryTemplate:
"ytd", "ytd",
], ],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
}, },
"SPECIFIC CONSUMPTION": { "SPECIFIC CONSUMPTION": {
...@@ -273,7 +280,7 @@ class SterliteRefineryTemplate: ...@@ -273,7 +280,7 @@ class SterliteRefineryTemplate:
"data_column": ["consumables", "uom", "norms", "on_date", "mtd", "data_column": ["consumables", "uom", "norms", "on_date", "mtd",
"ytd"], "ytd"],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
}, },
}, },
...@@ -298,7 +305,7 @@ class SterliteRefineryTemplate: ...@@ -298,7 +305,7 @@ class SterliteRefineryTemplate:
"cir_2", "cir_2",
], ],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
}, },
"SUSPENDED SOLIDS": { "SUSPENDED SOLIDS": {
...@@ -307,7 +314,7 @@ class SterliteRefineryTemplate: ...@@ -307,7 +314,7 @@ class SterliteRefineryTemplate:
"data": [], "data": [],
"data_column": ["suspended_solids"], "data_column": ["suspended_solids"],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
}, },
}, },
...@@ -318,7 +325,7 @@ class SterliteRefineryTemplate: ...@@ -318,7 +325,7 @@ class SterliteRefineryTemplate:
"data": [], "data": [],
"data_column": ["bleeding_section", "uom", "on_date", "mtd", "ytd"], "data_column": ["bleeding_section", "uom", "on_date", "mtd", "ytd"],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
}, },
"BANK / CROP": { "BANK / CROP": {
...@@ -327,7 +334,7 @@ class SterliteRefineryTemplate: ...@@ -327,7 +334,7 @@ class SterliteRefineryTemplate:
"data": [], "data": [],
"data_column": ["bank_crop", "time", "weight", "cells", "reading"], "data_column": ["bank_crop", "time", "weight", "cells", "reading"],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
}, },
}, },
...@@ -352,7 +359,7 @@ class SterliteRefineryTemplate: ...@@ -352,7 +359,7 @@ class SterliteRefineryTemplate:
"cause", "cause",
], ],
"additions": [], "additions": [],
"description": "",
"format": "", "format": "",
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment