private void MatchPickTask(Hu hu)
 {
     if (hu == null)
     {
         throw new BusinessException("条码不存在");
     }
 }
예제 #2
0
 private void ScanBarCode()
 {
     if (this.tbBarCode.Text.Trim() == string.Empty)
     {
         if (this.btnIndex == 1)
         {
             this.btnMore2_Click(null, null);
         }
         else if (this.btnIndex == 2)
         {
             this.btnMore3_Click(null, null);
         }
         else if (this.btnIndex == 3)
         {
             this.btnMore1_Click(null, null);
         }
     }
     else
     {
         this.hu = smartDeviceService.GetHu(this.tbBarCode.Text.Trim());
         this.tbBarCode.Text = string.Empty;
         this.tbBarCode.Focus();
         this.btnMore1_Click(null, null);
     }
 }
예제 #3
0
        protected void MatchHu(Hu hu)
        {
            base.CheckHu(hu);

            if (!base.isCancel)
            {
                GroupHu groupHu = new GroupHu();

                if (groupHus == null)
                {
                    groupHus = new List<GroupHu>();
                }

                var q = groupHus
                    .Where(g => g.Item.Equals(hu.Item, StringComparison.OrdinalIgnoreCase)
                        && g.Uom.Equals(hu.Uom, StringComparison.OrdinalIgnoreCase)
                        && g.UnitCount == hu.UnitCount);
                if (q.Count() > 0)
                {
                    groupHu = q.Single();
                }
                else
                {
                    groupHu.Item = hu.Item;
                    groupHu.ItemDescription = hu.ItemDescription;
                    groupHu.ReferenceItemCode = hu.ReferenceItemCode;
                    groupHu.UnitCount = hu.UnitCount;
                    groupHu.Uom = hu.Uom;

                    var flowDetailList = new List<FlowDetail>();
                    groupHus.Add(groupHu);
                }

                groupHu.CurrentQty += hu.Qty;
                groupHu.Carton++;
                //
                base.hus.Insert(0, hu);
            }
            else
            {
                this.CancelHu(hu);
            }
            this.gvListDataBind();
        }
예제 #4
0
        private void MatchHu(Hu hu)
        {
            if (hu == null)
            {
                throw new BusinessException("条码不存在");
            }
            if (hu.Qty <= 0)
            {
                throw new BusinessException("条码的数量须大于0");
            }


            hu.CurrentQty = hu.Qty;


            //if (hu.IsFreeze)
            //{
            //    throw new BusinessException("条码被冻结!");
            //}
            //if (hu.OccupyType != OccupyType.None)
            //{
            //    throw new BusinessException("条码被{0}占用!", hu.OccupyReferenceNo);
            //}

            if (!base.isCancel)
            {
                if (this.isOldHu) //old
                {
                    this.oldHus.Insert(0, hu);
                    this.gvListDataBind();
                }
                else //new
                {

                }
            }
            else
            {
                this.CancelHu(hu);
            }
        }
예제 #5
0
        private OrderDetail MatchOrderDetail(Hu hu, List<OrderDetail> orderDetailList)
        {
            if (orderDetailList != null && orderDetailList.Count > 0)
            {
                //先匹配发货明细的制造商
                OrderDetail matchedOrderDetail = orderDetailList.Where(o => (o.ManufactureParty == null ? string.Empty : o.ManufactureParty.Trim())
                    == (hu.ManufactureParty == null ? string.Empty : hu.ManufactureParty.Trim())).FirstOrDefault();

                //在匹配没有制造上的发货明细
                if (matchedOrderDetail == null)
                {
                    matchedOrderDetail = orderDetailList.Where(o => string.IsNullOrEmpty(o.ManufactureParty)).FirstOrDefault();
                }

                return matchedOrderDetail;
            }
            return null;
        }
예제 #6
0
        private void DoPickUp()
        {
            if (this.tbBarCode.Text.Trim() == string.Empty)
            {
                return;
            }
            this.hu = this.smartDeviceService.GetHu(this.tbBarCode.Text.Trim());
            if (this.hu == null)
            {
                throw new BusinessException("此条码不存在");
            }

            if (!Utility.HasPermission(user.Permissions, null, true, false, this.hu.Region, null))
            {
                throw new BusinessException("没有操作此区域{0}的权限", hu.Region);
            }

            this.smartDeviceService.DoPickUp(this.tbBarCode.Text.Trim(), this.user.Code);

            this.lbl01.Text = this.hu.Item;
            this.lbl02.Text = this.hu.ReferenceItemCode;
            this.lbl03.Text = this.hu.LotNo;
            this.lbl04.Text = this.hu.Qty.ToString("0.###");
            this.lbl05.Text = this.hu.Uom;
            this.lbl06.Text = this.hu.Location;
            this.lbl07.Text = this.hu.ManufactureDate.ToString("yyyy-MM-dd HH:mm");
            this.lbl08.Text = this.hu.ManufactureParty;
            this.lblBarCodeInfo.Text = this.hu.HuId;
            this.lblItemDescInfo.Text = this.hu.ItemDescription;
            this.tbBarCode.Text = string.Empty;
            this.tbBarCode.Focus();
            this.lblMessage.Text = "下架成功";
        }
예제 #7
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();
        }
