private FBAPickDetail CreateFBAPickDetailFromCartonLocation(FBACartonLocation fbaCartonLocationInDb, FBAShipOrder shipOrderInDb, int ctnQuantity, IList <FBAPickDetailCarton> pickDetailCartonList) { var pickDetail = new FBAPickDetail(); pickDetail.AssembleUniqueIndex(fbaCartonLocationInDb.Container, fbaCartonLocationInDb.GrandNumber); pickDetail.AssembleFirstStringPart(fbaCartonLocationInDb.ShipmentId, fbaCartonLocationInDb.AmzRefId, fbaCartonLocationInDb.WarehouseCode); pickDetail.AssembleActualDetails(fbaCartonLocationInDb.GrossWeightPerCtn * ctnQuantity, fbaCartonLocationInDb.CBMPerCtn * ctnQuantity, ctnQuantity); pickDetail.Status = FBAStatus.Picking; pickDetail.Size = FBAStatus.Na; pickDetail.CtnsPerPlt = 0; pickDetail.PickableCtns = ctnQuantity; pickDetail.Location = fbaCartonLocationInDb.Location; pickDetail.InboundDate = fbaCartonLocationInDb.FBAOrderDetail.FBAMasterOrder.InboundDate; fbaCartonLocationInDb.PickingCtns += ctnQuantity; fbaCartonLocationInDb.AvailableCtns -= ctnQuantity; fbaCartonLocationInDb.Status = FBAStatus.Picking; pickDetail.FBACartonLocation = fbaCartonLocationInDb; pickDetail.OrderType = FBAOrderType.ECommerce; pickDetail.HowToDeliver = fbaCartonLocationInDb.HowToDeliver; pickDetail.FBAShipOrder = shipOrderInDb; var pickDetailCarton = new FBAPickDetailCarton(); pickDetailCarton.FBACartonLocation = fbaCartonLocationInDb; pickDetailCarton.FBAPickDetail = pickDetail; pickDetailCarton.PickCtns = ctnQuantity; pickDetailCartonList.Add(pickDetailCarton); return(pickDetail); }
private FBAPickDetail CreateFBAPickDetailFromPalletLocation(FBAPalletLocation fbaPalletLocationInDb, FBAShipOrder shipOrderInDb, int pltQuantity, int newPltQuantity, IList <FBAPickDetailCarton> pickDetailCartonList, IEnumerable <PickCartonDto> objArray) { var pickDetail = new FBAPickDetail(); pickDetail.AssembleUniqueIndex(fbaPalletLocationInDb.Container, fbaPalletLocationInDb.GrandNumber); pickDetail.AssembleFirstStringPart(fbaPalletLocationInDb.ShipmentId, fbaPalletLocationInDb.AmzRefId, fbaPalletLocationInDb.WarehouseCode); pickDetail.AssembleActualDetails(0, 0, objArray.Sum(x => x.PickQuantity)); pickDetail.Status = FBAStatus.Picking; pickDetail.Size = fbaPalletLocationInDb.PalletSize; pickDetail.PickableCtns = objArray.Sum(x => x.PickQuantity); pickDetail.NewPlts = newPltQuantity; pickDetail.PltsFromInventory = pltQuantity; //pickDetail.ActualPlts = pltQuantity + newPltQuantity; //现在强行规定,实际出库托盘数量为0,防止仓库偷懒不调整 pickDetail.ActualPlts = 0; pickDetail.CtnsPerPlt = fbaPalletLocationInDb.CtnsPerPlt; pickDetail.Location = fbaPalletLocationInDb.Location; fbaPalletLocationInDb.PickingPlts += pltQuantity; //如果需要在库存中体现新打的托盘数量,禁用上面一行,启用下面一行 //fbaPalletLocationInDb.PickingPlts += pltQuantity + newPltQuantity; fbaPalletLocationInDb.AvailablePlts -= pltQuantity; fbaPalletLocationInDb.Status = FBAStatus.Picking; pickDetail.HowToDeliver = fbaPalletLocationInDb.HowToDeliver; pickDetail.FBAPalletLocation = fbaPalletLocationInDb; pickDetail.OrderType = FBAOrderType.Standard; pickDetail.HowToDeliver = fbaPalletLocationInDb.HowToDeliver; pickDetail.InboundDate = fbaPalletLocationInDb.FBAMasterOrder.InboundDate; pickDetail.FBAShipOrder = shipOrderInDb; var cartonLocationInPalletsInDb = fbaPalletLocationInDb.FBAPallet.FBACartonLocations; foreach (var obj in objArray) { if (obj.PickQuantity == 0) { continue; } var cartonInPalletInDb = cartonLocationInPalletsInDb.SingleOrDefault(x => x.Id == obj.Id); cartonInPalletInDb.PickingCtns += obj.PickQuantity; var pickDetailCarton = new FBAPickDetailCarton { PickCtns = obj.PickQuantity, FBAPickDetail = pickDetail, FBACartonLocation = cartonInPalletInDb }; cartonInPalletInDb.AvailableCtns -= obj.PickQuantity; pickDetail.ActualCBM += obj.PickQuantity * cartonInPalletInDb.CBMPerCtn; pickDetail.ActualGrossWeight += obj.PickQuantity * cartonInPalletInDb.GrossWeightPerCtn; pickDetailCartonList.Add(pickDetailCarton); } // 如果捡完了托盘数量但是箱子还有剩余,则报错 var availablePlts = fbaPalletLocationInDb.FBAPallet.FBAPalletLocations.Sum(x => x.AvailablePlts); var availableCtns = fbaPalletLocationInDb.FBAPallet.FBACartonLocations.Sum(x => x.AvailableCtns); if (availablePlts == 0 && availableCtns != 0) { throw new Exception("Pick failed. The pallets number of SKU " + fbaPalletLocationInDb.ShipmentId + " will be 0 after this pick but there are still many cartons inside. Please make sure there is no thing left before picking the last pallte."); } // 如果托盘中的箱子捡完了但是托盘数没捡完,则自动把所有剩下的托盘数带上 if (availableCtns == 0 && availablePlts != 0) { pickDetail.PltsFromInventory += availablePlts; fbaPalletLocationInDb.PickingPlts += availablePlts; fbaPalletLocationInDb.AvailablePlts = 0; } return(pickDetail); }