|
|
|
@ -514,6 +514,7 @@ async def get_forecast_eaf(
|
|
|
|
|
|
|
|
|
|
|
|
# 2. Determine Last Overhaul Date from Master Data
|
|
|
|
# 2. Determine Last Overhaul Date from Master Data
|
|
|
|
oh_record = await _get_or_create_master_data(db_session, "Last Overhaul Date", 0)
|
|
|
|
oh_record = await _get_or_create_master_data(db_session, "Last Overhaul Date", 0)
|
|
|
|
|
|
|
|
next_oh = await _get_or_create_master_data(db_session, "Next Overhaul Date", 0)
|
|
|
|
|
|
|
|
|
|
|
|
# If not set, use a fallback (e.g., start of current year)
|
|
|
|
# If not set, use a fallback (e.g., start of current year)
|
|
|
|
if not oh_record.value_string:
|
|
|
|
if not oh_record.value_string:
|
|
|
|
@ -524,9 +525,11 @@ async def get_forecast_eaf(
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
# Ensure oh_date is naive
|
|
|
|
# Ensure oh_date is naive
|
|
|
|
oh_date = datetime.fromisoformat(oh_date_str).replace(tzinfo=None)
|
|
|
|
oh_date = datetime.fromisoformat(oh_date_str).replace(tzinfo=None)
|
|
|
|
|
|
|
|
next_oh_date = datetime.fromisoformat(next_oh.value_string).replace(tzinfo=None)
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
oh_date = datetime(now.year, 1, 1).replace(tzinfo=None)
|
|
|
|
oh_date = datetime(now.year, 1, 1).replace(tzinfo=None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
oh_interval = hours_between(oh_date, next_oh_date)
|
|
|
|
duration = 168 if time_range == "weekly" else 720
|
|
|
|
duration = 168 if time_range == "weekly" else 720
|
|
|
|
end_date = now + timedelta(hours=duration)
|
|
|
|
end_date = now + timedelta(hours=duration)
|
|
|
|
duration_simulation = hours_between(oh_date, end_date)
|
|
|
|
duration_simulation = hours_between(oh_date, end_date)
|
|
|
|
@ -541,7 +544,8 @@ async def get_forecast_eaf(
|
|
|
|
OffSet=0,
|
|
|
|
OffSet=0,
|
|
|
|
SimSeed=1,
|
|
|
|
SimSeed=1,
|
|
|
|
SimNumRun=1,
|
|
|
|
SimNumRun=1,
|
|
|
|
IsDefault=False
|
|
|
|
IsDefault=False,
|
|
|
|
|
|
|
|
OverhaulInterval=oh_interval
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# 6. Initialize Simulation in DB
|
|
|
|
# 6. Initialize Simulation in DB
|
|
|
|
|