예제 #8
0
        protected override void ScanBarCode()
        {
            base.ScanBarCode();

            if (this.orderMaster == null)
            {
                if (base.op == CodeMaster.BarCodeType.ORD.ToString())
                {
                    //var orderMaster = base.smartDeviceService.GetOrderKeyParts(base.barCode);
                    if (orderMaster.PauseStatus == PauseStatus.Paused)
                    {
                        throw new BusinessException("订单已暂停");
                    }
                    //检查订单类型
                    //else if (orderMaster.Type != OrderType.Transfer && orderMaster.OrderStrategy != FlowStrategy.KIT)
                    //{
                    //    throw new BusinessException("扫描的单号不为分装生产单。");
                    //}
                    //检查订单状态,应该为Close
                    //else if (orderMaster.Status != OrderStatus.Close)
                    //{
                    //    throw new BusinessException("扫描的分装生产单状态不正确");
                    //}
                    List<OrderDetail> orderDetails = new List<OrderDetail>();
                    List<OrderMaster> kitOrders = null;//this.smartDeviceService.GetKitBindingOrders(orderMaster.OrderNo).ToList();
                    foreach (var kitOrder in kitOrders)
                    {
                        var orderDetail = new OrderDetail();
                        orderDetail.Item = kitOrder.OrderNo;
                        orderDetail.CurrentQty = 1;
                        orderDetail.OrderedQty = 1;
                        orderDetail.IsScanHu = true;
                        orderDetail.ItemDescription = "分装生产单";
                        orderDetails.Add(orderDetail);
                    }

                    orderMaster.OrderDetails = orderMaster.OrderDetails.Union(orderDetails).ToArray();
                    this.lblMessage.Text = "请扫描关键件条码或者子生产单。";
                    this.orderMaster = orderMaster;
                    this.gvListDataBind();
                    //this.MergeOrderMaster(orderMaster);
                }
                else
                {
                    throw new BusinessException("请扫描分装生产单。");
                }
            }
            else
            {
                if (base.barCode.Length == 17 && Utility.IsValidateLotNo(base.barCode.Substring(9, 4)) == true)
                {
                    base.op = CodeMaster.BarCodeType.HU.ToString();
                }
                if (base.op == CodeMaster.BarCodeType.HU.ToString())
                {

                    Hu hu = new Hu();
                    try
                    {
                        hu = this.smartDeviceService.GetHu(this.barCode);
                    }
                    catch
                    {
                        if (this.barCode.Length == 17)
                        {
                            hu = this.smartDeviceService.ResolveHu(this.barCode, this.user.Code);
                        }
                    }
                    this.MatchHu(hu);
                }
                else if (base.op == CodeMaster.BarCodeType.ORD.ToString())
                {
                    if (isCancel)
                    {
                        if (this.hus.Any(h => h.HuId == base.barCode))
                        {
                            this.hus.Remove(this.hus.FirstOrDefault(h => h.HuId == base.barCode));
                        }
                        else
                        {
                            throw new BusinessException("条码未扫入,不可以取消");
                        }
                    }
                    else
                    {
                        var orderMaster = base.smartDeviceService.GetOrder(base.barCode, false);
                        if (orderMaster.PauseStatus == PauseStatus.Paused)
                        {
                            throw new BusinessException("订单已暂停");
                        }
                        //检查订单类型
                        //else if (orderMaster.Type != OrderType.Transfer && orderMaster.OrderStrategy != FlowStrategy.KIT)
                        //{
                        //    throw new BusinessException("扫描的单号不为分装生产单。");
                        //}
                        else if (orderMaster.Status != OrderStatus.Close)
                        {
                            throw new BusinessException("扫描的分装生产单未关闭");
                        }
                        else if (this.orderMaster.OrderDetails.All(o => o.Item != base.barCode))
                        {
                            throw new BusinessException("分装生产单{0}不是生产单{1}的子生产单", base.barCode, this.orderMaster.OrderNo);
                        }
                        
                        var orderDetail = this.orderMaster.OrderDetails.FirstOrDefault(h => h.Item == base.barCode);
                        orderDetail.ReceivedQty = 1;
                        orderDetail.CurrentQty = 0;
                        Hu hu = new Hu();
                        hu.HuId = orderMaster.OrderNo;
                        hu.Item = orderMaster.OrderNo;
                        hu.ItemDescription = "分装生产单";
                        this.hus.Add(hu);
                        this.subKitOrders.Add(orderMaster);
                        this.gvListDataBind();
                        this.lblMessage.Text = "请扫描关键件条码或者子生产单。";
                    }
                }
                else if (this.op == CodeMaster.BarCodeType.L.ToString())
                {
                    this.barCode = this.barCode.Substring(2, this.barCode.Length - 2);
                    Location location = smartDeviceService.GetLocation(this.barCode);

                    //检查权限
                    if (!Utility.HasPermission(user.Permissions, OrderType.Transfer, false, true, null, location.Region))
                    {
                        throw new BusinessException("没有此区域的权限");
                    }
                    this.location = location;
                }
                else if (base.op == CodeMaster.BarCodeType.DATE.ToString())
                {
                    base.barCode = base.barCode.Substring(2, base.barCode.Length - 2);
                    this.effDate = base.smartDeviceService.GetEffDate(base.barCode);

                    this.lblMessage.Text = "生效时间:" + this.effDate.Value.ToString("yyyy-MM-dd HH:mm");
                    this.tbBarCode.Text = string.Empty;
                    //this.tbBarCode.Focus();
                }
                else
                {
                    throw new BusinessException("条码格式不合法");
                }
            }
        }
예제 #9
0
 private void Reset()
 {
     this.lblMessage.Text = string.Empty;
     this.lbl01.Text = string.Empty;
     this.lbl02.Text = string.Empty;
     this.lbl03.Text = string.Empty;
     this.lbl04.Text = string.Empty;
     this.lbl05.Text = string.Empty;
     this.lbl06.Text = string.Empty;
     this.lbl07.Text = string.Empty;
     this.lbl08.Text = string.Empty;
     this.lblBarCodeInfo.Text = string.Empty;
     this.lblItemDescInfo.Text = string.Empty;
     this.tbBarCode.Text = string.Empty;
     this.tbBarCode.Focus();
     this.hu = new Hu();
     this.keyCodeDiff = Utility.GetKeyCodeDiff();
 }
예제 #10
0
 private void CancelHu(Hu hu)
 {
     if (this.hus == null)
     {
         this.Reset();
     }
     if (this.hus.Count > 0)
     {
         this.hus.Remove(hu);
     }
 }
