change-修改5楼辅料移库

master
liuwf 1 year ago
parent 573f7bfe70
commit 822dda30d0

@ -2462,6 +2462,8 @@
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
@ -2469,33 +2471,73 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="辅料移库" FontSize="100" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Column="0" Grid.ColumnSpan="4"/>
<TextBlock Text="辅料移库" FontSize="50" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Column="0" Grid.ColumnSpan="4"/>
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="原料箱号:" FontSize="70" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="rawSourceBox" LostFocus="rawSourceBox_LostFocus" FontSize="50" Width="500" Height="150" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<TextBlock Text="原料箱号:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<hc:TextBox x:Name="rawSourceBox" TextChanged="rawSourceBox_TextChanged" FontSize="40" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<Button Click="rawSourceBoxClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="-100,0,0,0" Grid.Column="5" Grid.Row="2">
<Image Source="..\Resources\cancel.png"/>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="原条码号:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="rawSourceBarCode" FontSize="40" TextChanged="rawSourceBarCode_TextChanged" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<Button Click="rawSourceBarCodeClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="-100,0,0,0" Grid.Column="5" Grid.Row="2">
<Image Source="..\Resources\cancel.png"/>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="移库料箱:" FontSize="70" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="removeSourceBox" FontSize="50" LostFocus="removeSourceBox_LostFocus" Width="500" Height="150" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<TextBlock Text="移库料箱:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="removeSourceBox" FontSize="40" TextChanged="removeSourceBox_TextChanged" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<Button Click="removeSourceBoxClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="-100,0,0,0" Grid.Column="5" Grid.Row="2">
<Image Source="..\Resources\cancel.png"/>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2" Grid.ColumnSpan="3" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="条码号:" FontSize="70" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="removeBarCode" FontSize="50" LostFocus="removeBarCode_LostFocus" Width="750" Height="150" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<Button Click="removeBarCodeClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="-100,0,0,0" Grid.Column="5" Grid.Row="2">
<StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="移库条码:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="removeSourceBarCode" FontSize="40" TextChanged="removeSourceBarCode_TextChanged" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<Button Click="removeSourceBarCodeClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="-100,0,0,0" Grid.Column="5" Grid.Row="2">
<Image Source="..\Resources\cancel.png"/>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="3" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="数量:" FontSize="70" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock x:Name="removeScan" FontSize="50" Width="150" Margin="0,0,0,0" />
<StackPanel Orientation="Horizontal" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="物料名称:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="rawSourceMaterialName" FontSize="40" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
</StackPanel>
<Button Content="确认移库" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" Width="600" Height="150" FontSize="75" Background="#346DFF" Foreground="White" Click="btnRemoveConfirmBox_Click"/>
<StackPanel Orientation="Horizontal" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="物料规格:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="rawSourceMaterialSpec" FontSize="40" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="物料名称:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="removeSourceMaterialName" FontSize="40" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="物料规格:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="removeSourceMaterialSpec" FontSize="40" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="移库数量:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="removeScan" FontSize="40" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
</StackPanel>
<Button Content="确认移库" Grid.Row="5" Grid.Column="2" Grid.ColumnSpan="4" Width="500" Height="150" FontSize="75" Background="#346DFF" Foreground="White" Click="btnRemoveConfirmBox_Click"/>
<StackPanel Orientation="Horizontal" Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="4" HorizontalAlignment="Left" Margin="100 0 0 0 ">
<TextBlock Text="提示信息:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock x:Name="RemoveMsg" HorizontalAlignment="Left" FontSize="40" Foreground="White" Width="1200" Height="60" Margin="10,0,0,0" />
</StackPanel>
</Grid>
</TabItem>
<TabItem x:Name="FirstFloorManager" Header="一楼接驳位" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="#213269" Foreground="White" Width="160" Height="100" Margin="5">

