|
|
|
@ -4,7 +4,7 @@ from uuid import uuid4, uuid4, UUID
|
|
|
|
import logging
|
|
|
|
import logging
|
|
|
|
import httpx
|
|
|
|
import httpx
|
|
|
|
from fastapi import HTTPException, status
|
|
|
|
from fastapi import HTTPException, status
|
|
|
|
from sqlalchemy import delete, select, update
|
|
|
|
from sqlalchemy import delete, select, update, and_
|
|
|
|
from sqlalchemy.orm import selectinload
|
|
|
|
from sqlalchemy.orm import selectinload
|
|
|
|
|
|
|
|
|
|
|
|
from src.config import AEROS_BASE_URL, DEFAULT_PROJECT_NAME
|
|
|
|
from src.config import AEROS_BASE_URL, DEFAULT_PROJECT_NAME
|
|
|
|
@ -22,7 +22,9 @@ from .model import (
|
|
|
|
AerosSimulationPlotResult,
|
|
|
|
AerosSimulationPlotResult,
|
|
|
|
AerosSchematic
|
|
|
|
AerosSchematic
|
|
|
|
)
|
|
|
|
)
|
|
|
|
from .schema import SimulationInput
|
|
|
|
from src.aeros_equipment.model import AerosEquipment, AerosEquipmentCustomParameterData
|
|
|
|
|
|
|
|
from src.aeros_equipment.schema import EquipmentWithCustomParameters
|
|
|
|
|
|
|
|
from .schema import SimulationInput, SimulationRankingParameters
|
|
|
|
|
|
|
|
|
|
|
|
client = httpx.AsyncClient(timeout=300.0)
|
|
|
|
client = httpx.AsyncClient(timeout=300.0)
|
|
|
|
active_simulations = {}
|
|
|
|
active_simulations = {}
|
|
|
|
@ -489,7 +491,6 @@ async def get_simulation_with_calc_result(
|
|
|
|
query = (select(AerosSimulationCalcResult).filter(
|
|
|
|
query = (select(AerosSimulationCalcResult).filter(
|
|
|
|
AerosSimulationCalcResult.aeros_simulation_id == simulation_id))
|
|
|
|
AerosSimulationCalcResult.aeros_simulation_id == simulation_id))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if schematic_name:
|
|
|
|
if schematic_name:
|
|
|
|
if schematic_name == "WTP":
|
|
|
|
if schematic_name == "WTP":
|
|
|
|
query = query.join(
|
|
|
|
query = query.join(
|
|
|
|
@ -512,24 +513,39 @@ async def get_simulation_with_calc_result(
|
|
|
|
|
|
|
|
|
|
|
|
async def get_result_ranking(*, db_session: DbSession, simulation_id: UUID):
|
|
|
|
async def get_result_ranking(*, db_session: DbSession, simulation_id: UUID):
|
|
|
|
|
|
|
|
|
|
|
|
query = select(AerosSimulationCalcResult).where(
|
|
|
|
query = select(AerosEquipment, AerosSimulationCalcResult.eaf).join(AerosNode, AerosNode.node_name == AerosEquipment.node_name).join(AerosSimulationCalcResult, AerosSimulationCalcResult.aeros_node_id == AerosNode.id)
|
|
|
|
AerosSimulationCalcResult.aeros_simulation_id == simulation_id
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
query = query.join(
|
|
|
|
query = query.filter(
|
|
|
|
AerosNode, AerosNode.id == AerosSimulationCalcResult.aeros_node_id
|
|
|
|
and_(
|
|
|
|
|
|
|
|
AerosSimulationCalcResult.aeros_simulation_id == simulation_id,
|
|
|
|
|
|
|
|
AerosNode.node_type == "RegularNode",
|
|
|
|
|
|
|
|
AerosEquipment.custom_parameters.any()
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
query = query.where(AerosNode.node_type == "RegularNode")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
query = query.order_by(AerosSimulationCalcResult.eaf.desc()).limit(10)
|
|
|
|
query = query.order_by(AerosSimulationCalcResult.eaf.desc()).limit(10)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
query = query.options(
|
|
|
|
query = query.options(
|
|
|
|
selectinload(AerosSimulationCalcResult.aeros_node))
|
|
|
|
selectinload(AerosEquipment.custom_parameters)).options(
|
|
|
|
|
|
|
|
selectinload(AerosEquipment.master_equipment)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
result = await db_session.execute(query)
|
|
|
|
result = await db_session.execute(query)
|
|
|
|
|
|
|
|
|
|
|
|
return result.scalars().all()
|
|
|
|
data = [
|
|
|
|
|
|
|
|
SimulationRankingParameters(
|
|
|
|
|
|
|
|
location_tag=equipment.location_tag,
|
|
|
|
|
|
|
|
master_equipment=equipment.master_equipment,
|
|
|
|
|
|
|
|
custom_parameters=equipment.custom_parameters,
|
|
|
|
|
|
|
|
eaf=eaf
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
for equipment, eaf in result
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def get_simulation_with_plot_result(
|
|
|
|
async def get_simulation_with_plot_result(
|
|
|
|
|