Exemple #1
0
        private void MatchHu(Hu hu)
        {
            base.CheckHu(hu);

            if (!base.isCancel)
            {
                #region 条码匹配
                //支持发货扫描条码选项为false时,扫描条码仍起到数据收集作用
                //if (hu.Status != HuStatus.Location)
                //{
                //    throw new BusinessException("条码不在库位中");
                //}
                if (orderMasters.Any(o => o.IsShipScanHu))
                {
                    if (hu.Status != HuStatus.Location)
                    {
                        throw new BusinessException("条码不在库位中");
                    }
                }

                var orderDetails = new List<OrderDetail>();
                var orderMaster = this.orderMasters.First();
                //string huId = hu.HuId;
                string huId = orderMasters.Any(o => o.IsShipScanHu) ? hu.HuId : null;

                //先按开始日期排序,在按订单序号排序
                foreach (var om in orderMasters.OrderBy(o => o.StartTime))
                {
                    orderDetails.AddRange(om.OrderDetails.Where(o => o.OrderedQty > o.ShippedQty).OrderBy(o => o.Sequence));
                }

                var matchedOrderDetailList = orderDetails.Where(o => o.Item == hu.Item);
                if (matchedOrderDetailList == null || matchedOrderDetailList.Count() == 0)
                {
                    throw new BusinessException("没有找到和条码{0}的零件号{1}匹配的订单明细。", huId, hu.Item);
                }

                matchedOrderDetailList = matchedOrderDetailList.Where(o => o.Uom.Equals(hu.Uom, StringComparison.OrdinalIgnoreCase));
                if (matchedOrderDetailList == null || matchedOrderDetailList.Count() == 0)
                {
                    throw new BusinessException("没有找到和条码{0}的单位{1}匹配的订单明细。", huId, hu.Uom);
                }

                matchedOrderDetailList = matchedOrderDetailList.Where(o => o.LocationFrom.Equals(hu.Location, StringComparison.OrdinalIgnoreCase));
                if (matchedOrderDetailList == null || matchedOrderDetailList.Count() == 0)
                {
                    throw new BusinessException("没有找到和条码{0}的库位{1}匹配的订单明细。", huId, hu.Location);
                }

                if (orderMaster.IsShipFulfillUC)
                {
                    matchedOrderDetailList = matchedOrderDetailList.Where(o => o.UnitCount == hu.UnitCount);
                    if (matchedOrderDetailList == null || matchedOrderDetailList.Count() == 0)
                    {
                        throw new BusinessException("没有找到和条码{0}的包装数{1}匹配的订单明细。", huId, hu.UnitCount.ToString());
                    }
                }

                matchedOrderDetailList = matchedOrderDetailList.Where(o => o.QualityType == hu.QualityType);
                if (matchedOrderDetailList == null || matchedOrderDetailList.Count() == 0)
                {
                    throw new BusinessException("没有找到和条码{0}的质量状态匹配的订单明细。", huId);
                }

                #region 先匹配未满足订单发货数的(未超发的)
                OrderDetail matchedOrderDetail = MatchOrderDetail(hu, matchedOrderDetailList.Where(o => o.CurrentQty >= hu.Qty).ToList());
                #endregion

                //#region 再匹配允许超发的订单,未发满但是+本次发货超发了
                //if (matchedOrderDetail == null)
                //{
                //    IList<string> orderNoList = orderMasters.Where(o => o.IsShipExceed).Select(o => o.OrderNo).ToList();
                //    matchedOrderDetail = MatchOrderDetail(hu, matchedOrderDetailList.Where(o => (o.CurrentQty > 0)
                //        && (o.CurrentQty < hu.Qty) && orderNoList.Contains(o.OrderNo)).ToList());

                //    #region 再匹配允许超发的订单,已经满了或已经超发了
                //    if (matchedOrderDetail == null)
                //    {
                //        matchedOrderDetail = MatchOrderDetail(hu, matchedOrderDetailList.Where(o => (o.CurrentQty <= 0) && orderNoList.Contains(o.OrderNo)).ToList());
                //    }
                //    #endregion
                //}
                #endregion

                #region 未找到匹配的订单,报错信息
                if (matchedOrderDetail == null)
                {
                    if (string.IsNullOrEmpty(hu.ManufactureParty))
                    {
                        //条码未指定制造商
                        if (matchedOrderDetailList.Where(o => string.IsNullOrEmpty(o.ManufactureParty)).Count() > 0)
                        {
                            //有未指定制造商的订货明细
                            throw new BusinessException("和条码{0}匹配的订单明细的发货数已经全部满足。", huId, hu.Item);
                        }
                        else
                        {
                            //没有未指定制造商的订货明细
                            throw new BusinessException("待发货订单明细指定了制造商,而条码{0}没有指定制造商", huId);
                        }
                    }
                    else
                    {
                        //条码指定了制造商
                        if (matchedOrderDetailList.Where(o => o.ManufactureParty == hu.ManufactureParty).Count() > 0)
                        {
                            //有未指定制造商的订货明细
                            throw new BusinessException("和条码{0}匹配的订单明细的发货数已经全部满足。", huId);
                        }
                        else
                        {
                            //没有未指定制造商的订货明细
                            throw new BusinessException("待发货订单明细指定的制造商和条码{0}制造商{1}不匹配", huId, hu.ManufactureParty);
                        }
                    }
                }
                #endregion

                OrderDetailInput orderDetailInput = new OrderDetailInput();
                orderDetailInput.HuId = hu.HuId;
                orderDetailInput.ShipQty = hu.Qty;
                orderDetailInput.LotNo = hu.LotNo;
                orderDetailInput.Id = matchedOrderDetail.Id;

                List<OrderDetailInput> orderDetailInputs = new List<OrderDetailInput>();
                if (matchedOrderDetail.OrderDetailInputs != null)
                {
                    orderDetailInputs = matchedOrderDetail.OrderDetailInputs.ToList();
                }

                orderDetailInputs.Add(orderDetailInput);

                matchedOrderDetail.OrderDetailInputs = orderDetailInputs.ToArray();
                matchedOrderDetail.CurrentQty -= hu.Qty;
                matchedOrderDetail.Carton++;
                base.hus.Insert(0, hu);
            }
            else
            {
                #region 取消
                this.CancelHu(hu);
                #endregion
            }
            this.gvListDataBind();
        }
