1 year ago
parent f31843d810
commit 8bb61cd5f2

@ -1322,11 +1322,7 @@ FontSize="25" Width="160" Height="80" VerticalAlignment="Top" HorizontalAlignmen
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10 0 0 0"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10 0 0 0">
<ComboBox x:Name="WareHouseId"> <ComboBox x:Name="WareHouseId" SelectionChanged="WareHouseId_SelectionChanged"/>
<ComboBoxItem Content="二楼仓库" Tag="2" IsSelected="True"/>
<ComboBoxItem Content="三楼仓库" Tag="3"/>
<ComboBoxItem Content="五楼仓库" Tag="5"/>
</ComboBox>
<Button Content="刷新" Foreground="White" Height="50" Margin="5" FontSize="25" Width="132" Click="Refulsh_Click"> <Button Content="刷新" Foreground="White" Height="50" Margin="5" FontSize="25" Width="132" Click="Refulsh_Click">
<Button.Template > <Button.Template >
<ControlTemplate TargetType="{x:Type Button}" > <ControlTemplate TargetType="{x:Type Button}" >

@ -13,6 +13,7 @@ using Khd.Core.Wpf.TaskForm;
using Khd.Core.Wpf.WindowPage; using Khd.Core.Wpf.WindowPage;
using Masuit.Tools; using Masuit.Tools;
using Masuit.Tools.Logging; using Masuit.Tools.Logging;
using Microsoft.CodeAnalysis;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
@ -38,6 +39,7 @@ using System.Windows.Media.Media3D;
using System.Windows.Threading; using System.Windows.Threading;
using Z.EntityFramework.Plus; using Z.EntityFramework.Plus;
using static HandyControl.Tools.Interop.InteropValues; using static HandyControl.Tools.Interop.InteropValues;
using Location = Khd.Core.Wpf.dto.Location;
namespace Khd.Core.Wpf.Form namespace Khd.Core.Wpf.Form
{ {
@ -126,7 +128,12 @@ namespace Khd.Core.Wpf.Form
{ {
CheckVersion(); CheckVersion();
InitializeData(1); InitializeData(1);
Refulsh_Click(null,null); this.WareHouseId.ItemsSource = new List<string>
{
"二楼仓库","三楼仓库","五楼仓库"
};
this.WarehourseId.Items.Refresh();
this.WareHouseId.SelectedIndex = 0;
foreach (var item in this.TabControl.Items) foreach (var item in this.TabControl.Items)
{ {
if (item is TabItem tabItem) if (item is TabItem tabItem)
@ -5007,10 +5014,43 @@ namespace Khd.Core.Wpf.Form
} }
private void Refulsh_Click(object sender, RoutedEventArgs e) private void Refulsh_Click(object sender, RoutedEventArgs e)
{
UpdateLocations(GetLocations());
}
private void UpdateLocations(List<WmsBaseLocation> wmsBaseLocations)
{ {
try try
{ {
var wareHouse = WareHouseId.SelectionBoxItem.ToString(); foreach (var item in this.LocaltionGrid.Children)
{
if(item is Grid grid)
{
foreach(var btn in grid.Children)
{
if(btn is Button button)
{
var location = wmsBaseLocations.Where(t => t.locationCode == button.Name.Replace("Location", "")).FirstOrDefault();
if(location != null)
{
button.Background = string.IsNullOrEmpty(location.containerCode) ? new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4789AE")) : new SolidColorBrush((Color)ColorConverter.ConvertFromString("#75F76D"));
}
}
}
}
}
}
catch
{
}
}
private List<WmsBaseLocation> GetLocations()
{
try
{
var wareHouse = WareHouseId.SelectedItem.ToString();
var warehouseId = new List<long>(); var warehouseId = new List<long>();
if (wareHouse == "二楼仓库") if (wareHouse == "二楼仓库")
{ {
@ -5028,8 +5068,71 @@ namespace Khd.Core.Wpf.Form
} }
var scope = _host.Services.CreateScope(); var scope = _host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>(); var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var wmsBaseLocations = dbContext.WmsBaseLocation.Where(t => warehouseId.Contains(t.warehouseId)).ToList(); return dbContext.WmsBaseLocation.Where(t => warehouseId.Contains(t.warehouseId)).ToList();
loadLocations(wmsBaseLocations); }
catch
{
return new List<WmsBaseLocation>();
}
}
private void DrawLocaitons()
{
loadLocations(GetLocations());
}
private void loadLocations(List<WmsBaseLocation> wmsBaseLocations)
{
try
{
if (wmsBaseLocations == null || wmsBaseLocations.Count == 0)
{
return;
}
Dispatcher.Invoke(() =>
{
this.LocaltionGrid.Children.Clear();
this.LocaltionGrid.RowDefinitions.Clear();
this.LocaltionGrid.ColumnDefinitions.Clear();
List<long> list = wmsBaseLocations.Select(t => t.warehouseId).Distinct().ToList();
int? column = 0;
for (var i = 0; i < list.Count; i++)
{
this.LocaltionGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1.0, GridUnitType.Star) });
var grid = new Grid();
List<WmsBaseLocation> locations = wmsBaseLocations.Where(t => t.warehouseId == list[i]).ToList();
var row = locations.Max(t => t.locRow);
column = locations.Max(t => t.locColumn);
for (var j = 0; j < row; j++)
{
grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1.0, GridUnitType.Star) });
}
for (var j = 0; j < column; j++)
{
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1.0, GridUnitType.Star) });
}
foreach (var location in locations)
{
var button = new Button()
{
Name = $"Location{location.locationCode}",
Content = location.locationCode,
Width = 50,
Height = 50,
Margin = new Thickness(2),
Tag = location.locationId,
Background = string.IsNullOrEmpty(location.containerCode) ? new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4789AE")) : new SolidColorBrush((Color)ColorConverter.ConvertFromString("#75F76D"))
};
button.Click += OnLocationButton_Click;
Grid.SetColumn(button, location.locColumn.Value - 1);
Grid.SetRow(button, -(location.locRow.Value - row.Value));
grid.Children.Add(button);
}
Grid.SetRow(grid, i);
this.LocaltionGrid.Children.Add(grid);
}
});
} }
catch catch
{ {
@ -5038,64 +5141,22 @@ namespace Khd.Core.Wpf.Form
} }
private void loadLocations(List<WmsBaseLocation> wmsBaseLocations)
{
Dispatcher.Invoke(() =>
{
this.LocaltionGrid.Children.Clear();
this.LocaltionGrid.RowDefinitions.Clear();
this.LocaltionGrid.ColumnDefinitions.Clear();
List<long> list = wmsBaseLocations.Select(t => t.warehouseId).Distinct().ToList();
for (var i = 0; i < list.Count; i++)
{
this.LocaltionGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1.0, GridUnitType.Star) });
var grid = new Grid();
List<WmsBaseLocation> locations = wmsBaseLocations.Where(t => t.warehouseId == list[i]).ToList();
var row = locations.Max(t => t.locRow);
var column = locations.Max(t => t.locColumn);
for (var j = 0; j < row; j++)
{
grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1.0, GridUnitType.Star) });
}
for (var j = 0; j < column; j++)
{
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1.0, GridUnitType.Star) });
}
foreach (var location in locations)
{
var button = new Button()
{
Name = $"Location{location.locationCode}",
Content = location.locationCode,
Width = 50,
Height = 50,
Margin = new Thickness(5, 5, 5, 5),
Tag=location.locationId,
Background = string.IsNullOrEmpty(location.containerCode) ? new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4789AE")) : new SolidColorBrush((Color)ColorConverter.ConvertFromString("#75F76D"))
};
button.Click += OnLocationButton_Click;
Grid.SetColumn(button, location.locColumn.Value - 1);
Grid.SetRow(button, -(location.locRow.Value - row.Value));
grid.Children.Add(button);
}
Grid.SetRow(grid, i);
this.LocaltionGrid.Children.Add(grid);
}
});
}
private void OnLocationButton_Click(object sender, RoutedEventArgs e) private void OnLocationButton_Click(object sender, RoutedEventArgs e)
{ {
if (sender is Button button) if (sender is Button button)
{ {
if (button.Tag is long locationId) if (button.Tag is long locationId)
{ {
StockWindow stockWindow = new StockWindow(_host,locationId); StockWindow stockWindow = new StockWindow(_host, locationId);
stockWindow.ShowDialog(); stockWindow.ShowDialog();
} }
} }
} }
private void WareHouseId_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
DrawLocaitons();
}
} }
} }

@ -46,7 +46,7 @@ namespace Khd.Core.Wpf.WindowPage
{ {
var stockList = await dbContext.WmsRawStock.Where(x => x.palletInfoCode == location.containerCode).ToListAsync(); var stockList = await dbContext.WmsRawStock.Where(x => x.palletInfoCode == location.containerCode && x.palletInfoCode != null).ToListAsync();
if (stockList != null && stockList.Count > 0) if (stockList != null && stockList.Count > 0)
{ {
// 获取所有库存物料 ID // 获取所有库存物料 ID

Loading…
Cancel
Save