|
|
|
@ -27,7 +27,7 @@ from .schema import (OverhaulActivityCreate, OverhaulActivityRead,
|
|
|
|
|
|
|
|
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
from src.database.core import CollectorDbSession
|
|
|
|
from src.database.core import CollectorDbSession
|
|
|
|
from src.maximo.service import get_cm_cost_summary
|
|
|
|
from src.maximo.service import get_cm_cost_summary, get_oh_cost_summary
|
|
|
|
|
|
|
|
|
|
|
|
async def get(
|
|
|
|
async def get(
|
|
|
|
*, db_session: DbSession, assetnum: str, overhaul_session_id: Optional[UUID] = None
|
|
|
|
*, db_session: DbSession, assetnum: str, overhaul_session_id: Optional[UUID] = None
|
|
|
|
@ -108,6 +108,7 @@ async def get_all(
|
|
|
|
|
|
|
|
|
|
|
|
material_cost = await get_cm_cost_summary(collector_db=collector_db, last_oh_date=prev_oh_scope.end_date, upcoming_oh_date=overhaul.start_date)
|
|
|
|
material_cost = await get_cm_cost_summary(collector_db=collector_db, last_oh_date=prev_oh_scope.end_date, upcoming_oh_date=overhaul.start_date)
|
|
|
|
service_cost = get_service_cost(scope=overhaul.maintenance_type.name, total_equipment=num_equipments)
|
|
|
|
service_cost = get_service_cost(scope=overhaul.maintenance_type.name, total_equipment=num_equipments)
|
|
|
|
|
|
|
|
overhaul_cost = await get_oh_cost_summary(collector_db=collector_db, last_oh_date=prev_oh_scope.end_date, upcoming_oh_date=overhaul.start_date)
|
|
|
|
|
|
|
|
|
|
|
|
equipments = await search_filter_sort_paginate(model=query, **common)
|
|
|
|
equipments = await search_filter_sort_paginate(model=query, **common)
|
|
|
|
data = equipments['items']
|
|
|
|
data = equipments['items']
|
|
|
|
@ -120,11 +121,13 @@ async def get_all(
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
cost = material_cost.get(equipment.location_tag, 0)
|
|
|
|
cost = material_cost.get(equipment.location_tag, 0)
|
|
|
|
|
|
|
|
oh_cost = overhaul_cost.get(equipment.location_tag, 0)
|
|
|
|
|
|
|
|
|
|
|
|
res = OverhaulActivityRead(
|
|
|
|
res = OverhaulActivityRead(
|
|
|
|
id=equipment.id,
|
|
|
|
id=equipment.id,
|
|
|
|
material_cost=float(cost),
|
|
|
|
material_cost=float(cost),
|
|
|
|
service_cost=float(service_cost),
|
|
|
|
service_cost=float(service_cost),
|
|
|
|
|
|
|
|
overhaul_cost=float(oh_cost),
|
|
|
|
location_tag=equipment.location_tag,
|
|
|
|
location_tag=equipment.location_tag,
|
|
|
|
equipment_name=equipment.master_equipment.name if equipment.master_equipment else None,
|
|
|
|
equipment_name=equipment.master_equipment.name if equipment.master_equipment else None,
|
|
|
|
oh_scope=overhaul.maintenance_type.name,
|
|
|
|
oh_scope=overhaul.maintenance_type.name,
|
|
|
|
@ -161,14 +164,16 @@ async def get_standard_scope_by_session_id(*, db_session: DbSession, overhaul_se
|
|
|
|
results = []
|
|
|
|
results = []
|
|
|
|
material_cost = await get_cm_cost_summary(collector_db=collector_db, last_oh_date=prev_oh_scope.end_date, upcoming_oh_date=overhaul.start_date)
|
|
|
|
material_cost = await get_cm_cost_summary(collector_db=collector_db, last_oh_date=prev_oh_scope.end_date, upcoming_oh_date=overhaul.start_date)
|
|
|
|
service_cost = get_service_cost(scope=overhaul.maintenance_type.name, total_equipment=len(eqs))
|
|
|
|
service_cost = get_service_cost(scope=overhaul.maintenance_type.name, total_equipment=len(eqs))
|
|
|
|
|
|
|
|
overhaul_cost = await get_oh_cost_summary(collector_db=collector_db, last_oh_date=prev_oh_scope.end_date, upcoming_oh_date=overhaul.start_date)
|
|
|
|
|
|
|
|
|
|
|
|
for equipment in eqs:
|
|
|
|
for equipment in eqs:
|
|
|
|
cost = material_cost.get(equipment.location_tag,0)
|
|
|
|
cost = material_cost.get(equipment.location_tag,0)
|
|
|
|
|
|
|
|
oh_cost = overhaul_cost.get(equipment.location_tag,0)
|
|
|
|
res = OverhaulActivityRead(
|
|
|
|
res = OverhaulActivityRead(
|
|
|
|
id=equipment.id,
|
|
|
|
id=equipment.id,
|
|
|
|
material_cost=float(cost),
|
|
|
|
material_cost=float(cost),
|
|
|
|
service_cost=float(service_cost),
|
|
|
|
service_cost=float(service_cost),
|
|
|
|
|
|
|
|
overhaul_cost=float(oh_cost),
|
|
|
|
location_tag=equipment.location_tag,
|
|
|
|
location_tag=equipment.location_tag,
|
|
|
|
equipment_name=equipment.master_equipment.name if equipment.master_equipment else None,
|
|
|
|
equipment_name=equipment.master_equipment.name if equipment.master_equipment else None,
|
|
|
|
oh_scope=overhaul.maintenance_type.name,
|
|
|
|
oh_scope=overhaul.maintenance_type.name,
|
|
|
|
|