Esempio n. 1
0
        public void PrintSingle(UpDownMessage upDownMessage)
        {
            if (sysConfig.PrintType == PrintType.一次性打印)
            {
                return;
            }
            upDownMessage.UpDownCommand = UpDownCommand.PrintSingle;

            Parallel.ForEach(service, o => o.PrintSingle(upDownMessage));

            SetText($"格口[{upDownMessage.LatticeByUpDown.First().LatticeNo}]已打印");
            //波次是否完成
            if (slaveInfoService.IsComplete)
            {
                if (sysConfig.PrintType == PrintType.逐个打印 && slaveInfoService.LatticeInfoList.All(o => o.IsPrint))
                {
                    WaveComplete(new UpDownMessage {
                    });
                }
            }
            if (slaveInfoService.SlaveInfo.IsPrintOver)
            {
                WavePrintOver();
            }
        }
Esempio n. 2
0
 public void PutSuccess(UpDownMessage upDownMessage)
 {
     upDownMessage.LatticeByUpDown.ForEach(o =>
     {
         var tempPutNum  = o.Num;
         var latticeInfo = SlaveInfoService.GetLatticeInfo(o.LatticeNo);
         latticeInfo.Product
         .FindAll(p => p.Status == ProductStatus.WaitPut)
         .ForEach(p =>
         {
             var MaxWaitPut = p.WaitNum - p.PutNum;
             if (MaxWaitPut >= tempPutNum)
             {
                 p.PutNum += tempPutNum;
             }
             else
             {
                 p.PutNum   += MaxWaitPut;
                 tempPutNum -= MaxWaitPut;
             }
         });
         //latticeInfo.Product.First(p=>p.Status==ProductStatus.WaitPut).PutNum += o.Num;
         SlaveInfoService.SetLatticeStatus(latticeInfo, LatticeStatus.None);
         SlaveInfoService.ProductTransformNone(latticeInfo);
     });
     UpdateButton(upDownMessage);
     SlaveInfoService.SaveAync();
 }
Esempio n. 3
0
        public void BlockError(UpDownMessage upDownMessage)
        {
            upDownMessage.UpDownCommand = UpDownCommand.BlockError;

            upDownMessage.LatticeByUpDown.ForEach(o =>
            {
                var latticeInfo = slaveInfoService.GetLatticeInfo(o.LatticeNo);
                if (latticeInfo.Status == LatticeStatus.WaitPut && latticeInfo.Product.Where(p => p.Status == ProductStatus.WaitPut).Sum(t => t.WaitNum - t.PutNum) == 1)
                {
                    PutSuccess(new UpDownMessage
                    {
                        LatticeByUpDown = new List <LatticeByUpDown>
                        {
                            new LatticeByUpDown {
                                LatticeNo = latticeInfo.LatticeNo, Num = 1
                            }
                        }
                    });
                }
                else
                {
                    BlockErrorSuccess(upDownMessage);
                }
            });
        }
Esempio n. 4
0
        public void WavePowerCompleteSuccess(UpDownMessage upDownMessage)
        {
            SlaveInfoService.SlaveInfo.IsCompleteHand = true;
            SlaveInfoService.SaveAync();
            new WaveApiService().Complete(SlaveInfoService.SlaveInfo.WaveNo);
            //打印缺货
            var data       = SlaveInfoService.GetSortingDetail().Where(o => o.WaitNum > o.PutNum).ToList();
            var lattieInfo = new LatticeInfo
            {
                Product = new List <Product>()
            };

            for (int i = 0; i < data.Count; i++)
            {
                lattieInfo.Product.Add(new Product
                {
                    ProductName = data[i].OrderNo,
                    BarCode     = data[i].BarCode,
                    PutNum      = data[i].PutNum,
                    WaitNum     = data[i].WaitNum
                });
                lattieInfo.OrderNo = data[i].OrderNo;

                new ProductPrint().PrintSetup(lattieInfo);
                lattieInfo.Product.Clear();
            }
            if (lattieInfo.Product.Count > 0)
            {
                new ProductPrint().PrintSetup(lattieInfo);
            }
            // SlaveInfoService.InitSlaveInfo();
            SoundService.PlaySoundAsny(SoundType.WavePowerComplete);
            FlashGreenLight();
        }