Exemple #2
0
 /// <remarks/>
 public System.IAsyncResult BeginDoTransfer(FlowMaster flowMaster, OrderDetailInput[] orderDetailInputList, string userCode, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("DoTransfer", new object[] {
                 flowMaster,
                 orderDetailInputList,
                 userCode}, callback, asyncState);
 }
        private void MatchOrderMaster(Hu hu)
        {
            //if (this.orderMasters[0].OrderStrategy == FlowStrategy.KIT && this.orderMasters[0].Status == OrderStatus.InProcess)
            //{
            //    throw new BusinessException("此KIT单无需扫描条码");
            //}

            base.CheckHu(hu);

            if (!base.isCancel)
            {
                if (this.orderMasters[0].Type == OrderType.Procurement)
                {
                    if (hu.Status == HuStatus.Location)
                    {
                        throw new BusinessException("条码已经在库位{0}中", hu.Location);
                    }
                    if (hu.Status == HuStatus.Ip)
                    {
                        throw new BusinessException("条码已经在途{0}");
                    }
                }
                else if (this.orderMasters[0].Type == OrderType.Transfer)
                {
                    if (hu.Status != HuStatus.Location)
                    {
                        throw new BusinessException("条码不在库位中");
                    }
                }

                #region 条码匹配
                var orderDetails = new List<OrderDetail>();
                var orderMaster = this.orderMasters.First();
                string huId = hu.HuId;

                //先按开始日期排序,在按订单序号排序
                foreach (var om in orderMasters.OrderBy(o => o.StartTime))
                {
                    orderDetails.AddRange(om.OrderDetails.OrderBy(o => o.Sequence));
                }

                var matchedOrderDetailList = orderDetails.Where(o => o.Item == hu.Item);
                if (matchedOrderDetailList == null || matchedOrderDetailList.Count() == 0)
                {
                    throw new BusinessException("没有找到和条码{0}的零件号{1}匹配的订单明细。", huId, hu.Item);
                }

                matchedOrderDetailList = matchedOrderDetailList.Where(o => o.Uom.Equals(hu.Uom, StringComparison.OrdinalIgnoreCase));
                if (matchedOrderDetailList == null || matchedOrderDetailList.Count() == 0)
                {
                    throw new BusinessException("没有找到和条码{0}的单位{1}匹配的订单明细。", huId, hu.Uom);
                }

                //强制收货不考虑包装
                //if (orderMaster.IsOrderFulfillUC)
                //{
                //    matchedOrderDetailList = matchedOrderDetailList.Where(o => o.UnitCount == hu.UnitCount);
                //    if (matchedOrderDetailList == null || matchedOrderDetailList.Count() == 0)
                //    {
                //        throw new BusinessException("没有找到和条码{0}的包装数{1}匹配的订单明细。", huId, hu.UnitCount.ToString());
                //    }
                //}

                matchedOrderDetailList = matchedOrderDetailList.Where(o => o.QualityType == hu.QualityType);
                if (matchedOrderDetailList == null || matchedOrderDetailList.Count() == 0)
                {
                    throw new BusinessException("没有找到和条码{0}的质量状态匹配的订单明细。", huId);
                }

                #region 先匹配未满足订单发货数的(未超收的)
                OrderDetail matchedOrderDetail = MatchOrderDetail(hu, matchedOrderDetailList.Where(o => o.CurrentQty >= hu.Qty).ToList());
                #endregion

                #region 再匹配允许超收的订单,未发满但是+本次发货超收了 todo
                //if (matchedOrderDetail == null)
                //{
                //    IList<string> orderNoList = orderMasters.Where(o => o.IsReceiveExceed).Select(o => o.OrderNo).ToList();
                //    matchedOrderDetail = MatchOrderDetail(hu, matchedOrderDetailList.Where(o => (o.CurrentQty > 0)
                //        && (o.CurrentQty < hu.Qty) && orderNoList.Contains(o.OrderNo)).ToList());

                //    #region 再匹配允许超发的订单,已经满了或已经超发了
                //    if (matchedOrderDetail == null)
                //    {
                //        matchedOrderDetail = MatchOrderDetail(hu, matchedOrderDetailList.Where(o => (o.CurrentQty <= 0) && orderNoList.Contains(o.OrderNo)).ToList());
                //    }
                //    #endregion
                //}
                #endregion

                #region 未找到匹配的订单,报错信息
                if (matchedOrderDetail == null)
                {
                    if (string.IsNullOrEmpty(hu.ManufactureParty))
                    {
                        //条码未指定制造商
                        if (matchedOrderDetailList.Where(o => string.IsNullOrEmpty(o.ManufactureParty)).Count() > 0)
                        {
                            //有未指定制造商的订货明细
                            throw new BusinessException("和条码{0}匹配的订单明细的发货数已经全部满足。", huId, hu.Item);
                        }
                        else
                        {
                            //没有未指定制造商的订货明细
                            throw new BusinessException("待发货订单明细指定了制造商,而条码{0}没有指定制造商", huId);
                        }
                    }
                    else
                    {
                        //条码指定了制造商
                        if (matchedOrderDetailList.Where(o => o.ManufactureParty == hu.ManufactureParty).Count() > 0)
                        {
                            //有未指定制造商的订货明细
                            throw new BusinessException("和条码{0}匹配的订单明细的发货数已经全部满足。", huId);
                        }
                        else
                        {
                            //没有未指定制造商的订货明细
                            throw new BusinessException("待发货订单明细指定的制造商和条码{0}制造商{1}不匹配", huId, hu.ManufactureParty);
                        }
                    }
                }
                #endregion

                OrderDetailInput input = new OrderDetailInput();
                input.HuId = hu.HuId;
                input.ReceiveQty = hu.Qty;
                input.LotNo = hu.LotNo;
                input.Id = matchedOrderDetail.Id;

                List<OrderDetailInput> orderDetailInputs = new List<OrderDetailInput>();
                if (matchedOrderDetail.OrderDetailInputs != null)
                {
                    orderDetailInputs = matchedOrderDetail.OrderDetailInputs.ToList();
                }
                orderDetailInputs.Add(input);

                matchedOrderDetail.OrderDetailInputs = orderDetailInputs.ToArray();
                matchedOrderDetail.CurrentQty -= hu.Qty;
                matchedOrderDetail.Carton++;
                base.hus.Insert(0, hu);
                #endregion
            }
            else
            {
                this.CancelHu(hu);
            }

            this.gvListDataBind();
        }
