From bb1b875f09c32e3e25d05e0319ec4e522d263d5f Mon Sep 17 00:00:00 2001 From: Cizz22 Date: Wed, 8 Oct 2025 15:22:11 +0700 Subject: [PATCH] fix --- src/calculation_time_constrains/service.py | 16 ++++++++++------ src/maximo/service.py | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/calculation_time_constrains/service.py b/src/calculation_time_constrains/service.py index 0fd963b..b77c3a7 100644 --- a/src/calculation_time_constrains/service.py +++ b/src/calculation_time_constrains/service.py @@ -809,13 +809,17 @@ async def get_calculation_result(db_session: DbSession, calculation_id: str, tok 'critical_procurement_items': 0 } - # plant_monthly_metrics = await plant_simulation_metrics(simulation_id=scope_calculation.rbd_simulation_id, location_tag="plant", use_location_tag=0, token=token, last_oh_date=prev_oh_scope.end_date, max_interval=scope_calculation.max_interval) + # The code `plant_monthly_metrics` is likely a function or a variable in Python. Without + # seeing the implementation of the code, it is not possible to determine exactly what it is + # doing. It could be used to store monthly metrics for a plant, calculate metrics, or perform + # some other operation related to plant data. + plant_monthly_metrics = await plant_simulation_metrics(simulation_id=scope_calculation.rbd_simulation_id, location_tag="plant", use_location_tag=0, token=token, last_oh_date=prev_oh_scope.end_date, max_interval=scope_calculation.max_interval) - # REFERENCE_CAPACITY = 630 # or 550 - # COST_PER_MWH = 1_000_000 # rupiah + REFERENCE_CAPACITY = 630 # or 550 + COST_PER_MWH = 1_000_000 # rupiah - # plant_capacity_loss_money = [metrics['derated_mwh'] * COST_PER_MWH for metrics in plant_monthly_metrics.values()] - # # cumulative_loss_money = np.cumsum(plant_capacity_loss_money) + plant_capacity_loss_money = [metrics['derated_mwh'] * COST_PER_MWH for metrics in plant_monthly_metrics.values()] + cumulative_loss_money = np.cumsum(plant_capacity_loss_money) # # raise Exception(plant_monthly_metrics) @@ -823,7 +827,7 @@ async def get_calculation_result(db_session: DbSession, calculation_id: str, tok for month_index in range(data_num): month_result = { "overhaul_cost": 0.0, - "corrective_cost": 0.0, + "corrective_cost": cumulative_loss_money, "procurement_cost": 0.0, "num_failures": 0.0, "day": month_index + 1, diff --git a/src/maximo/service.py b/src/maximo/service.py index 21d47cd..b5192de 100644 --- a/src/maximo/service.py +++ b/src/maximo/service.py @@ -62,6 +62,7 @@ filtered_wo AS ( FROM wo_costs w JOIN location_max lm ON w.asset_location = lm.asset_location WHERE w.total_wo_cost > 0 + AND w.total_wo_cost >= lm.max_cost * 0.10 -- keep within 10% of max ) SELECT asset_location,