diff --git a/src/Khd.Core.Wpf/Form/FormBoardT.xaml b/src/Khd.Core.Wpf/Form/FormBoardT.xaml index c46253b..153a85a 100644 --- a/src/Khd.Core.Wpf/Form/FormBoardT.xaml +++ b/src/Khd.Core.Wpf/Form/FormBoardT.xaml @@ -15,7 +15,12 @@ Height="1080" > + + + + + @@ -362,6 +367,36 @@ + + + + + + @@ -1203,6 +1238,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Khd.Core.Wpf/WindowPage/StockWindow.xaml.cs b/src/Khd.Core.Wpf/WindowPage/StockWindow.xaml.cs new file mode 100644 index 0000000..a37fbbd --- /dev/null +++ b/src/Khd.Core.Wpf/WindowPage/StockWindow.xaml.cs @@ -0,0 +1,75 @@ +using Khd.Core.Domain.Models; +using Khd.Core.EntityFramework; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace Khd.Core.Wpf.WindowPage +{ + /// + /// StockWindow.xaml 的交互逻辑 + /// + public partial class StockWindow : Window + { + private IHost host = null; + public StockWindow(IHost _host,long locationId) + { + host = _host; + InitializeComponent(); + Init(locationId); + } + + public async Task Init(long locationId) + { + using var scope = host.Services.CreateScope(); + var dbContext = scope.ServiceProvider.GetRequiredService(); + var location = await dbContext.WmsBaseLocation.Where(x => x.locationId == locationId).FirstOrDefaultAsync(); + positionRowTxt.Text = location.locRow.ToString(); + positionColumnTxt.Text = location.locColumn.ToString(); + positionLayerTxt.Text = location.layerNum.ToString(); + locationTxt.Text = location.locationCode; + palletTxt.Text = location.containerCode; + + var stockList = await dbContext.WmsRawStock.Where(x => x.palletInfoCode == location.containerCode).ToListAsync(); + if(stockList != null && stockList.Count > 0) + { + // 获取所有库存物料 ID + var materialIds = stockList.Select(stock => stock.materialId).Distinct().ToList(); + var materialInfos = await dbContext.MesBaseMaterialInfo + .Where(material => materialIds.Contains(material.MaterialId)) + .ToListAsync(); + + // 将库存物料信息和物料详细信息合并 + var stockDetails = from stock in stockList + from material in materialInfos + where stock.materialId == material.MaterialId + select new + { + materialCode = material.MaterialCode, + materialName = material.MaterialName, + materialSpec = material.MaterialSpec, + totalAmount = stock.totalAmount, + frozenAmount = stock.frozenAmount + + }; + + + StockDataGrid.ItemsSource = stockDetails; + } + + } + } +} diff --git a/src/Khd.Core.Wpf/dto/Location.cs b/src/Khd.Core.Wpf/dto/Location.cs new file mode 100644 index 0000000..b54a5b2 --- /dev/null +++ b/src/Khd.Core.Wpf/dto/Location.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Khd.Core.Wpf.dto +{ + public class Location + { + public long LocationId { get; set; } // 新增 LocationId + public string Code { get; set; } + public LocationStatus Status { get; set; } + } + + public enum LocationStatus + { + // 在库有库存 + InAndStock, + //// 在库无库存 + //InNoStock, + //库外 + OutOfStock, + + } +}