示例#1
0
        public void Pick(string pickid, string pickedhu, string picker)
        {
            PickTask task = this.genericMgr.FindAll<PickTask>("from PickTask where PickId = ? ", pickid).SingleOrDefault();
            if (task == null)
            {
                throw new BusinessException("找不到拣货任务");
            }
            else if (!task.Picker.Equals(picker))
            {
                throw new BusinessException("条码对应拣货工为" + task.Picker);
            }
            else if (task.IsHold)
            {
                throw new BusinessException("拣货任务已被冻结");
            }
            else if (task.PickedQty >= task.OrderedQty)
            {
                throw new BusinessException("拣货任务已经完成");
            }

            IList<Hu> hu = huMgr.LoadHus(new string[] { pickedhu });
            if (hu != null && hu.Count == 1)
            {
                //是否有足够库存并占用库存
                if (locationDetailMgr.CanInventoryOccupy(task.Supplier, task.LocationFrom, task.Item, CodeMaster.QualityType.Qualified, hu[0].Qty))
                {
                    //创建拣货结果
                    string resultid = GeneratePickResultId();
                    PickResult result = new PickResult();
                    result.ResultId = resultid;
                    result.PickId = task.PickId;
                    result.Picker = picker;
                    result.PickDate = DateTime.Now;
                    result.PickedHu = pickedhu;
                    result.PickedQty = hu[0].Qty;
                    result.IsShip = false;

                    locationDetailMgr.InventoryOccupy(CodeMaster.OccupyType.Pick, result.ResultId,
                        task.Supplier, task.LocationFrom, task.Item, CodeMaster.QualityType.Qualified, hu[0].Qty);

                    this.genericMgr.Create(result);

                    //更新拣货数
                    task.PickedQty += hu[0].Qty;
                    this.genericMgr.Update(task);

                    //删除配送条码
                    this.genericMgr.Delete("from PickHu where PickId = '"
                        + task.PickId + "' and RepackHu = '" + pickedhu + "'");
                }
                else
                {
                    throw new BusinessException("没有足够库存:" + task.Supplier + "," + task.LocationFrom + "," + task.Item);
                }
            }
            else
            {
                throw new BusinessException("找不到对应的条码!");
            }
        }
示例#2
0
        public void CancelPickResult(PickResult result)
        {
            //查询拣货任务关联的拣货结果,取消拣货(删除拣货结果明细),更新累计拣货数(订单单位)
            //,恢复已经删除的配送条码PickHu,释放已占用的库存。
            //禁止取消AsnNo有值的拣货结果
            if (!result.IsShip)
            {
                PickTask task = this.genericMgr.FindAll<PickTask>("from PickTask where PickId = ? ", result.PickId).SingleOrDefault();
                if (task == null)
                {
                    throw new BusinessException("找不到拣货任务");
                }

                //恢复配送条码
                PickHu oldPickedHu = new PickHu();
                oldPickedHu.PickId = result.PickId;
                oldPickedHu.RepackHu = result.PickedHu;
                this.genericMgr.Create(oldPickedHu);

                //释放已占用库存
                locationDetailMgr.CancelInventoryOccupy(CodeMaster.OccupyType.Pick, result.ResultId);

                //更新累计数
                task.PickedQty -= result.PickedQty;
                this.genericMgr.Update(task);

                //删除result
                this.genericMgr.Delete(result);
            }
            else
            {
                throw new BusinessException("拣货条码已经发货,不能取消");
            }
        }