예제 #1
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);
        }
예제 #2
0
        public VScanResponse Scan(long id, VCheckScan request)
        {
            var check = wmsstock.TInvtChecks.Where(x => x.Id == id).FirstOrDefault();


            var response = new VScanResponse();
            var prodSku  = skuService.GetSkuByBarcode(request.Barcode);

            if (prodSku == null)
            {
                throw new Exception("barcode is not exits");
            }

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

            //扫描货位和条码
            TInvtCheckLog detail = new TInvtCheckLog
            {
                HId         = id,
                WhId        = check.WhId,
                Code        = check.Code,
                Barcode     = request.Barcode,
                Carton      = request.Carton,
                SkuId       = prodSku.Id,
                Sku         = prodSku.Code,
                ZoneId      = zoneBin.ZoneId,
                ZoneCode    = zoneBin.ZoneCode,
                BinId       = zoneBin.Id,
                BinCode     = request.BinCode,
                Qty         = 1,
                CreatedBy   = DefaultUser.UserName,
                CreatedTime = DateTime.UtcNow,
            };

            wmsstock.TInvtCheckLogs.Add(detail);

            wmsstock.SaveChanges();

            return(response);
        }
예제 #3
0
        public VScanResponse MoveUp(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 ups = wmsstock.TInvtUps.Where(x => x.HId == id).Count();

            if (ups + 1 <= move.Qty)
            {
                TInvtUp up = new TInvtUp();
                up.HId         = id;
                up.Code        = move.Code;
                up.TypeCode    = "MoveUp";
                up.Carton      = request.Carton;
                up.Barcode     = request.Barcode;
                up.ToZoneId    = zoneBin.ZoneId;
                up.ToZoneCode  = zoneBin.ZoneCode;
                up.ToBinId     = zoneBin.Id;
                up.ToBinCode   = request.BinCode;
                up.Carton      = request.Carton;
                up.SkuId       = prodSku.Id;
                up.Sku         = prodSku.Code;
                up.Qty         = 1;
                up.CreatedBy   = DefaultUser.UserName;
                up.CreatedTime = DateTime.UtcNow;
                wmsstock.TInvtUps.Add(up);

                move.UpStatus = Enum.GetName(typeof(EnumOperateStatus), EnumOperateStatus.Doing);
                wmsstock.SaveChanges();

                if (ups + 1 == move.Qty)
                {
                    result.IsAllFinished = true;
                    result.Message       = string.Format("{0}/{1}", ups + 1, move.Qty);
                    move.UpStatus        = Enum.GetName(typeof(EnumOperateStatus), EnumOperateStatus.Done);

                    //更新上架数量
                    inventoryService.UnlockAndMove(move.Id, move.Code, move.WhId, 0,
                                                   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
                    },
                                                   new VInvtData
                    {
                        ZoneId   = move.ToZoneId,
                        ZoneCode = move.ToZoneCode,
                        BinId    = move.ToBinId,
                        BinCode  = move.ToBinCode,
                        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);
        }