Esempio n. 5
0
        public void PutSuccess(UpDownMessage upDownMessage)
        {
            upDownMessage.UpDownCommand = UpDownCommand.PutSuccess;
            upDownMessage.Message       = $"投递成功";

            Parallel.ForEach(service, o => o.PutSuccess(upDownMessage));
            //格口是否完成
            upDownMessage.LatticeByUpDown.ForEach(o =>
            {
                var latticeInfo = slaveInfoService.GetLatticeInfo(o.LatticeNo);
                if (latticeInfo.IsComplete)
                {
                    LatticeComplete(new UpDownMessage()
                    {
                        LatticeByUpDown = new List <LatticeByUpDown>()
                        {
                            new LatticeByUpDown()
                            {
                                LatticeNo = o.LatticeNo
                            },
                        },
                        Message = $"格口[{latticeInfo.LatticeNo}]已完成"
                    });
                }
            });
            //波次是否完成
            if (slaveInfoService.IsComplete)
            {
                WaveComplete(new UpDownMessage {
                    Message = $"完成波次:{slaveInfoService.SlaveInfo.WaveNo}"
                });
            }
        }
Esempio n. 6
0
 public void PutIng(UpDownMessage upDownMessage)
 {
     upDownMessage.LatticeByUpDown.ForEach(o =>
     {
         //过滤
         var latticeInfo = slaveInfoService.GetLatticeInfo(o.LatticeNo);
         var waitputNum  = latticeInfo.Product.Where(p => p.Status == ProductStatus.WaitPut).Sum(t => t.WaitNum - t.PutNum);
         if (upDownMessage.Type == "1" && waitputNum > 1)//1代表光栅投递
         {
         }
         else if (waitputNum < upDownMessage.LatticeByUpDown.First().Num)
         {
             //upDownMessage.Message = $"超出可投数:{waitputNum}";
             //PutNumError(upDownMessage);
         }
         else if (latticeInfo.Status != LatticeStatus.WaitPut && slaveInfoService.SlaveInfo.LatticeStatus == LatticeStatus.WaitPut)
         {
             upDownMessage.Message = $"格口[{latticeInfo.LatticeNo}]投递出错";
             PutError(upDownMessage);
         }
         else if (latticeInfo.Status == LatticeStatus.WaitPut && slaveInfoService.SlaveInfo.LatticeStatus == LatticeStatus.WaitPut)
         {
             PutSuccess(upDownMessage);
         }
     });
 }
Esempio n. 7
0
        public void WavePowerCompleteSuccess(UpDownMessage upDownMessage)
        {
            upDownMessage.UpDownCommand = UpDownCommand.WavePowerCompleteSuccess;

            Parallel.ForEach(service, o => o.WavePowerCompleteSuccess(upDownMessage));
            SetText("强制完成成功");
        }
Esempio n. 8
0
 private void btnPutSuccess_Click(object sender, EventArgs e)
 {
     Task3 = Task.Run(() =>
     {
         Enumerable.Range(1, 50).ToList().ForEach(o =>
         {
             var upDownMessage = new UpDownMessage()
             {
                 UpDownCommand   = UpDownCommand.PutSuccess,
                 LatticeByUpDown = new List <LatticeByUpDown>
                 {
                     new LatticeByUpDown {
                         LatticeNo = o.ToString(), Num = 1
                     }
                 },
                 Type = "0"
             };
             Invoke((MethodInvoker) delegate()
             {
                 var btn       = this.Controls.Find("btn" + o.ToString(), true)[0] as Button;
                 btn.BackColor = Color.Gainsboro;
             });
             SendMsg(upDownMessage);
             Thread.Sleep(200);
         });
     });
 }
Esempio n. 9
0
 /// <summary>
 /// 投递成功
 /// </summary>
 /// <param name="upDownMessage"></param>
 public void LatticePutSuccess(UpDownMessage upDownMessage)
 {
     upDownMessage.LatticeByUpDown.ForEach(o =>
     {
         SlaveInfoService.LatticeInfoList.First(l => l.LatticeNo == o.LatticeNo).Status =
             LatticeStatus.None;
     });
 }
