/// <summary>
        /// 断电恢复
        /// </summary>
        private void RestoringFromPowerOff()
        {
            try
            {
                //获取最新的一条分拣记录
                var log = OrderSortService.GetTheLastOrderSortingLog();
                if (log != null && log.Status == 3)
                {
                    switch (log.Status)
                    {
                    case 3:    //3投递异常
                        Invoke((MethodInvoker) delegate()
                        {
                            //目标柜格,亮绿灯
                            _TargetLattice = _LatticesettingList.Find(s => s.CabinetId == Convert.ToInt32(log.TargetCabinetId) && s.LatticeId == log.TargetLatticeId);
                            if (OrderSortService.SetLED(_TargetLattice, 0))
                            {
                                _ButtonList.FirstOrDefault(b => b.TabIndex == _TargetLattice.ID).BackColor = GetColor(0);
                            }
                            //投入柜格,亮红灯
                            _ResultLattice = _LatticesettingList.Find(s => s.CabinetId == Convert.ToInt32(log.ResultCabinetId) && s.LatticeId == log.ResultLatticeId);
                            if (OrderSortService.SetLED(_ResultLattice, 1))
                            {
                                _ButtonList.FirstOrDefault(b => b.TabIndex == _ResultLattice.ID).BackColor = GetColor(1);
                            }
                            lblOrderId.Text = log.OrderId;
                            _TargetLattice  = null;
                            _IsError        = true;
                        });
                        break;

                    case 4:    //4重复扫描
                        Invoke((MethodInvoker) delegate()
                        {
                            _LastSuccessOrderId = log.OrderId;
                            _LastOrderId        = string.Empty;
                            //目标柜格,亮绿灯
                            _TargetLattice = _LatticesettingList.Find(s => s.CabinetId == Convert.ToInt32(log.TargetCabinetId) && s.LatticeId == log.TargetLatticeId);
                            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;
                                _IsError       = true;
                                return;
                            }
                        });
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                SaveErrLogHelper.SaveErrorLog(string.Empty, ex.ToString());
                MessageBox.Show(ex.Message);
            }
        }
示例#2
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);
                    }
                });
            }));
        }