@ -1869,6 +1869,16 @@ namespace Khd.Core.Wpf.Form
{
this.removeSourceBox.Text = string.Empty;
}
private void rawSourceBarCodeClear_Click(object sender, RoutedEventArgs e)
{
this.rawSourceBarCode.Text = string.Empty;
}
private void removeSourceBarCodeClear_Click(object sender, RoutedEventArgs e)
{
this.removeSourceBarCode.Text = string.Empty;
}
/// <summary>
/// 入库扫描
/// </summary>
@ -4050,92 +4060,162 @@ namespace Khd.Core.Wpf.Form
}
#region 移库方法
private void removeSourceBox_LostFocus(object sender, RoutedEventArgs e)
private void rawSourceBox_TextChanged(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(this.removeSourceBox.Text))
if (this.rawSourceBox.Text.Length >=1 && this.rawSourceBox.Text.Length < 15)
{
this.RemoveMsg.Text = "";
return;
}
try
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
WcsTask? wcsTask = dbContext.WcsTask.Where(t => t.containerNo == this.removeSourceBox.Text).FirstOrDefault();
if (wcsTask == null)
//WcsTask? wcsTask = dbContext.WcsTask.Where(t => t.containerNo == this.rawSourceBox.Text).FirstOrDefault();
//if (wcsTask == null)
//{
// this.RemoveMsg.Text = $"未找到该托盘{this.rawSourceBox.Text}的移库任务!";
// this.rawSourceBox.Text = "";
// return;
//}
//else
{
HandyControl.Controls.MessageBox.Show("未找到该托盘!");
this.removeSourceBox.Text = "";
return;
rawSourceBarCode.Focus();
}
}
catch
catch (Exception ex)
{
this.RemoveMsg.Text = ex.Message;
}
}
private void rawSourceBox_LostFocus(object sender, RoutedEventArgs e)
private void rawSourceBarCode_TextChanged(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(this.rawSourceBox.Text))
if (this.rawSourceBarCode.Text.Length < 19)
{
rawSourceMaterialName.Text = "";
rawSourceMaterialSpec.Text = "";
removeScan.Text = "";
return;
}
string barCode = rawSourceBarCode.Text;
try
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
WcsTask? wcsTask = dbContext.WcsTask.Where(t => t.containerNo == this.rawSourceBox.Text).FirstOrDefault();
if (wcsTask == null)
{
HandyControl.Controls.MessageBox.Show("未找到该托盘!");
this.rawSourceBox.Text = "";
return;
}
}
catch
{
}
}
private void removeBarCodeClear_Click(object sender, RoutedEventArgs e)
{
removeBarCode.Text = "";
}
private void removeBarCode_LostFocus(object sender, RoutedEventArgs e)
{
try
{
if (string.IsNullOrEmpty(this.removeBarCode.Text))
{
return;
}
if (string.IsNullOrEmpty(this.rawSourceBox.Text))
{
HandyControl.Controls.MessageBox.Show("请先选择托盘!");
return;
}
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
WmsRawStock? wmsRawStock = dbContext.WmsRawStock.Where(t => t.palletInfoCode == this.rawSourceBox.Text)
.Where(t => t.instockBatch == this.removeBarCode.Text)
.FirstOrDefault();
.Where(t => t.instockBatch == barCode)
.FirstOrDefault();
if (wmsRawStock == null)
{
HandyControl.Controls.MessageBox.Show($"未在{this.rawSourceBox.Text}托盘中找到{this.removeBarCode.Text}条码!");
this.removeBarCode.Text = "";
this.removeScan.Text = string.Empty;
RemoveMsg.Text = $"未在{this.rawSourceBox.Text}托盘中找到{barCode}条码!" ;
rawSourceBarCode.Text = string.Empty;
rawSourceMaterialName.Text = "";
rawSourceMaterialSpec.Text = "";
return;
}
var material = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == barCode);
if (material == null)
{
RemoveMsg.Text = $"未查询{barCode}条码内容!";
rawSourceBarCode.Text = string.Empty;
}
else
{
this.removeScan.Text = (wmsRawStock.totalAmount - wmsRawStock.frozenAmount).ToString();
var mesBaseMaterialInfo = dbContext.MesBaseMaterialInfo.FirstOrDefault(t => t.MaterialId == material.materialId);
if (mesBaseMaterialInfo == null)
{
RemoveMsg.Text = $"未查询{barCode}绑定的物料信息!";
rawSourceBarCode.Text = string.Empty;
}
else
{
rawSourceMaterialName.Text = mesBaseMaterialInfo.MaterialName;
rawSourceMaterialSpec.Text = mesBaseMaterialInfo.MaterialSpec;
this.removeScan.Text = string.Format("{0:0}", wmsRawStock.totalAmount - wmsRawStock.frozenAmount);
removeSourceBox.Focus();
}
}
}
catch
catch (Exception ex)
{
RemoveMsg.Text = $"查询{barCode}条码内容异常!";
rawSourceBarCode.Text = string.Empty;
rawSourceMaterialName.Text = "";
rawSourceMaterialSpec.Text = "";
}
}
private void removeSourceBox_TextChanged(object sender, RoutedEventArgs e)
{
if (this.rawSourceBox.Text.Length >= 15)
{
removeSourceBarCode.Focus();
}
}
private void removeSourceBarCode_TextChanged(object sender, RoutedEventArgs e)
{
if (this.removeSourceBarCode.Text.Length < 19)
{
removeSourceMaterialName.Text = "";
removeSourceMaterialSpec.Text = "";
return;
}
string barCode = removeSourceBarCode.Text;
try
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
//WmsRawStock? wmsRawStock = dbContext.WmsRawStock.Where(t => t.palletInfoCode == this.removeSourceBox.Text)
// .Where(t => t.instockBatch == barCode)
// .FirstOrDefault();
//if (wmsRawStock == null)
//{
// RemoveMsg.Text = $"未在目标托盘中找到条码,请打印粘贴后重新扫描!";
// removeSourceBarCode.Text = string.Empty;
// removeSourceMaterialName.Text = "";
// removeSourceMaterialSpec.Text = "";
// return;
//}
var material = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == barCode);
if (material == null)
{
RemoveMsg.Text = $"未查询{barCode}条码信息!";
removeSourceBarCode.Text = string.Empty;
}
else
{
var mesBaseMaterialInfo = dbContext.MesBaseMaterialInfo.FirstOrDefault(t => t.MaterialId == material.materialId);
if (mesBaseMaterialInfo == null)
{
RemoveMsg.Text = $"未查询{barCode}绑定的物料信息!";
removeSourceBarCode.Text = string.Empty;
}
else
{
removeSourceMaterialName.Text = mesBaseMaterialInfo.MaterialName;
removeSourceMaterialSpec.Text = mesBaseMaterialInfo.MaterialSpec;
}
}
}
catch (Exception ex)
{
RemoveMsg.Text = $"查询{barCode}条码内容异常!";
removeSourceBarCode.Text = string.Empty;
removeSourceMaterialName.Text = "";
removeSourceMaterialSpec.Text = "";
}
}
@ -4144,17 +4224,22 @@ namespace Khd.Core.Wpf.Form
if (string.IsNullOrEmpty(this.rawSourceBox.Text))
{
HandyControl.Controls.MessageBox.Show("请先选择移库源托盘!");
this.RemoveMsg.Text = "请先选择原托盘!";
return;
}
if (string.IsNullOrEmpty(this.rawSourceBarCode.Text))
{
this.RemoveMsg.Text = "请先选择原条码!";
return;
}
if (string.IsNullOrEmpty(this.removeSourceBox.Text))
{
HandyControl.Controls.MessageBox.Show("请先选择移库条码!");
this.RemoveMsg.Text = "请先选择移库目标托盘!";
return;
}
if (string.IsNullOrEmpty(this.removeBarCode.Text))
if (string.IsNullOrEmpty(this.removeSourceBarCode.Text))
{
HandyControl.Controls.MessageBox.Show("请先扫码移库数量!");
this.RemoveMsg.Text = "请先选择移库目标条码!";
return;
}
using var scope = _host.Services.CreateScope();
@ -4163,19 +4248,48 @@ namespace Khd.Core.Wpf.Form
{
WmsBaseLocation removeLocation = dbContext.WmsBaseLocation.Where(t => t.containerCode == this.removeSourceBox.Text).First();
WmsBaseLocation rawLocation = dbContext.WmsBaseLocation.Where(t => t.containerCode == this.rawSourceBox.Text).First();
// 更新 WmsRawStock 中的记录
dbContext.WmsRawStock
.Where(t => t.locationCode == rawLocation.locationCode)
.Where(t => t.instockBatch == this.removeBarCode.Text)
.Update(t => new WmsRawStock
{
locationCode = removeLocation.locationCode, // 更新 locationCode
palletInfoCode = removeLocation.containerCode // 更新 palletInfoCode
});
HandyControl.Controls.MessageBox.Show("移库成功!");
this.removeBarCode.Text = "";
this.removeScan.Text = string.Empty;
//1.先校验物料类型是否一致
var rawBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == this.rawSourceBarCode.Text);
var removeBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == this.removeSourceBarCode.Text);
if(rawBarcodeInfo.materialId != removeBarcodeInfo.materialId)
{
this.RemoveMsg.Text = "两个条码物料类型不同,请更换目标条码!";
return;
}
//判断目标库位是否有该物料
WmsRawStock? targetStock = dbContext.WmsRawStock.Where(t => t.palletInfoCode == this.removeSourceBox.Text && t.materialId == rawBarcodeInfo.materialId).FirstOrDefault();
if(targetStock == null || (targetStock != null && removeBarcodeInfo.batchFlag == "0"))
{
// 更新 WmsRawStock 中的记录
dbContext.WmsRawStock
.Where(t => t.locationCode == rawLocation.locationCode)
.Where(t => t.instockBatch == this.rawSourceBarCode.Text)
.Update(t => new WmsRawStock
{
locationCode = removeLocation.locationCode, // 更新 locationCode
palletInfoCode = removeLocation.containerCode // 更新 palletInfoCode
});
}
else
{
targetStock.totalAmount += Convert.ToInt32(this.removeScan.Text);
dbContext.WmsRawStock.Update(targetStock);
}
#region 插入移库记录
#endregion
dbContext.SaveChanges();
this.RemoveMsg.Text = "移库成功!";
removeSourceBarCode.Text = string.Empty;
removeSourceMaterialName.Text = "";
removeSourceMaterialSpec.Text = "";
rawSourceBarCode.Text = string.Empty;
rawSourceMaterialName.Text = "";
rawSourceMaterialSpec.Text = "";
this.removeScan.Text = "";
}
catch
{

Loading…
Cancel
Save