|
|
|
|
@ -26,7 +26,7 @@ async def get_all_budget_constrains(
|
|
|
|
|
"""Get all overhaul overview with EAF values that sum to 100%."""
|
|
|
|
|
calc_result = simulation_result['calc_result']
|
|
|
|
|
plant_result = simulation_result['plant_result']
|
|
|
|
|
plot_result = simulation_result['plot_result']
|
|
|
|
|
# plot_result = simulation_result['plot_result']
|
|
|
|
|
|
|
|
|
|
equipments = await get_standard_scope_by_session_id(
|
|
|
|
|
db_session=db_session,
|
|
|
|
|
@ -47,16 +47,15 @@ async def get_all_budget_constrains(
|
|
|
|
|
equipments_eaf_contribution = calculate_asset_eaf_contributions(
|
|
|
|
|
plant_result=plant_result,
|
|
|
|
|
eq_results=eq_results,
|
|
|
|
|
plot_result=plot_result
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Create result array of dictionaries
|
|
|
|
|
result = [
|
|
|
|
|
{
|
|
|
|
|
"id": equipment.id,
|
|
|
|
|
"assetnum": equipment.assetnum,
|
|
|
|
|
"location_tag": equipment.equipment.location_tag,
|
|
|
|
|
"name": equipment.equipment.name,
|
|
|
|
|
"location_tag": equipment.location_tag,
|
|
|
|
|
"name": equipment.equipment_name,
|
|
|
|
|
"total_cost": equipment.overhaul_cost + equipment.service_cost,
|
|
|
|
|
"eaf_contribution": equipments_eaf_contribution.get(equipment.location_tag, 0)
|
|
|
|
|
}
|
|
|
|
|
@ -87,19 +86,19 @@ async def get_all_budget_constrains(
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def calculate_asset_eaf_contributions(plant_result, eq_results, plot_result):
|
|
|
|
|
def calculate_asset_eaf_contributions(plant_result, eq_results):
|
|
|
|
|
"""
|
|
|
|
|
Calculate each asset's negative contribution to plant EAF
|
|
|
|
|
Higher contribution = more impact on reducing plant EAF
|
|
|
|
|
"""
|
|
|
|
|
plant_production = plant_result.get('production', 0)
|
|
|
|
|
results = defaultdict(list)
|
|
|
|
|
results = defaultdict(float)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for asset in eq_results:
|
|
|
|
|
# Weight based on production capacity
|
|
|
|
|
capacity_weight = asset.get('production', 0) / plant_production if plant_productions > 0 else 0
|
|
|
|
|
plot_data = next((item for item in plot_result if item['aeros_node']['node_name'] == asset['aeros_node']['node_name']), None)
|
|
|
|
|
capacity_weight = asset.get('production', 0) / plant_production if plant_production > 0 else 0
|
|
|
|
|
# plot_data = next((item for item in plot_result if item['aeros_node']['node_name'] == asset['aeros_node']['node_name']), None)
|
|
|
|
|
|
|
|
|
|
# Get asset EAF and downtime
|
|
|
|
|
asset_eaf = asset.get('eaf', 0)
|
|
|
|
|
@ -113,8 +112,8 @@ def calculate_asset_eaf_contributions(plant_result, eq_results, plot_result):
|
|
|
|
|
sim_duration = plant_result.get('sim_duration', 8760) # Default to 1 year
|
|
|
|
|
downtime_hours = (asset_derating_pct / 100) * sim_duration
|
|
|
|
|
|
|
|
|
|
results[asset['aeros_node']['node_name']] = eaf_contribution
|
|
|
|
|
results[asset['aeros_node']['node_name']] = round(eaf_contribution)
|
|
|
|
|
|
|
|
|
|
# Sort by contribution (worst contributors first)
|
|
|
|
|
results = sorted(results.items(), key=lambda x: x[1], reverse=True)
|
|
|
|
|
# results = sorted(results.items(), key=lambda x: x[1], reverse=True)
|
|
|
|
|
return results
|