Exemple #4
0
 /// <remarks/>
 public System.IAsyncResult BeginDoReceiveOrder(OrderDetailInput[] orderDetailInputList, System.Nullable<System.DateTime> effDate, string userCode, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("DoReceiveOrder", new object[] {
                 orderDetailInputList,
                 effDate,
                 userCode}, callback, asyncState);
 }
Exemple #5
0
 public void DoTransfer(FlowMaster flowMaster, OrderDetailInput[] orderDetailInputList, string userCode) {
     this.Invoke("DoTransfer", new object[] {
                 flowMaster,
                 orderDetailInputList,
                 userCode});
 }
Exemple #6
0
 public void DoReceiveOrder(OrderDetailInput[] orderDetailInputList, [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] System.Nullable<System.DateTime> effDate, string userCode) {
     this.Invoke("DoReceiveOrder", new object[] {
                 orderDetailInputList,
                 effDate,
                 userCode});
 }
Exemple #7
0
        protected override void DoSubmit()
        {
            try
            {
                if (this.flowMaster == null)
                {
                    throw new BusinessException("请先扫描路线,库位或者库格。");
                }
                List<OrderDetailInput> orderDetailInputList = new List<OrderDetailInput>();

                if (this.flowMaster.FlowDetails != null)
                {
                    foreach (var flowDetail in this.flowMaster.FlowDetails)
                    {
                        if (flowDetail.FlowDetailInputs != null)
                        {
                            foreach (var fdi in flowDetail.FlowDetailInputs)
                            {
                                OrderDetailInput orderDetailInput = new OrderDetailInput();
                                orderDetailInput.HuId = fdi.HuId;
                                orderDetailInput.Qty = fdi.Qty;
                                orderDetailInput.LotNo = fdi.LotNo;
                                orderDetailInput.Id = flowDetail.Id;

                                orderDetailInputList.Add(orderDetailInput);
                            }
                        }
                    }
                }
                this.smartDeviceService.DoTransfer(flowMaster, orderDetailInputList.ToArray(), base.user.Code);
                this.Reset();
                base.lblMessage.Text = "移库成功";
            }
            catch (Exception ex)
            {
                this.isMark = true;
                this.tbBarCode.Text = string.Empty;
                //this.tbBarCode.Focus();
                Utility.ShowMessageBox(ex.Message);
            }
        }
        private void MatchHu(Hu hu)
        {
            base.CheckHu(hu);

            if (!base.isCancel)
            {
                #region 条码匹配
                //if (hu.Status != HuStatus.Location)
                //{
                //    if (this.location == null)
                //    {
                //        throw new BusinessException("请先扫描库位条码。");
                //    }
                //}


                var orderDetails = new List<OrderDetail>();
                //var orderMaster = this.orderMasters.First();
                string huId = hu.HuId;

                //先按开始日期排序,在按订单序号排序
                //foreach (var om in orderMasters.OrderBy(o => o.StartTime))
                //{
                //    orderDetails.AddRange(om.OrderDetails.Where(o => o.OrderedQty > o.ShippedQty).OrderBy(o => o.Sequence));
                //}



                var matchedOrderDetail = this.orderMaster.OrderDetails.Where(o => o.Item == hu.Item && o.IsScanHu).FirstOrDefault();
                if (matchedOrderDetail == null)
                {
                    throw new BusinessException("分装生产单{0}不需要扫描零件号为{1}的零件。", this.orderMaster.OrderNo, hu.Item);
                }
                else
                {
                    if (matchedOrderDetail.OrderedQty != hu.Qty)
                    {
                        throw new BusinessException("条码{0}的数量不等于零件{1}需要投入的数量。", huId, hu.Item);
                    }
                }
                matchedOrderDetail.ReceivedQty = hu.Qty;
                matchedOrderDetail.CurrentQty = matchedOrderDetail.CurrentQty - hu.Qty;
                #endregion

                OrderDetailInput orderDetailInput = new OrderDetailInput();
                orderDetailInput.HuId = hu.HuId;
                orderDetailInput.ReceiveQty = hu.Qty;
                orderDetailInput.LotNo = hu.LotNo;
                orderDetailInput.Id = matchedOrderDetail.Id;
                if (hu.Status == HuStatus.Location)
                {
                    orderDetailInput.IsHuInLocation = true;
                }
                else
                {
                    orderDetailInput.IsHuInLocation = false;
                }
                this.orderDetailInputs.Add(orderDetailInput);

                this.lblMessage.Text = "请扫描关键件条码或者子生产单。";
                base.hus.Insert(0, hu);
            }
            else
            {
                #region 取消
                this.CancelHu(hu);
                #endregion
            }
            this.gvListDataBind();
        }
