New alert service
This commit is contained in:
@@ -39,7 +39,7 @@ from typing import List, Dict, Any
|
||||
# Add project root to path
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent.parent.parent))
|
||||
|
||||
from shared.messaging.rabbitmq import RabbitMQClient
|
||||
from shared.messaging import RabbitMQClient
|
||||
from shared.schemas.alert_types import AlertTypeConstants
|
||||
import structlog
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ from pathlib import Path
|
||||
# Add project root to path
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent.parent.parent))
|
||||
|
||||
from shared.messaging.rabbitmq import RabbitMQClient
|
||||
from shared.messaging import RabbitMQClient
|
||||
import structlog
|
||||
|
||||
logger = structlog.get_logger()
|
||||
@@ -65,7 +65,17 @@ DEMO_ALERTS = [
|
||||
'minimum_stock': 200,
|
||||
'unit': 'kg',
|
||||
'supplier_name': 'Harinera San José',
|
||||
'last_order_date': (datetime.utcnow() - timedelta(days=7)).isoformat()
|
||||
'last_order_date': (datetime.utcnow() - timedelta(days=7)).isoformat(),
|
||||
'i18n': {
|
||||
'title_key': 'alerts.low_stock_warning.title',
|
||||
'message_key': 'alerts.low_stock_warning.message_generic',
|
||||
'title_params': {'ingredient_name': 'Harina Tipo 55'},
|
||||
'message_params': {
|
||||
'ingredient_name': 'Harina Tipo 55',
|
||||
'current_stock': 45,
|
||||
'minimum_stock': 200
|
||||
}
|
||||
}
|
||||
},
|
||||
'timestamp': datetime.utcnow().isoformat()
|
||||
},
|
||||
@@ -94,7 +104,19 @@ DEMO_ALERTS = [
|
||||
'financial_impact_eur': 450,
|
||||
'deadline': (datetime.utcnow() + timedelta(hours=6)).isoformat(),
|
||||
'quantity_needed': 15,
|
||||
'unit': 'kg'
|
||||
'unit': 'kg',
|
||||
'i18n': {
|
||||
'title_key': 'alerts.supplier_delay.title',
|
||||
'message_key': 'alerts.supplier_delay.message',
|
||||
'title_params': {'supplier_name': 'Levadura Fresh'},
|
||||
'message_params': {
|
||||
'supplier_name': 'Levadura Fresh',
|
||||
'ingredient_name': 'Levadura Fresca',
|
||||
'po_id': 'PO-DEMO-123',
|
||||
'new_delivery_date': (datetime.utcnow() + timedelta(hours=24)).strftime('%Y-%m-%d'),
|
||||
'original_delivery_date': (datetime.utcnow() - timedelta(hours=24)).strftime('%Y-%m-%d')
|
||||
}
|
||||
}
|
||||
},
|
||||
'timestamp': datetime.utcnow().isoformat()
|
||||
},
|
||||
@@ -127,7 +149,18 @@ DEMO_ALERTS = [
|
||||
{'day': 'Wed', 'waste_pct': 23},
|
||||
{'day': 'Thu', 'waste_pct': 8},
|
||||
{'day': 'Fri', 'waste_pct': 6}
|
||||
]
|
||||
],
|
||||
'i18n': {
|
||||
'title_key': 'alerts.waste_trend.title',
|
||||
'message_key': 'alerts.waste_trend.message',
|
||||
'title_params': {'product_name': 'Croissant Mantequilla'},
|
||||
'message_params': {
|
||||
'product_name': 'Croissant Mantequilla',
|
||||
'spike_percent': 15,
|
||||
'trend_days': 3,
|
||||
'pattern': 'wednesday_overproduction'
|
||||
}
|
||||
}
|
||||
},
|
||||
'timestamp': datetime.utcnow().isoformat()
|
||||
},
|
||||
@@ -149,7 +182,17 @@ DEMO_ALERTS = [
|
||||
'days_affected': ['2024-11-23', '2024-11-24'],
|
||||
'expected_demand_increase_pct': 15,
|
||||
'confidence': 0.78,
|
||||
'recommended_action': 'Aumentar producción croissants y pan rústico 15%'
|
||||
'recommended_action': 'Aumentar producción croissants y pan rústico 15%',
|
||||
'i18n': {
|
||||
'title_key': 'alerts.demand_surge_weekend.title',
|
||||
'message_key': 'alerts.demand_surge_weekend.message',
|
||||
'title_params': {'weekend_date': (datetime.utcnow() + timedelta(days=1)).strftime('%Y-%m-%d')},
|
||||
'message_params': {
|
||||
'surge_percent': 15,
|
||||
'date': (datetime.utcnow() + timedelta(days=1)).strftime('%Y-%m-%d'),
|
||||
'products': ['croissants', 'pan rustico']
|
||||
}
|
||||
}
|
||||
},
|
||||
'timestamp': datetime.utcnow().isoformat()
|
||||
},
|
||||
@@ -175,7 +218,17 @@ DEMO_ALERTS = [
|
||||
'last_maintenance': (datetime.utcnow() - timedelta(days=90)).isoformat(),
|
||||
'maintenance_interval_days': 90,
|
||||
'supplier_contact': 'TecnoHornos Madrid',
|
||||
'supplier_phone': '+34-555-6789'
|
||||
'supplier_phone': '+34-555-6789',
|
||||
'i18n': {
|
||||
'title_key': 'alerts.maintenance_required.title',
|
||||
'message_key': 'alerts.maintenance_required.message_with_hours',
|
||||
'title_params': {'equipment_name': 'Horno Industrial Principal'},
|
||||
'message_params': {
|
||||
'equipment_name': 'Horno Industrial Principal',
|
||||
'hours_until': 48,
|
||||
'maintenance_date': (datetime.utcnow() + timedelta(hours=48)).strftime('%Y-%m-%d')
|
||||
}
|
||||
}
|
||||
},
|
||||
'timestamp': datetime.utcnow().isoformat()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user