public void AddPickListResult(PickListResult pickListResult) { if (PickListResults == null) { PickListResults = new List<PickListResult>(); } PickListResults.Add(pickListResult); }
public void DoPick(IList<PickListDetail> pickListDetailList) { if (pickListDetailList.Select(det => det.PickListNo).Distinct().Count() > 1) { throw new TechnicalException("不能跨拣货单拣货。"); } string pickListNo = pickListDetailList.Select(det => det.PickListNo).Distinct().Single(); #region 判断是否全0拣货 if (pickListDetailList == null || pickListDetailList.Count == 0) { throw new BusinessException("拣货明细不能为空。"); } IList<PickListDetail> nonZeroPickListDetailList = pickListDetailList.Where(o => o.PickListDetailInputs != null && o.PickListDetailInputs.Count > 0).ToList(); if (nonZeroPickListDetailList.Count == 0) { throw new BusinessException("拣货明细不能为空。"); } #endregion #region 库存占用 IList<InventoryOccupy> inventoryOccupyList = new List<InventoryOccupy>(); foreach (PickListDetail pickListDetail in nonZeroPickListDetailList) { foreach (PickListDetailInput pickListDetailInput in pickListDetail.PickListDetailInputs) { InventoryOccupy inventoryOccupy = new InventoryOccupy(); inventoryOccupy.HuId = pickListDetailInput.HuId; inventoryOccupy.Location = pickListDetail.LocationFrom; inventoryOccupy.QualityType = CodeMaster.QualityType.Qualified; inventoryOccupy.OccupyType = CodeMaster.OccupyType.Pick; inventoryOccupy.OccupyReferenceNo = pickListDetail.PickListNo; inventoryOccupyList.Add(inventoryOccupy); } } IList<LocationLotDetail> locationLotDetailList = this.locationDetailMgr.InventoryOccupy(inventoryOccupyList); #endregion #region 检查是否超拣 BusinessException businessException = new BusinessException(); foreach (PickListDetail pickListDetail in nonZeroPickListDetailList) { decimal pickedQty = locationLotDetailList.Where(l => pickListDetail.GetPickedHuList().Contains(l.HuId)).Sum(l => l.HuQty); if (pickListDetail.Qty < pickListDetail.PickedQty + pickedQty) { businessException.AddMessage("拣货行{0}的拣货数已经超过待拣数。", pickListDetail.Sequence.ToString()); } pickListDetail.PickedQty += pickedQty; } #endregion if (businessException.HasMessage) { throw businessException; } #region 更新拣货单头 PickListMaster pickListMaster = this.genericMgr.FindById<PickListMaster>(pickListNo); pickListMaster.CompleteDate = DateTime.Now; pickListMaster.CompleteUserId = SecurityContextHolder.Get().Id; pickListMaster.CompleteUserName = SecurityContextHolder.Get().FullName; #endregion #region 更新拣货明细 foreach (PickListDetail pickListDetail in nonZeroPickListDetailList) { this.genericMgr.Update(pickListDetail); foreach (PickListDetailInput pickListDetailInput in pickListDetail.PickListDetailInputs) { LocationLotDetail huLocationLotDetail = locationLotDetailList.Where(l => l.HuId == pickListDetailInput.HuId).Single(); PickListResult pickListResult = new PickListResult(); pickListResult.PickListNo = pickListMaster.PickListNo; pickListResult.PickListDetailId = pickListDetail.Id; pickListResult.OrderDetailId = pickListDetail.OrderDetailId; pickListResult.Item = pickListDetail.Item; pickListResult.ItemDescription = pickListDetail.ItemDescription; pickListResult.ReferenceItemCode = pickListDetail.ReferenceItemCode; pickListResult.Uom = huLocationLotDetail.HuUom; pickListResult.BaseUom = huLocationLotDetail.BaseUom; pickListResult.UnitCount = huLocationLotDetail.UnitCount; pickListResult.UnitQty = huLocationLotDetail.UnitQty; pickListResult.HuId = huLocationLotDetail.HuId; pickListResult.LotNo = huLocationLotDetail.LotNo; pickListResult.IsConsignment = huLocationLotDetail.IsConsignment; pickListResult.PlanBill = huLocationLotDetail.PlanBill; pickListResult.QualityType = huLocationLotDetail.QualityType; pickListResult.IsFreeze = huLocationLotDetail.IsFreeze; pickListResult.IsATP = huLocationLotDetail.IsATP; pickListResult.Qty = huLocationLotDetail.Qty / huLocationLotDetail.UnitQty; this.genericMgr.Create(pickListResult); } } #endregion #region 新增拣货明细 #endregion }