Improve the frontend 3
This commit is contained in:
@@ -26,6 +26,66 @@ class ProductionServiceClient(BaseServiceClient):
|
||||
# PRODUCTION PLANNING
|
||||
# ================================================================
|
||||
|
||||
async def generate_schedule(
|
||||
self,
|
||||
tenant_id: str,
|
||||
forecast_data: Dict[str, Any],
|
||||
inventory_data: Optional[Dict[str, Any]] = None,
|
||||
recipes_data: Optional[Dict[str, Any]] = None,
|
||||
target_date: Optional[str] = None,
|
||||
planning_horizon_days: int = 1
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
Generate production schedule (called by Orchestrator).
|
||||
|
||||
Args:
|
||||
tenant_id: Tenant ID
|
||||
forecast_data: Forecast data from forecasting service
|
||||
inventory_data: Optional inventory snapshot (NEW - to avoid duplicate fetching)
|
||||
recipes_data: Optional recipes snapshot (NEW - to avoid duplicate fetching)
|
||||
target_date: Optional target date
|
||||
planning_horizon_days: Number of days to plan
|
||||
|
||||
Returns:
|
||||
Dict with schedule_id, batches_created, etc.
|
||||
"""
|
||||
try:
|
||||
request_data = {
|
||||
"forecast_data": forecast_data,
|
||||
"target_date": target_date,
|
||||
"planning_horizon_days": planning_horizon_days
|
||||
}
|
||||
|
||||
# NEW: Include cached data if provided
|
||||
if inventory_data:
|
||||
request_data["inventory_data"] = inventory_data
|
||||
if recipes_data:
|
||||
request_data["recipes_data"] = recipes_data
|
||||
|
||||
result = await self.post(
|
||||
"production/generate-schedule",
|
||||
data=request_data,
|
||||
tenant_id=tenant_id
|
||||
)
|
||||
|
||||
if result:
|
||||
logger.info(
|
||||
"Generated production schedule",
|
||||
schedule_id=result.get('schedule_id'),
|
||||
batches_created=result.get('batches_created', 0),
|
||||
tenant_id=tenant_id
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
"Error generating production schedule",
|
||||
error=str(e),
|
||||
tenant_id=tenant_id
|
||||
)
|
||||
return None
|
||||
|
||||
async def get_production_requirements(self, tenant_id: str, date: Optional[str] = None) -> Optional[Dict[str, Any]]:
|
||||
"""Get production requirements for procurement planning"""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user