public ActionResult New(PickStrategy pickStrategy)
 {
     if (ModelState.IsValid)
     {
         base.genericMgr.Create(pickStrategy);
         SaveSuccessMessage("添加成功");
         return RedirectToAction("Index");
     }
     else
     {
         return View(pickStrategy);
     }
 }
 public ActionResult New(PickStrategy pickStrategy)
 {
     if (ModelState.IsValid)
     {
         genericMgr.CreateWithTrim(pickStrategy);
         SaveSuccessMessage(Resources.EXT.ControllerLan.Con_AddedSuccessfully);
         return RedirectToAction("Index");
     }
     else
     {
         return View(pickStrategy);
     }
 }
 public ActionResult Edit(PickStrategy pickStrategy)
 {
     base.genericMgr.Update(pickStrategy);
     SaveSuccessMessage("修改成功");
     return RedirectToAction("Index");
 }
 public ActionResult Edit(PickStrategy pickStrategy)
 {
     genericMgr.UpdateWithTrim(pickStrategy);
     SaveSuccessMessage(Resources.EXT.ControllerLan.Con_ModificateSuccessfully);
     return RedirectToAction("Index");
 }
        private IList<PickLocationDetail> PickMatch(ref decimal pickQty, decimal unitCount,
            PickStrategy pickStrategy, IList<PickLocationDetail> matchedLocationLotDetailList)
        {
            IList<PickLocationDetail> newPickLocationDetailList = new List<PickLocationDetail>();
            #region 零头不占用发货数
            if (!pickStrategy.IsOddOccupy)
            {
                //零头全部发走
                var oddLocationLotDetails = matchedLocationLotDetailList.Where(l => l.IsOdd && l.UnitCount < unitCount);
                foreach (PickLocationDetail matchedLocationLotDetail in oddLocationLotDetails)
                {
                    PickLocationDetail pickLocationDetail = Mapper.Map<PickLocationDetail, PickLocationDetail>(matchedLocationLotDetail);
                    pickLocationDetail.PickStrategy = pickStrategy.Code;
                    pickLocationDetail.IsInventory = true;
                    newPickLocationDetailList.Add(pickLocationDetail);
                    matchedLocationLotDetail.Qty = 0; //库存明细数量置零
                }
            }
            #endregion

            //优先匹配不要拆箱的.
            var qty = pickQty;
            var matchUcDetail = matchedLocationLotDetailList.Where(l => l.Qty > 0)
                .Where(p => qty == p.Qty).FirstOrDefault();
            if (matchUcDetail != null && matchedLocationLotDetailList.Where(l => l.Qty > 0).First().LotNo == matchUcDetail.LotNo)
            {
                PickLocationDetail pickLocationDetail = Mapper.Map<PickLocationDetail, PickLocationDetail>(matchUcDetail);
                pickLocationDetail.Qty = pickQty;
                pickLocationDetail.PickStrategy = pickStrategy.Code;
                pickLocationDetail.IsInventory = true;
                matchUcDetail.Qty = 0;
                pickQty = 0;
                newPickLocationDetailList.Add(pickLocationDetail);
            }
            else
            {
                #region 循环拣货
                var matchDetails = matchedLocationLotDetailList.Where(l => l.Qty > 0).ToList();
                foreach (PickLocationDetail matchedLocationLotDetail in matchDetails)
                {
                    if (pickQty <= 0)
                    {
                        break;
                    }
                    PickLocationDetail pickLocationDetail = Mapper.Map<PickLocationDetail, PickLocationDetail>(matchedLocationLotDetail);
                    pickLocationDetail.PickStrategy = pickStrategy.Code;
                    pickLocationDetail.IsInventory = true;

                    if (pickQty >= matchedLocationLotDetail.Qty)
                    {
                        pickLocationDetail.Qty = matchedLocationLotDetail.Qty;
                        pickQty -= matchedLocationLotDetail.Qty;
                        matchedLocationLotDetail.Qty = 0; //库存明细数量置零
                    }
                    else
                    {
                        var deviation = unitCount * ((decimal)pickStrategy.UcDeviation / 100);
                        if (pickQty < deviation)
                        {
                            pickQty = 0;
                            break;
                            //小于容差值,可以不拣
                        }
                        else if (pickStrategy.IsDevan)
                        {
                            #region 允许拆箱
                            pickLocationDetail.Qty = pickQty;
                            pickLocationDetail.IsDevan = true;
                            matchedLocationLotDetail.Qty -= pickQty;
                            pickQty = 0;
                            #endregion
                        }
                        else
                        {
                            #region 不允许拆箱,全部发走
                            pickLocationDetail.Qty = matchedLocationLotDetail.Qty;
                            matchedLocationLotDetail.Qty = 0; //库存明细数量置零
                            pickQty = 0;
                            #endregion
                        }
                    }
                    newPickLocationDetailList.Add(pickLocationDetail);
                }
                #endregion
            }
            return newPickLocationDetailList;
        }