Beispiel #1
0
 /// <summary>
 /// 创建扫描记录,亮灯
 /// </summary>
 private void CreateOrderSortingLogAndTurnOnGreenLight()
 {
     //创建扫描记录
     if (OrderSortService.CreateOrderSortingLog(_Orderinfo, _TargetLattice, null, _UserInfo, 1, 1))
     {
         OrderSortService.SetLED(_TargetLattice, 0);
         //重置计数器
         OrderSortService.ReSetGratingOrButton(3);
         //重置警示灯
         OrderSortService.ReSetWarningLight();
         lblOrderId.Text = _Orderinfo.OrderId;
         //_buttonList.ForEach(b => b.BackColor = GetColor(3));
         _ButtonList.FirstOrDefault(b => b.TabIndex == _TargetLattice.ID).BackColor = GetColor(0);
         _IsRepeatError     = false;
         _LatticeOrdersList = null;
         _LastOrderId       = _Orderinfo.OrderId;
         lblMsg.Text        = "";
     }
 }
Beispiel #2
0
        /// <summary>
        /// 检查光栅状态,检查每一个格口是否有物体通过
        /// </summary>
        private Task CheckGratingAsync()
        {
            return(Task.Run(() =>
            {
                try
                {
                    if (IsCheckGratingSuspending)
                    {
                        return;
                    }
                    _IsCheckGratingRunning = true;
                    if (_SlaveConfig == null)
                    {
                        SaveErrLogHelper.SaveErrorLog(string.Empty, "检查光栅状态时出现异常:_SlaveConfig为Null");
                    }
                    foreach (var slave in _SlaveConfig)
                    {
                        var registersGrating = OrderSortService.ReadGratingRegisters(slave.SlaveAddress);
                        if (registersGrating == null)
                        {
                            SaveErrLogHelper.SaveErrorLog(string.Empty, "检查光栅状态时出现异常:registersGrating为Null");
                            continue;
                        }

                        if (_TargetLattice == null)
                        {
                            SaveErrLogHelper.SaveErrorLog(string.Empty, "检查光栅状态时出现异常:_TargetLattice为Null");
                            continue;
                        }

                        for (int i = 0; i < registersGrating.Length; i++)
                        {
                            //是否有包裹投入
                            if (registersGrating[i] < 1)
                            {
                                continue;
                            }

                            //投放错误
                            if (_TargetLattice.GratingIndex != i || slave.CabinetId != _TargetLattice.CabinetId)
                            {
                                if (_LatticesettingList == null)
                                {
                                    SaveErrLogHelper.SaveErrorLog(string.Empty, "检查光栅状态时出现异常:_LatticesettingList为Null");
                                }
                                _ResultLattice = _LatticesettingList.Find(lsc => lsc.GratingIndex == i && lsc.CabinetId == slave.CabinetId);
                                //创建分拣记录
                                if (OrderSortService.CreateOrderSortingLog(_Orderinfo, _TargetLattice, _ResultLattice, _UserInfo, 2, 3))
                                {
                                    OrderSortService.SetWarningLight(4, 1);
                                    //亮红灯
                                    OrderSortService.SetLED(_ResultLattice, 1);
                                    _LastOrderId = string.Empty;
                                    _TargetLattice = null;
                                    _BlockLattice = null;
                                    //按钮变红色
                                    //_buttonList.ForEach(b => b.BackColor = GetColor(3));
                                    _ButtonList.FirstOrDefault(b => b.TabIndex == _ResultLattice.ID).BackColor = GetColor(1);
                                    Invoke((MethodInvoker) delegate()
                                    {
                                        lblMsg.Text = "投放错误";
                                    });
                                }
                            }
                            else
                            {
                                //创建分拣记录
                                if (OrderSortService.CreateOrderSortingLog(_Orderinfo, _TargetLattice, _TargetLattice, _UserInfo, 2, 2))
                                {
                                    OrderSortService.ReSetLED();
                                    OrderSortService.ReSetWarningLight();
                                    _LastSuccessOrderId = _Orderinfo.OrderId;
                                    Invoke((MethodInvoker) delegate()
                                    {
                                        //更新格口统计信息
                                        _ButtonList.FirstOrDefault(b => b.TabIndex == _TargetLattice.ID).Text = OrderSortService.GetLatticeNewText(_TargetLattice);
                                    });
                                    if (OrderSortService.IsFullLattice(_TargetLattice.ID))
                                    {
                                        int cabinetId = _TargetLattice.CabinetId;
                                        int index = _TargetLattice.LEDIndex;
                                        OrderSortService.SetLED(cabinetId, index, 1);
                                        Thread.Sleep(500);
                                        OrderSortService.SetLED(cabinetId, index, 3);
                                    }
                                    _LastOrderId = string.Empty;
                                    _ResultLattice = null;
                                    _BlockLattice = null;
                                    _TargetLattice = null;
                                    //按钮颜色恢复
                                    _ButtonList.ForEach(b => b.BackColor = GetColor(3));
                                    Invoke((MethodInvoker) delegate() { ResetLabelTest(); });
                                    OrderSortService.ReSetGratingOrButton(1);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    SaveErrLogHelper.SaveErrorLog(string.Empty, ex.ToString());
                }
                finally
                {
                    _IsCheckGratingRunning = false;
                }
            }));
        }
Beispiel #3
0
        /// <summary>
        /// 检查订单信息
        /// </summary>
        private Task CheckOrderIdAsync()
        {
            return(Task.Run(() =>
            {
                Invoke((MethodInvoker) delegate()
                {
                    try
                    {
                        var orderid = txtOrderId.Text.Trim();
                        txtOrderId.Text = "";
                        if (!string.IsNullOrWhiteSpace(lblOrderId.Text) && lblOrderId.Text != orderid)
                        {
                            if (_TargetLattice != null && !string.IsNullOrWhiteSpace(_LastOrderId) && !_LastOrderId.Equals(orderid))
                            {
                                //禁止同时扫两个订单
                                OrderSortService.SetLED(_TargetLattice, 3);
                                _ButtonList.FirstOrDefault(b => b.TabIndex == _TargetLattice.ID).BackColor = GetColor(3);
                                _TargetLattice = null;
                                //_LastOrderId = string.Empty;
                                //ResetLabelTest();
                                lblMsg.Text = string.Format("不可同时扫描两个订单:{0},{1}", lblOrderId.Text, orderid);
                            }

                            return;
                        }
                        else
                        {
                            OrderSortService.ReSetLED();
                        }
                        //根据订单号获取订单信息,并获取目标格口
                        if (!CheckOrderinfo(orderid))
                        {
                            return;
                        }
                        //是否连续两次重复投递
                        //var lastOrderLog = OrderSortService.GetTheLastOrderSortingLog();
                        //if (lastOrderLog != null && lastOrderLog.OrderId == orderid && lastOrderLog.Status == 2)
                        if (_LastSuccessOrderId.Equals(orderid))
                        {
                            //创建扫描记录
                            if (OrderSortService.CreateOrderSortingLog(_Orderinfo, _TargetLattice, null, _UserInfo, 1, 4))
                            {
                                OrderSortService.SetLED(_TargetLattice, 1);
                                //准备进行重复扫描异常处理
                                _LatticeOrdersList = OrderSortService.GetLatticeOrdersListByLatticesettingId(_TargetLattice.ID);
                                if (_LatticeOrdersList != null && _LatticeOrdersList.Count > 0)
                                {
                                    _ButtonList.FirstOrDefault(b => b.TabIndex == _TargetLattice.ID).BackColor = GetColor(1);
                                    _IsRepeatError = true;
                                    _TargetLattice = null;
                                    lblMsg.Text = string.Format("不可重复扫描,订单号:{0}", orderid);
                                    return;
                                }
                            }
                            return;
                        }
                        //创建扫描记录,亮灯
                        CreateOrderSortingLogAndTurnOnGreenLight();
                    }
                    catch (Exception ex)
                    {
                        SaveErrLogHelper.SaveErrorLog(string.Empty, ex.ToString());
                        MessageBox.Show(ex.Message);
                    }
                });
            }));
        }