private List <RobotArticle> BuildArticleList(List <RobotPack> packList, bool includeArticleDetails)
        {
            List <RobotArticle> articleList = new List <RobotArticle>();

            foreach (RobotPack pack in packList)
            {
                RobotArticle currentArticle = null;

                foreach (RobotArticle Article in articleList)
                {
                    if (Article.Code == pack.RobotArticleCode)
                    {
                        currentArticle = Article;
                        break;
                    }
                }

                if (currentArticle == null)
                {
                    if (includeArticleDetails)
                    {
                        StorageSystemArticleInformation articleInformation = this.stock.ArticleInformationList.GetArticleInformation(pack.RobotArticleCode, false);
                        currentArticle = new RobotArticle
                        {
                            Code               = articleInformation.Code,
                            Name               = articleInformation.Name,
                            DosageForm         = articleInformation.DosageForm,
                            PackagingUnit      = articleInformation.PackagingUnit,
                            MaxSubItemQuantity = articleInformation.MaxSubItemQuantity
                        };
                        articleList.Add(currentArticle);
                    }
                    else
                    {
                        currentArticle = new RobotArticle
                        {
                            Code = pack.RobotArticleCode
                        };
                        articleList.Add(currentArticle);
                    }
                }

                currentArticle.PackCount++;
            }

            return(articleList);
        }
        private StockOutputOrderItemPack GetOrderItemPackFromStock(
            StockOutputOrder outputOrder,
            StorageSystemArticleInformation articleInformation,
            RobotPack packInStock)
        {
            StockOutputOrderItemPack result = new StockOutputOrderItemPack();

            if (articleInformation != null)
            {
                result.RobotArticleCode               = articleInformation.Code;
                result.RobotArticleName               = articleInformation.Name;
                result.RobotArticleDosageForm         = articleInformation.DosageForm;
                result.RobotArticlePackagingUnit      = articleInformation.PackagingUnit;
                result.RobotArticleMaxSubItemQuantity = articleInformation.MaxSubItemQuantity;
            }
            else
            {
                result.RobotArticleCode = packInStock.RobotArticleCode;
            }

            result.BoxNumber       = outputOrder.BoxNumber;
            result.BatchNumber     = packInStock.BatchNumber;
            result.Depth           = packInStock.Depth;
            result.Height          = packInStock.Height;
            result.Width           = packInStock.Width;
            result.ExpiryDate      = packInStock.ExpiryDate;
            result.ExternalID      = packInStock.ExternalID;
            result.ID              = packInStock.ID;
            result.LabelState      = StockOutputOrderItemPackLabelState.Labelled;
            result.OutputNumber    = outputOrder.OutputNumber;
            result.OutputPoint     = outputOrder.OutputPoint;
            result.Shape           = packInStock.Shape;
            result.SubItemQuantity = packInStock.SubItemQuantity;

            result.MachineLocation          = packInStock.MachineLocation;
            result.StockLocationID          = packInStock.StockLocationID;
            result.StockLocationDescription = this.simulatorStockLocation.GetDescription(result.StockLocationID);
            result.TenantID          = packInStock.TenantID;
            result.TenantDescription = this.simulatorTenant.GetDescription(result.TenantID);

            return(result);
        }
