liuwf 1 year ago
parent f05a1153c9
commit 24dbc80a04

@ -41,6 +41,6 @@ namespace Khd.Core.Domain.Models
/// 物料类型id,如果为null盘所有库不为null盘该物料的库 /// 物料类型id,如果为null盘所有库不为null盘该物料的库
/// </summary> /// </summary>
[Column("material_id")] [Column("material_id")]
public long? MaterialId { get; set; } public string? MaterialId { get; set; }
} }
} }

@ -1938,6 +1938,7 @@
<Button Content="搜索" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="100" Margin="20,0,0,0" Click="SelectInventoryButton_Click"/> <Button Content="搜索" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="100" Margin="20,0,0,0" Click="SelectInventoryButton_Click"/>
<Button Content="添加盘库任务" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="200" Margin="20,0,0,0" Click="AddInventoryButton_Click"/> <Button Content="添加盘库任务" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="200" Margin="20,0,0,0" Click="AddInventoryButton_Click"/>
<Button Content="库存盘点" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="150" Margin="20,0,0,0" Click="InventoryTaskButton_Click"/> <Button Content="库存盘点" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="150" Margin="20,0,0,0" Click="InventoryTaskButton_Click"/>
<Button Content="一键收料" Grid.Row="7" Grid.ColumnSpan="2" FontSize="25" Height="50" Width="150" Background="#346DFF" Foreground="White" Click="callPlc_Click" HorizontalAlignment="Left" Grid.Column="4" Margin="222,0,0,0"/>
</StackPanel> </StackPanel>
<DataGrid <DataGrid
Style="{StaticResource DataGridStyle}" Style="{StaticResource DataGridStyle}"

