|
|
|
@ -242,6 +242,7 @@ class SparepartRequirement:
|
|
|
|
lead_time: int
|
|
|
|
lead_time: int
|
|
|
|
sparepart_name: str
|
|
|
|
sparepart_name: str
|
|
|
|
unit_cost: float
|
|
|
|
unit_cost: float
|
|
|
|
|
|
|
|
avg_cost: float
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
@dataclass
|
|
|
|
class SparepartStock:
|
|
|
|
class SparepartStock:
|
|
|
|
@ -395,7 +396,7 @@ class SparepartManager:
|
|
|
|
sparepart_id = requirement.sparepart_id
|
|
|
|
sparepart_id = requirement.sparepart_id
|
|
|
|
needed_quantity = requirement.quantity_required
|
|
|
|
needed_quantity = requirement.quantity_required
|
|
|
|
sparepart_name = requirement.sparepart_name
|
|
|
|
sparepart_name = requirement.sparepart_name
|
|
|
|
unit_cost = requirement.unit_cost
|
|
|
|
unit_cost = requirement.avg_cost
|
|
|
|
|
|
|
|
|
|
|
|
current_stock = adjusted_stocks.get(sparepart_id, 0)
|
|
|
|
current_stock = adjusted_stocks.get(sparepart_id, 0)
|
|
|
|
|
|
|
|
|
|
|
|
@ -917,6 +918,12 @@ item_descriptions AS (
|
|
|
|
) as description
|
|
|
|
) as description
|
|
|
|
FROM public.maximo_sparepart_pr_po_line
|
|
|
|
FROM public.maximo_sparepart_pr_po_line
|
|
|
|
WHERE description IS NOT NULL
|
|
|
|
WHERE description IS NOT NULL
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
item_inventory as (
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
|
|
itemnum,
|
|
|
|
|
|
|
|
avgcost
|
|
|
|
|
|
|
|
FROM public.maximo_inventory
|
|
|
|
)
|
|
|
|
)
|
|
|
|
SELECT
|
|
|
|
SELECT
|
|
|
|
lss.asset_location,
|
|
|
|
lss.asset_location,
|
|
|
|
@ -927,6 +934,7 @@ SELECT
|
|
|
|
ROUND(CAST(lss.avg_qty_per_wo AS NUMERIC), 2) as avg_qty_per_wo,
|
|
|
|
ROUND(CAST(lss.avg_qty_per_wo AS NUMERIC), 2) as avg_qty_per_wo,
|
|
|
|
lss.min_qty_used,
|
|
|
|
lss.min_qty_used,
|
|
|
|
lss.max_qty_used,
|
|
|
|
lss.max_qty_used,
|
|
|
|
|
|
|
|
iin.avgcost,
|
|
|
|
-- Lead time metrics
|
|
|
|
-- Lead time metrics
|
|
|
|
COALESCE(lt.avg_leadtime_months, 0) as avg_leadtime_months,
|
|
|
|
COALESCE(lt.avg_leadtime_months, 0) as avg_leadtime_months,
|
|
|
|
COALESCE(lt.min_leadtime_months, 0) as min_leadtime_months,
|
|
|
|
COALESCE(lt.min_leadtime_months, 0) as min_leadtime_months,
|
|
|
|
@ -947,6 +955,7 @@ FROM location_sparepart_stats lss
|
|
|
|
LEFT JOIN item_descriptions id ON lss.itemnum = id.item_num
|
|
|
|
LEFT JOIN item_descriptions id ON lss.itemnum = id.item_num
|
|
|
|
LEFT JOIN leadtime_stats lt ON lss.itemnum = lt.item_num
|
|
|
|
LEFT JOIN leadtime_stats lt ON lss.itemnum = lt.item_num
|
|
|
|
LEFT JOIN cost_stats cs ON lss.itemnum = cs.item_num
|
|
|
|
LEFT JOIN cost_stats cs ON lss.itemnum = cs.item_num
|
|
|
|
|
|
|
|
LEFT JOIN item_inventory iin ON lss.itemnum = iin.itemnum
|
|
|
|
ORDER BY lss.asset_location, lss.itemnum;""")
|
|
|
|
ORDER BY lss.asset_location, lss.itemnum;""")
|
|
|
|
|
|
|
|
|
|
|
|
equipment_requirements_query = await db_session.execute(query)
|
|
|
|
equipment_requirements_query = await db_session.execute(query)
|
|
|
|
@ -958,7 +967,8 @@ ORDER BY lss.asset_location, lss.itemnum;""")
|
|
|
|
quantity_required=float(req_record.avg_qty_per_wo),
|
|
|
|
quantity_required=float(req_record.avg_qty_per_wo),
|
|
|
|
lead_time=float(req_record.avg_leadtime_months),
|
|
|
|
lead_time=float(req_record.avg_leadtime_months),
|
|
|
|
sparepart_name=req_record.item_description,
|
|
|
|
sparepart_name=req_record.item_description,
|
|
|
|
unit_cost=float(req_record.avg_unit_cost)
|
|
|
|
unit_cost=float(req_record.avg_unit_cost),
|
|
|
|
|
|
|
|
avg_cost=float(req_record.avgcost)
|
|
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
equipment_requirements[req_record.asset_location].append(requirement)
|
|
|
|
equipment_requirements[req_record.asset_location].append(requirement)
|
|
|
|
|