|
|
|
@ -15,7 +15,7 @@ from src.database.core import DbSession
|
|
|
|
from src.logging import setup_logging
|
|
|
|
from src.logging import setup_logging
|
|
|
|
from src.overhaul_activity.service import get_all as get_all_by_session_id
|
|
|
|
from src.overhaul_activity.service import get_all as get_all_by_session_id
|
|
|
|
from src.overhaul_scope.service import get as get_scope, get_prev_oh
|
|
|
|
from src.overhaul_scope.service import get as get_scope, get_prev_oh
|
|
|
|
from src.sparepart.service import load_sparepart_data_from_db
|
|
|
|
from src.sparepart.service import get_spareparts_paginated, load_sparepart_data_from_db
|
|
|
|
from src.utils import get_latest_numOfFail
|
|
|
|
from src.utils import get_latest_numOfFail
|
|
|
|
from src.workorder.model import MasterWorkOrder
|
|
|
|
from src.workorder.model import MasterWorkOrder
|
|
|
|
from src.sparepart.model import MasterSparePart
|
|
|
|
from src.sparepart.model import MasterSparePart
|
|
|
|
@ -754,7 +754,7 @@ async def create_param_and_data(
|
|
|
|
return calculationData
|
|
|
|
return calculationData
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def get_calculation_result(db_session: DbSession, calculation_id: str, token):
|
|
|
|
async def get_calculation_result(db_session: DbSession, calculation_id: str, collector_db_session):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Get calculation results with improved error handling, performance, and sparepart details
|
|
|
|
Get calculation results with improved error handling, performance, and sparepart details
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
@ -798,6 +798,7 @@ async def get_calculation_result(db_session: DbSession, calculation_id: str, tok
|
|
|
|
# Filter included equipment for performance
|
|
|
|
# Filter included equipment for performance
|
|
|
|
included_equipment = [eq for eq in scope_calculation.equipment_results if eq.is_included]
|
|
|
|
included_equipment = [eq for eq in scope_calculation.equipment_results if eq.is_included]
|
|
|
|
all_equipment = scope_calculation.equipment_results
|
|
|
|
all_equipment = scope_calculation.equipment_results
|
|
|
|
|
|
|
|
all_spareparts = await get_spareparts_paginated(db_session=db_session, collector_db_session=collector_db_session )
|
|
|
|
|
|
|
|
|
|
|
|
# Pre-calculate aggregated statistics
|
|
|
|
# Pre-calculate aggregated statistics
|
|
|
|
calculation_results = []
|
|
|
|
calculation_results = []
|
|
|
|
@ -807,7 +808,8 @@ async def get_calculation_result(db_session: DbSession, calculation_id: str, tok
|
|
|
|
'excluded_equipment': len(all_equipment) - len(included_equipment),
|
|
|
|
'excluded_equipment': len(all_equipment) - len(included_equipment),
|
|
|
|
'equipment_with_sparepart_constraints': 0,
|
|
|
|
'equipment_with_sparepart_constraints': 0,
|
|
|
|
'total_procurement_items': 0,
|
|
|
|
'total_procurement_items': 0,
|
|
|
|
'critical_procurement_items': 0
|
|
|
|
'critical_procurement_items': 0,
|
|
|
|
|
|
|
|
'total_spareparts': len(all_spareparts)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# The code `plant_monthly_metrics` is likely a function or a variable in Python. Without
|
|
|
|
# The code `plant_monthly_metrics` is likely a function or a variable in Python. Without
|
|
|
|
|