Exemple #9
0
        private void MatchOrderMaster(Hu hu)
        {
            if (hu == null)
            {
                throw new BusinessException("条码不存在");
            }

            hu.CurrentQty = hu.Qty;
            var matchHu = this.hus.Where(h => h.HuId.Equals(hu.HuId, StringComparison.OrdinalIgnoreCase));

            #region 取消条码
            if (this.isCancel)
            {
                if (matchHu == null || matchHu.Count() == 0)
                {
                    throw new BusinessException("没有需要取消匹配条码:{0}", hu.HuId);
                }
                else if (matchHu.Count() == 1)
                {
                    this.CancelHu(hu);
                }
                else
                {
                    throw new Exception("匹配了多个条码");
                }
            }
            #endregion
            #region 检查条码并匹配收货条件。
            else
            {
                if (hu.IsFreeze)
                {
                    throw new BusinessException("条码被冻结!");
                }
                if (this.ipMaster == null &&
                    (this.orderMasters[0].Type == OrderType.Transfer || this.orderMasters[0].Type == OrderType.SubContractTransfer))
                {
                    if (hu.Status != HuStatus.Location)
                    {
                        throw new BusinessException("不在库存中的条码不能被收货");
                    }

                    if (!Utility.HasPermission(user.Permissions, null, true, false, hu.Region, null))
                    {
                        throw new BusinessException("没有此条码的权限");
                    }
                }
                else
                {
                    if (hu.Status == HuStatus.Location)
                    {
                        throw new BusinessException("在库存中的条码不能被收货");
                    }
                }
                if (this.orderMasters[0].Type == OrderType.Procurement)
                {
                    if (hu.Status == HuStatus.Location)
                    {
                        throw new BusinessException("条码已经在库位{0}中", hu.Location);
                    }
                    if (hu.Status == HuStatus.Ip)
                    {
                        throw new BusinessException("条码已经在途{0}");
                    }
                }
                else if (this.orderMasters[0].Type == OrderType.Transfer)
                {
                    if (hu.Status != HuStatus.Location)
                    {
                        throw new BusinessException("条码不在库位中");
                    }
                }

                if (matchHu != null && matchHu.Count() > 0)
                {
                    throw new BusinessException("条码重复扫描!");
                }

                if (this.orderMasters[0].OrderStrategy == FlowStrategy.KIT)
                {
                    if (this.orderMasters.Count > 1)
                    {
                        this.Reset();
                        throw new BusinessException("合并收货包括了KIT单,全部取消,重新扫描");
                    }
                    //接下来应该是统一的逻辑去处理 
                }

                var orderDetailList = new List<OrderDetail>();
                foreach (var om in this.orderMasters)
                {
                    orderDetailList.AddRange(om.OrderDetails);
                }
                #region  标准匹配流程
                List<Hu> inputHus = new List<Hu>();
                List<Hu> needRemoveHus = new List<Hu>();
                inputHus.Add(hu);
                orderDetailList = orderDetailList.OrderByDescending(p => p.RemainReceivedQty).ToList();

                //循环条码做非条码匹配
                foreach (Hu inputHu in inputHus)
                {
                    //var matchIpDetail = new IpDetail();
                    //匹配物料,包装,供应商,质量状态(没有手动修改单包装的)
                    var matchOrderDetailsFirst = new List<OrderDetail>();
                    matchOrderDetailsFirst = orderDetailList.Where(i => i.Item == inputHu.Item &&
                        //i.UnitCount == inputHu.UnitCount &&
                                                i.Uom == inputHu.Uom &&
                                                //i.ManufactureParty == inputHu.ManufactureParty &&
                                                i.RemainReceivedQty >= inputHu.Qty &&
                                                i.QualityType == inputHu.QualityType &&
                                                i.IsChangeUnitCount == false).ToList();

                    if (matchOrderDetailsFirst.Count() > 0)
                    {
                        var matchedOrderDetail = matchOrderDetailsFirst.First();

                        var orderDetailInput = new OrderDetailInput();
                        orderDetailInput.HuId = inputHu.HuId;
                        orderDetailInput.Id = matchedOrderDetail.Id;
                        orderDetailInput.LotNo = inputHu.LotNo;
                        orderDetailInput.ReceiveQty = inputHu.Qty;
                        matchedOrderDetail.RemainReceivedQty = matchedOrderDetail.RemainReceivedQty - inputHu.Qty;
                        matchedOrderDetail.CurrentQty = matchedOrderDetail.CurrentQty - inputHu.Qty;
                        matchedOrderDetail.Carton++;
                        List<OrderDetailInput> orderDetailsProcess = matchedOrderDetail.OrderDetailInputs.ToList();
                        orderDetailsProcess.Add(orderDetailInput);
                        matchedOrderDetail.OrderDetailInputs = orderDetailsProcess.ToArray();
                        needRemoveHus.Add(inputHu);
                    }

                    //匹配物料,供应商,质量状态(手动修改单包装的)
                    matchOrderDetailsFirst = new List<OrderDetail>();
                    matchOrderDetailsFirst = orderDetailList.Where(i => i.Item == inputHu.Item &&
                                                i.Uom == inputHu.Uom &&
                                                //i.ManufactureParty == inputHu.ManufactureParty &&
                                                i.RemainReceivedQty >= inputHu.Qty &&
                                                i.QualityType == inputHu.QualityType &&
                                                i.IsChangeUnitCount == true).ToList();

                    if (matchOrderDetailsFirst.Count() > 0)
                    {
                        var matchedOrderDetail = matchOrderDetailsFirst.First();

                        var orderDetailInput = new OrderDetailInput();
                        orderDetailInput.HuId = inputHu.HuId;
                        orderDetailInput.Id = matchedOrderDetail.Id;
                        orderDetailInput.LotNo = inputHu.LotNo;
                        orderDetailInput.ReceiveQty = inputHu.Qty;
                        matchedOrderDetail.RemainReceivedQty = matchedOrderDetail.RemainReceivedQty - inputHu.Qty;
                        matchedOrderDetail.CurrentQty = matchedOrderDetail.CurrentQty - inputHu.Qty;
                        matchedOrderDetail.Carton++;
                        List<OrderDetailInput> orderDetailsProcess = matchedOrderDetail.OrderDetailInputs.ToList();
                        orderDetailsProcess.Add(orderDetailInput);
                        matchedOrderDetail.OrderDetailInputs = orderDetailsProcess.ToArray();
                        needRemoveHus.Add(inputHu);
                    }
                }

                foreach (var item in needRemoveHus)
                {
                    inputHus.Remove(item);
                }
                needRemoveHus = new List<Hu>();

                //如果inputHus没有全部匹配,接下来匹配物料,包装,质量状态
                if (inputHus.Count > 0)
                {
                    foreach (Hu inputHu in inputHus)
                    {
                        //var matchIpDetail = new IpDetail();
                        //再匹配物料,质量状态
                        var matchOrderDetailsFirst = new List<OrderDetail>();
                        matchOrderDetailsFirst = orderDetailList.Where(i => i.Item.Equals(inputHu.Item, StringComparison.OrdinalIgnoreCase) &&
                            //i.UnitCount == inputHu.UnitCount &&
                                                        i.Uom == inputHu.Uom &&
                            //i.ManufactureParty.Equals(inputHu.ManufactureParty, StringComparison.OrdinalIgnoreCase) &&
                                                        i.RemainReceivedQty >= inputHu.Qty &&
                                                        i.QualityType == inputHu.QualityType &&
                                                        i.IsChangeUnitCount == false).ToList();

                        if (matchOrderDetailsFirst.Count() > 0)
                        {
                            var matchedOrderDetail = matchOrderDetailsFirst.First();

                            var orderDetailInput = new OrderDetailInput();
                            orderDetailInput.HuId = inputHu.HuId;
                            orderDetailInput.Id = matchedOrderDetail.Id;
                            orderDetailInput.LotNo = inputHu.LotNo;
                            orderDetailInput.ReceiveQty = inputHu.Qty;
                            matchedOrderDetail.RemainReceivedQty = matchedOrderDetail.RemainReceivedQty - inputHu.Qty;
                            matchedOrderDetail.CurrentQty = matchedOrderDetail.CurrentQty - inputHu.Qty;
                            matchedOrderDetail.Carton++;
                            List<OrderDetailInput> orderDetailsProcess = matchedOrderDetail.OrderDetailInputs.ToList();
                            orderDetailsProcess.Add(orderDetailInput);
                            matchedOrderDetail.OrderDetailInputs = orderDetailsProcess.ToArray();
                            needRemoveHus.Add(inputHu);
                        }

                        //再匹配物料,包装,质量状态
                        matchOrderDetailsFirst = new List<OrderDetail>();
                        matchOrderDetailsFirst = orderDetailList.Where(i => i.Item.Equals(inputHu.Item, StringComparison.OrdinalIgnoreCase) &&
                            //i.UnitCount == inputHu.UnitCount &&
                                                    i.Uom == inputHu.Uom &&
                            //i.ManufactureParty.Equals(inputHu.ManufactureParty, StringComparison.OrdinalIgnoreCase) &&
                                                    i.RemainReceivedQty >= inputHu.Qty &&
                                                    i.QualityType == inputHu.QualityType &&
                                                    i.IsChangeUnitCount == true).ToList();

                        if (matchOrderDetailsFirst.Count() > 0)
                        {
                            var matchedOrderDetail = matchOrderDetailsFirst.First();

                            var orderDetailInput = new OrderDetailInput();
                            orderDetailInput.HuId = inputHu.HuId;
                            orderDetailInput.Id = matchedOrderDetail.Id;
                            orderDetailInput.LotNo = inputHu.LotNo;
                            orderDetailInput.ReceiveQty = inputHu.Qty;
                            matchedOrderDetail.RemainReceivedQty = matchedOrderDetail.RemainReceivedQty - inputHu.Qty;
                            matchedOrderDetail.CurrentQty = matchedOrderDetail.CurrentQty - inputHu.Qty;
                            matchedOrderDetail.Carton++;
                            List<OrderDetailInput> orderDetailsProcess = matchedOrderDetail.OrderDetailInputs.ToList();
                            orderDetailsProcess.Add(orderDetailInput);
                            matchedOrderDetail.OrderDetailInputs = orderDetailsProcess.ToArray();
                            needRemoveHus.Add(inputHu);
                        }
                    }
                    foreach (var item in needRemoveHus)
                    {
                        inputHus.Remove(item);
                    }
                }

                //如果还有未匹配成功的就报错
                if (inputHus.Count > 0)
                {
                    throw new BusinessException("条码{0}在不满足订单所有收货明细行收货条件", hu.HuId);
                }

                #endregion
                this.gvListDataBind();
                this.lblMessage.Text = "请扫描收货物料条码";
                this.hus.Add(hu);
            #endregion
            }

        }
