|
|
|
@ -1,11 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from datetime import datetime
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
from typing import Any, Dict
|
|
|
|
from typing import Any, Dict
|
|
|
|
from fastapi import HTTPException
|
|
|
|
from fastapi import HTTPException
|
|
|
|
import httpx
|
|
|
|
import httpx
|
|
|
|
from starlette.config import Config
|
|
|
|
from starlette.config import Config
|
|
|
|
from src.config import config
|
|
|
|
from src.config import MAXIMO_API_KEY, MAXIMO_BASE_URL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MaximoDataMapper:
|
|
|
|
class MaximoDataMapper:
|
|
|
|
@ -69,18 +69,56 @@ class MaximoDataMapper:
|
|
|
|
cost = self.data.get('totalCost', 0)
|
|
|
|
cost = self.data.get('totalCost', 0)
|
|
|
|
return float(cost)
|
|
|
|
return float(cost)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_scope_name(self) -> str:
|
|
|
|
|
|
|
|
scope_name = self.data.get('location', "A")
|
|
|
|
|
|
|
|
return scope_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MaximoService:
|
|
|
|
class MaximoService:
|
|
|
|
def __init__(self):
|
|
|
|
def __init__(self):
|
|
|
|
# TODO: Update these settings based on actual MAXIMO API configuration
|
|
|
|
# TODO: Update these settings based on actual MAXIMO API configuration
|
|
|
|
self.base_url = config.get("MAXIMO_BASE_URL")
|
|
|
|
self.base_url = MAXIMO_BASE_URL
|
|
|
|
self.api_key = config.get("MAXIMO_API_KEY")
|
|
|
|
self.api_key = MAXIMO_API_KEY
|
|
|
|
|
|
|
|
|
|
|
|
async def get_recent_overhaul(self) -> dict:
|
|
|
|
async def get_recent_overhaul(self) -> dict:
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Fetch most recent overhaul from MAXIMO.
|
|
|
|
Fetch most recent overhaul from MAXIMO.
|
|
|
|
TODO: Update this method based on actual MAXIMO API endpoints and parameters
|
|
|
|
TODO: Update this method based on actual MAXIMO API endpoints and parameters
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
current_date = datetime.now()
|
|
|
|
|
|
|
|
schedule_start = current_date + \
|
|
|
|
|
|
|
|
timedelta(days=30) # Starting in 30 days
|
|
|
|
|
|
|
|
schedule_end = schedule_start + \
|
|
|
|
|
|
|
|
timedelta(days=90) # 90 day overhaul period
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
"scheduleStart": schedule_start.isoformat(),
|
|
|
|
|
|
|
|
"scheduleEnd": schedule_end.isoformat(),
|
|
|
|
|
|
|
|
"workOrderId": "WO-2024-12345",
|
|
|
|
|
|
|
|
"status": "PLAN", # Common Maximo statuses: SCHEDULED, INPRG, COMP, CLOSE
|
|
|
|
|
|
|
|
"totalCost": 10000000.00,
|
|
|
|
|
|
|
|
"description": "Annual Turbine Overhaul",
|
|
|
|
|
|
|
|
"priority": 1,
|
|
|
|
|
|
|
|
"location": "A",
|
|
|
|
|
|
|
|
"assetDetails": [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"assetnum": "ASSET001",
|
|
|
|
|
|
|
|
"description": "Gas Turbine",
|
|
|
|
|
|
|
|
"status": "OPERATING"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"assetnum": "ASSET002",
|
|
|
|
|
|
|
|
"description": "Steam Turbine",
|
|
|
|
|
|
|
|
"status": "OPERATING"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
"workType": "OH", # OH for Overhaul
|
|
|
|
|
|
|
|
"createdBy": "MAXADMIN",
|
|
|
|
|
|
|
|
"createdDate": (current_date - timedelta(days=10)).isoformat(),
|
|
|
|
|
|
|
|
"lastModifiedBy": "MAXADMIN",
|
|
|
|
|
|
|
|
"lastModifiedDate": current_date.isoformat()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async with httpx.AsyncClient() as client:
|
|
|
|
async with httpx.AsyncClient() as client:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
# TODO: Update endpoint and parameters based on actual MAXIMO API
|
|
|
|
# TODO: Update endpoint and parameters based on actual MAXIMO API
|
|
|
|
|