Пример #1
0
        private void SetAllocationItemInfo <T>(T item, SOItemType itemType, int itemGroupQuantity, List <AllocateItemInfo> productList)
            where T : OrderItem
        {
            if (productList == null)
            {
                productList = new List <AllocateItemInfo>();
            }

            if (!productList.Exists(subItem =>
            {
                if (subItem.ProductID == item.ProductSysNo)
                {
                    subItem.Quantity += item.UnitQuantity * itemGroupQuantity;
                    return(true);
                }
                return(false);
            }))
            {
                AllocateItemInfo allocateInfo = new AllocateItemInfo();
                allocateInfo.ProductID   = item.ProductSysNo;
                allocateInfo.ProductCode = item.ProductID;
                allocateInfo.ProductName = item.ProductName;
                allocateInfo.ProductType = itemType;
                allocateInfo.Quantity    = item.UnitQuantity * itemGroupQuantity;
                productList.Add(allocateInfo);
            }
        }
Пример #2
0
        private void FilterAllocatedItemInventoryInfo(AllocateItemInfo productInfo, List <AllocatedItemInventoryInfo> productAllocateInventoryList)
        {
            if (productAllocateInventoryList == null || productAllocateInventoryList.Count <= 0)
            {
                return;
            }

            //规则1 优先从实库仓发货
            if (productAllocateInventoryList.Exists(item =>
            {
                return(item.StockAvailableQty + item.StockConsignQty > 0);
            }))
            {
                productAllocateInventoryList.RemoveAll(item =>
                {
                    return(item.StockAvailableQty + item.StockConsignQty <= 0);
                });
            }

            //规则2 优先从评分最高的仓库发货
            int maxScore = productAllocateInventoryList.Max(item => item.WareHouseScore);

            productAllocateInventoryList.RemoveAll(item =>
            {
                return(item.WareHouseScore < maxScore);
            });

            //规则3 优先从库存充足的仓库发货
            if (productAllocateInventoryList.Exists(item =>
            {
                return(item.StockAvailableQty + item.StockConsignQty + item.StockVirtualQty >= item.ShoppingQty);
            }))
            {
                productAllocateInventoryList.RemoveAll(item =>
                {
                    return(item.StockAvailableQty + item.StockConsignQty + item.StockVirtualQty < item.ShoppingQty);
                });
            }

            //规则4 优先从仓库编号最小的仓库发货
            int minWarehouseNumber = productAllocateInventoryList.Min(item => item.WarehouseNumber);

            productAllocateInventoryList.RemoveAll(item =>
            {
                return(item.WarehouseNumber > minWarehouseNumber);
            });
        }