예제 #11
0
        private void MatchHu(Hu hu)
        {
            base.CheckHu(hu);

            if (!base.isCancel)
            {
                //if (hu.Status != HuStatus.Location)
                //{
                //    throw new BusinessException("条码不在库位中");
                //}
                //新的条码逻辑
                if (this.flowMaster.IsShipScanHu && hu.Status != HuStatus.Location)
                {
                    throw new BusinessException("条码不在库位中");
                }

                if (!this.flowMaster.IsShipScanHu && this.flowMaster.IsReceiveScanHu)
                {
                    throw new BusinessException("快速移库不支持数量发货条码收货的配置");
                }

                if (hu.QualityType == QualityType.Inspect)
                {
                    throw new BusinessException("待验条码不能移库");
                }

                if (hu.QualityType == QualityType.Reject)
                {
                    throw new BusinessException("不合格条码不能移库");
                }

                FlowDetail matchedFlowDetail = new FlowDetail();
                var flowDetails = this.flowMaster.FlowDetails;

                if (string.IsNullOrEmpty(this.flowMaster.Code))
                {
                    if (flowDetails == null)
                    {
                        flowDetails = new List<FlowDetail>().ToArray();
                        this.flowMaster.LocationFrom = hu.Location;
                        this.flowMaster.PartyFrom = hu.Region;
                    }
                    else
                    {
                        if (!this.flowMaster.LocationFrom.Equals(hu.Location, StringComparison.OrdinalIgnoreCase))
                        {
                            throw new BusinessException("当前条码{0}的来源库位{1}与其他物料的来源库位{2}不一致。", hu.HuId, hu.Location, this.flowMaster.LocationFrom);
                        }
                    }

                    var q = flowDetails
                        .Where(f => f.Item.Equals(hu.Item, StringComparison.OrdinalIgnoreCase)
                            && f.Uom.Equals(hu.Uom, StringComparison.OrdinalIgnoreCase)
                            && f.UnitCount == hu.UnitCount);
                    if (q.Count() > 0)
                    {
                        matchedFlowDetail = q.Single();
                    }
                    else
                    {
                        //检查权限
                        if (!Utility.HasPermission(user.Permissions, OrderType.Transfer, false, true, null, hu.Region))
                        {
                            throw new BusinessException("没有此移库路线的权限");
                        }
                        matchedFlowDetail.Id = FindMinId() - 1;
                        matchedFlowDetail.Item = hu.Item;
                        //matchedFlowDetail.Sequence++;
                        matchedFlowDetail.ReferenceItemCode = hu.ReferenceItemCode;
                        matchedFlowDetail.UnitCount = hu.UnitCount;
                        matchedFlowDetail.Uom = hu.Uom;

                        var flowDetailList = new List<FlowDetail>();
                        if (this.flowMaster.FlowDetails != null)
                        {
                            flowDetailList = this.flowMaster.FlowDetails.ToList();
                        }
                        flowDetailList.Add(matchedFlowDetail);
                        this.flowMaster.FlowDetails = flowDetailList.ToArray();
                    }
                }
                else
                {
                    #region 物料匹配

                    if (flowMaster.IsManualCreateDetail)
                    {
                        if (flowDetails != null)
                        {
                            var q = flowDetails.Where(f => f.Item.Equals(hu.Item, StringComparison.OrdinalIgnoreCase));
                            if (q.Count() > 0)
                            {
                                matchedFlowDetail = q.First();
                                //matchedFlowDetail.CurrentQty += hu.Qty;
                                //matchedFlowDetail.Carton++;
                            }
                            else
                            {
                                List<FlowDetail> flowDetailList = flowDetails.ToList();
                                if (flowMaster.FlowDetails != null)
                                {
                                    flowDetailList = flowMaster.FlowDetails.ToList();
                                }
                                matchedFlowDetail = this.Hu2FlowDetail(flowMaster, hu);
                                flowDetailList.Add(matchedFlowDetail);
                                flowMaster.FlowDetails = flowDetailList.ToArray();
                            }
                        }
                        else
                        {
                            List<FlowDetail> flowDetailList = new List<FlowDetail>();
                            if (flowMaster.FlowDetails != null)
                            {
                                flowDetailList = flowMaster.FlowDetails.ToList();
                            }
                            matchedFlowDetail = this.Hu2FlowDetail(flowMaster, hu);
                            flowDetailList.Add(matchedFlowDetail);
                            flowMaster.FlowDetails = flowDetailList.ToArray();
                        }
                    }
                    else
                    {
                        if (this.flowMaster.FlowDetails == null)
                        {
                            throw new BusinessException("没有找到和条码{0}的零件号{1}匹配的订单明细。", hu.HuId, hu.Item);
                        }

                        var matchedOrderDetailList = flowDetails.Where(o => o.Item == hu.Item);
                        if (matchedOrderDetailList == null || matchedOrderDetailList.Count() == 0)
                        {
                            throw new BusinessException("没有找到和条码{0}的零件号{1}匹配的订单明细。", hu.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}匹配的订单明细。", hu.HuId, hu.Uom);
                        }

                        if (this.flowMaster.IsOrderFulfillUC)
                        {
                            matchedOrderDetailList = matchedOrderDetailList.Where(o => o.UnitCount == hu.UnitCount);
                            if (matchedOrderDetailList == null || matchedOrderDetailList.Count() == 0)
                            {
                                throw new BusinessException("没有找到和条码{0}的包装数{1}匹配的订单明细。", hu.HuId, hu.UnitCount.ToString());
                            }
                        }
                        matchedFlowDetail = matchedOrderDetailList.First();
                    }
                    #endregion
                }

                FlowDetailInput input = new FlowDetailInput();
                input.HuId = hu.HuId;
                input.Qty = hu.Qty;
                input.LotNo = hu.LotNo;

                List<FlowDetailInput> flowDetailInputs = new List<FlowDetailInput>();
                if (matchedFlowDetail.FlowDetailInputs != null)
                {
                    flowDetailInputs = matchedFlowDetail.FlowDetailInputs.ToList();
                }
                flowDetailInputs.Add(input);
                matchedFlowDetail.FlowDetailInputs = flowDetailInputs.ToArray();
                matchedFlowDetail.CurrentQty += hu.Qty;
                matchedFlowDetail.Carton++;
                //
                base.hus.Insert(0, hu);
            }
            else
            {
                this.CancelHu(hu);
            }
            this.gvListDataBind();
        }
예제 #12
0
 private void CancelHu(Hu hu)
 {
     if (this.isOldHu) //old
     {
         var q = this.oldHus
          .Where(g => g.HuId.Equals(hu.HuId, StringComparison.OrdinalIgnoreCase));
         if (q.Count() > 0)
         {
             var firstHu = q.First();
             this.oldHus.Remove(firstHu);
             this.gvListDataBind();
         }
         else
         {
             throw new BusinessException("没有可取消的物料{0}", hu.Item);
         }
     }
     else //new
     {
         var q = this.newHus
          .Where(g => g.HuId.Equals(hu.HuId, StringComparison.OrdinalIgnoreCase));
         if (q.Count() > 0)
         {
             var firstHu = q.First();
             this.newHus.Remove(firstHu);
             this.gvHuListDataBind();
         }
         else
         {
             throw new BusinessException("没有可取消的物料{0}", hu.Item);
         }
     }
 }
예제 #13
0
 private void Reset()
 {
     this.hu = null; this.tbBarCode.Text = string.Empty;
     this.tbBarCode.Focus();
     this.label01.Text = "物料号:";
     this.label02.Text = "参考号:";
     this.label03.Text = "方向:";
     this.label04.Text = "数量:";
     this.label05.Text = "单位:";
     this.label06.Text = "库位:";
     this.label07.Text = "库格:";
     this.label08.Text = "状态:";
     this.label09.Text = "制造时间:";
     this.label10.Text = "条码选项:";
     this.lbl01.Text = string.Empty;
     this.lbl02.Text = string.Empty;
     this.lbl03.Text = string.Empty;
     this.lbl04.Text = string.Empty;
     this.lbl05.Text = string.Empty;
     this.lbl06.Text = string.Empty;
     this.lbl07.Text = string.Empty;
     this.lbl08.Text = string.Empty;
     this.lbl09.Text = string.Empty;
     this.lbl10.Text = string.Empty;
     this.lblBarCodeInfo.Text = string.Empty;
     this.lblItemDescInfo.Text = string.Empty;
 }
예제 #14
0
 public void DoRepackAndShipOrder(Hu[] huList, [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] System.Nullable<System.DateTime> effDate, string userCode) {
     this.Invoke("DoRepackAndShipOrder", new object[] {
                 huList,
                 effDate,
                 userCode});
 }
