예제 #1
0
        public VScanResponse MoveDown(long id, VMoveScan request)
        {
            var prodSku = skuService.GetSkuByBarcode(request.Barcode);

            var move = wmsstock.TInvtMoves.Where(x => x.Id == id).FirstOrDefault();

            var zoneBin = binService.GetBinByCode(move.WhId, request.BinCode);

            TInvtDown down = new TInvtDown();

            down.HId          = id;
            down.Code         = move.Code;
            down.TypeCode     = "RepDown";
            down.Carton       = request.Carton;
            down.Barcode      = request.Barcode;
            down.FromZoneId   = zoneBin.ZoneId;
            down.FromZoneCode = zoneBin.ZoneCode;
            down.FromBinId    = zoneBin.Id;
            down.FromBinCode  = request.BinCode;
            down.Carton       = request.Carton;
            down.SkuId        = prodSku.Id;
            down.Sku          = prodSku.Code;
            down.Qty          = 1;
            down.CreatedBy    = DefaultUser.UserName;
            down.CreatedTime  = DateTime.UtcNow;

            wmsstock.TInvtDowns.Add(down);

            wmsstock.SaveChanges();

            return(new VScanResponse());
        }
예제 #2
0
        public VScanResponse MoveDown(long id, VMoveScan request)
        {
            //移货下架的时候锁定库存
            var result  = new VScanResponse();
            var prodSku = skuService.GetSkuByBarcode(request.Barcode);
            var move    = wmsstock.TInvtMoves.Where(x => x.Id == id).FirstOrDefault();
            var zoneBin = binService.GetBinByCode(move.WhId, request.BinCode);
            var downs   = wmsstock.TInvtDowns.Where(x => x.HId == id).Count();

            if (downs + 1 <= move.Qty)
            {
                TInvtDown down = new TInvtDown();
                down.HId      = id;
                down.Code     = move.Code;
                down.TypeCode = "MoveDown";
                down.Carton   = request.Carton;
                down.Barcode  = request.Barcode;
                down.ToZoneId = zoneBin.ZoneId;
                //down.FromZoneCode = request.FromZoneCode;
                down.ToBinId = zoneBin.Id;
                //down.FromBinCode = request.FromBinCode;
                down.Carton      = request.Carton;
                down.SkuId       = prodSku.Id;
                down.Sku         = prodSku.Code;
                down.Qty         = 1;
                down.CreatedBy   = DefaultUser.UserName;
                down.CreatedTime = DateTime.UtcNow;

                wmsstock.TInvtDowns.Add(down);
                move.DownStatus = Enum.GetName(typeof(EnumOperateStatus), EnumOperateStatus.Doing);
                wmsstock.SaveChanges();

                if (downs + 1 == move.Qty)
                {
                    result.IsAllFinished = true;
                    result.Message       = string.Format("{0}/{1}", downs + 1, move.Qty);
                    move.DownStatus      = Enum.GetName(typeof(EnumOperateStatus), EnumOperateStatus.Done);
                    move.UpStatus        = Enum.GetName(typeof(EnumOperateStatus), EnumOperateStatus.Init);
                    //更新冻结数量
                    inventoryService.Locked(new VInvtData
                    {
                        ZoneId   = move.FromZoneId,
                        ZoneCode = move.FromZoneCode,
                        BinId    = move.FromBinId,
                        BinCode  = move.FromBinCode,
                        SkuId    = move.SkuId,
                        Sku      = move.Sku,
                        Barcode  = move.Barcode,
                        Qty      = move.Qty
                    });
                }
            }
            else
            {
                result.IsAllFinished = true;
                result.Message       = string.Format("{0}/{1}", move.Qty, move.Qty);
            }
            return(result);
        }