Beispiel #1
0
 public void AddPickingSlot(PickingSlot pickingSlot)
 {
     if (!PickingSlots.ContainsKey(pickingSlot.ToString()))
     {
         PickingSlots.Add(pickingSlot.ToString(), pickingSlot);
     }
 }
Beispiel #2
0
 public void AddPickingSlots(IEnumerable <PickingSlot> slots)
 {
     foreach (var pickingSlot in slots)
     {
         if (!PickingSlots.ContainsKey(pickingSlot.ToString()))
         {
             PickingSlots.Add(pickingSlot.ToString(), pickingSlot);
         }
     }
 }
Beispiel #3
0
        public void ReserveArticles(string positionAddress, long sku, int units)
        {
            if (!PickingSlots.TryGetValue(positionAddress, out var position))
            {
                throw new InvalidOperationException("Position does not exist");
            }
            if (position.Sku != sku)
            {
                throw new InvalidOperationException("Position does not contain SKU");
            }
            if (position.AvailableUnits < units)
            {
                throw new InvalidOperationException("Position does not contain enough units");
            }

            position.ReservedUnits += units;
        }
Beispiel #4
0
        public void CalculatePickingRoutes(PathSolver solver)
        {
            var coordsSet = new HashSet <Coord>(PickingSlots.Select(x => x.Value.Position))
            {
                GetPickingStartPosition(),
                GetPickingEndPosition()
            };
            var coords = coordsSet.ToArray();

            var collection = new ConcurrentDictionary <RouteBetweenCoords, byte>();
            int done       = 1;
            int todo       = coords.Length;
            var sw         = new Stopwatch();

            sw.Start();
            Parallel.For(0, coords.Length, startIndex =>
            {
                var coord1 = coords[startIndex];

                for (var endIndex = startIndex + 1; endIndex < PickingSlots.Count; endIndex++)
                {
                    var coord2 = coords[endIndex];
                    var result = solver.FindPath(new TravelStep(coord1), new TravelStep(coord2), false);
                    if (result.Success)
                    {
                        //Debug.WriteLine($"Sprawdzono {coord1} - {coord2}");
                        var route = new RouteBetweenCoords(coord1, coord2);
                        route.ReadTravelsteps(result.Steps);
                        collection.AddOrUpdate(route, x => 0, (x, b) => 0);
                    }
                }

                done += 1;
                PickingRoutesCalculationProgress?.Invoke(null, new CalculatePickingRouteProgressEventArgs()
                {
                    Done           = done,
                    IterationIndex = startIndex,
                    Todo           = todo,
                    Elapsed        = sw.Elapsed,
                    CheckeCoord    = coord1
                });
            });
            PickingSlotRoutes = new HashSet <RouteBetweenCoords>(collection.Keys);
        }
Beispiel #5
0
 public List <PickingSlot> GetPickingSlots()
 {
     return(new List <PickingSlot>(PickingSlots.Select(x => x.Value)));
 }
Beispiel #6
0
        //public RouteBetweenCoords TravelRouteBetween(Coord coord1, Coord coord2)
        //{
        //	if (coord1 == coord2)
        //	{
        //		return new RouteBetweenCoords(coord1, coord2);
        //	}
        //	if (PickingSlotRoutes.TryGetValue(new RouteBetweenCoords(coord1, coord2), out var route))
        //	{
        //		return route;
        //	}
        //	else
        //	{
        //		throw new Exception("Travel route unknown");
        //	}
        //}

        public List <PickingSlot> GetPickingSlotsWithSku(long sku)
        {
            return(PickingSlots.Select(x => x.Value).Where(x => x.Sku == sku && x.Units - x.ReservedUnits > 0).ToList());
        }