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()); }
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); }
public bool Scan(long waveId, VScanBinRequest detail) { var pick = wmsoutbound.TOutPicks.Where(x => x.WaveId == waveId).FirstOrDefault(); if (pick == null) { throw new Exception("pick is not exist."); } //获取SKU信息 var prodSku = skuService.GetSkuByBarcode(detail.Barcode); if (prodSku == null) { throw new Exception("barcode is not exist."); } //新增拣货明细 var pickDetail = wmsoutbound.TOutPickDs.Where(x => x.HId == pick.Id && x.Barcode == detail.Barcode).FirstOrDefault(); if (pickDetail == null) { pickDetail = new TOutPickD { HId = pick.Id, }; } if (pick.FirstScanAt == null) { pick.FirstScanAt = DateTime.UtcNow; } pick.LastScanAt = DateTime.UtcNow; pick.Qty += 1; pick.Status = Enum.GetName(typeof(EnumOperateStatus), EnumOperateStatus.Doing); //获取货区货位信息 var zoneBin = binService.GetBinByCode(pick.WhId, detail.BinCode); pickDetail.ActBinId = zoneBin.Id; pickDetail.ActBinCode = detail.BinCode; pickDetail.Qty = 1; pickDetail.ActZoneCode = zoneBin.ZoneCode; pickDetail.ActZoneId = zoneBin.ZoneId; pickDetail.IsPicked = true; pickDetail.LastModifiedBy = DefaultUser.UserName; pickDetail.LastModifiedTime = DateTime.UtcNow; if (pickDetail.Id == 0) { wmsoutbound.TOutPickDs.Add(pickDetail); } return(wmsoutbound.SaveChanges() > 0); }
public Tuple<bool, string> Scan(long id, TInPutawayD detail) { //校验商品 var prodSku = skuService.GetSkuByBarcode(detail.Barcode); if (prodSku == null) return new Tuple<bool, string>(false, "barcode is not exist."); var pt = wmsinbound.TInPutaways.Where(x => x.Id == id).FirstOrDefault(); //校验货位 var bin = binService.GetBinByCode(pt.WhId, detail.BinCode); if (bin == null) return new Tuple<bool, string>(false, "binCode is not exist."); var zone = zoneService.GetZoneByCode(pt.WhId, bin.ZoneCode); //校验数量 var skuQty = wmsinbound.TInPutawayDs.Where(x => x.HId == pt.Id && x.SkuId == prodSku.Id).Sum(x => x.Qty); var inboundSkuQty = wmsinbound.TInInboundDs.Where(x => x.HId == pt.InboundId && x.SkuId == prodSku.Id) .Select(x => x.Qty).FirstOrDefault(); var inbound = wmsinbound.TInInbounds.Where(x => x.Id == pt.InboundId).FirstOrDefault(); if (skuQty + 1 <= inboundSkuQty) { if (pt.FirstScanAt == null) pt.FirstScanAt = DateTime.UtcNow; pt.LastScanAt = DateTime.UtcNow; pt.Qty += skuQty + 1; pt.Status = Enum.GetName(typeof(EnumOperateStatus), EnumOperateStatus.Doing); detail.SkuId = prodSku.Id; detail.ZoneId = zone.Id; detail.ZoneCode = zone.Code; detail.BinId = bin.Id; detail.BinCode = bin.Code; detail.HId = id; detail.CreatedBy = DefaultUser.UserName; detail.CreatedTime = DateTime.UtcNow; detail.Qty = 1; inbound.PStatus = pt.Status; wmsinbound.TInPutawayDs.Add(detail); var r = wmsinbound.SaveChanges() > 0; return new Tuple<bool, string>(false, string.Format("{0}/{1}", skuQty + 1, inboundSkuQty)); } else { return new Tuple<bool, string>(true, string.Format("{0}/{1}", inboundSkuQty, inboundSkuQty)); } }
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); }
public VPickScanResponse Scan(long pickId, VScanBinRequest detail) { VPickScanResponse response = new VPickScanResponse { AllFinished = false, BinFinished = false, Message = "" }; var pick = wmsoutbound.TOutPicks.Where(x => x.Id == pickId).FirstOrDefault(); if (pick == null) { throw new Exception("pick is not exist."); } //获取SKU信息 var prodSku = skuService.GetSkuByBarcode(detail.Barcode); if (prodSku == null) { throw new Exception("barcode is not exist."); } //获取货区货位信息 var zoneBin = binService.GetBinByCode(pick.WhId, detail.BinCode); if (zoneBin == null) { throw new Exception("zoneBin is not exist."); } //更新拣货明细 var pickDetail = wmsoutbound.TOutPickDs.Where(x => x.HId == pickId && x.Barcode == detail.Barcode && !x.IsPicked).FirstOrDefault(); if (pickDetail == null) { throw new Exception("pickDetail is not exist."); } //计算每个条码的需要扫描的总数量和货位数量 var skuAllQty = wmsoutbound.TOutPickDs.Where(x => x.HId == pick.Id && x.Barcode == detail.Barcode).Count(); var pickAllQty = wmsoutbound.TOutPickDs.Where(x => x.HId == pick.Id && x.Barcode == detail.Barcode && x.IsPicked).Count(); //计算每个条码的当前货位需要扫描的数量 var skuBinQty = wmsoutbound.TOutPickDs.Where(x => x.HId == pickId && x.Barcode == detail.Barcode && x.BinCode == detail.AdvBinCode).Count(); //计算每个条码的当前货位已扫描的数量 var pickBinQty = wmsoutbound.TOutPickDs.Where(x => x.HId == pickId && x.Barcode == detail.Barcode && x.BinCode == detail.AdvBinCode && x.IsPicked).Count(); //计算当前货位是否已经都扫描完毕了,如果是的话,需要跳转到下一个货位的 if (skuAllQty == pickAllQty) { response.AllFinished = true; response.Message = string.Format("{0}/{1}/{2}", skuBinQty, skuBinQty, skuAllQty); } else if (pickBinQty + 1 <= skuBinQty) { response.BinFinished = true; UpdatePickDetail(zoneBin, pick, pickDetail); response.Message = string.Format("{0}/{1}/{2}", pickBinQty + 1, skuBinQty, skuAllQty); } return(response); }