Exemple #10
0
        protected override void DoSubmit()
        {
            if ((this.orderMasters == null || this.orderMasters.Count == 0)
                && (this.ipMaster == null))
            {
                throw new BusinessException("请先扫描订单或送货单。");
            }

            #region 要货单收货的逻辑
            //ORD收货
            if (this.ipMaster == null)
            {
                List<OrderDetail> orderDetailList = new List<OrderDetail>();
                List<OrderDetailInput> orderDetailInputList = new List<OrderDetailInput>();

                ////2012-06-09 丁丁说后台可以接受多个KIT收货。最后讨论的是只有安吉或者外部的才会合并 在前面做判断即可
                //if (this.orderMasters.Count > 1)
                //{
                //    if (this.orderMasters.Where(o => o.OrderStrategy == FlowStrategy.KIT).Count() > 0)
                //    {
                //        throw new BusinessException("KIT单不能合并收货。");
                //    }
                //}

                foreach (var om in orderMasters)
                {
                    if (om.OrderDetails != null)
                    {
                        orderDetailList.AddRange(om.OrderDetails);
                    }
                }

                //if (orderDetailList.Any(od => od.CurrentQty > 0))
                //{
                //    DialogResult dr = MessageBox.Show("本次收货有未收完的明细,是否继续?", "未全部收货", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                //    if (dr == DialogResult.No)
                //    {
                //        this.isMark = true;
                //        //this.tbBarCode.Focus();
                //        return;
                //    }
                //}

                if (this.isScanOne == false)
                {
                    foreach (var orderDetail in orderDetailList)
                    {
                        if (orderDetail.OrderedQty - orderDetail.ReceivedQty > 0)
                        {
                            var orderDetailInput = new OrderDetailInput();
                            orderDetailInput.Id = orderDetail.Id;
                            orderDetailInput.ReceiveQty = orderDetail.OrderedQty - orderDetail.ReceivedQty;
                            orderDetailInputList.Add(orderDetailInput);
                        }
                    }
                }
                else
                {
                    foreach (var orderDetail in orderDetailList)
                    {
                        if (orderDetail.OrderDetailInputs != null)
                        {
                            orderDetailInputList.AddRange(orderDetail.OrderDetailInputs);
                        }
                    }
                }

                //if (this.orderMasters[0].OrderStrategy == FlowStrategy.KIT && this.orderMasters[0].Status == OrderStatus.InProcess)
                //{
                //    this.smartDeviceService.DoReceiveKit(this.orderMasters[0].OrderNo, this.effDate, base.user.Code);
                //}

                if (orderDetailInputList.Count == 0)
                {
                    throw new BusinessException("没有扫描条码");
                }
                //if (this.orderMasters[0].OrderStrategy == FlowStrategy.KIT && this.orderMasters[0].Status == OrderStatus.Submit
                //    && this.orderMasters[0].OrderDetails.Count(o => o.CurrentQty != 0) > 0)
                //{
                //    throw new BusinessException("必须满足KIT单收货数。");
                //}
                this.smartDeviceService.DoReceiveOrder(orderDetailInputList.ToArray(), this.effDate, base.user.Code);

            }
            #endregion

            #region ASN收货逻辑
            //ASN收货
            else
            {
                List<IpDetailInput> ipDetailInputList = new List<IpDetailInput>();

                if (this.ipMaster.IpDetails.Any(od => od.CurrentQty > 0))
                {
                    DialogResult dr = MessageBox.Show("本次收货有未收完的明细,是否继续?", "未全部收货", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    if (dr == DialogResult.No)
                    {
                        this.isMark = true;
                        //this.tbBarCode.Focus();
                        return;
                    }
                }
                //安吉或者外部直送的排序单,全部需要扫描
                if (this.ipMaster.Type == IpType.SEQ)
                {
                    ////如果是外部的直送的排序单,必须扫描全部关键件
                    //if (this.ipMaster.PartyFrom == this.smartDeviceService.GetEntityPreference(CodeEnum.WMSAnjiRegion) || this.ipMaster.OrderType == OrderType.ScheduleLine || this.ipMaster.OrderType == OrderType.Procurement)
                    //{
                    //    foreach (var ipDetail in this.ipMaster.IpDetails)
                    //    {
                    //        //确认关键全部扫描,将条码传给后(排序单所有零件都是关键件)
                    //        if (this.ipMaster.IpDetailInputs.Where(i => i.Id == ipDetail.Id && !string.IsNullOrEmpty(i.HuId)).Count() == 0)
                    //        {
                    //            throw new BusinessException("安吉或者外部直送排序单需扫描全部关键件。");
                    //        }

                    //        var ipDetailInput = this.ipMaster.IpDetailInputs.FirstOrDefault(i => i.Id == ipDetail.Id && !string.IsNullOrEmpty(i.HuId));
                    //        ipDetailInputList.Add(ipDetailInput);
                    //    }
                    //}
                    ////内部排序要么全部扫描要么全部不扫描
                    //else
                    //{
                    //如果扫了一个必须全部扫描
                    if (this.isScanOne == true)
                    {
                        foreach (var ipDetail in this.ipMaster.IpDetails)
                        {
                            if (this.ipMaster.IpDetailInputs.Where(i => i.Id == ipDetail.Id && !string.IsNullOrEmpty(i.HuId)).Count() == 0)
                            {
                                throw new BusinessException("已扫入一个或多个条码,需将剩下的条码全部扫描。");
                            }

                            var ipDetailInput = this.ipMaster.IpDetailInputs.FirstOrDefault(i => i.Id == ipDetail.Id && !string.IsNullOrEmpty(i.HuId));
                            ipDetailInputList.Add(ipDetailInput);
                        }
                    }
                    else
                    {
                        foreach (var ipDetail in this.ipMaster.IpDetails)
                        {
                            //所有零件都直接填充数量传到后台
                            if (ipDetail.RemainReceivedQty > 0)
                            {
                                var ipDetailInput = new IpDetailInput();
                                ipDetailInput.Id = ipDetail.Id;
                                ipDetailInput.ReceiveQty = ipDetail.Qty;
                                ipDetailInputList.Add(ipDetailInput);
                            }
                        }
                    }
                    //}
                }
                //如果是KIT需要区分内部和外部,外部的KIT不需要扫描条码,内部的必须扫描全部关键件。
                if (this.ipMaster.Type == IpType.KIT)
                {
                    //外部送货的KIT单
                    if (this.ipMaster.PartyFrom == this.smartDeviceService.GetEntityPreference(CodeEnum.WMSAnjiRegion) || this.ipMaster.OrderType == OrderType.ScheduleLine || this.ipMaster.OrderType == OrderType.Procurement)
                    {
                        foreach (var ipDetail in this.ipMaster.IpDetails)
                        {
                            //所有零件都直接填充数量传到后台
                            if (ipDetail.RemainReceivedQty > 0)
                            {
                                var ipDetailInput = new IpDetailInput();
                                ipDetailInput.Id = ipDetail.Id;
                                ipDetailInput.ReceiveQty = ipDetail.Qty;
                                ipDetailInputList.Add(ipDetailInput);
                            }
                        }
                        //ipDetailInputList.AddRange(this.ipMaster.IpDetailInputs);
                    }
                    //内部移库的KIT单
                    else
                    {
                        foreach (var ipDetail in this.ipMaster.IpDetails)
                        {
                            //确认关键全部扫描,将条码传给后台
                            if (ipDetail.IsScanHu == true)
                            {
                                if (this.ipMaster.IpDetailInputs.Where(i => i.Id == ipDetail.Id && !string.IsNullOrEmpty(i.HuId)).Count() == 0)
                                {
                                    throw new BusinessException("内部KIT单需要扫描全部关键件");
                                }

                                var ipDetailInput = this.ipMaster.IpDetailInputs.FirstOrDefault(i => i.Id == ipDetail.Id && !string.IsNullOrEmpty(i.HuId));
                                ipDetailInputList.Add(ipDetailInput);
                            }
                            //非关键件直接填充数量
                            else if (ipDetail.RemainReceivedQty > 0)
                            {
                                var ipDetailInput = new IpDetailInput();
                                ipDetailInput.Id = ipDetail.Id;
                                ipDetailInput.ReceiveQty = ipDetail.Qty;
                                ipDetailInputList.Add(ipDetailInput);
                            }
                        }
                        //ipDetailInputList.AddRange(this.ipMaster.IpDetailInputs); 
                    }
                }
                //如果普通收货没有有扫描条码的,全部按数量收货
                if (this.isScanOne == false && this.ipMaster.IpDetailInputs.Count() == 0 && this.ipMaster.Type != IpType.KIT && this.ipMaster.Type != IpType.SEQ)
                {
                    foreach (var ipDetail in this.ipMaster.IpDetails)
                    {
                        if (ipDetail.Qty - ipDetail.ReceivedQty > 0)
                        {
                            var ipDetailInput = new IpDetailInput();
                            ipDetailInput.Id = ipDetail.Id;
                            ipDetailInput.ReceiveQty = ipDetail.Qty - ipDetail.ReceivedQty;
                            ipDetailInputList.Add(ipDetailInput);
                        }
                    }
                }
                else
                {
                    foreach (var ipDetailInput in this.ipMaster.IpDetailInputs)
                    {
                        //ipDetailInput.ReceiveQty = ipDetailInput.ReceiveQty;
                        if (ipDetailInput.ReceiveQty > 0)
                        {
                            ipDetailInputList.Add(ipDetailInput);
                        }
                    }
                }
                if (ipDetailInputList.Count == 0)
                {
                    this.Reset();
                    throw new BusinessException("本次收货出现错误,请重新收货");
                }
                this.smartDeviceService.DoReceiveIp(ipDetailInputList.ToArray(), this.effDate, base.user.Code);
            #endregion

            }

            this.Reset();
            base.lblMessage.Text = "收货成功";
        }