Esempio n. 10
0
        public void BlockErrorSuccess(UpDownMessage upDownMessage)
        {
            upDownMessage.UpDownCommand = UpDownCommand.BlockErrorSuccess;

            Parallel.ForEach(service, o => o.BlockErrorSuccess(upDownMessage));

            SetText($"格口[{upDownMessage.LatticeByUpDown.First().LatticeNo}]阻挡");
        }
Esempio n. 11
0
 public void LatticeWaitPut(UpDownMessage upDownMessage)
 {
     upDownMessage.LatticeByUpDown.ForEach(o =>
     {
         SlaveInfoService.LatticeInfoList.First(l => l.LatticeNo == o.LatticeNo).Status =
             LatticeStatus.WaitPut;
     });
     UpdateButton(upDownMessage);
 }
Esempio n. 12
0
        /// <summary>
        /// 获取格口
        /// </summary>
        /// <param name="upDownMessage"></param>
        /// <returns></returns>
        public List <LatticeInfo> GetLatticeInfoList(UpDownMessage upDownMessage)
        {
            List <LatticeInfo> latticeInfoList = new List <LatticeInfo>();

            upDownMessage.LatticeByUpDown.ForEach(o =>
            {
                latticeInfoList.Add(GetLatticeInfo(o.LatticeNo));
            });
            return(latticeInfoList);
        }
Esempio n. 13
0
        public void WaveNotfound(string wave)
        {
            var upDownMessage = new UpDownMessage()
            {
                UpDownCommand = UpDownCommand.WaveNotfound,
                Message       = $"未找到波次号[{wave}]"
            };

            Parallel.ForEach(service, o => o.WaveNotfound(upDownMessage));
        }
Esempio n. 14
0
 public void RemoveBlockErrorSuccess(UpDownMessage upDownMessage)
 {
     upDownMessage.LatticeByUpDown.ForEach(o =>
     {
         var latticeInfo = SlaveInfoService.GetLatticeInfo(o.LatticeNo);
         SlaveInfoService.SetLatticeStatus(latticeInfo, LatticeStatus.None);
     });
     UpdateButton(upDownMessage);
     SoundService.PlaySoundAsny(SoundType.RemoveBlockError);
 }
Esempio n. 15
0
        public void BeginSort(SlaveInfo slaveInfo)
        {
            var upDownMessage = new UpDownMessage
            {
                UpDownCommand = UpDownCommand.BeginSort,
                Message       = $"开始波次"
            };

            SendMsg(upDownMessage);
        }
Esempio n. 16
0
 private void UpdateButton(UpDownMessage upDownMessage = null)
 {
     if (upDownMessage == null)
     {
         current.Post((o) => { ButtonService.UpdateButtons(); }, null);
     }
     else
     {
         current.Post((o) => { ButtonService.UpdateButton(upDownMessage); }, null);
     }
 }
Esempio n. 17
0
 public void PutError(UpDownMessage upDownMessage)
 {
     upDownMessage.LatticeByUpDown.ForEach(o =>
     {
         var latticeInfo = SlaveInfoService.GetLatticeInfo(o.LatticeNo);
         SlaveInfoService.SetLatticeStatus(latticeInfo, LatticeStatus.PutError);
     });
     UpdateButton(upDownMessage);
     SlaveInfoService.SaveAync();
     SoundService.PlaySoundAsny(SoundType.PutError);
 }
