Improve the frontend 3
This commit is contained in:
@@ -12,7 +12,6 @@ from sqlalchemy import text
|
||||
from app.core.config import settings
|
||||
from app.core.database import database_manager
|
||||
from app.services.production_alert_service import ProductionAlertService
|
||||
from app.services.production_scheduler_service import ProductionSchedulerService
|
||||
from shared.service_base import StandardFastAPIService
|
||||
|
||||
# Import standardized routers
|
||||
@@ -24,7 +23,8 @@ from app.api import (
|
||||
analytics,
|
||||
quality_templates,
|
||||
equipment,
|
||||
internal_demo
|
||||
internal_demo,
|
||||
orchestrator # NEW: Orchestrator integration endpoint
|
||||
)
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class ProductionService(StandardFastAPIService):
|
||||
]
|
||||
|
||||
self.alert_service = None
|
||||
self.scheduler_service = None
|
||||
# REMOVED: scheduler_service (replaced by Orchestrator Service)
|
||||
|
||||
# Create custom checks for services
|
||||
async def check_alert_service():
|
||||
@@ -71,14 +71,6 @@ class ProductionService(StandardFastAPIService):
|
||||
self.logger.error("Alert service health check failed", error=str(e))
|
||||
return False
|
||||
|
||||
async def check_scheduler_service():
|
||||
"""Check production scheduler service health"""
|
||||
try:
|
||||
return bool(self.scheduler_service) if self.scheduler_service else False
|
||||
except Exception as e:
|
||||
self.logger.error("Scheduler service health check failed", error=str(e))
|
||||
return False
|
||||
|
||||
super().__init__(
|
||||
service_name=settings.SERVICE_NAME,
|
||||
app_name=settings.APP_NAME,
|
||||
@@ -88,8 +80,7 @@ class ProductionService(StandardFastAPIService):
|
||||
database_manager=database_manager,
|
||||
expected_tables=production_expected_tables,
|
||||
custom_health_checks={
|
||||
"alert_service": check_alert_service,
|
||||
"scheduler_service": check_scheduler_service
|
||||
"alert_service": check_alert_service
|
||||
}
|
||||
)
|
||||
|
||||
@@ -100,22 +91,15 @@ class ProductionService(StandardFastAPIService):
|
||||
await self.alert_service.start()
|
||||
self.logger.info("Production alert service started")
|
||||
|
||||
# Initialize production scheduler service
|
||||
self.scheduler_service = ProductionSchedulerService(settings)
|
||||
await self.scheduler_service.start()
|
||||
self.logger.info("Production scheduler service started")
|
||||
# REMOVED: Production scheduler service initialization
|
||||
# Scheduling is now handled by the Orchestrator Service
|
||||
# which calls our /generate-schedule endpoint
|
||||
|
||||
# Store services in app state
|
||||
app.state.alert_service = self.alert_service
|
||||
app.state.scheduler_service = self.scheduler_service
|
||||
|
||||
async def on_shutdown(self, app: FastAPI):
|
||||
"""Custom startup logic for production service"""
|
||||
# Stop scheduler service
|
||||
if self.scheduler_service:
|
||||
await self.scheduler_service.stop()
|
||||
self.logger.info("Scheduler service stopped")
|
||||
|
||||
"""Custom shutdown logic for production service"""
|
||||
# Stop alert service
|
||||
if self.alert_service:
|
||||
await self.alert_service.stop()
|
||||
@@ -127,7 +111,7 @@ class ProductionService(StandardFastAPIService):
|
||||
"production_planning",
|
||||
"batch_management",
|
||||
"production_scheduling",
|
||||
"automated_daily_scheduling", # NEW: Automated scheduler
|
||||
"orchestrator_integration", # NEW: Orchestrator-driven scheduling
|
||||
"quality_control",
|
||||
"equipment_management",
|
||||
"capacity_planning",
|
||||
@@ -166,6 +150,7 @@ service.setup_custom_middleware()
|
||||
|
||||
# Include standardized routers
|
||||
# NOTE: Register more specific routes before generic parameterized routes
|
||||
service.add_router(orchestrator.router) # NEW: Orchestrator integration endpoint
|
||||
service.add_router(quality_templates.router) # Register first to avoid route conflicts
|
||||
service.add_router(equipment.router)
|
||||
service.add_router(production_batches.router)
|
||||
@@ -175,20 +160,8 @@ service.add_router(production_dashboard.router)
|
||||
service.add_router(analytics.router)
|
||||
service.add_router(internal_demo.router)
|
||||
|
||||
|
||||
@app.post("/test/production-scheduler")
|
||||
async def test_production_scheduler():
|
||||
"""Test endpoint to manually trigger production scheduler"""
|
||||
try:
|
||||
if hasattr(app.state, 'scheduler_service'):
|
||||
scheduler_service = app.state.scheduler_service
|
||||
await scheduler_service.test_production_schedule_generation()
|
||||
return {"message": "Production scheduler test triggered successfully"}
|
||||
else:
|
||||
return {"error": "Scheduler service not available"}
|
||||
except Exception as e:
|
||||
service.logger.error("Error testing production scheduler", error=str(e))
|
||||
return {"error": f"Failed to trigger scheduler test: {str(e)}"}
|
||||
# REMOVED: test_production_scheduler endpoint
|
||||
# Production scheduling is now triggered by the Orchestrator Service
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user