コード例 #1
0
ファイル: MoveBillCreater.cs プロジェクト: uwitec/wms_rfid
        private void MoveToPieceArea(MoveBillMaster moveBillMaster, Storage sourceStorage, Cell[] cc)
        {
            var cells = cc.Where(c => c.DefaultProductCode == sourceStorage.ProductCode
                                      || (c.Storages.Any()
                                         && c.Storages.FirstOrDefault().ProductCode == sourceStorage.ProductCode));
            foreach (var c in cells)
            {
                lock (c)
                {
                    var targetStorage = Locker.LockStorage(c);
                    if (sourceStorage != null && targetStorage != null
                        && (string.IsNullOrEmpty(targetStorage.ProductCode)
                            || targetStorage.ProductCode == sourceStorage.ProductCode
                            || (targetStorage.Quantity == 0
                                && targetStorage.InFrozenQuantity == 0)))
                    {
                        decimal moveQuantity = Math.Floor((sourceStorage.Quantity - sourceStorage.OutFrozenQuantity)
                                                    / sourceStorage.Product.Unit.Count)
                                                   * sourceStorage.Product.Unit.Count;
                        moveQuantity = moveQuantity % (targetStorage.Cell.MaxQuantity * sourceStorage.Product.Unit.Count);
                        decimal targetAbleQuantity = Math.Floor((targetStorage.Cell.MaxQuantity
                                                        * sourceStorage.Product.Unit.Count
                                                        - targetStorage.Quantity
                                                        - targetStorage.InFrozenQuantity
                                                        + targetStorage.OutFrozenQuantity) / sourceStorage.Product.Unit.Count)
                                                        * sourceStorage.Product.Unit.Count;
                        moveQuantity = moveQuantity <= targetAbleQuantity ? moveQuantity : targetAbleQuantity;
                        AddToMoveBillDetail(moveBillMaster, sourceStorage, targetStorage, moveQuantity,"1");
                    }

                    if (targetStorage != null)
                    {
                        targetStorage.LockTag = string.Empty;
                    }
                }
            }

            cells = cc.Where(c => string.IsNullOrEmpty(c.DefaultProductCode));

            foreach (var c in cells)
            {
                lock (c)
                {
                    var targetStorage = Locker.LockStorage(c);
                    if (sourceStorage != null && targetStorage != null
                        && (string.IsNullOrEmpty(targetStorage.ProductCode)
                            || targetStorage.ProductCode == sourceStorage.ProductCode
                            || (targetStorage.Quantity == 0
                                && targetStorage.InFrozenQuantity == 0)))
                    {
                        decimal moveQuantity = Math.Floor((sourceStorage.Quantity - sourceStorage.OutFrozenQuantity)
                                                    / sourceStorage.Product.Unit.Count)
                                                   * sourceStorage.Product.Unit.Count;
                        moveQuantity = moveQuantity % (targetStorage.Cell.MaxQuantity * sourceStorage.Product.Unit.Count);
                        decimal targetAbleQuantity = Math.Floor((c.MaxQuantity
                                                        * sourceStorage.Product.Unit.Count
                                                        - targetStorage.Quantity
                                                        - targetStorage.InFrozenQuantity
                                                        + targetStorage.OutFrozenQuantity)/sourceStorage.Product.Unit.Count)
                                                        * sourceStorage.Product.Unit.Count;
                        moveQuantity = moveQuantity <= targetAbleQuantity ? moveQuantity : targetAbleQuantity;
                        AddToMoveBillDetail(moveBillMaster, sourceStorage, targetStorage, moveQuantity,"1");
                    }
                    if (targetStorage != null)
                    {
                        targetStorage.LockTag = string.Empty;
                    }
                }
            }
        }
コード例 #2
0
ファイル: MoveBillCreater.cs プロジェクト: uwitec/wms_rfid
        private void MoveToBarArea(MoveBillMaster moveBillMaster, Storage sourceStorage, Cell[] cc)
        {
            var cells = cc.Where(c => c.DefaultProductCode == sourceStorage.ProductCode
                                      || (c.Storages.Any()
                                         && c.Storages.FirstOrDefault().ProductCode == sourceStorage.ProductCode));
            foreach (var c in cells)
            {
                lock (c)
                {
                    var targetStorage = Locker.LockStorage(c);
                    if (sourceStorage != null && targetStorage != null
                        && (string.IsNullOrEmpty(targetStorage.ProductCode)
                            || targetStorage.ProductCode == sourceStorage.ProductCode
                            || (targetStorage.Quantity == 0
                                && targetStorage.InFrozenQuantity == 0)))
                    {
                        decimal moveQuantity = (sourceStorage.Quantity - sourceStorage.OutFrozenQuantity) % sourceStorage.Product.Unit.Count;
                        AddToMoveBillDetail(moveBillMaster, sourceStorage, targetStorage, moveQuantity,"1");
                    }

                    if (targetStorage != null)
                    {
                        targetStorage.LockTag = string.Empty;
                    }
                }
            }

            cells = cc.Where(c => string.IsNullOrEmpty(c.DefaultProductCode));

            foreach (var c in cells)
            {
                lock (c)
                {
                    var targetStorage = Locker.LockStorage(c);
                    if (sourceStorage != null && targetStorage != null
                        && (string.IsNullOrEmpty(targetStorage.ProductCode)
                            || targetStorage.ProductCode == sourceStorage.ProductCode
                            || (targetStorage.Quantity == 0
                                && targetStorage.InFrozenQuantity == 0)))
                    {
                        decimal moveQuantity = (sourceStorage.Quantity - sourceStorage.OutFrozenQuantity) % sourceStorage.Product.Unit.Count;
                        AddToMoveBillDetail(moveBillMaster, sourceStorage, targetStorage, moveQuantity,"1");
                    }
                    if (targetStorage != null)
                    {
                        targetStorage.LockTag = string.Empty;
                    }
                }
            }
        }