Esempio n. 18
0
        private void SendMsg(UpDownMessage upDownMessage)
        {
            upDownMessage.Message = upDownMessage.Message + $"【{SlaveInfoService.SlaveInfo.NeedWaitPutByApi}:{SlaveInfoService.SlaveInfo.PutNum}】";
            string data = $"*#{upDownMessage.UpDownCommand}#";

            if (upDownMessage.LatticeByUpDown != null && upDownMessage.LatticeByUpDown.Count != 0)
            {
                upDownMessage.LatticeByUpDown.ForEach(o =>
                {
                    if (upDownMessage.UpDownCommand == UpDownCommand.PutSuccess ||
                        upDownMessage.UpDownCommand == UpDownCommand.PutError ||
                        upDownMessage.UpDownCommand == UpDownCommand.LatticeComplete ||
                        upDownMessage.UpDownCommand == UpDownCommand.BlockErrorSuccess ||
                        upDownMessage.UpDownCommand == UpDownCommand.RemoveBlockErrorSuccess ||
                        upDownMessage.UpDownCommand == UpDownCommand.RemovePutError)
                    //底层投递成功投递失败等不能传递格口数量
                    {
                        data += $"{o.LatticeNo},";
                    }
                    else
                    {
                        data += $"{o.LatticeNo}&{o.Num},";
                    }
                });
                data = data.Substring(0, data.Length - 1);
            }
            if (string.IsNullOrWhiteSpace(upDownMessage.Message))
            {
                data += $"#*";
            }
            else
            {
                var           msgGBK     = System.Text.Encoding.GetEncoding("GBK").GetBytes(upDownMessage.Message);
                StringBuilder msg16      = new StringBuilder();
                int           ASCIIBegin = 0x01;
                int           ASCIIEnd   = 0x7F;
                foreach (var s in msgGBK)
                {
                    int target = (int)s;
                    if (ASCIIBegin <= target && target <= ASCIIEnd)
                    {
                        msg16.Append("00");
                    }

                    msg16.Append(Convert.ToString(s, 16));
                }

                data += $"#{string.Join("", msg16)}*";
            }
            byte[] byteArray = System.Text.Encoding.GetEncoding("GBK").GetBytes(data);
            Socket.Send(byteArray);
            log.Debug(data);
        }
