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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AICL Example: Warehouse Management System
|
| 2 |
+
# Comprehensive warehouse management platform covering inventory control, pick-pack-ship operations, slotting optimization, labor management, and cross-dock coordination for high-throughput distribution centers
|
| 3 |
+
|
| 4 |
+
Goal: Deliver a warehouse management system that maximizes storage utilization through intelligent slotting, optimizes pick-path efficiency, ensures inventory accuracy through cycle counting and reconciliation, coordinates inbound and outbound logistics, and provides real-time visibility into warehouse operations for workforce and capacity planning
|
| 5 |
+
|
| 6 |
+
Constraint: Inventory movements must maintain lot traceability from receipt through shipment for regulatory compliance
|
| 7 |
+
Constraint: Pick assignments must respect weight limits, hazmat segregation, and product compatibility constraints
|
| 8 |
+
Constraint: Slotting optimization must not reassign active picks or reserved inventory without coordination window
|
| 9 |
+
Constraint: Shipping manifest must match load plan with zero discrepancy before carrier release
|
| 10 |
+
Constraint: Cycle count variances above materiality threshold must trigger root cause investigation before adjustment
|
| 11 |
+
|
| 12 |
+
Risk: Inventory accuracy degradation below 98 percent causing fulfillment errors and customer complaints
|
| 13 |
+
Recovery: Trigger emergency full physical count for affected zones; implement blind recount verification; analyze variance patterns by SKU and location; adjust counting frequency for high-variance items; enforce receiving inspection protocols
|
| 14 |
+
|
| 15 |
+
Risk: Pick-path congestion during peak hours causing throughput bottleneck and missed shipping windows
|
| 16 |
+
Recovery: Implement dynamic pick-wave staggering; activate overflow pick zones; deploy temporary labor augmentation; adjust cartonization logic to reduce partial picks; resequence waves by priority and proximity
|
| 17 |
+
|
| 18 |
+
Risk: Slotting misassignment placing incompatible products in proximity causing contamination or damage
|
| 19 |
+
Recovery: Immediately relocate affected products to quarantine zone; inspect for contamination or damage; validate product compatibility matrix; correct slotting algorithm constraints; audit recent slotting assignments for similar violations
|
| 20 |
+
|
| 21 |
+
Risk: Shipping manifest discrepancy discovered after carrier departure causing delivery and billing errors
|
| 22 |
+
Recovery: Notify carrier of discrepancy with corrected manifest; alert customer service for affected orders; generate supplemental manifest; adjust inventory records; implement pre-ship verification checkpoint enhancement
|
| 23 |
+
|
| 24 |
+
Risk: Receiving dock bottleneck from unplanned inbound volume exceeding staging capacity
|
| 25 |
+
Recovery: Activate overflow receiving area; implement appointment-based receiving schedule; prioritize receipts for backorder fulfillment; deploy cross-dock bypass for pre-allocated items; coordinate with transportation on delivery rescheduling
|
| 26 |
+
|
| 27 |
+
Risk: Labor allocation imbalance between zones causing idle resources in some areas and overtime in others
|
| 28 |
+
Recovery: Implement real-time labor balancing dashboard; cross-train associates for multi-zone flexibility; activate dynamic task interleaving; adjust shift start times based on workload forecast; deploy supervisor reallocation authority
|
| 29 |
+
|
| 30 |
+
Layer: InventoryControl
|
| 31 |
+
SubLayer: StockTracking
|
| 32 |
+
SubLayer: LotManagement
|
| 33 |
+
SubLayer: CycleCounting
|
| 34 |
+
SubLayer: InventoryAdjustment
|
| 35 |
+
|
| 36 |
+
Layer: InboundOperations
|
| 37 |
+
SubLayer: DockScheduling
|
| 38 |
+
SubLayer: Receiving
|
| 39 |
+
SubLayer: Putaway
|
| 40 |
+
SubLayer: CrossDock
|
| 41 |
+
|
| 42 |
+
Layer: OutboundOperations
|
| 43 |
+
SubLayer: OrderWavePlanning
|
| 44 |
+
SubLayer: Picking
|
| 45 |
+
SubLayer: Packing
|
| 46 |
+
SubLayer: Shipping
|
| 47 |
+
|
| 48 |
+
Layer: SlottingOptimization
|
| 49 |
+
SubLayer: VelocityAnalysis
|
| 50 |
+
SubLayer: CompatibilityEngine
|
| 51 |
+
SubLayer: SlotAssignment
|
| 52 |
+
SubLayer: ReplenishmentPlanning
|
| 53 |
+
|
| 54 |
+
Layer: LaborManagement
|
| 55 |
+
SubLayer: WorkforceScheduling
|
| 56 |
+
SubLayer: TaskAssignment
|
| 57 |
+
SubLayer: PerformanceTracking
|
| 58 |
+
SubLayer: TrainingCompliance
|
| 59 |
+
|
| 60 |
+
Validation: All inventory receipts must reference a valid purchase order or transfer order before putaway
|
| 61 |
+
Validation: Pick quantities must exactly match order line quantities with zero tolerance for overpick
|
| 62 |
+
Validation: Packing operations must validate order completeness and generate accurate weight and dimension data
|
| 63 |
+
Validation: Shipping manifests must reconcile all packed cartons against load plan before carrier release
|
| 64 |
+
Validation: Slot assignments must pass product compatibility and physical constraint validation before activation
|
| 65 |
+
Validation: Cycle count adjustments must include root cause codes and supervisor approval for variances exceeding threshold
|
| 66 |
+
|
| 67 |
+
Entity InventoryItem
|
| 68 |
+
sku: string
|
| 69 |
+
productName: string
|
| 70 |
+
category: string
|
| 71 |
+
lotNumber: string
|
| 72 |
+
expirationDate: datetime
|
| 73 |
+
quantityOnHand: float
|
| 74 |
+
quantityReserved: float
|
| 75 |
+
quantityAvailable: float
|
| 76 |
+
locationId: string
|
| 77 |
+
abcVelocity: string
|
| 78 |
+
productGroup: string
|
| 79 |
+
hazmatClass: string
|
| 80 |
+
temperatureRange: dict
|
| 81 |
+
|
| 82 |
+
Entity PickTask
|
| 83 |
+
taskId: string
|
| 84 |
+
waveId: string
|
| 85 |
+
orderId: string
|
| 86 |
+
sku: string
|
| 87 |
+
lotNumber: string
|
| 88 |
+
sourceLocation: string
|
| 89 |
+
targetLocation: string
|
| 90 |
+
pickQuantity: float
|
| 91 |
+
pickedQuantity: float
|
| 92 |
+
assignedTo: string
|
| 93 |
+
priority: integer
|
| 94 |
+
status: string
|
| 95 |
+
createdAt: datetime
|
| 96 |
+
completedAt: datetime
|
| 97 |
+
|
| 98 |
+
Entity SlotAssignment
|
| 99 |
+
slotId: string
|
| 100 |
+
warehouseCode: string
|
| 101 |
+
zone: string
|
| 102 |
+
aisle: string
|
| 103 |
+
rack: string
|
| 104 |
+
level: string
|
| 105 |
+
slotType: string
|
| 106 |
+
assignedSku: string
|
| 107 |
+
velocityClass: string
|
| 108 |
+
capacityUnits: float
|
| 109 |
+
utilizedUnits: float
|
| 110 |
+
compatibilityGroup: string
|
| 111 |
+
replenishmentSource: string
|
| 112 |
+
lastReassigned: datetime
|
| 113 |
+
|
| 114 |
+
Entity ShipmentManifest
|
| 115 |
+
manifestId: string
|
| 116 |
+
carrierId: string
|
| 117 |
+
trailerId: string
|
| 118 |
+
doorAssignment: string
|
| 119 |
+
orderCount: integer
|
| 120 |
+
cartonCount: integer
|
| 121 |
+
totalWeight: float
|
| 122 |
+
totalCube: float
|
| 123 |
+
status: string
|
| 124 |
+
shipments: list
|
| 125 |
+
sealNumber: string
|
| 126 |
+
departureTime: datetime
|
| 127 |
+
complianceChecks: dict
|
| 128 |
+
|
| 129 |
+
Entity ReceiptRecord
|
| 130 |
+
receiptId: string
|
| 131 |
+
purchaseOrderRef: string
|
| 132 |
+
supplierId: string
|
| 133 |
+
dockDoor: string
|
| 134 |
+
receivedBy: string
|
| 135 |
+
receiptDate: datetime
|
| 136 |
+
expectedQuantity: float
|
| 137 |
+
receivedQuantity: float
|
| 138 |
+
damagedQuantity: float
|
| 139 |
+
qualityHoldQuantity: float
|
| 140 |
+
lotNumbers: list
|
| 141 |
+
putawayComplete: boolean
|
| 142 |
+
inspectionRequired: boolean
|
| 143 |
+
|
| 144 |
+
Entity LaborAllocation
|
| 145 |
+
allocationId: string
|
| 146 |
+
employeeId: string
|
| 147 |
+
zone: string
|
| 148 |
+
shift: string
|
| 149 |
+
taskType: string
|
| 150 |
+
assignedTasks: integer
|
| 151 |
+
completedTasks: integer
|
| 152 |
+
unitsProcessed: float
|
| 153 |
+
efficiencyRate: float
|
| 154 |
+
startTime: datetime
|
| 155 |
+
endTime: datetime
|
| 156 |
+
overtimeHours: float
|
| 157 |
+
crossTrainedZones: list
|
| 158 |
+
|
| 159 |
+
Behavior ReceiveInboundShipment
|
| 160 |
+
Input: purchaseOrderRef: string, dockDoor: string, receivedQuantities: list, lotData: list
|
| 161 |
+
Output: receiptRecord: ReceiptRecord
|
| 162 |
+
Action: Validate purchase order reference; assign dock door and staging lane; record received quantities per line; capture lot numbers and expiration dates; flag damaged items for inspection; quarantine quality hold items; update inventory positions; emit receipt event; trigger putaway task generation
|
| 163 |
+
|
| 164 |
+
Behavior GeneratePickWave
|
| 165 |
+
Input: orderPool: list, priorityRules: dict, capacityConstraints: dict
|
| 166 |
+
Output: wavePlan: dict
|
| 167 |
+
Action: Select orders for wave based on priority and ship-by dates; group by zone for pick efficiency; generate pick tasks with optimal path sequence; assign cartonization rules; check inventory availability; allocate inventory to tasks; emit wave released event; update order fulfillment status
|
| 168 |
+
|
| 169 |
+
Behavior ExecutePutaway
|
| 170 |
+
Input: receiptId: string, sku: string, quantity: float, lotNumber: string
|
| 171 |
+
Output: putawayConfirmation: dict
|
| 172 |
+
Action: Determine optimal putaway location via slotting rules; verify location compatibility and capacity; generate putaway task; guide associate to location; confirm placement with scan verification; update inventory position; emit putaway complete event; replenish forward pick locations if needed
|
| 173 |
+
|
| 174 |
+
Behavior OptimizeSlotting
|
| 175 |
+
Input: warehouseCode: string, strategy: string, constraints: dict
|
| 176 |
+
Output: slottingPlan: dict
|
| 177 |
+
Action: Analyze product velocity and pick frequency data; evaluate product compatibility constraints; calculate optimal slot assignments by velocity class; respect physical constraints of rack and zone; minimize replenishment travel distance; generate reassignment plan with coordination windows; simulate throughput improvement; emit slotting plan event; schedule phased reassignment
|
| 178 |
+
|
| 179 |
+
Behavior PackAndVerify
|
| 180 |
+
Input: orderId: string, pickedItems: list, cartonizationRules: dict
|
| 181 |
+
Output: packResult: dict
|
| 182 |
+
Action: Validate all order lines are present; apply cartonization logic for optimal box selection; scan verify each item into carton; capture weight and dimensions; generate packing slip and shipping label; validate against order completeness; emit pack complete event; update shipment manifest; trigger shipping workflow
|
| 183 |
+
|
| 184 |
+
Behavior ProcessCycleCount
|
| 185 |
+
Input: zone: string, skuList: list, countMethod: string
|
| 186 |
+
Output: countResult: dict
|
| 187 |
+
Action: Generate count tasks for selected items; assign counters with blind count protocol; record physical counts; compare against system quantities; flag variances above threshold; require recount for flagged items; initiate root cause investigation; apply approved adjustments; update inventory positions; emit count complete event
|
| 188 |
+
|
| 189 |
+
Condition:
|
| 190 |
+
When inventoryItem.quantityAvailable falls below minimumDisplayQuantity AND item is in forward pick location
|
| 191 |
+
Then trigger replenishment task from reserve storage; calculate replenishment quantity based on velocity; prioritize replenishment task; notify zone supervisor; update pick availability flag
|
| 192 |
+
|
| 193 |
+
Condition:
|
| 194 |
+
When pickTask.pickedQuantity does not equal pickTask.pickQuantity AND variance exceeds shortShipTolerance
|
| 195 |
+
Then place pick task on exception hold; notify order management of potential short ship; trigger inventory discrepancy investigation; adjust available quantity; generate exception pick if substitute available
|
| 196 |
+
|
| 197 |
+
Condition:
|
| 198 |
+
When slotAssignment.utilizedUnits exceeds 95 percent of capacityUnits AND velocity class is A
|
| 199 |
+
Then flag for slot expansion or relocation to higher-capacity position; adjust replenishment parameters; recommend slotting reoptimization; prevent new SKU assignments to slot; notify slotting coordinator
|
| 200 |
+
|
| 201 |
+
Condition:
|
| 202 |
+
When shipmentManifest complianceChecks contain any failed items
|
| 203 |
+
Then hold manifest from carrier release; notify shipping supervisor; generate resolution tasks; require re-verification after correction; log compliance failure for audit; escalate persistent failures
|
| 204 |
+
|
| 205 |
+
Condition:
|
| 206 |
+
When laborAllocation.efficiencyRate falls below 75 percent for two consecutive shifts
|
| 207 |
+
Then trigger performance review notification; analyze task assignment appropriateness; evaluate training needs; adjust zone assignment; recommend cross-training; alert shift supervisor
|
| 208 |
+
|
| 209 |
+
Event:
|
| 210 |
+
On ReceiptCompleted
|
| 211 |
+
Action: Update inventory positions; generate putaway tasks; trigger quality inspection if required; update purchase order receipt status; emit inbound dashboard refresh; calculate dock-to-stock time; update supplier delivery metrics
|
| 212 |
+
|
| 213 |
+
Event:
|
| 214 |
+
On PickWaveReleased
|
| 215 |
+
Action: Assign pick tasks to available associates; update pick path displays; activate zone workload indicators; notify packing stations of expected volume; refresh outbound dashboard; start pick timing metrics
|
| 216 |
+
|
| 217 |
+
Event:
|
| 218 |
+
On SlottingReassignmentComplete
|
| 219 |
+
Action: Update inventory location records; refresh pick path algorithms; update replenishment source mappings; validate forward pick availability; emit slotting update event; recalculate zone capacity metrics
|
| 220 |
+
|
| 221 |
+
Event:
|
| 222 |
+
On ShipmentDispatched
|
| 223 |
+
Action: Finalize inventory deductions; transmit manifest to carrier; update order tracking; generate bill of lading; close shipment record; emit outbound dashboard refresh; update carrier performance tracking
|
| 224 |
+
|
| 225 |
+
Event:
|
| 226 |
+
On CycleCountVarianceDetected
|
| 227 |
+
Action: Initiate root cause investigation; flag SKU for increased count frequency; adjust inventory valuation if material; notify inventory control manager; update accuracy metrics; log variance for trend analysis
|
| 228 |
+
|
| 229 |
+
Parallel:
|
| 230 |
+
- Inbound receiving and putaway task processing
|
| 231 |
+
- Outbound pick wave generation and task assignment
|
| 232 |
+
- Real-time slotting optimization calculation
|
| 233 |
+
- Cycle count scheduling and variance analysis
|
| 234 |
+
- Labor efficiency monitoring and reallocation
|
| 235 |
+
|
| 236 |
+
Optimize: Warehouse throughput and inventory accuracy
|
| 237 |
+
Priority: Inventory accuracy and lot traceability over processing speed
|
| 238 |
+
Priority: Order fulfillment completeness over throughput volume
|
| 239 |
+
Priority: Product safety and compliance over storage density
|
| 240 |
+
Priority: Associate safety and ergonomics over pick speed
|
| 241 |
+
|
| 242 |
+
Learn: Pick path efficiency optimization
|
| 243 |
+
Goal: Reduce average pick travel time by 20 percent through path learning
|
| 244 |
+
Adapt: Pick task sequencing and zone grouping algorithms
|
| 245 |
+
Based: Historical pick completion times, path traversal data, and congestion patterns
|
| 246 |
+
|
| 247 |
+
Learn: Slotting velocity prediction
|
| 248 |
+
Goal: Predict SKU velocity class changes 4 weeks in advance with 70 percent accuracy
|
| 249 |
+
Adapt: Slot assignment and replenishment parameters
|
| 250 |
+
Based: Demand trend analysis, seasonal patterns, and promotional calendar impact
|
| 251 |
+
|
| 252 |
+
Learn: Receiving dock scheduling optimization
|
| 253 |
+
Goal: Reduce dock-to-stock time by 25 percent through appointment optimization
|
| 254 |
+
Adapt: Dock appointment scheduling and labor pre-allocation
|
| 255 |
+
Based: Historical receiving volume patterns, supplier delivery window adherence, and putaway velocity
|
| 256 |
+
|
| 257 |
+
Learn: Labor demand forecasting
|
| 258 |
+
Goal: Predict zone labor requirements within 10 percent of actual 2 weeks in advance
|
| 259 |
+
Adapt: Workforce scheduling and cross-training priorities
|
| 260 |
+
Based: Order volume forecasts, seasonal workload patterns, and historical productivity rates
|
| 261 |
+
|
| 262 |
+
Security:
|
| 263 |
+
Encrypt: All inventory valuation and cost data at rest and in transit
|
| 264 |
+
Encrypt: Supplier proprietary information including lot and batch data
|
| 265 |
+
Encrypt: Employee performance and labor allocation data with access restriction
|
| 266 |
+
Protect: Inventory adjustment transactions with dual-authorization and audit trail
|
| 267 |
+
Protect: Shipping manifest data with carrier-specific access controls
|
| 268 |
+
Protect: Slotting optimization algorithms and parameters as proprietary business logic
|
| 269 |
+
Protect: Cycle count results from premature visibility to maintain blind count integrity
|
| 270 |
+
|
| 271 |
+
Native: python
|
| 272 |
+
{
|
| 273 |
+
from datetime import datetime, timedelta
|
| 274 |
+
from typing import Dict, List, Optional, Tuple
|
| 275 |
+
import math
|
| 276 |
+
|
| 277 |
+
class SlottingOptimizer:
|
| 278 |
+
"""Warehouse slotting optimization with velocity and compatibility constraints."""
|
| 279 |
+
|
| 280 |
+
def __init__(self, warehouse_config: Dict, compatibility_matrix: Dict):
|
| 281 |
+
self.config = warehouse_config
|
| 282 |
+
self.compatibility = compatibility_matrix
|
| 283 |
+
|
| 284 |
+
def optimize(self, sku_velocity: Dict, current_assignments: Dict,
|
| 285 |
+
strategy: str = "velocity") -> Dict:
|
| 286 |
+
ranked_skus = sorted(sku_velocity.items(), key=lambda x: x[1]["picks_per_day"], reverse=True)
|
| 287 |
+
forward_slots = self._get_forward_slots()
|
| 288 |
+
reserve_slots = self._get_reserve_slots()
|
| 289 |
+
|
| 290 |
+
plan = {"assignments": [], "relocations": [], "estimated_impact": {}}
|
| 291 |
+
|
| 292 |
+
# Assign top velocity SKUs to most accessible forward positions
|
| 293 |
+
for i, (sku, velocity) in enumerate(ranked_skus):
|
| 294 |
+
if i < len(forward_slots):
|
| 295 |
+
target_slot = forward_slots[i]
|
| 296 |
+
current = current_assignments.get(sku)
|
| 297 |
+
if current and current != target_slot["slot_id"]:
|
| 298 |
+
plan["relocations"].append({
|
| 299 |
+
"sku": sku,
|
| 300 |
+
"from_slot": current,
|
| 301 |
+
"to_slot": target_slot["slot_id"],
|
| 302 |
+
"reason": "velocity_optimization"
|
| 303 |
+
})
|
| 304 |
+
plan["assignments"].append({
|
| 305 |
+
"sku": sku,
|
| 306 |
+
"slot_id": target_slot["slot_id"],
|
| 307 |
+
"zone": target_slot["zone"],
|
| 308 |
+
"velocity_class": "A" if i < len(forward_slots) * 0.2 else "B"
|
| 309 |
+
})
|
| 310 |
+
else:
|
| 311 |
+
target_slot = reserve_slots[i - len(forward_slots)] if i - len(forward_slots) < len(reserve_slots) else reserve_slots[-1]
|
| 312 |
+
plan["assignments"].append({
|
| 313 |
+
"sku": sku,
|
| 314 |
+
"slot_id": target_slot["slot_id"],
|
| 315 |
+
"zone": target_slot["zone"],
|
| 316 |
+
"velocity_class": "C"
|
| 317 |
+
})
|
| 318 |
+
|
| 319 |
+
plan["estimated_impact"] = self._simulate_impact(plan, sku_velocity)
|
| 320 |
+
return plan
|
| 321 |
+
|
| 322 |
+
def _get_forward_slots(self) -> List[Dict]:
|
| 323 |
+
slots = []
|
| 324 |
+
for zone in self.config["zones"]:
|
| 325 |
+
if zone["type"] == "forward_pick":
|
| 326 |
+
for aisle in range(1, zone["aisle_count"] + 1):
|
| 327 |
+
for level in range(1, zone["level_count"] + 1):
|
| 328 |
+
# Lower levels and center aisles are more accessible
|
| 329 |
+
accessibility = (zone["aisle_count"] - abs(aisle - zone["aisle_count"]/2)) + (zone["level_count"] - level)
|
| 330 |
+
slots.append({
|
| 331 |
+
"slot_id": f"{zone['code']}-A{aisle:02d}-L{level:02d}",
|
| 332 |
+
"zone": zone["code"],
|
| 333 |
+
"accessibility_score": accessibility
|
| 334 |
+
})
|
| 335 |
+
return sorted(slots, key=lambda s: s["accessibility_score"], reverse=True)
|
| 336 |
+
|
| 337 |
+
def _get_reserve_slots(self) -> List[Dict]:
|
| 338 |
+
slots = []
|
| 339 |
+
for zone in self.config["zones"]:
|
| 340 |
+
if zone["type"] == "reserve_storage":
|
| 341 |
+
for rack in range(1, zone["rack_count"] + 1):
|
| 342 |
+
slots.append({
|
| 343 |
+
"slot_id": f"{zone['code']}-R{rack:03d}",
|
| 344 |
+
"zone": zone["code"],
|
| 345 |
+
"accessibility_score": 0
|
| 346 |
+
})
|
| 347 |
+
return slots
|
| 348 |
+
|
| 349 |
+
def _simulate_impact(self, plan: Dict, velocity: Dict) -> Dict:
|
| 350 |
+
current_travel = sum(v["avg_pick_travel_min"] for v in velocity.values())
|
| 351 |
+
# Estimate 20% improvement for velocity-based slotting
|
| 352 |
+
estimated_travel = current_travel * 0.80
|
| 353 |
+
return {
|
| 354 |
+
"current_avg_pick_travel_min": round(current_travel, 1),
|
| 355 |
+
"estimated_avg_pick_travel_min": round(estimated_travel, 1),
|
| 356 |
+
"improvement_percent": 20.0,
|
| 357 |
+
"relocation_count": len(plan["relocations"])
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
|
| 361 |
+
class PickWaveGenerator:
|
| 362 |
+
"""Generates optimized pick waves from order pools."""
|
| 363 |
+
|
| 364 |
+
def __init__(self, zone_config: Dict):
|
| 365 |
+
self.zones = zone_config
|
| 366 |
+
|
| 367 |
+
def generate_wave(self, orders: List[Dict], max_orders: int = 50) -> Dict:
|
| 368 |
+
prioritized = sorted(orders, key=lambda o: (
|
| 369 |
+
-o.get("priority", 0),
|
| 370 |
+
o.get("ship_by", datetime.max).isoformat()
|
| 371 |
+
))[:max_orders]
|
| 372 |
+
|
| 373 |
+
zone_groups = {}
|
| 374 |
+
for order in prioritized:
|
| 375 |
+
for line in order["lines"]:
|
| 376 |
+
zone = self._get_zone_for_sku(line["sku"])
|
| 377 |
+
if zone not in zone_groups:
|
| 378 |
+
zone_groups[zone] = []
|
| 379 |
+
zone_groups[zone].append({
|
| 380 |
+
"order_id": order["order_id"],
|
| 381 |
+
"sku": line["sku"],
|
| 382 |
+
"qty": line["qty"],
|
| 383 |
+
"location": line.get("location")
|
| 384 |
+
})
|
| 385 |
+
|
| 386 |
+
wave_id = f"WV-{datetime.utcnow().strftime('%Y%m%d%H%M%S')}"
|
| 387 |
+
return {
|
| 388 |
+
"wave_id": wave_id,
|
| 389 |
+
"order_count": len(prioritized),
|
| 390 |
+
"zone_groups": zone_groups,
|
| 391 |
+
"estimated_units": sum(
|
| 392 |
+
sum(l["qty"] for l in lines) for lines in zone_groups.values()
|
| 393 |
+
),
|
| 394 |
+
"released_at": datetime.utcnow().isoformat()
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
def _get_zone_for_sku(self, sku: str) -> str:
|
| 398 |
+
for zone, config in self.zones.items():
|
| 399 |
+
if sku.startswith(tuple(config.get("sku_prefixes", []))):
|
| 400 |
+
return zone
|
| 401 |
+
return "default"
|
| 402 |
+
}
|