示例#3
0
        public void ProcessInitiateStockInputRequest(InitiateStockInputRequest initiateInputRequest)
        {
            InitiateStockInputResponse initiateInputReponse = new InitiateStockInputResponse();

            initiateInputReponse.AdoptHeader(initiateInputRequest);
            initiateInputReponse.IsDeliveryInput     = initiateInputRequest.IsDeliveryInput;
            initiateInputReponse.SetPickingIndicator = initiateInputRequest.SetPickingIndicator;
            initiateInputReponse.InputSource         = initiateInputRequest.InputSource;
            initiateInputReponse.InputPoint          = initiateInputRequest.InputPoint;
            initiateInputReponse.Status = this.initiateStockInputState;

            foreach (RobotPack pack in initiateInputRequest.Packs)
            {
                bool articleInfoFound = false;
                foreach (RobotArticle article in initiateInputReponse.Articles)
                {
                    if (article.Code == pack.RobotArticleCode)
                    {
                        articleInfoFound = true;
                        break;
                    }
                }

                if (!articleInfoFound)
                {
                    // get article Info
                    StorageSystemArticleInformation articleInformation =
                        this.stock.ArticleInformationList.GetArticleInformation(pack.RobotArticleCode, false);

                    if (articleInformation == null)
                    {
                        // article not found ? try with the scan code.
                        articleInformation = this.stock.ArticleInformationList.GetArticleInformation(pack.ScanCode, false);
                    }

                    if (articleInformation != null)
                    {
                        RobotArticle newArticle = new RobotArticle();
                        newArticle.Code               = articleInformation.Code;
                        newArticle.Name               = articleInformation.Name;
                        newArticle.DosageForm         = articleInformation.DosageForm;
                        newArticle.PackagingUnit      = articleInformation.PackagingUnit;
                        newArticle.MaxSubItemQuantity = articleInformation.MaxSubItemQuantity;
                        initiateInputReponse.Articles.Add(newArticle);
                    }
                }
            }

            initiateInputReponse.Packs.AddRange(initiateInputRequest.Packs);
            initiateInputReponse.ConverterStream.Write(initiateInputReponse);

            if (initiateInputReponse.Status == InitiateStockInputState.Accepted)
            {
                this.initiateStockInputWaitForInputResponse = initiateInputReponse;
                this.ScanPack(initiateInputReponse.TenantID,
                              "",
                              initiateInputRequest.SetPickingIndicator,
                              initiateInputRequest.IsDeliveryInput,
                              initiateInputReponse.Packs);
            }
        }
        private List <StockOutputOrderItemPack> GetOrderItemFromStock(
            StockOutputMessage stockOutputMessage,
            StockOutputOrderItem stockOutputOrderItem,
            List <RobotPack> availableStock,
            List <RobotPack> usedStock)
        {
            List <StockOutputOrderItemPack> result             = new List <StockOutputOrderItemPack>();
            StorageSystemArticleInformation articleInformation = this.stock.ArticleInformationList.GetArticleInformation(string.IsNullOrWhiteSpace(stockOutputOrderItem.RobotArticleCode) ?
                                                                                                                         stockOutputOrderItem.PISArticleCode : stockOutputOrderItem.RobotArticleCode, false);
            string pickedBatchNumber     = String.Empty;
            int    subIemQuantityInStock = 0;

            // if possible pick a pack that match exactly the requested subquantity.
            foreach (RobotPack availablePack in availableStock)
            {
                if (stockOutputOrderItem.ProcessedSubItemQuantity < stockOutputOrderItem.RequestedSubItemQuantity)
                {
                    if (availablePack.SubItemQuantity == stockOutputOrderItem.RequestedSubItemQuantity)
                    {
                        stockOutputOrderItem.ProcessedSubItemQuantity += availablePack.SubItemQuantity;
                        result.Add(this.GetOrderItemPackFromStock(
                                       stockOutputMessage.Order,
                                       articleInformation,
                                       availablePack));
                        usedStock.Add(availablePack);
                        pickedBatchNumber = availablePack.BatchNumber;
                    }
                }
                subIemQuantityInStock += availablePack.SubItemQuantity;
            }

            // update available stock
            foreach (RobotPack usedPack in usedStock)
            {
                if (availableStock.Contains(usedPack))
                {
                    availableStock.Remove(usedPack);
                }
            }

            // Normal picking.
            foreach (RobotPack availablePack in availableStock)
            {
                if (availablePack.SubItemQuantity == 0)
                {
                    // Full pack
                    if ((stockOutputOrderItem.ProcessedQuantity < stockOutputOrderItem.RequestedQuantity) &&
                        (!stockOutputOrderItem.SingleBatchNumber || (pickedBatchNumber == availablePack.BatchNumber) || (String.IsNullOrEmpty(pickedBatchNumber))))
                    {
                        stockOutputOrderItem.ProcessedQuantity++;
                        result.Add(this.GetOrderItemPackFromStock(
                                       stockOutputMessage.Order,
                                       articleInformation,
                                       availablePack));
                        usedStock.Add(availablePack);
                        pickedBatchNumber = availablePack.BatchNumber;
                    }
                    else
                    {
                        // if we don't have enough open pack in stock, add full packs
                        if (subIemQuantityInStock < stockOutputOrderItem.RequestedSubItemQuantity)
                        {
                            if (articleInformation.MaxSubItemQuantity != 0)
                            {
                                if ((stockOutputOrderItem.ProcessedSubItemQuantity < stockOutputOrderItem.RequestedSubItemQuantity) &&
                                    (!stockOutputOrderItem.SingleBatchNumber || (pickedBatchNumber == availablePack.BatchNumber)))
                                {
                                    stockOutputOrderItem.ProcessedSubItemQuantity += articleInformation.MaxSubItemQuantity;
                                    result.Add(this.GetOrderItemPackFromStock(
                                                   stockOutputMessage.Order,
                                                   articleInformation,
                                                   availablePack));
                                    usedStock.Add(availablePack);
                                    pickedBatchNumber = availablePack.BatchNumber;
                                }
                            }
                            else
                            {
                                if ((stockOutputOrderItem.ProcessedSubItemQuantity < stockOutputOrderItem.RequestedSubItemQuantity) &&
                                    (!stockOutputOrderItem.SingleBatchNumber || (pickedBatchNumber == availablePack.BatchNumber)))
                                {
                                    stockOutputOrderItem.ProcessedQuantity += 1;
                                    result.Add(this.GetOrderItemPackFromStock(
                                                   stockOutputMessage.Order,
                                                   articleInformation,
                                                   availablePack));
                                    usedStock.Add(availablePack);
                                    pickedBatchNumber = availablePack.BatchNumber;
                                }
                                break;
                            }
                        }
                    }
                }
                else
                {
                    // Open pack
                    if ((stockOutputOrderItem.ProcessedSubItemQuantity < stockOutputOrderItem.RequestedSubItemQuantity) &&
                        (!stockOutputOrderItem.SingleBatchNumber || (pickedBatchNumber == availablePack.BatchNumber)))
                    {
                        stockOutputOrderItem.ProcessedSubItemQuantity += availablePack.SubItemQuantity;
                        result.Add(this.GetOrderItemPackFromStock(
                                       stockOutputMessage.Order,
                                       articleInformation,
                                       availablePack));
                        usedStock.Add(availablePack);
                        pickedBatchNumber = availablePack.BatchNumber;
                    }
                }

                if ((stockOutputOrderItem.ProcessedQuantity >= stockOutputOrderItem.RequestedQuantity) &&
                    (stockOutputOrderItem.ProcessedSubItemQuantity >= stockOutputOrderItem.RequestedSubItemQuantity))
                {
                    break;
                }
            }

            // update available stock
            foreach (RobotPack usedPack in usedStock)
            {
                if (availableStock.Contains(usedPack))
                {
                    availableStock.Remove(usedPack);
                }
            }

            return(result);
        }
        private void BuildMessageAlwaysComplete(StockOutputMessage stockOutputMessage)
        {
            foreach (StockOutputOrderItem stockOutputOrderItem in stockOutputMessage.Order.Items)
            {
                StorageSystemArticleInformation articleInformation = this.stock.ArticleInformationList.GetArticleInformation(string.IsNullOrWhiteSpace(stockOutputOrderItem.RobotArticleCode) ?
                                                                                                                             stockOutputOrderItem.PISArticleCode : stockOutputOrderItem.RobotArticleCode, false);

                stockOutputOrderItem.ProcessedQuantity        = stockOutputOrderItem.RequestedQuantity;
                stockOutputOrderItem.ProcessedSubItemQuantity = stockOutputOrderItem.RequestedSubItemQuantity;

                if ((stockOutputOrderItem.PackID != 0) && (stockOutputOrderItem.ProcessedQuantity > 1))
                {
                    // if requesting a specific Pack ID, only this pack will be dispened.
                    stockOutputOrderItem.ProcessedQuantity = 1;
                }

                for (int i = 0; i < stockOutputOrderItem.ProcessedQuantity || (i == 0 && stockOutputOrderItem.ProcessedSubItemQuantity > 0); i++)
                {
                    StockOutputOrderItemPack newPack = new StockOutputOrderItemPack();
                    if (articleInformation != null)
                    {
                        newPack.RobotArticleCode               = articleInformation.Code;
                        newPack.RobotArticleName               = articleInformation.Name;
                        newPack.RobotArticleDosageForm         = articleInformation.DosageForm;
                        newPack.RobotArticlePackagingUnit      = articleInformation.PackagingUnit;
                        newPack.RobotArticleMaxSubItemQuantity = articleInformation.MaxSubItemQuantity;
                    }
                    else
                    {
                        newPack.RobotArticleCode = string.IsNullOrWhiteSpace(stockOutputOrderItem.RobotArticleCode) ? stockOutputOrderItem.PISArticleCode : stockOutputOrderItem.RobotArticleCode;
                    }

                    newPack.BoxNumber   = stockOutputMessage.Order.BoxNumber;
                    newPack.BatchNumber = stockOutputOrderItem.BatchNumber;
                    newPack.Depth       = 60;
                    newPack.Height      = 60;
                    newPack.Width       = 60;
                    if (stockOutputOrderItem.ExpiryDate.Ticks == 0)
                    {
                        // PMR is not requesting a specific date, we need to set a valide date.
                        newPack.ExpiryDate = DateTime.Now.AddMonths(3);
                    }
                    else
                    {
                        newPack.ExpiryDate = stockOutputOrderItem.ExpiryDate;
                    }

                    newPack.ExternalID      = stockOutputOrderItem.ExternalID;
                    newPack.ID              = stockOutputOrderItem.PackID != 0 ? stockOutputOrderItem.PackID : this.stock.GetNextPackID();;
                    newPack.LabelState      = StockOutputOrderItemPackLabelState.Labelled;
                    newPack.OutputNumber    = stockOutputMessage.Order.OutputNumber;
                    newPack.OutputPoint     = stockOutputMessage.Order.OutputPoint;
                    newPack.Shape           = PackShape.Cuboid;
                    newPack.SubItemQuantity = stockOutputOrderItem.RequestedSubItemQuantity;

                    newPack.MachineLocation          = stockOutputOrderItem.MachineLocation;
                    newPack.StockLocationID          = stockOutputOrderItem.StockLocationID;
                    newPack.StockLocationDescription = this.simulatorStockLocation.GetDescription(newPack.StockLocationID);
                    newPack.TenantID          = stockOutputOrderItem.TenantID;
                    newPack.TenantDescription = this.simulatorTenant.GetDescription(newPack.TenantID);

                    stockOutputOrderItem.Packs.Add(newPack);
                }
            }
        }