From 29e1a311be5a034dbf81f454e307e0384a9f6bcd Mon Sep 17 00:00:00 2001 From: liuwf Date: Sat, 21 Sep 2024 11:46:45 +0800 Subject: [PATCH] =?UTF-8?q?change-=E6=8F=90=E4=BA=A4=E7=9B=98=E5=BA=93?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Khd.Core.Wpf/Form/FormBoardT.xaml.cs | 20 ++++ .../TaskForm/Inventory/InventoryTaskForm.xaml | 25 +++-- .../Inventory/InventoryTaskForm.xaml.cs | 87 ++++++++-------- .../Inventory/UpdateAmountWindow.xaml | 34 +++++++ .../Inventory/UpdateAmountWindow.xaml.cs | 99 +++++++++++++++++++ 5 files changed, 217 insertions(+), 48 deletions(-) create mode 100644 src/Khd.Core.Wpf/TaskForm/Inventory/UpdateAmountWindow.xaml create mode 100644 src/Khd.Core.Wpf/TaskForm/Inventory/UpdateAmountWindow.xaml.cs diff --git a/src/Khd.Core.Wpf/Form/FormBoardT.xaml.cs b/src/Khd.Core.Wpf/Form/FormBoardT.xaml.cs index 063d5b2..e8b8b6e 100644 --- a/src/Khd.Core.Wpf/Form/FormBoardT.xaml.cs +++ b/src/Khd.Core.Wpf/Form/FormBoardT.xaml.cs @@ -3029,6 +3029,7 @@ namespace Khd.Core.Wpf.Form MaterialId = rawItem.materialId, ErpStatus = "0", ErpAmount = 0, + CheckType ="1" }); } } @@ -3629,6 +3630,25 @@ namespace Khd.Core.Wpf.Form SystemData.PlcDic[1].WriteToPoint(basePlcpoint.plcpointAddress, "1", basePlcpoint.plcpointLength.ToString()); MsgText.Text = "一键收料发送成功"; HandyControl.Controls.MessageBox.Show("一键收料发送成功!"); + + // 修改所有盘库明细任务状态 + using var scope = _host.Services.CreateScope(); + using var dbContext = scope.ServiceProvider.GetRequiredService(); + List list = dbContext.WmsInventoryCheckDetail.Where(t => t.CheckStatus=="1").ToList(); + if (list != null) + { + list.ForEach(t => t.CheckStatus = "2"); + dbContext.UpdateRange(list); + } + WmsInventoryCheck wmsInventoryCheck = dbContext.WmsInventoryCheck.FirstOrDefault(t => t.CheckStatus == "1"); + if(wmsInventoryCheck != null) + { + wmsInventoryCheck.InventoriedAmount = dbContext.WmsInventoryCheckDetail.Where(t => t.InventoryCheckId == wmsInventoryCheck.InventoryCheckId).ToList().Count(); + wmsInventoryCheck.InventoryingAmount = 0; + dbContext.SaveChanges(); + } + + } catch (Exception ex) { diff --git a/src/Khd.Core.Wpf/TaskForm/Inventory/InventoryTaskForm.xaml b/src/Khd.Core.Wpf/TaskForm/Inventory/InventoryTaskForm.xaml index ef83bac..9910028 100644 --- a/src/Khd.Core.Wpf/TaskForm/Inventory/InventoryTaskForm.xaml +++ b/src/Khd.Core.Wpf/TaskForm/Inventory/InventoryTaskForm.xaml @@ -42,13 +42,14 @@ - - - - + diff --git a/src/Khd.Core.Wpf/TaskForm/Inventory/InventoryTaskForm.xaml.cs b/src/Khd.Core.Wpf/TaskForm/Inventory/InventoryTaskForm.xaml.cs index cd7062b..abd7a18 100644 --- a/src/Khd.Core.Wpf/TaskForm/Inventory/InventoryTaskForm.xaml.cs +++ b/src/Khd.Core.Wpf/TaskForm/Inventory/InventoryTaskForm.xaml.cs @@ -31,6 +31,7 @@ namespace Khd.Core.Wpf.TaskForm Thread scanThread = new Thread(ScanMessage); scanThread.IsBackground = true; scanThread.Start(); + UpdateAmountWindow.RefreshDelegateEvent += GetData; } @@ -122,19 +123,34 @@ namespace Khd.Core.Wpf.TaskForm .ToList(); List list = wmsInventoryCheckDetails.Select(t => t.MaterialId).Distinct().ToList(); List mesBaseMaterialInfos = dbContext.MesBaseMaterialInfo.Where(t => list.Contains(t.MaterialId)).ToList(); - this.InventoryDataGrid.ItemsSource = wmsInventoryCheckDetails.GroupBy(t => t.MaterialId).Select(t => - new - { - //ContainerNo = wcsTask.containerNo, - MaterialBatch = t.FirstOrDefault(n => n.MaterialId == t.Key)?.MaterialBatch, - MaterialSpec = mesBaseMaterialInfos.FirstOrDefault(m => m.MaterialId == t.Key)?.MaterialSpec, - MaterialName = mesBaseMaterialInfos.FirstOrDefault(m => m.MaterialId == t.Key)?.MaterialName, - StockAmount = t.Sum(n => n.StockAmount), - LocationCode = wcsTask.currPointNo, - MaterialId = t.Key, - RealAmount = (t.Sum(n => n.RealAmount)).ToString(), - }); - this.InventoryDataGrid.Items.Refresh(); + //this.InventoryDataGrid.ItemsSource = wmsInventoryCheckDetails.GroupBy(t => t.MaterialId).Select(t => + // new + // { + // //ContainerNo = wcsTask.containerNo, + // MaterialBatch = t.FirstOrDefault(n => n.MaterialId == t.Key)?.MaterialBatch, + // MaterialSpec = mesBaseMaterialInfos.FirstOrDefault(m => m.MaterialId == t.Key)?.MaterialSpec, + // MaterialName = mesBaseMaterialInfos.FirstOrDefault(m => m.MaterialId == t.Key)?.MaterialName, + // StockAmount = t.Sum(n => n.StockAmount), + // LocationCode = wcsTask.currPointNo, + // MaterialId = t.Key, + // //RealAmount = (t.Sum(n => n.RealAmount)).ToString(), + // }); + + this.InventoryDataGrid.ItemsSource = wmsInventoryCheckDetails.Select(t => + new + { + //ContainerNo = wcsTask.containerNo, + MaterialBatch = t.MaterialBatch, + MaterialSpec = mesBaseMaterialInfos.FirstOrDefault(m => m.MaterialId == t.MaterialId)?.MaterialSpec, + MaterialName = mesBaseMaterialInfos.FirstOrDefault(m => m.MaterialId == t.MaterialId)?.MaterialName, + StockAmount = t.StockAmount, + LocationCode = wcsTask.currPointNo, + MaterialId = t.MaterialId, + //RealAmount = (t.Sum(n => n.RealAmount)).ToString(), + }); + + + this.InventoryDataGrid.Items.Refresh(); if (wmsInventoryCheckDetails.Count == 0) { HandyControl.Controls.MessageBox.Show("该料箱为空料箱"); @@ -155,32 +171,19 @@ namespace Khd.Core.Wpf.TaskForm private void EditBtn_Click(object sender, RoutedEventArgs e) { - //if (this.InventoryDataGrid.SelectedItem != null) - //{ - // dynamic item = this.InventoryDataGrid.SelectedItem; - // long materialId = item.MaterialId; - // string containerNo = item.ContainerNo; - // string materialName = item.MaterialName; - // string locationCode = item.LocationCode; - // InventoryTaskEditForm editForm = new InventoryTaskEditForm(_host, materialId, containerNo, materialName, locationCode, this); - // this.Hide(); - // editForm.ShowDialog(); - // GetData(); - //} - //else - //{ - // if (this.ContainerCodeBox.SelectedItem is WcsTask task) - // { - // InventoryTaskEditForm editForm = new InventoryTaskEditForm(_host, 0, task.containerNo, "", task.currPointNo, this); - // this.Hide(); - // editForm.ShowDialog(); - // GetData(); - // } - // else - // { - // HandyControl.Controls.MessageBox.Show("请先选择料箱号!"); - // } - //} + + //if (!string.IsNullOrEmpty(txtInBox.Text)) + //{ + // InventoryTaskEditForm editForm = new InventoryTaskEditForm(_host, 0, txtInBox.Text, "", task.currPointNo, this); + // this.Hide(); + // editForm.ShowDialog(); + // GetData(); + //} + //else + //{ + // HandyControl.Controls.MessageBox.Show("请先选择料箱号!"); + //} + } private void Update_Click(object sender, RoutedEventArgs e) @@ -188,15 +191,15 @@ namespace Khd.Core.Wpf.TaskForm if (this.InventoryDataGrid.SelectedItem != null) { dynamic item = this.InventoryDataGrid.SelectedItem; - UpdateStockAmount updateStockAmount = new UpdateStockAmount(_host, item.MaterialBatch); + UpdateAmountWindow updateStockAmount = new UpdateAmountWindow(_host, item.MaterialBatch, item.LocationCode, txtInBox.Text); updateStockAmount.ShowDialog(); - + //long materialId = item.MaterialId; //string containerNo = txtInBox.Text; //string materialName = item.MaterialName; //string locationCode = item.LocationCode; //string realAmount = item.RealAmount; - + //GetData(txtInBox.Text); } } diff --git a/src/Khd.Core.Wpf/TaskForm/Inventory/UpdateAmountWindow.xaml b/src/Khd.Core.Wpf/TaskForm/Inventory/UpdateAmountWindow.xaml new file mode 100644 index 0000000..82b8890 --- /dev/null +++ b/src/Khd.Core.Wpf/TaskForm/Inventory/UpdateAmountWindow.xaml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + +