Improve te panel de control logic
This commit is contained in:
@@ -593,6 +593,105 @@
|
||||
"production_notes": "Planificado para mañana",
|
||||
"quality_notes": null,
|
||||
"equipment_used": ["50000000-0000-0000-0000-000000000001"]
|
||||
},
|
||||
{
|
||||
"id": "40000000-0000-0000-0000-999999999001",
|
||||
"batch_number": "BATCH-TODAY-001",
|
||||
"product_id": "20000000-0000-0000-0000-000000000002",
|
||||
"product_name": "Croissant de Mantequilla Artesanal",
|
||||
"recipe_id": "30000000-0000-0000-0000-000000000002",
|
||||
"planned_start_offset_days": 0,
|
||||
"planned_start_hour": 6,
|
||||
"planned_start_minute": 0,
|
||||
"planned_duration_minutes": 240,
|
||||
"planned_quantity": 120.0,
|
||||
"actual_quantity": null,
|
||||
"status": "PENDING",
|
||||
"priority": "HIGH",
|
||||
"current_process_stage": null,
|
||||
"yield_percentage": null,
|
||||
"quality_score": null,
|
||||
"waste_quantity": null,
|
||||
"defect_quantity": null,
|
||||
"waste_defect_type": null,
|
||||
"estimated_cost": 280.00,
|
||||
"actual_cost": null,
|
||||
"labor_cost": null,
|
||||
"material_cost": null,
|
||||
"overhead_cost": null,
|
||||
"station_id": "STATION-02",
|
||||
"is_rush_order": false,
|
||||
"is_special_recipe": false,
|
||||
"is_ai_assisted": true,
|
||||
"production_notes": "Lote programado para hoy - Demanda prevista alta",
|
||||
"quality_notes": null,
|
||||
"equipment_used": ["50000000-0000-0000-0000-000000000002", "50000000-0000-0000-0000-000000000001"]
|
||||
},
|
||||
{
|
||||
"id": "40000000-0000-0000-0000-999999999002",
|
||||
"batch_number": "BATCH-TODAY-002",
|
||||
"product_id": "20000000-0000-0000-0000-000000000001",
|
||||
"product_name": "Baguette Francesa Tradicional",
|
||||
"recipe_id": "30000000-0000-0000-0000-000000000001",
|
||||
"planned_start_offset_days": 0,
|
||||
"planned_start_hour": 8,
|
||||
"planned_start_minute": 30,
|
||||
"planned_duration_minutes": 165,
|
||||
"planned_quantity": 100.0,
|
||||
"actual_quantity": null,
|
||||
"status": "PENDING",
|
||||
"priority": "MEDIUM",
|
||||
"current_process_stage": null,
|
||||
"yield_percentage": null,
|
||||
"quality_score": null,
|
||||
"waste_quantity": null,
|
||||
"defect_quantity": null,
|
||||
"waste_defect_type": null,
|
||||
"estimated_cost": 150.00,
|
||||
"actual_cost": null,
|
||||
"labor_cost": null,
|
||||
"material_cost": null,
|
||||
"overhead_cost": null,
|
||||
"station_id": "STATION-01",
|
||||
"is_rush_order": false,
|
||||
"is_special_recipe": false,
|
||||
"is_ai_assisted": true,
|
||||
"production_notes": "Producción diaria programada",
|
||||
"quality_notes": null,
|
||||
"equipment_used": ["50000000-0000-0000-0000-000000000001"]
|
||||
},
|
||||
{
|
||||
"id": "40000000-0000-0000-0000-999999999003",
|
||||
"batch_number": "BATCH-TODAY-003",
|
||||
"product_id": "20000000-0000-0000-0000-000000000003",
|
||||
"product_name": "Pan de Pueblo con Masa Madre",
|
||||
"recipe_id": "30000000-0000-0000-0000-000000000003",
|
||||
"planned_start_offset_days": 0,
|
||||
"planned_start_hour": 10,
|
||||
"planned_start_minute": 0,
|
||||
"planned_duration_minutes": 300,
|
||||
"planned_quantity": 60.0,
|
||||
"actual_quantity": null,
|
||||
"status": "PENDING",
|
||||
"priority": "MEDIUM",
|
||||
"current_process_stage": null,
|
||||
"yield_percentage": null,
|
||||
"quality_score": null,
|
||||
"waste_quantity": null,
|
||||
"defect_quantity": null,
|
||||
"waste_defect_type": null,
|
||||
"estimated_cost": 180.00,
|
||||
"actual_cost": null,
|
||||
"labor_cost": null,
|
||||
"material_cost": null,
|
||||
"overhead_cost": null,
|
||||
"station_id": "STATION-01",
|
||||
"is_rush_order": false,
|
||||
"is_special_recipe": true,
|
||||
"is_ai_assisted": true,
|
||||
"production_notes": "Masa madre preparada ayer - Listo para horneado",
|
||||
"quality_notes": null,
|
||||
"equipment_used": ["50000000-0000-0000-0000-000000000001"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ DEMO_TENANT_SAN_PABLO = uuid.UUID("a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6") # Ind
|
||||
DEMO_TENANT_LA_ESPIGA = uuid.UUID("b2c3d4e5-f6a7-48b9-c0d1-e2f3a4b5c6d7") # Central bakery
|
||||
|
||||
# Base reference date for date calculations
|
||||
# MUST match shared/utils/demo_dates.py for proper demo session cloning
|
||||
# This fixed date allows demo sessions to adjust all dates relative to session creation time
|
||||
BASE_REFERENCE_DATE = datetime(2025, 1, 15, 12, 0, 0, tzinfo=timezone.utc)
|
||||
|
||||
|
||||
@@ -140,7 +142,19 @@ async def seed_batches_for_tenant(
|
||||
actual_end = actual_start + timedelta(minutes=actual_duration)
|
||||
completed_at = actual_end
|
||||
elif batch_data["status"] == "IN_PROGRESS":
|
||||
actual_start = planned_start
|
||||
# For IN_PROGRESS batches, set actual_start to a recent time to ensure valid progress calculation
|
||||
# If planned_start is in the past, use it; otherwise, set to 30 minutes ago
|
||||
now = datetime.now(timezone.utc)
|
||||
if planned_start < now:
|
||||
# If planned start was in the past, use a time that ensures batch is ~30% complete
|
||||
elapsed_time_minutes = min(
|
||||
int(batch_data["planned_duration_minutes"] * 0.3),
|
||||
int((now - planned_start).total_seconds() / 60)
|
||||
)
|
||||
actual_start = now - timedelta(minutes=elapsed_time_minutes)
|
||||
else:
|
||||
# If planned_start is in the future, start batch 30 minutes ago
|
||||
actual_start = now - timedelta(minutes=30)
|
||||
actual_duration = None
|
||||
actual_end = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user