private void MatchHu(Hu hu) { base.CheckHu(hu); if (!Utility.HasPermission(user.Permissions, null, true, false, hu.Region, null)) { throw new BusinessException("没有此条码的权限"); } if (!base.isCancel) { #region 物料匹配 if (hu.Status != HuStatus.Location) { throw new BusinessException("条码{0}不在库存中,不能拣货", hu.HuId); } var pickListDetails = this.pickListMaster.PickListDetails; var pickListDetailList = pickListDetails.Where(o => o.Item == hu.Item || (o.ItemDisconList != null && o.ItemDisconList.Contains(hu.Item))); if (pickListDetailList == null || pickListDetailList.Count() == 0) { throw new BusinessException("没有找到和条码{0}的物料号{1}匹配的拣货单明细。", hu.HuId, hu.Item); } pickListDetailList = pickListDetailList.Where(o => o.Uom.Equals(hu.Uom, StringComparison.OrdinalIgnoreCase)); if (pickListDetailList == null || pickListDetailList.Count() == 0) { throw new BusinessException("没有找到和条码{0}的单位{1}匹配的拣货单明细。", hu.HuId, hu.Uom); } //pickListDetailList = pickListDetailList.Where(o => o.UnitCount == hu.UnitCount || o.UnitCount == 1); //if (pickListDetailList == null || pickListDetailList.Count() == 0) //{ // throw new BusinessException("没有找到和条码{0}的包装数{1}匹配的拣货单明细。", hu.HuId, hu.UnitCount.ToString("0.###")); //} //强制拣货不需要严格限制批次号 pickListDetailList = pickListDetailList.Where(o => o.LotNo == hu.LotNo); if (pickListDetailList == null || pickListDetailList.Count() == 0) { throw new BusinessException("没有找到和条码{0}的批号{1}匹配的拣货单明细。", hu.HuId, hu.LotNo.ToString()); } //pickListDetailList = pickListDetailList.Where(o => o.ManufactureParty == hu.ManufactureParty); //if (pickListDetailList == null || pickListDetailList.Count() == 0) //{ // throw new BusinessException("没有找到和条码{0}的供应商{1}匹配的拣货单明细。", hu.HuId, hu.ManufactureParty); //} //pickListDetailList = pickListDetailList.Where(o => o.IsOdd == hu.IsOdd); //if (pickListDetailList == null || pickListDetailList.Count() == 0) //{ // throw new BusinessException("没有找到匹配条码{0}{1}零头的拣货单明细。", hu.HuId, hu.IsOdd ? "是" : "不是"); //} pickListDetailList = pickListDetailList.Where(o => o.QualityType == hu.QualityType); if (pickListDetailList == null || pickListDetailList.Count() == 0) { throw new BusinessException("没有找到和条码{0}的质量状态{1}匹配的拣货单明细。", hu.HuId, hu.QualityType.ToString()); } pickListDetailList = pickListDetailList.Where(o => !o.IsMatchDirection || (o.Direction == hu.Direction || (string.IsNullOrEmpty(o.Direction) && string.IsNullOrEmpty(hu.Direction)))); if (pickListDetailList == null || pickListDetailList.Count() == 0) { throw new BusinessException("没有找到和条码{0}的方向{1}匹配的拣货单明细。", hu.HuId, hu.Direction); } pickListDetailList = pickListDetailList.Where(o => o.Bin == hu.Bin); if (pickListDetailList == null || pickListDetailList.Count() == 0) { throw new BusinessException("没有找到和条码{0}的库格{1}匹配的拣货单明细。", hu.HuId, hu.Bin); } if (hu.HuOption == HuOption.UnAging) { pickListDetailList = pickListDetailList.Where(o => (o.LocationTo == hu.AgingLocation)); if (pickListDetailList == null || pickListDetailList.Count() == 0) { throw new BusinessException("条码{0}未老化,不能拣货。", hu.HuId); } } pickListDetailList = pickListDetailList .Where(p => p.CurrentQty > 0) .Where(p => p.UcDeviation < 0 || (p.CurrentQty > p.UnitCount * (p.UcDeviation / 100))) .OrderByDescending(p => p.CurrentQty); var matchedpickListDetail = pickListDetailList.Where(p => p.UnitCount == hu.Qty).FirstOrDefault(); if (matchedpickListDetail == null) { matchedpickListDetail = pickListDetailList.FirstOrDefault(); } if (matchedpickListDetail == null) { throw new BusinessException("没有找到和条码{0}相匹配的拣货单明细。", hu.HuId); } #endregion PickListDetailInput input = new PickListDetailInput(); input.HuId = hu.HuId; input.Id = matchedpickListDetail.Id; List<PickListDetailInput> pickListDetailInputs = new List<PickListDetailInput>(); if (matchedpickListDetail.PickListDetailInputs != null) { pickListDetailInputs = matchedpickListDetail.PickListDetailInputs.ToList(); } pickListDetailInputs.Add(input); matchedpickListDetail.PickListDetailInputs = pickListDetailInputs.ToArray(); matchedpickListDetail.CurrentQty -= hu.Qty; matchedpickListDetail.Carton++; this.hus.Insert(0, hu); } else { DoCancel(); } this.gvListDataBind(); }
/// <remarks/> public System.IAsyncResult BeginDoPickList(PickListDetailInput[] pickListDetailInputList, string userCode, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("DoPickList", new object[] { pickListDetailInputList, userCode}, callback, asyncState); }
private void MatchHu(Hu hu) { base.CheckHu(hu); if (!base.isCancel) { #region 物料匹配 var pickListDetails = this.pickListMaster.PickListDetails; var pickListDetailList = pickListDetails.Where(o => o.Item == hu.Item); if (pickListDetailList == null || pickListDetailList.Count() == 0) { throw new BusinessException("没有找到和条码{0}的零件号{1}匹配的订单明细。", hu.HuId, hu.Item); } pickListDetailList = pickListDetailList.Where(o => o.Uom.Equals(hu.Uom, StringComparison.OrdinalIgnoreCase)); if (pickListDetailList == null || pickListDetailList.Count() == 0) { throw new BusinessException("没有找到和条码{0}的单位{1}匹配的订单明细。", hu.HuId, hu.Uom); } pickListDetailList = pickListDetailList.Where(o => o.UnitCount == hu.UnitCount); if (pickListDetailList == null || pickListDetailList.Count() == 0) { throw new BusinessException("没有找到和条码{0}的包装数{1}匹配的订单明细。", hu.HuId, hu.UnitCount.ToString()); } //强制拣货不需要严格限制批次号 pickListDetailList = pickListDetailList.Where(o => o.LotNo == hu.LotNo); if (pickListDetailList == null || pickListDetailList.Count() == 0) { throw new BusinessException("没有找到和条码{0}的批号{1}匹配的订单明细。", hu.HuId, hu.LotNo.ToString()); } pickListDetailList = pickListDetailList.Where(o => o.ManufactureParty == hu.ManufactureParty); if (pickListDetailList == null || pickListDetailList.Count() == 0) { throw new BusinessException("没有找到和条码{0}的供应商{1}匹配的订单明细。", hu.HuId, hu.ManufactureParty.ToString()); } var matchedpickListDetail = pickListDetailList.FirstOrDefault(o => o.Item == hu.Item && o.UnitCount == hu.UnitCount && o.ManufactureParty == hu.ManufactureParty); #endregion PickListDetailInput input = new PickListDetailInput(); input.HuId = hu.HuId; input.Id = matchedpickListDetail.Id; List<PickListDetailInput> pickListDetailInputs = new List<PickListDetailInput>(); if (matchedpickListDetail.PickListDetailInputs != null) { pickListDetailInputs = matchedpickListDetail.PickListDetailInputs.ToList(); } pickListDetailInputs.Add(input); matchedpickListDetail.PickListDetailInputs = pickListDetailInputs.ToArray(); matchedpickListDetail.CurrentQty -= hu.Qty; matchedpickListDetail.Carton++; this.hus.Insert(0, hu); } this.gvListDataBind(); }
public void DoPickList(PickListDetailInput[] pickListDetailInputList, string userCode) { this.Invoke("DoPickList", new object[] { pickListDetailInputList, userCode}); }
private void MatchHu(Hu hu) { base.CheckHu(hu); if (this.isCancel) { var matchHu = this.hus.Where(h => h.HuId.Equals(hu.HuId, StringComparison.OrdinalIgnoreCase)); if (matchHu == null || matchHu.Count() == 0) { throw new BusinessException("没有需要取消匹配条码:{0}", hu.HuId); } else if (matchHu.Count() == 1) { this.CancelHu(hu); } else { throw new Exception("匹配了多个条码"); } } else { #region 物料匹配 var pickListDetails = this.pickListMaster.PickListDetails; var pickListDetailList = pickListDetails.Where(o => o.Item == hu.Item); if (pickListDetailList == null || pickListDetailList.Count() == 0) { throw new BusinessException("没有找到和条码{0}的零件号{1}匹配的订单明细。", hu.HuId, hu.Item); } pickListDetailList = pickListDetails.Where(o => o.Uom.Equals(hu.Uom, StringComparison.OrdinalIgnoreCase)); if (pickListDetailList == null || pickListDetailList.Count() == 0) { throw new BusinessException("没有找到和条码{0}的单位{1}匹配的订单明细。", hu.HuId, hu.Uom); } pickListDetailList = pickListDetails.Where(o => o.LocationFrom.Equals(hu.Location, StringComparison.OrdinalIgnoreCase)); if (pickListDetailList == null || pickListDetailList.Count() == 0) { throw new BusinessException("条码{0}不在拣货单{1}的待拣货库位中。", hu.HuId, this.pickListMaster.PickListNo); } //pickListDetailList = pickListDetailList.Where(o => o.UnitCount == hu.UnitCount); //if (pickListDetailList == null || pickListDetailList.Count() == 0) //{ // throw new BusinessException("没有找到和条码{0}的包装数{1}匹配的订单明细。", hu.HuId, hu.UnitCount.ToString()); //} //强制拣货不需要严格限制批次号 //pickListDetailList = pickListDetailList.Where(o => o.LotNo == hu.LotNo); //if (pickListDetailList == null || pickListDetailList.Count() == 0) //{ // throw new BusinessException("没有找到和条码{0}的批号{1}匹配的订单明细。", hu.HuId, hu.LotNo.ToString()); //} pickListDetailList = pickListDetails.Where(o => o.ManufactureParty == hu.ManufactureParty || string.IsNullOrEmpty(o.ManufactureParty)); if (pickListDetailList == null || pickListDetailList.Count() == 0) { throw new BusinessException("没有找到和条码{0}的供应商{1}匹配的订单明细。", hu.HuId, hu.ManufactureParty.ToString()); } var matchedpickListDetails = pickListDetails.Where(o => o.Item == hu.Item && o.LocationFrom == hu.Location && o.UnitCount == hu.UnitCount && o.Uom == hu.Uom && o.CurrentQty >= hu.Qty && (o.ManufactureParty == hu.ManufactureParty || string.IsNullOrEmpty(o.ManufactureParty))); if (matchedpickListDetails.Count() == 0) { matchedpickListDetails = pickListDetailList.Where(o => o.Item == hu.Item && o.LocationFrom == hu.Location && o.Uom == hu.Uom && o.CurrentQty >= hu.Qty && (o.ManufactureParty == hu.ManufactureParty || string.IsNullOrEmpty(o.ManufactureParty))); if (matchedpickListDetails.Count() == 0) { throw new BusinessException("零件{0}的剩余拣货数小于条码{1}的数量。",hu.Item, hu.HuId); } } var matchedpickListDetail = matchedpickListDetails.FirstOrDefault(); #endregion PickListDetailInput input = new PickListDetailInput(); input.HuId = hu.HuId; input.Id = matchedpickListDetail.Id; List<PickListDetailInput> pickListDetailInputs = new List<PickListDetailInput>(); if (matchedpickListDetail.PickListDetailInputs != null) { pickListDetailInputs = matchedpickListDetail.PickListDetailInputs.ToList(); } pickListDetailInputs.Add(input); matchedpickListDetail.PickListDetailInputs = pickListDetailInputs.ToArray(); matchedpickListDetail.CurrentQty -= hu.Qty; matchedpickListDetail.Carton++; this.hus.Insert(0, hu); } this.gvListDataBind(); }