예제 #15
0
 /// <remarks/>
 public System.IAsyncResult BeginDoRepackAndShipOrder(Hu[] huList, System.Nullable<System.DateTime> effDate, string userCode, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("DoRepackAndShipOrder", new object[] {
                 huList,
                 effDate,
                 userCode}, callback, asyncState);
 }
예제 #16
0
        private void MatchPickTask(Hu hu)
        {
            if (hu == null)
            {
                throw new BusinessException("条码不存在");
            }

            if (isPickByHu == false)
            {
                var matchedPickTasks = this.pickTasks.Where(p => p.Item == hu.Item && p.LotNo == hu.LotNo && p.Uom == hu.Uom && p.UnitCount == hu.UnitCount && p.Bin == hu.Bin).OrderBy(p => p.WinTime);
                if (matchedPickTasks == null || matchedPickTasks.Count() == 0)
                {
                    throw new BusinessException("未找到与条码{0}相关的拣货任务。", hu.HuId);
                }
                else if (matchedPickTasks.Count() == 1)
                {
                    var pickTask = matchedPickTasks.FirstOrDefault();

                    if (pickTask.OrderQty - pickTask.PickQty < hu.Qty)
                    {
                        throw new BusinessException("条码{0}匹配的拣货任务已拣满。", hu.HuId);
                    }
                    else
                    {
                        pickTask.PickQty += hu.Qty;
                        pickTask.CurrentQty = pickTask.OrderQty - pickTask.PickQty;
                        hu.OrderDetId = pickTask.Id;
                        this.hus.Add(hu);
                    }
                }
                else
                {
                    var isMatched = false;
                    foreach (var pickTask in matchedPickTasks)
                    {
                        if (pickTask.OrderQty - pickTask.PickQty >= hu.Qty)
                        {
                            pickTask.PickQty += hu.Qty;
                            pickTask.CurrentQty = pickTask.OrderQty - pickTask.PickQty;
                            hu.OrderDetId = pickTask.Id;
                            this.hus.Add(hu);
                            isMatched = true;
                            break;
                        }
                    }
                    if (isMatched == false)
                    {
                        throw new BusinessException("条码{0}匹配的拣货任务已拣满。", hu.HuId);
                    }
                }
            }
            else
            {
                var matchedPickTasks = this.pickTasks.Where(p => p.HuId == hu.HuId);
                if (matchedPickTasks == null || matchedPickTasks.Count() == 0)
                {
                    throw new BusinessException("未找到与条码{0}相关的拣货任务。", hu.HuId);
                }
                else if (matchedPickTasks.Count() == 1)
                {
                    var pickTask = matchedPickTasks.FirstOrDefault();

                    if (pickTask.OrderQty - pickTask.PickQty < hu.Qty)
                    {
                        throw new BusinessException("条码{0}匹配的拣货任务已拣满。", hu.HuId);
                    }
                    else
                    {
                        pickTask.PickQty += hu.Qty;
                        pickTask.CurrentQty = pickTask.OrderQty - pickTask.PickQty;
                        hu.OrderDetId = pickTask.Id;
                        this.hus.Add(hu);
                        
                    }
                }
            }
        }
예제 #17
0
        protected void CancelHu(Hu hu)
        {
            //if (this.flowMaster == null || this.flowMaster.FlowDetails == null || this.flowMaster.FlowDetails.Count() == 0)
            if(this.hus == null)
            {
                //this.ModuleSelectionEvent(CodeMaster.TerminalPermission.M_Switch);
                this.Reset();
                return;
            }

            if (hu != null)
            {
                foreach (var flowDetail in this.flowMaster.FlowDetails)
                {
                    if (flowDetail.FlowDetailInputs != null)
                    {
                        var q_pdi = flowDetail.FlowDetailInputs.Where(p => p.HuId == hu.HuId);
                        if (q_pdi != null && q_pdi.Count() > 0)
                        {
                            flowDetail.FlowDetailInputs.ToList().Remove(q_pdi.First());
                            flowDetail.CurrentQty -= hu.Qty;
                            flowDetail.Carton--;
                            break;
                        }
                    }
                }
                base.hus = base.hus.Where(h => !h.HuId.Equals(hu.HuId, StringComparison.OrdinalIgnoreCase)).ToList();
                this.gvHuListDataBind();
            }
        }
예제 #18
0
        private FlowDetail Hu2FlowDetail(FlowMaster flowMaster, Hu hu)
        {
            //int seq = 10;
            //if (flowMaster.FlowDetails != null)
            //{
            //    seq = flowMaster.FlowDetails.Max(f => f.Sequence) + 10;
            //}

            FlowDetail flowDetail = new FlowDetail();
            flowDetail.Id = this.FindMinId() - 1;
            //flowDetail.CurrentQty = hu.UnitCount;
            flowDetail.Flow = flowMaster.Code;
            flowDetail.Item = hu.Item;
            flowDetail.LocationFrom = flowMaster.LocationFrom;
            flowDetail.LocationTo = flowMaster.LocationTo;
            flowDetail.ReferenceItemCode = hu.ReferenceItemCode;
            //flowDetail.Sequence = seq;
            flowDetail.UnitCount = hu.UnitCount;
            flowDetail.Uom = hu.Uom;

            return flowDetail;
        }
예제 #19
0
        private void CancelHu(Hu hu)
        {
            //if (this.orderMasters == null || this.orderMasters.Count() == 0)
            if(this.hus == null)
            {
                //this.ModuleSelectionEvent(CodeMaster.TerminalPermission.M_Switch);
                this.Reset();
                return;
            }

            if (hu != null)
            {
                var orderDetailList = new List<OrderDetail>();
                foreach (var om in this.orderMasters)
                {
                    orderDetailList.AddRange(om.OrderDetails);
                }

                foreach (var orderDetail in orderDetailList)
                {
                    if (orderDetail.OrderDetailInputs != null)
                    {
                        var q_pdi = orderDetail.OrderDetailInputs.Where(p => p.HuId == hu.HuId);
                        if (q_pdi != null && q_pdi.Count() > 0)
                        {
                            var orderDetailInputList = orderDetail.OrderDetailInputs.ToList();
                            orderDetailInputList.Remove(q_pdi.First());
                            orderDetail.OrderDetailInputs = orderDetailInputList.ToArray();
                            orderDetail.CurrentQty += hu.Qty;
                            orderDetail.Carton--;
                            break;
                        }
                    }
                }
                base.hus = base.hus.Where(h => !h.HuId.Equals(hu.HuId, StringComparison.OrdinalIgnoreCase)).ToList();
                this.gvHuListDataBind();
            }
        }