@ -114,6 +114,7 @@ namespace Khd.Core.Wpf.Form
{ {
InitializeComponent(); InitializeComponent();
this._host = host; this._host = host;
InventoryMaterialWindow.RefreshInventoryListEvent += GetInvertoryData;
} }
/// <summary> /// <summary>
/// 页面加载事件 /// 页面加载事件
@ -296,7 +297,7 @@ namespace Khd.Core.Wpf.Form
HandyControl.Controls.MessageBox.Error(ex.Message); HandyControl.Controls.MessageBox.Error(ex.Message);
} }
} }
#region 库位状态可视化 #region 库位状态可视化
@ -1550,7 +1551,7 @@ namespace Khd.Core.Wpf.Form
// GetTask(); // GetTask();
//} //}
if (selectedTabItem != null && selectedTabItem.Name == "CallPersonManager") if (selectedTabItem != null && selectedTabItem.Name == "CallPersonManager")
{ //人工叫料界面 { //人工叫料界面
CallSelectedItem.Clear(); CallSelectedItem.Clear();
await GetPersonCallMaterialData(); await GetPersonCallMaterialData();
@ -2904,11 +2905,15 @@ namespace Khd.Core.Wpf.Form
if (!hasTask) if (!hasTask)
{ {
List<string>? locationCodeList = null; List<string>? locationCodeList = null;
if (InventoryCheck.MaterialId != null) if (!string.IsNullOrEmpty(InventoryCheck.MaterialId))
{ {
// 盘点某个型号的物料库存的库位 List<long> materialIds = InventoryCheck.MaterialId.Split(';').Select(id => long.Parse(id)).ToList();
locationCodeList = dbContext.WmsRawStock.Where(t => t.warehouseId == 512 && t.materialId == InventoryCheck.MaterialId ).Select(x=>x.locationCode).ToList(); if(materialIds!=null && materialIds.Count > 0)
{
// 盘点指定型号的物料库存的库位
locationCodeList = dbContext.WmsRawStock.Where(t => t.warehouseId == 512 && materialIds.Contains((long)t.materialId)).Select(x => x.locationCode).Distinct().ToList();
}
} }
//所有满足条件的需要盘库的库位 //所有满足条件的需要盘库的库位
var wmsBaseLocations = dbContext.WmsBaseLocation var wmsBaseLocations = dbContext.WmsBaseLocation
@ -2917,9 +2922,9 @@ namespace Khd.Core.Wpf.Form
.OrderBy(t => t.locRow) .OrderBy(t => t.locRow)
.ThenBy(t => t.locColumn) .ThenBy(t => t.locColumn)
.ToList(); .ToList();
if(locationCodeList != null && locationCodeList.Count > 0) if (locationCodeList != null && locationCodeList.Count > 0)
{ {
wmsBaseLocations = wmsBaseLocations.Where(x=>locationCodeList.Contains(x.locationCode)).ToList(); wmsBaseLocations = wmsBaseLocations.Where(x => locationCodeList.Contains(x.locationCode)).ToList();
} }
var wmsInventoryCheckDetails = dbContext.WmsInventoryCheckDetail var wmsInventoryCheckDetails = dbContext.WmsInventoryCheckDetail
@ -2932,8 +2937,7 @@ namespace Khd.Core.Wpf.Form
List<string> locations = wmsBaseLocations.Select(t => t.locationCode).ToList(); List<string> locations = wmsBaseLocations.Select(t => t.locationCode).ToList();
List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock.Where(t => t.warehouseId == 512) List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock.Where(t => t.warehouseId == 512)
.Where(t => locations.Contains(t.locationCode)) .Where(t => locations.Contains(t.locationCode)).ToList();
.WhereIf(InventoryCheck.MaterialId!=null,t => t.materialId == InventoryCheck.MaterialId).ToList();
// 过滤后需要满足条件的有库存的库位 // 过滤后需要满足条件的有库存的库位
List<string> codes = wmsRawStocks.Select(t => t.locationCode).Distinct().ToList(); List<string> codes = wmsRawStocks.Select(t => t.locationCode).Distinct().ToList();
@ -2949,7 +2953,7 @@ namespace Khd.Core.Wpf.Form
WmsBaseLocation startBaseLocation = item.a; WmsBaseLocation startBaseLocation = item.a;
startBaseLocation.locationStatus = "6"; startBaseLocation.locationStatus = "6";
//startBaseLocation.ContainerStatus = "2"; //startBaseLocation.ContainerStatus = "2";
addList.Add(new WcsTaskManual() addList.Add(new WcsTaskManual()
{ {
objid = Global.SnowId.NextId(), objid = Global.SnowId.NextId(),
@ -4295,7 +4299,7 @@ namespace Khd.Core.Wpf.Form
{ {
InventoryMaterialWindow window = new InventoryMaterialWindow(_host); InventoryMaterialWindow window = new InventoryMaterialWindow(_host);
window.ShowDialog(); window.ShowDialog();
} }
private void GetInvertoryData() private void GetInvertoryData()

@ -31,6 +31,11 @@ namespace Khd.Core.Wpf.WindowPage
private ObservableCollection<StockItem> itemsControlItems; private ObservableCollection<StockItem> itemsControlItems;
/// <summary>
/// 刷新盘库任务列表
/// </summary>
public delegate void RefreshInventoryList();
public static event RefreshInventoryList? RefreshInventoryListEvent;
public InventoryMaterialWindow(IHost _host) public InventoryMaterialWindow(IHost _host)
@ -121,16 +126,21 @@ namespace Khd.Core.Wpf.WindowPage
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>(); var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
int locationCount = 0; int locationCount = 0;
if(itemsControlItems.Count == 0)
if (string.IsNullOrEmpty(SelectMaterialId.Text)){ {
locationCount = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512).Count(); locationCount = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512 && t.ContainerStatus == "1").Count();
} }
else else
{ {
locationCount = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512).Count(); var materialIdList = itemsControlItems.Select(t => long.Parse(t.materialId)).ToList();
var locations = dbContext.WmsRawStock.Where(t => materialIdList.Contains((long)t.materialId)).ToList().Select(t=>t.locationCode).Distinct();
locationCount = locations.Count();
}
string materialIds = null;
if (itemsControlItems.Count > 0)
{
materialIds = string.Join(";", itemsControlItems.Select(t => t.materialId));
} }
var Orders = dbContext.WmsInventoryCheck.Where(t => t.CheckStatus == "0" || t.CheckStatus == "1").ToList(); var Orders = dbContext.WmsInventoryCheck.Where(t => t.CheckStatus == "0" || t.CheckStatus == "1").ToList();
if (Orders != null && Orders.Count > 0) if (Orders != null && Orders.Count > 0)
@ -153,7 +163,7 @@ namespace Khd.Core.Wpf.WindowPage
InventoryingAmount = 0, InventoryingAmount = 0,
WarehouseId = 512, WarehouseId = 512,
CreateBy = "WCS", CreateBy = "WCS",
MaterialId = string.IsNullOrEmpty(SelectMaterialId.Text) ? null : long.Parse(SelectMaterialId.Text) MaterialId = materialIds
}) ; }) ;
dbContext.SaveChanges(); dbContext.SaveChanges();
HandyControl.Controls.Growl.Info("创建盘库任务成功!"); HandyControl.Controls.Growl.Info("创建盘库任务成功!");
@ -178,7 +188,7 @@ namespace Khd.Core.Wpf.WindowPage
InventoryingAmount = 0, InventoryingAmount = 0,
WarehouseId = 512, WarehouseId = 512,
CreateBy = "WCS", CreateBy = "WCS",
MaterialId = string.IsNullOrEmpty(SelectMaterialId.Text) ? null : long.Parse(SelectMaterialId.Text) MaterialId = materialIds
}); });
dbContext.SaveChanges(); dbContext.SaveChanges();
HandyControl.Controls.Growl.Info("创建盘库任务成功!"); HandyControl.Controls.Growl.Info("创建盘库任务成功!");
@ -186,7 +196,10 @@ namespace Khd.Core.Wpf.WindowPage
} }
this.Close(); this.Close();
//刷新列表
RefreshInventoryListEvent?.Invoke();
} }
catch catch
{ {
@ -210,12 +223,12 @@ namespace Khd.Core.Wpf.WindowPage
dynamic Currentselected = StockDataGrid.SelectedItem; dynamic Currentselected = StockDataGrid.SelectedItem;
if (checkbox.IsChecked != null && checkbox.IsChecked.Value) if (checkbox.IsChecked != null && checkbox.IsChecked.Value)
{ {
if (itemsControlItems != null && itemsControlItems.Count >= 6) //if (itemsControlItems != null && itemsControlItems.Count >= 6)
{ //{
MessageBox.Show("最多只能选择6个"); // MessageBox.Show("最多只能选择6个");
checkbox.IsChecked = false; // checkbox.IsChecked = false;
return; // return;
} //}
// 添加选中项 // 添加选中项
string selectedItem = Currentselected.materialName; string selectedItem = Currentselected.materialName;

Loading…
Cancel
Save