Пример #1
0
 /// <summary>
 /// 强制完成
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ToolWavePowerComplete_Click(object sender, EventArgs e)
 {
     try
     {
         if (!SlaveInfoService.SlaveInfo.IsComplete)
         {
             var result = MessageBox.Show($"确定强制完成波次:{SlaveInfoService.SlaveInfo.WaveNo}?", "提示",
                                          MessageBoxButtons.OKCancel);
             if (result == DialogResult.OK)
             {
                 UpDownService.WavePowerComplete(new UpDownMessage
                 {
                     Message = $"强制完成波次号:{SlaveInfoService.SlaveInfo.WaveNo}"
                 });
                 lblMsg.Text = $"已强制完成波次号:{SlaveInfoService.SlaveInfo.WaveNo}";
             }
         }
         else
         {
             lblMsg.Text = $"未找到进行中的波次号!";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #2
0
 /// <summary>
 /// 初始化服务
 /// </summary>
 private void InitService()
 {
     SlaveInfoService = new SlaveInfoService();
     ButtonService    = new ButtonService(SlaveInfoService);
     SysConfig        = new SysConfigService().Get();
     WaveApiService   = new WaveApiService();
     UpDownService    = new UpDownService(SysConfig, SlaveInfoService, Main.CurUser);
     UpDownService.AddService(new PcUpDownService(SlaveInfoService, ButtonService, SynchronizationContext.Current, SysConfig, Main.CurUser));
     UpDownService.AddService(new BoardUpDownService(SlaveInfoService));
 }
Пример #3
0
        /// <summary>
        /// 开始波次
        /// </summary>
        /// <param name="waveNo"></param>
        private void SortWaveBegin(string waveNo)
        {
            if (!string.IsNullOrWhiteSpace(SlaveInfoService.SlaveInfo.WaveNo) && !SlaveInfoService.SlaveInfo.IsPrintOver)
            {
                SoundService.PlaySoundAsny(SoundType.WatitPrintOver);
                UpDownService.SetText("请等待打印完毕!");
                return;
            }

            var waveApi = WaveApiService.Get(waveNo);

            if (waveApi == null)
            {
                UpDownService.WaveNotfound(waveNo);
                Invoke((MethodInvoker) delegate()
                {
                    lblMsg.Text = $"未找到波次:{waveNo}";
                });

                return;
            }
            if (waveApi.Status == WaveStatus.Complete)
            {
                //var result = MessageBox.Show($"波次:{waveNo}已分拣完,是否重新分拣?", "提示",
                //          MessageBoxButtons.OKCancel);
                //if (result == DialogResult.OK)
                //{
                var slaveInfo = SlaveInfoService.GetSlaveInfo(o => o.WaveNo == waveNo);
                SlaveInfoService.DeleteSlaveInfo(slaveInfo);
                slaveInfo = WaveApiService.WaveApiTransformSlaveInfo(waveApi);
                UpDownService.BeginSort(slaveInfo);
                Invoke((MethodInvoker) delegate()
                {
                    lblMsg.Text = $"开始波次:{waveNo}";
                });
                //}
                return;
            }
            if (waveApi.Status == WaveStatus.Unwork)
            {
                var slaveInfo = WaveApiService.WaveApiTransformSlaveInfo(waveApi);
                if (slaveInfo != null)
                {
                    UpDownService.BeginSort(slaveInfo);
                    Invoke((MethodInvoker) delegate()
                    {
                        lblMsg.Text = $"开始波次:{waveNo}";
                    });
                }
            }
        }
Пример #4
0
 /// <summary>
 /// 开始分拣
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void StarMenu_Click(object sender, EventArgs e)
 {
     try
     {
         if (ConnectBoard())
         {
             //检查是否有上次未分拨完的
             var slaveInfo = SlaveInfoService.GetSlaveInfo(o => !o.IsComplete);
             if (slaveInfo != null)
             {
                 var result = MessageBox.Show($"波次:{slaveInfo.WaveNo}未分拣完,是否继续?", "提示",
                                              MessageBoxButtons.OKCancel);
                 if (result == DialogResult.OK)
                 {
                     UpDownService.BeginSort(slaveInfo);
                     lblMsg.Text = $"开始波次:{slaveInfo.WaveNo}";
                 }
                 else
                 {
                     SlaveInfoService.DeleteSlaveInfo(slaveInfo);
                 }
             }
             try
             {
                 if (serialPort_Scan.IsOpen)
                 {
                     serialPort_Scan.Close();
                 }
                 serialPort_Scan.PortName = SysConfig.ScanPortName ?? "";
                 serialPort_Scan.Open();
             }
             catch (Exception ex) { LogHelper.SaveAsyn("开始分拣出错", ex); }
             txtInput.Enabled = true;
             txtInput.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         LogHelper.SaveAsyn("开始分拣出错", ex);
     }
 }
Пример #5
0
 /// <summary>
 /// 分拨中断
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ToolWaveCancel_Click(object sender, EventArgs e)
 {
     try
     {
         if (!string.IsNullOrEmpty(SlaveInfoService.SlaveInfo.WaveNo))
         {
             var result = MessageBox.Show($"确定中断波次:{SlaveInfoService.SlaveInfo.WaveNo}?", "提示",
                                          MessageBoxButtons.OKCancel);
             if (result == DialogResult.OK)
             {
                 UpDownService.WaveCancel(new UpDownMessage
                 {
                     Message = "中断分拨成功"
                 });
                 lblMsg.Text = $"已中断波次号:{SlaveInfoService.SlaveInfo.WaveNo}";
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #6
0
        private void CommandHandle(UpDownMessage upDownMessage)
        {
            //用反射可以一劳永益以后不用再一个一个添加,但影响效率的效率有多少?
            switch (upDownMessage.UpDownCommand)
            {
            case UpDownCommand.PutIng:
                UpDownService.PutIng(upDownMessage);
                break;

            case UpDownCommand.BlockError:
                UpDownService.BlockError(upDownMessage);
                break;

            case UpDownCommand.RemoveBlockError:
                UpDownService.RemoveBlockError(upDownMessage);
                break;

            case UpDownCommand.PrintSingle:
                UpDownService.PrintSingle(upDownMessage);
                break;

            case UpDownCommand.PrintAll:
                UpDownService.PrintAll(upDownMessage);
                break;

            case UpDownCommand.WaveCancel:
                UpDownService.WaveCancel(upDownMessage);
                break;

            case UpDownCommand.WavePowerComplete:
                UpDownService.WavePowerComplete(upDownMessage);
                break;

            default:
                break;
            }
        }
Пример #7
0
        private bool ConnectBoard()
        {
            try
            {
                if (socketSend == null || !socketSend.Connected)
                {
                    socketSend = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    IPEndPoint point = new IPEndPoint(IPAddress.Parse(SysConfig.IP), Convert.ToInt32(SysConfig.Port));
                    socketSend.Connect(point);
                    UpDownService.SetSocket(socketSend);
                    lblMsg.Text = "连接分拣架成功!";

                    Thread th = new Thread(ReceiveBoardMsg);
                    th.IsBackground = true;
                    th.Start();
                }
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("连接分拣架失败!");
                return(false);
            }
        }
Пример #8
0
        /// <summary>
        /// 开始分拣产品
        /// </summary>
        /// <param name="productCode"></param>
        private void SortProductBegin(string barCode)
        {
            //0.验证
            if (SlaveInfoService.SlaveInfo.LatticeStatus == LatticeStatus.PutError)
            {
                if (SlaveInfoService.LatticeInfoList.Exists(o => o.Status == LatticeStatus.WaitPut && o.Product.Exists(p => p.BarCode == barCode)))
                {
                    var latticePutError = SlaveInfoService.LatticeInfoList.Where(o => o.Status == LatticeStatus.PutError).ToList();
                    UpDownService.RemovePutError(new UpDownMessage()
                    {
                        LatticeByUpDown =
                            latticePutError.Select(l => new LatticeByUpDown {
                            LatticeNo = l.LatticeNo
                        }).ToList()
                    });

                    lblMsg.Text = string.Format(Resources.RemovePutError, barCode);
                }
                else
                {
                    lblMsg.Text = string.Format(Resources.PleaseSolvePutError, barCode);
                    SoundService.PlaySound(SoundType.PutError);
                }
                return;
            }
            if (SlaveInfoService.SlaveInfo.LatticeStatus == LatticeStatus.BlockError)
            {
                lblMsg.Text = string.Format(Resources.PleaseSolveBlockError, barCode);
                SoundService.PlaySound(SoundType.BlockError);
                return;
            }
            if (SlaveInfoService.SlaveInfo.LatticeStatus == LatticeStatus.WaitPut)
            {
                lblMsg.Text = string.Format(Resources.PleaseWait, barCode);
                UpDownService.SetText("存在待投递的产品!");
                SoundService.PlaySoundAsny(SoundType.WaitPut);
                return;
            }

            //1.装载格口
            var waveApiList = WaveApiService.GetOrderApiList(SlaveInfoService.SlaveInfo.WaveNo, barCode);

            if (waveApiList.Count == 0)
            {
                UpDownService.ProductNotFound();
                lblMsg.Text = string.Format(Resources.ProductError, SlaveInfoService.SlaveInfo.WaveNo, barCode);
                return;
            }
            waveApiList.ForEach(o =>
            {
                if (!SlaveInfoService.LatticeInfoList.Exists(s => s.OrderNo == o.OrderNo))
                {
                    SlaveInfoService.LoadLattice(o);
                }
            });
            if (!SlaveInfoService.SlaveInfo.LatticeInfo.SelectMany(o => o.Product).Where(o => o.BarCode == barCode).Any(o => !o.IsComplete))
            {
                lblMsg.Text = $"货物已配足:{barCode}";
                UpDownService.SetText($"货物已配足:{barCode}");
                SoundService.PlaySoundAsny(SoundType.ProductOver);
                return;
            }
            //2.更新格口为待投递
            string orderNo        = waveApiList.First().OrderNo;
            var    waitPutLattice = SlaveInfoService.LatticeInfoList.Where(o => !o.IsComplete && waveApiList.Select(s => s.OrderNo).Contains(o.OrderNo)).ToList();

            UpDownService.WaitPut(waitPutLattice, barCode);
        }
Пример #9
0
 public LatticeConfig(string latticeNo, UpDownService upDownService, SlaveInfoService slaveInfoService, ButtonService buttonService) : this(latticeNo)
 {
     this.upDownService    = upDownService;
     this.slaveInfoService = slaveInfoService;
     this.buttonService    = buttonService;
 }