예제 #20
0
        private void CancelHu(Hu hu)
        {
            if (this.hus == null)
            {
                //this.ModuleSelectionEvent(CodeMaster.TerminalPermission.M_Switch);
                this.Reset();
                return;
            }

            if (hu != null)
            {
                var matchedOrderDetails = this.inspectMaster.InspectDetails.Where(i => hu.HuId.Equals(i.HuId, StringComparison.OrdinalIgnoreCase));
                if (matchedOrderDetails == null || matchedOrderDetails.Count() == 0)
                {
                    throw new BusinessException("没有需要取消的匹配条码");
                }
                else
                {
                    var matchedOrderDetail = matchedOrderDetails.First();
                    matchedOrderDetail.CurrentQty += hu.Qty;
                    matchedOrderDetail.Carton--;
                }
                base.hus = base.hus.Where(h => !h.HuId.Equals(hu.HuId, StringComparison.OrdinalIgnoreCase)).ToList();
                this.gvHuListDataBind();
            }
        }
예제 #21
0
        private void CancelHu(Hu hu)
        {
            //if (this.ipMaster == null && (this.orderMasters == null || this.orderMasters.Count() == 0))
            if (this.hus == null)
            {
                //this.ModuleSelectionEvent(CodeMaster.TerminalPermission.M_Switch);
                this.Reset();
                return;
            }

            if (hu != null)
            {
                base.hus = base.hus.Where(h => !h.HuId.Equals(hu.HuId, StringComparison.OrdinalIgnoreCase)).ToList();
                this.gvHuListDataBind();
            }
        }
예제 #22
0
 protected void CancelHu(Hu hu)
 {
     //if (this.pickListMaster == null || this.pickListMaster.PickListDetails == null || this.pickListMaster.PickListDetails.Count() == 0)
     if (this.hus == null)
     {
         //this.ModuleSelectionEvent(CodeMaster.TerminalPermission.M_Switch);
         this.Reset();
         return;
     }
     else
     {
         foreach (var pickListDetail in this.pickListMaster.PickListDetails)
         {
             if (pickListDetail.PickListDetailInputs != null)
             {
                 var q_pdi = pickListDetail.PickListDetailInputs.Where(p => p.HuId == hu.HuId);
                 if (q_pdi != null && q_pdi.Count() > 0)
                 {
                     var list = pickListDetail.PickListDetailInputs.ToList();
                     list.Remove(q_pdi.First());
                     pickListDetail.PickListDetailInputs = list.ToArray();
                     //pickListDetail.PickListDetailInputs.ToList().Remove(q_pdi.First());
                     pickListDetail.CurrentQty += hu.Qty;
                     pickListDetail.Carton--;
                     break;
                 }
             }
         }
         this.hus.Remove(hu);
         this.gvHuListDataBind();
     }
 }
예제 #23
0
        private void MatchHu(Hu hu)
        {
            if (hu == null)
            {
                throw new BusinessException("条码不存在");
            }
            hu.CurrentQty = hu.Qty;

            if (this.hus == null)
            {
                this.hus = new List<Hu>();
            }
            if (hu.IsFreeze)
            {
                throw new BusinessException("条码被冻结!");
            }
            if (hu.OccupyType != OccupyType.None)
            {
                throw new BusinessException("条码被{0}占用!", hu.OccupyReferenceNo);
            }

            if (!base.isCancel)
            {
                if (this.isOldHu) //old
                {
                    if (hu.Status != HuStatus.Location)
                    {
                        throw new BusinessException("旧条码不库位中不能翻箱");
                    }
                    if (base.hus.Count > 0 && !base.hus[0].Location.Equals(hu.Location, StringComparison.OrdinalIgnoreCase))
                    {
                        throw new BusinessException("条码库位{0}和库位{1}不一致不能翻箱", hu.Location, base.hus[0].Location);
                    }

                    if (this.oldHus.Count(h => h.HuId.Equals(hu.HuId, StringComparison.OrdinalIgnoreCase)) > 0)
                    {
                        throw new BusinessException("条码重复扫描!");
                    }

                    this.oldHus.Insert(0, hu);
                    this.gvListDataBind();
                }
                else //new
                {
                    if (hu.Status == HuStatus.Ip)
                    {
                        throw new BusinessException("新条码已在途不能装箱");
                    }
                    if (hu.Status == HuStatus.Location)
                    {
                        throw new BusinessException("新条码已在库位中不能装箱");
                    }
                    if (this.newHus.Count(h => h.HuId.Equals(hu.HuId, StringComparison.OrdinalIgnoreCase)) > 0)
                    {
                        throw new BusinessException("条码重复扫描!");
                    }
                    this.newHus.Insert(0, hu);
                    this.gvHuListDataBind();
                }
            }
            else
            {
                this.CancelHu(hu);
            }
        }