Esempio n. 19
0
 private void ReceiveBoardMsg()
 {
     try
     {
         while (true)
         {
             byte[] buffer = new byte[socketSend.ReceiveBufferSize];
             int    r      = socketSend.Receive(buffer);
             if (r == 0)
             {
                 break;
             }
             string strMsg = Encoding.GetEncoding("GBK").GetString(buffer, 0, r);//GB2312
             //拆解包转为UpDownCommand对象
             try
             {
                 var commandArr = Regex.Matches(strMsg, "(?<=\\*)(.+?)(?=\\*)");
                 for (int i = 0; i < commandArr.Count; i++)
                 {
                     var command       = commandArr[i].Value;
                     var d             = command.Split('#');
                     var upDownMessage = new UpDownMessage
                     {
                         LatticeByUpDown = d[2].Split(',').Select(o =>
                                                                  new LatticeByUpDown
                         {
                             Num       = o.IndexOf('&') > 0 ? Convert.ToInt16(o.Split('&')[1]) : 0,
                             LatticeNo =
                                 string.IsNullOrWhiteSpace(o.Split('&')[0])
                                         ? ""
                                         : Convert.ToInt16(o.Split('&')[0]).ToString()
                         }
                                                                  ).ToList(),
                         UpDownCommand = (UpDownCommand)Enum.Parse(typeof(UpDownCommand), d[1], true),
                         Type          = d[0]
                     };
                     CommandHandle(upDownMessage);
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             LogHelper.SaveAsyn(strMsg);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 20
0
        public void WaveCancel(UpDownMessage upDownMessage)
        {
            upDownMessage.UpDownCommand = UpDownCommand.WaveCancel;
            bool isSuccess = slaveInfoService.DeleteSlaveInfo();

            if (isSuccess)
            {
                WaveCancelSuccess();
            }
            else
            {
                WaveCancelError();
            }
        }
Esempio n. 21
0
        public void WavePowerComplete(UpDownMessage upDownMessage)
        {
            upDownMessage.UpDownCommand = UpDownCommand.WavePowerComplete;
            var data = slaveInfoService.GetSortingDetail().Where(o => o.WaitNum > o.PutNum).ToList();

            if (OrderAPI.CompleteWaveAPI(sysConfig.DomainName, slaveInfoService.SlaveInfo.WaveNo, data, curUser.UserId))
            {
                Parallel.ForEach(service, o => o.WavePowerCompleteSuccess(upDownMessage));
            }
            else
            {
                SetText($"接口报错:CompleteWaveAPI");
            }
        }
Esempio n. 22
0
 public void PrintAll(UpDownMessage upDownMessage)
 {
     if (SysConfig.PrintType == PrintType.一次性打印)
     {
         SlaveInfoService?.LatticeInfoList?.ForEach(o =>
         {
             var latticeInfo = SlaveInfoService.GetLatticeInfo(o.LatticeNo);
             if (!string.IsNullOrWhiteSpace(latticeInfo.OrderNo))
             {
                 latticeInfo.IsPrint = true;
                 SlaveInfoService.SaveAync();
                 new CustomPrint().PrintSetup(latticeInfo);
             }
         });
     }
 }
Esempio n. 23
0
        public void PrintAll(UpDownMessage upDownMessage)
        {
            if (sysConfig.PrintType == PrintType.逐个打印)
            {
                return;
            }
            if (!slaveInfoService.IsComplete)
            {
                return;
            }
            upDownMessage.UpDownCommand = UpDownCommand.PrintAll;

            Parallel.ForEach(service, o => o.PrintAll(upDownMessage));
            WavePrintOver();
            SetText($"已全部打印");
        }
Esempio n. 24
0
        public void RemoveBlockErrorSuccess(UpDownMessage upDownMessage)
        {
            upDownMessage.UpDownCommand = UpDownCommand.RemoveBlockErrorSuccess;

            Parallel.ForEach(service, o => o.RemoveBlockErrorSuccess(upDownMessage));
            upDownMessage.LatticeByUpDown.ForEach(o =>
            {
                var latticeInfo = slaveInfoService.GetLatticeInfo(o.LatticeNo);
                if (latticeInfo.Product.Any(p => p.Status == ProductStatus.WaitPut))
                {
                    WaitPut(new List <LatticeInfo> {
                        latticeInfo
                    }, latticeInfo.Product.First(p => p.Status == ProductStatus.WaitPut).BarCode);
                }
            });
            SetText($"格口[{upDownMessage.LatticeByUpDown.First().LatticeNo}]已解除");
        }
Esempio n. 25
0
        public void WavePowerCompleteSuccess(UpDownMessage upDownMessage)
        {
            UpDownMessage udm = new UpDownMessage
            {
                UpDownCommand   = UpDownCommand.WavePowerCompleteSuccess,
                LatticeByUpDown = new List <LatticeByUpDown>(),
                Message         = "强制完成成功"
            };

            var latticeList = SlaveInfoService.LatticeInfoList;

            latticeList.ForEach(o =>
            {
                udm.LatticeByUpDown.Add(new LatticeByUpDown
                {
                    LatticeNo = o.LatticeNo,
                    Num       = o.WaitNum - o.PutNum
                });
            });
            SendMsg(udm);
        }
Esempio n. 26
0
        public void WaitPut(List <LatticeInfo> latticeInfoList, string barCode)
        {
            var upDownMessage = new UpDownMessage
            {
                UpDownCommand   = UpDownCommand.WaitPut,
                LatticeByUpDown = new List <LatticeByUpDown>(),
                Message         = "待投递"
            };

            latticeInfoList.ForEach(o =>
            {
                if (!o.Product.First(p => p.BarCode == barCode).IsComplete)
                {
                    upDownMessage.LatticeByUpDown.Add(new LatticeByUpDown
                    {
                        LatticeNo = o.LatticeNo,
                        Num       = o.Product.Where(p => p.BarCode == barCode).Sum(t => t.WaitNum - t.PutNum)
                    });
                }
            });
            SendMsg(upDownMessage);
        }
Esempio n. 27
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;
            }
        }
Esempio n. 28
0
 public void WavePrintOver(UpDownMessage upDownMessage)
 {
     SoundService.PlaySoundAsny(SoundType.WavePrintOver);
 }
Esempio n. 29
0
 public void SetText(UpDownMessage upDownMessage)
 {
 }
Esempio n. 30
0
 public void WaveNotfound(UpDownMessage upDownMessage)
 {
     SoundService.PlaySoundAsny(SoundType.WaveNotfound);
 }