Beispiel #1
0
        protected override void ScanBarCode()
        {
            base.ScanBarCode();

            if (this.location == null)
            {
                if (base.op == CodeMaster.BarCodeType.L.ToString())
                {
                    base.barCode = base.barCode.Substring(2, base.barCode.Length - 2);
                    var location = smartDeviceService.GetLocation(base.barCode);
                    //检查权限
                    if (!Utility.HasPermission(user.Permissions, null, false, true, null, location.Region))
                    {
                        throw new BusinessException("没有此库位的权限");
                    }
                    this.location = location;
                    this.lblMessage.Text = "当前库位:" + this.location.Code;
                }
                else
                {
                    throw new BusinessException("请先扫描库位");
                }
            }
            else
            {
                if (base.op == CodeMaster.BarCodeType.HU.ToString())
                {
                    Hu hu = smartDeviceService.GetHu(barCode);
                    if (hu.Status == HuStatus.Location)
                    {
                        throw new BusinessException("条码已在库位中不能装箱");
                    }

                    if (hu.Status == HuStatus.Ip)
                    {
                        throw new BusinessException("条码已在途不能装箱");
                    }
                    this.MatchHu(hu);
                }
                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("条码格式不合法");
                }
            }
        }
        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("条码格式不合法");
                }
            }
        }
Beispiel #3
0
 protected override void Reset()
 {
     this.groupHus = new List<GroupHu>();
     base.Reset();
     this.location = null;
     this.binCode = null;
     this.effDate = null;
     this.lblMessage.Text = "正常模式,请扫描库位或库格条码";
 }
        private void ScanBarCode()
        {
            string barCode = this.tbBarCode.Text.Trim();
            this.tbBarCode.Focus();
            this.tbBarCode.Text = string.Empty;
            string op = Utility.GetBarCodeType(this.user.BarCodeTypes, barCode);
            if (barCode.Length < 3)
            {
                throw new BusinessException("条码格式不合法");
            }

            if (this.orderMaster == null)
            {
                if (op == CodeMaster.BarCodeType.ORD.ToString())
                {
                    var orderMaster = this.smartDeviceService.GetOrder(barCode, false);

                    if (orderMaster.IsPause || orderMaster.Status != OrderStatus.Submit)
                    {
                        throw new BusinessException("生产单已暂停或状态不正确");
                    }
                    else if (orderMaster.Type != OrderType.Production)
                    {
                        throw new BusinessException("不是生产单不可以上线{0}", orderMaster.OrderNo);
                    }
                    else
                    {
                        if (!Utility.HasPermission(orderMaster, user))
                        {
                            throw new BusinessException("没有操作生产单{0}的权限", orderMaster.OrderNo);
                        }

                        //this.numOfScan = this.numOfScan + 1;
                        this.lblMessage.Text = "请继续扫描条码或者确认上线";
                        this.lblStartTimeInfo.Text = orderMaster.StartTime.ToString("yyyy-MM-dd HH:mm");
                        this.lblFlowInfo.Text = orderMaster.Flow;
                        this.lblSeqInfo.Text = orderMaster.Sequence.ToString();
                        this.lblVANInfo.Text = orderMaster.TraceCode;
                        this.lblWoInfo.Text = orderMaster.OrderNo;
                        this.orderMaster = orderMaster;
                    }
                }
                else
                {
                    this.Reset();
                    this.lblMessage.Text = "";
                    throw new BusinessException("请先扫描生产单");
                }
            }
            else
            {
                if (barCode.Length == 17 && this.smartDeviceService.IsValidLotNo(barCode.Substring(9, 4)) == true)
                {
                    op = CodeMaster.BarCodeType.HU.ToString();
                }
                if (op == CodeMaster.BarCodeType.ORD.ToString())
                {
                    Hu hu = null;// smartDeviceService.GetHuByOrderNo(barCode);
                    if (hu == null)
                    {
                        throw new BusinessException("未找到子生产单{0}的下线条码。", orderMaster.OrderNo);
                    }
                    else if (huList.Count()>0 && huList.Where(h => h.HuId == hu.HuId).Count()>0)
                    {
                        throw new BusinessException("子生产单{0}已扫描。", orderMaster.OrderNo);
                    }

                    if (hu.IsFreeze)
                    {
                        throw new BusinessException("条码被冻结。");
                    }
                    if (hu.OccupyType != OccupyType.None)
                    {
                        throw new BusinessException("条码被{0}占用。", hu.OccupyReferenceNo);
                    }
                    //if (!smartDeviceService.VerifyOrderCompareToHu(this.orderMaster.OrderNo, hu.HuId))
                    //{
                    //    throw new BusinessException("物料{0}不能投到生产单{1}", this.orderMaster.OrderNo, hu.HuId);
                    //}
                    huList.Insert(0, hu);

                    this.lblBarCodeInfo.Text = hu.HuId;
                    this.lblItemDescInfo.Text = hu.ItemDescription;
                    this.lblRefItemInfo.Text = hu.ReferenceItemCode;
                    this.lblItemInfo.Text = hu.Item;
                    return;
                }
                else if (op == CodeMaster.BarCodeType.HU.ToString())
                {
                    Hu hu = new Hu();
                    try
                    {
                        hu = this.smartDeviceService.GetHu(barCode);
                        if (!string.IsNullOrEmpty(hu.OrderNo))
                        {
                            hu.OrderNo = string.Empty;
                        }
                    }
                    catch
                    {
                        if (barCode.Length == 17)
                        {
                            hu = this.smartDeviceService.ResolveHu(barCode, this.user.Code);
                            hu.IsEffective = false;
                        }
                    }
                    if (hu == null)
                    {
                        throw new BusinessException("条码不存在");
                    }
                    hu.CurrentQty = hu.Qty;
                    var matchHu = this.huList.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 (hu.Status != HuStatus.Location)
                    {
                        if (this.location == null)
                        {
                            throw new BusinessException("请先扫描库位条码。");
                        }
                        hu.IsEffective = false;
                    }

                    //if (!smartDeviceService.VerifyOrderCompareToHu(this.orderMaster.OrderNo, hu.HuId))
                    //{
                    //    throw new BusinessException("物料{0}不能投到生产单{1}", this.orderMaster.OrderNo, hu.HuId);
                    //}
                    huList.Insert(0, hu);
                    this.lblBarCodeInfo.Text = hu.HuId;
                    this.lblItemDescInfo.Text = hu.ItemDescription;
                    this.lblRefItemInfo.Text = hu.ReferenceItemCode;
                    this.lblItemInfo.Text = hu.Item;
                    return;

                }
                else if (op == CodeMaster.BarCodeType.L.ToString())
                {
                    barCode = barCode.Substring(2, barCode.Length - 2);
                    Location location = smartDeviceService.GetLocation(barCode);

                    //检查权限
                    if (!Utility.HasPermission(user.Permissions, OrderType.Transfer, false, true, null, location.Region))
                    {
                        throw new BusinessException("没有此区域的权限");
                    }
                    this.location = location;
                }
                else
                {
                    throw new BusinessException("条码格式不合法");
                }
            }
        }