예제 #24
0
        private void ScanBarCode()
        {
            this.barCode = this.tbBarCode.Text.Trim();
            this.lblMessage.Text = string.Empty;
            this.tbBarCode.Text = string.Empty;

            if (this.barCode.Length < 3)
            {
                throw new BusinessException("条码格式不合法");
            }
            this.op = Utility.GetBarCodeType(this.user.BarCodeTypes, this.barCode);

            if (this.orderMaster == null && this.flowMaster == null)
            {
                if (this.op == CodeMaster.BarCodeType.ORD.ToString())
                {
                    this.Reset();
                    this.lblSeq.Text = "班次:";
                    this.lblFlow.Text = "产线:";
                    this.lblWo.Text = "工单:";
                    var orderMaster = this.smartDeviceService.GetOrder(this.barCode, true);
                    if (orderMaster.IsPause)
                    {
                        throw new BusinessException("订单已暂停");
                    }

                    //检查订单状态
                    if (orderMaster.Status != OrderStatus.Submit && orderMaster.Status != OrderStatus.InProcess)
                    {
                        throw new BusinessException("不是Submit或InProcess状态不能操作");
                    }

                    if (orderMaster.Type == OrderType.Production)
                    {
                        if (orderMaster.OrderDetails.Length != 1)
                        {
                            throw new BusinessException("只能对一料一单的生产单操作");
                        }

                        OrderDetail orderDetail = orderMaster.OrderDetails[0];

                        this.lblSeqInfo.Text = orderMaster.Shift;
                        this.lblFlowInfo.Text = orderMaster.Flow;
                        this.lblWoInfo.Text = orderMaster.OrderNo;
                        this.lblVANInfo.Text = orderMaster.StartTime.ToString("yyyy-MM-dd HH:mm");
                        this.lblFgInfo.Text = orderDetail.Item;
                        this.lblFgDescInfo.Text = orderDetail.ItemDescription;
                        this.tabPanel.SelectedIndex = 0;
                    }
                    else
                    {
                        throw new BusinessException("订单类型不正确:{0}", orderMaster.Type.ToString());
                    }

                    #region 界面控制
                    this.lblSeq.Visible = true;
                    this.lblFlow.Visible = true;
                    this.lblWo.Visible = true;
                    this.lblVAN.Visible = true;
                    this.lblFg.Visible = true;
                    this.lblFgDescription.Visible = true;
                    #endregion

                    this.orderMaster = orderMaster;
                }
                else if (this.op == CodeMaster.BarCodeType.F.ToString())
                {
                    throw new BusinessException("不支持生产线投料");
                    this.Reset();
                    this.barCode = this.barCode.Substring(2, this.barCode.Length - 2);
                    this.flowMaster = smartDeviceService.GetFlowMaster(this.barCode, false);

                    //检查订单类型
                    if (this.flowMaster.Type != OrderType.Production)
                    {
                        throw new BusinessException("不是生产线不能投料。");
                    }

                    //是否有效
                    if (!this.flowMaster.IsActive)
                    {
                        throw new BusinessException("此生产线无效。");
                    }

                    //检查权限
                    if (!Utility.HasPermission(this.flowMaster, this.user))
                    {
                        throw new BusinessException("没有此生产线的权限");
                    }
                    this.lblMessage.Text = this.flowMaster.Description;
                    //this.gvListDataBind();

                    this.lblSeq.Text = "产线:";
                    this.lblSeq.Visible = true;
                    this.lblSeqInfo.Text = this.flowMaster.Code;
                    this.lblFlow.Text = "描述:";
                    this.lblFlow.Visible = true;
                    this.lblFlowInfo.Text = this.flowMaster.Description;
                    this.lblWo.Text = "区域:";
                    this.lblWo.Visible = true;
                    this.lblWoInfo.Text = this.flowMaster.PartyFrom;

                    this.lblVANInfo.Text = string.Empty;

                    this.lblFgInfo.Text = string.Empty;

                    this.lblFgDescInfo.Text = string.Empty;
                    this.tabPanel.SelectedIndex = 0;
                }
                else
                {
                    throw new BusinessException("请先扫描订单或者生产线");
                }
            }
            else
            {
                if (this.op == CodeMaster.BarCodeType.HU.ToString())
                {
                    if (this.hus == null)
                    {
                        this.hus = new List<Hu>();
                    }
                    if (this.flowMaster == null && this.orderMaster == null)
                    {
                        throw new BusinessException("请先扫描生产单或生产线");
                    }

                    Hu hu = new Hu();
                    try
                    {
                        hu = this.smartDeviceService.GetHu(this.barCode);
                    }
                    catch
                    {
                        if (this.barCode.Length == 17)
                        {
                            hu = this.smartDeviceService.ResolveHu(this.barCode, this.user.Code);
                        }
                    }
                    if (string.IsNullOrEmpty(hu.HuId))
                    {
                        throw new BusinessException("条码不存在");
                    }
                    hu.CurrentQty = hu.Qty;
                    var matchHu = this.hus.Where(h => h.HuId.Equals(hu.HuId, StringComparison.OrdinalIgnoreCase));
                    if (matchHu != null && matchHu.Count() > 0)
                    {
                        throw new BusinessException("条码重复扫描!");
                    }
                    if (hu.IsFreeze)
                    {
                        throw new BusinessException("条码被冻结!");
                    }
                    if (hu.OccupyType != OccupyType.None)
                    {
                        throw new BusinessException("条码被{0}占用!", hu.OccupyReferenceNo);
                    }
                    if (!Utility.HasPermission(user.Permissions, null, true, false, hu.Region, null))
                    {
                        throw new BusinessException("没有此条码的权限");
                    }
                    if (hu.Status != HuStatus.Location)
                    {
                        throw new BusinessException("此条码不在库位中");
                    }

                    if (this.orderMaster != null)
                    {
                        this.hus.Insert(0, hu);
                        this.gvHuListDataBind();
                    }
                    else if (this.flowMaster != null)
                    {
                        this.hus.Insert(0, hu);
                        this.gvHuListDataBind();
                    }
                    else
                    {
                        this.Reset();
                        throw new BusinessException("请先扫描生产单或生产线");
                    }

                    this.tabPanel.SelectedIndex = 1;
                }
                else
                {
                    throw new BusinessException("条码格式不合法。");
                }
            }
        }
예제 #25
0
        private void MatchHu(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));

            if (this.isCancel)
            {
                if (matchHu == null || matchHu.Count() == 0)
                {
                    throw new BusinessException("没有需要取消匹配条码:{0}", hu.HuId);
                }
                else if (matchHu.Count() == 1)
                {
                    //var _hu = _hus.Single();
                    //this.hus.Remove(_hu);
                }
                else
                {
                    throw new Exception("匹配了多个条码");
                }
            }
            else
            {
                if (matchHu != null && matchHu.Count() > 0)
                {
                    throw new BusinessException("条码重复扫描!");
                }
            }

            if (this.hus == null)
            {
                this.hus = new List<Hu>();
            }
            if (hu.IsFreeze)
            {
                throw new BusinessException("条码被冻结!");
            }
            if (hu.OccupyReferenceNo != this.inspectMaster.InspectNo)
            {
                throw new BusinessException("条码被{0}占用!", hu.OccupyReferenceNo);
            }

            if (!Utility.HasPermission(user.Permissions, null, false, true, hu.Region, null))
            {
                throw new BusinessException("没有此条码的权限");
            }

            if (!base.isCancel)
            {
                if (hu.Status != HuStatus.Location)
                {
                    throw new BusinessException("条码不在库位中不能检验判定");
                }
                if (hu.QualityType != QualityType.Inspect)
                {
                    throw new BusinessException("以判定过的条码不能再检验判定");
                }

                var matchedOrderDetails = this.inspectMaster.InspectDetails.Where(i => hu.HuId.Equals(i.HuId, StringComparison.OrdinalIgnoreCase));
                if (matchedOrderDetails == null || matchedOrderDetails.Count() == 0)
                {
                    throw new BusinessException("没有匹配的条码");
                }
                var matchedOrderDetail = matchedOrderDetails.First();

                matchedOrderDetail.CurrentQty -= hu.Qty;
                matchedOrderDetail.Carton++;
                base.hus.Insert(0, hu);
            }
            else
            {
                #region 取消
                this.CancelHu(hu);
                #endregion
            }
            this.gvListDataBind();
        }
예제 #26
0
        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();
        }
예제 #27
0
        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();
        }
