/// <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)); }
/// <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}"; }); } } }
public SortingDetail(SlaveInfoService slaveInfoService) : this() { this.slaveInfoService = slaveInfoService; var waveNo = slaveInfoService?.SlaveInfo?.WaveNo; if (string.IsNullOrWhiteSpace(waveNo)) { return; } using (var db = new SortingDbContext()) { var result1 = from slave in db.SlaveInfo from lattice in slave.LatticeInfo from product in lattice.Product where slave.WaveNo == waveNo select new SortingDetailView { WaveNo = slave.WaveNo, LatticeNo = lattice.LatticeNo, OrderNo = lattice.OrderNo, latticeStatus = lattice.Status, BarCode = product.BarCode, ProductName = product.ProductName, PutNum = product.PutNum, WaitNum = product.WaitNum, ProductStatus = product.Status, IsPrint = lattice.IsPrint }; var result2 = from wave in db.WaveApi from order in wave.OrderApi from product in order.ProductApi where wave.WaveNo == waveNo && order.Status == Domain.Models.OrderStatus.Normal select new SortingDetailView { WaveNo = wave.WaveNo, LatticeNo = "", OrderNo = order.OrderNo, latticeStatus = Domain.Models.LatticeStatus.None, BarCode = product.BarCode, ProductName = product.ProductName, PutNum = 0, WaitNum = product.Num, ProductStatus = Domain.Models.ProductStatus.None, IsPrint = false }; var data = result1.Concat(result2.Where(o => !result1.Select(r => r.OrderNo).Contains(o.OrderNo))).ToList(); dataGridView1.DataSource = data; } }
/// <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); } }
public LatticeCacheDetail(string latticeNo, SlaveInfoService slaveInfoService) : this() { this.LatticeNo = latticeNo; this.slaveInfoService = slaveInfoService; Init(); }
/// <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); }
public LatticeConfig(string latticeNo, UpDownService upDownService, SlaveInfoService slaveInfoService, ButtonService buttonService) : this(latticeNo) { this.upDownService = upDownService; this.slaveInfoService = slaveInfoService; this.buttonService = buttonService; }