예제 #28
0
        /// <summary>
        /// 匹配逻辑:
        /// 1.如果发货时扫描了条码,就按条码匹配,条码匹配上Hu.ShipQty=Hu.Qty;如果条码匹配不上,就按物料匹配,物料匹配上Hu.ShipQty=0;
        ///   如果ipDetail上匹配的条码总数量大于ipDetail.Qty,则把Hu.ShipQty=0的拿出来再重新按物料匹配一次.
        /// 2.如果发货没有扫描条码,就按物料匹配.
        /// </summary>
        /// <param name="hu"></param>
        private void MatchIpMaster(Hu hu)
        {
            if (hu == null)
            {
                throw new BusinessException("条码不存在");
            }
            hu.CurrentQty = hu.Qty;

            if (!string.IsNullOrEmpty(hu.Location))
            {
                throw new BusinessException("条码{0}在库存中,不能收货", hu.HuId);
            }
            var matchHu = this.hus.Where(h => h.HuId.Equals(hu.HuId, StringComparison.OrdinalIgnoreCase));

            if (this.isCancel)
            {
                if (matchHu == null || matchHu.Count() == 0)
                {
                    throw new BusinessException("没有需要取消匹配条码:{0}", hu.HuId);
                }
                else if (matchHu.Count() == 1)
                {
                    //var _hu = _hus.Single();
                    //this.hus.Remove(_hu);
                }
                else
                {
                    throw new Exception("匹配了多个条码");
                }
            }
            else
            {
                if (matchHu != null && matchHu.Count() > 0)
                {
                    throw new BusinessException("条码重复扫描!");
                }
            }
            if (hu.IsFreeze)
            {
                throw new BusinessException("条码被冻结!");
            }

            if (!Utility.HasPermission(user.Permissions, null, false, true, hu.Region, null))
            {
                throw new BusinessException("没有此条码的权限");
            }

            var ipDetails = this.ipMaster.IpDetails;
            if (!base.isCancel)
            {
                #region 增加
                if (hu.Status == HuStatus.Location)
                {
                    throw new BusinessException("在库存中的条码不能被收货");
                }

                string huId = hu.HuId;

                if (this.ipMaster.IsReceiveScanHu)
                {
                    var isNeedRematch = false;
                    var matchedHuDetailInputs = new List<IpDetailInput>();
                    //首先匹配条码,如果条码匹配的话就调整ipDetail的数量RemainReceivedQty
                    //只有在条码完全匹配并且数量不满足收货的情况下产生IpDetailInputs的全部调整
                    var ipDetailInputMatchHuIds = this.ipMaster.IpDetailInputs.Where(id => id.HuId.Equals(hu.HuId, StringComparison.OrdinalIgnoreCase)).ToList();
                    if (ipDetailInputMatchHuIds.Count != 0)
                    {
                        var ipDetailInput = ipDetailInputMatchHuIds.First();
                        //var ipDetailMatchQty = this.ipMaster.IpDetails.Where(i => i.Id == ipDetailInput.Id && i.UnitCount ==hu.UnitCount && i.ManufactureParty==hu.ManufactureParty && i.RemainReceivedQty > hu.Qty).ToList();
                        var ipDetailMatchHu = this.ipMaster.IpDetails.Where(i => i.Id == ipDetailInput.Id).Single();
                        if (ipDetailMatchHu.RemainReceivedQty < hu.Qty)
                        {
                            isNeedRematch = true;
                            //将该零件号未匹配条码的先移开
                            foreach (var ipDetail in this.ipMaster.IpDetails.Where(i => i.Item == hu.Item))
                            {
                                matchedHuDetailInputs.AddRange(this.ipMaster.IpDetailInputs.Where(i => i.Id == ipDetail.Id && i.IsOriginal == true).ToList());
                                var matchTotal = this.ipMaster.IpDetailInputs.Where(i => i.Id == ipDetail.Id && i.IsMatchedHu == true).ToList().Sum(n => n.ReceiveQty);
                                ipDetail.RemainReceivedQty = ipDetail.Qty - ipDetail.ReceivedQty - matchTotal;
                                ipDetail.CurrentQty = ipDetail.Qty - ipDetail.ReceivedQty - matchTotal;
                            }
                            this.ipMaster.IpDetailInputs = matchedHuDetailInputs.ToArray();

                        }
                        //将满足的条码先放进去
                        ipDetailInput.ReceiveQty = hu.Qty;
                        ipDetailInput.LotNo = hu.LotNo;
                        ipDetailInput.IsMatchedHu = true;
                        ipDetailMatchHu.RemainReceivedQty = ipDetailMatchHu.Qty - hu.Qty;

                        ipDetailMatchHu.CurrentQty = ipDetailMatchHu.Qty - hu.Qty;
                        //this.ipMaster.IpDetails.Where(i => i.Id == ipDetailInput.Id).Single().CurrentQty -= hu.Qty;

                        //如果条码匹配上并且其他的零件也没有溢出那么直接返回
                        if (isNeedRematch == false)
                        {
                            base.hus.Insert(0, hu);
                            this.gvListDataBind();
                            return;
                        }
                    }

                    //以下为非条码匹配的标准流程
                    List<Hu> inputHus = new List<Hu>();
                    List<Hu> needRemoveHus = new List<Hu>();
                    //如果有条码被从已经匹配的地方挪出来,那么这个物料除了条码已经匹配上的,其他全部重新匹配
                    if (isNeedRematch == true)
                    {
                        var matchedInputHus = (from h in this.hus
                                               from detailInput in this.ipMaster.IpDetailInputs
                                               where h.HuId == detailInput.HuId
                                               && detailInput.IsMatchedHu
                                               select h).ToList();

                        foreach (var item in this.hus)
                        {
                            if (matchedInputHus.All(m => m.HuId != item.HuId))
                            {
                                inputHus.Add(item);
                            }
                        }
                    }
                    else
                    {
                        inputHus.Add(hu);
                    }

                    //循环条码做非条码匹配
                    foreach (Hu inputHu in inputHus)
                    {
                        //var matchIpDetail = new IpDetail();
                        //匹配零件,供应商,质量状态   强制收货不考虑包装
                        var matchIpDetailsFirst = this.ipMaster.IpDetails.Where(i => i.Item == inputHu.Item &&
                            //i.UnitCount == inputHu.UnitCount &&
                                                        i.ManufactureParty == inputHu.ManufactureParty &&
                                                        i.RemainReceivedQty >= inputHu.Qty &&
                                                        i.QualityType == inputHu.QualityType).ToList();

                        if (matchIpDetailsFirst.Count() > 0)
                        {
                            var matchIpDetail = matchIpDetailsFirst.First();

                            var ipDetailInput = new IpDetailInput();
                            ipDetailInput.HuId = inputHu.HuId;
                            ipDetailInput.Id = matchIpDetail.Id;
                            ipDetailInput.ReceiveQty = inputHu.Qty;
                            matchIpDetail.RemainReceivedQty = matchIpDetail.RemainReceivedQty - inputHu.Qty;
                            matchIpDetail.CurrentQty = matchIpDetail.CurrentQty - inputHu.Qty;
                            List<IpDetailInput> ipDetailProcess = this.ipMaster.IpDetailInputs.ToList();
                            ipDetailProcess.Add(ipDetailInput);
                            this.ipMaster.IpDetailInputs = ipDetailProcess.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 matchIpDetailsFirst = this.ipMaster.IpDetails.Where(i => i.Item.Equals(inputHu.Item, StringComparison.OrdinalIgnoreCase) &&
                                //i.UnitCount == inputHu.UnitCount &&
                                //i.ManufactureParty.Equals(inputHu.ManufactureParty, StringComparison.OrdinalIgnoreCase) &&
                                                            i.RemainReceivedQty >= inputHu.Qty &&
                                                            i.QualityType == inputHu.QualityType);

                            if (matchIpDetailsFirst.Count() > 0)
                            {
                                matchIpDetail = matchIpDetailsFirst.First();

                                var ipDetailInput = new IpDetailInput();
                                ipDetailInput.HuId = inputHu.HuId;
                                ipDetailInput.Id = matchIpDetail.Id;
                                ipDetailInput.ReceiveQty = inputHu.Qty;
                                matchIpDetail.RemainReceivedQty = matchIpDetail.RemainReceivedQty - inputHu.Qty;
                                matchIpDetail.CurrentQty = matchIpDetail.CurrentQty - inputHu.Qty;
                                List<IpDetailInput> ipDetailProcess = this.ipMaster.IpDetailInputs.ToList();
                                ipDetailProcess.Add(ipDetailInput);
                                this.ipMaster.IpDetailInputs = ipDetailProcess.ToArray();
                                needRemoveHus.Add(inputHu);
                            }
                        }
                        foreach (var item in needRemoveHus)
                        {
                            inputHus.Remove(item);
                        }
                    }

                    //如果还有未匹配成功的就报错
                    if (inputHus.Count > 0)
                    {
                        if (isNeedRematch == false)
                        {
                            throw new BusinessException("条码{0}无法满足送货单{1}明细的收货条件", hu.HuId, this.ipMaster.IpNo);
                        }
                        else
                        {
                            throw new BusinessException("物料{0}无法满足送货单{1}明细的收货条件", hu.Item, this.ipMaster.IpNo);
                        }
                    }
                    this.hus.Add(hu);
                }
                else
                {
                    throw new BusinessException("收货不需要扫描条码");
                }
                #endregion
            }
            else
            {
                this.CancelHu(hu);
            }

            this.gvListDataBind();
        }
예제 #29
0
        private void ScanBarCode()
        {
            string barCode = this.tbBarCode.Text.Trim();
            this.tbBarCode.Focus();
            this.tbBarCode.Text = string.Empty;

            if (barCode.Length < 3)
            {
                throw new BusinessException("条码格式不合法");
            }

            try
            {
                Hu hu = new Hu();
                if (this.isStart)
                {
                    hu = smartDeviceService.StartAging(barCode, this.user.Code);
                    //if (hu.Status != HuStatus.Location)
                    //{
                    //    throw new BusinessException("此条码不在库存中,不能进行老化操作");
                    //}

                    if (hu.IsFreeze)
                    {
                        throw new BusinessException("此条码已经冻结,不能进行老化操作");
                    }
                    if (!Utility.HasPermission(user.Permissions, null, true, false, hu.Region, null))
                    {
                        throw new BusinessException("没有此条码的权限");
                    }
                    this.lblMessage.Text = string.Format("老化开始成功,时间:{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
                    if (hu.HuOption == HuOption.NoNeed)
                    {
                        this.lblMessage.Text = string.Format("老化开始成功.注:此条码无需老化");
                    }
                    else
                    {
                        this.lblMessage.Text = string.Format("老化开始成功,时间:{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
                    }
                }
                else
                {
                    hu = smartDeviceService.DoAging(barCode, this.user.Code);
                    this.lblMessage.Text = string.Format("老化成功,新条码:{0}", hu.HuId);
                }
                this.lbl01.Text = hu.Item;
                this.lbl02.Text = hu.ReferenceItemCode;
                this.lbl03.Text = hu.Direction;
                this.lbl04.Text = hu.Qty.ToString("0.###") + " " + hu.Uom;
                this.lbl06.Text = hu.Location;
                this.lbl07.Text = hu.Bin;
                this.lbl08.Text = hu.HuOption == HuOption.Aged ? "已老化" : "未老化";
                this.lbl09.Text = hu.ManufactureDate.ToString("yyyy-MM-dd");
                this.lbl10.Text = hu.ManufactureParty;
                this.lblBarCodeInfo.Text = hu.HuId;
                this.lblItemDescInfo.Text = hu.ItemDescription;

            }
            catch (Exception ex)
            {
                if ((ex is System.Net.WebException) || (ex is SoapException))
                {
                    Utility.ShowMessageBox(ex);
                }
                else if (ex is BusinessException)
                {
                    Utility.ShowMessageBox(ex.Message);
                }
                else
                {
                    this.Reset();
                    Utility.ShowMessageBox(ex.Message);
                }
                this.isMark = true;
                this.tbBarCode.Text = string.Empty;
                this.tbBarCode.Focus();
            }
        }
예제 #30
0
        private void CancelHu(Hu hu)
        {
            if (this.hus == null)
            {
                //this.ModuleSelectionEvent(CodeMaster.TerminalPermission.M_Switch);
                this.Reset();
                return;
            }

            if (hu != null)
            {
                if (this.ipMaster == null)
                {
                    var orderDetailList = new List<OrderDetail>();
                    foreach (var om in this.orderMasters)
                    {
                        orderDetailList.AddRange(om.OrderDetails);
                    }

                    foreach (var orderDetail in orderDetailList)
                    {
                        if (orderDetail.OrderDetailInputs != null)
                        {
                            var q_pdi = orderDetail.OrderDetailInputs.Where(p => p.HuId == hu.HuId);
                            if (q_pdi != null && q_pdi.Count() > 0)
                            {
                                orderDetail.OrderDetailInputs.ToList().Remove(q_pdi.First());
                                orderDetail.CurrentQty += hu.Qty;
                                orderDetail.Carton--;
                                break;
                            }
                        }
                    }
                }
                else
                {
                    if (this.ipMaster.IpDetails == null || this.ipMaster.IpDetails.Count() == 0)
                    {
                        this.Reset();
                        throw new BusinessException("此ASN无明细");
                    }

                    //need change
                    //foreach (var ipDetail in this.ipMaster.IpDetails)
                    //{
                    //    if (ipDetail.IpDetailInputs != null)
                    //    {
                    //        var q_pdi = ipDetail.IpDetailInputs.Where(p => p.HuId == hu.HuId);
                    //        if (q_pdi != null && q_pdi.Count() > 0)
                    //        {
                    //            ipDetail.IpDetailInputs.ToList().Remove(q_pdi.First());
                    //            ipDetail.CurrentQty += hu.Qty;
                    //            ipDetail.Carton--;
                    //            break;
                    //        }
                    //    }
                    //}
                }
                base.hus = base.hus.Where(h => !h.HuId.Equals(hu.HuId, StringComparison.OrdinalIgnoreCase)).ToList();
                this.gvHuListDataBind();
            }
        }