change-优化扫描入库界面输入框自动跳转

add-同一批次产品可以继续入库加库存
master
liuwf 1 year ago
parent 17e48822e6
commit 12b7053a2f

@ -1924,25 +1924,28 @@
<RowDefinition Height="167*"/> <RowDefinition Height="167*"/>
<RowDefinition Height="83*"/> <RowDefinition Height="83*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="扫描入库" Foreground="White" FontSize="50" Grid.ColumnSpan="6" HorizontalAlignment="Center" VerticalAlignment="Center"/> <TextBlock Text="扫描入库" FontSize="50" Grid.ColumnSpan="6" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Text="扫描料箱号:" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/> <TextBlock Text="扫描料箱号:" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<TextBlock Text="扫描条码号:" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/> <TextBlock Text="扫描条码号:" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<TextBlock Text="入库数量:" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/> <TextBlock Text="入库数量:" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<hc:TextBox x:Name="txtInBox" hc:InfoElement.ShowClearButton="True" FontSize="50" LostFocus="txtInBox_TextChanged" Width="700" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="1" Grid.Column="3" Grid.ColumnSpan="3"/> <hc:TextBox x:Name="txtInBox" hc:InfoElement.ShowClearButton="True" FontSize="50" LostFocus="txtInBox_TextChanged" TextChanged="txtInBox_TextChanged" Width="700" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="1" Grid.Column="3" Grid.ColumnSpan="3"/>
<Button Click="barClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="0,0,130,0" Grid.Column="5" Grid.Row="2"> <Button Click="barClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="0,0,130,0" Grid.Column="5" Grid.Row="2">
<Image Source="..\Resources\cancel.png"/> <Image Source="..\Resources\cancel.png"/>
</Button> </Button>
<Button Click="boxClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="0,0,130,0" Grid.Column="5" Grid.Row="1"> <Button Click="boxClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="0,0,130,0" Grid.Column="5" Grid.Row="1">
<Image Source="..\Resources\cancel.png"/> <Image Source="..\Resources\cancel.png"/>
</Button> </Button>
<hc:TextBox x:Name="txtInBarCode" hc:InfoElement.ShowClearButton="True" FontSize="50" LostFocus="txtInBarCode_TextChanged" Width="700" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="2" Grid.Column="3" Grid.ColumnSpan="3"/> <hc:TextBox x:Name="txtInBarCode" hc:InfoElement.ShowClearButton="True" FontSize="50" LostFocus="txtInBarCode_TextChanged" TextChanged="txtInBarCode_TextChanged" Width="700" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="2" Grid.Column="3" Grid.ColumnSpan="3"/>
<hc:TextBox x:Name="txtInScan" FontSize="50" IsReadOnly="True" Width="700" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="3" Grid.Column="3" Grid.ColumnSpan="3" /> <hc:TextBox x:Name="txtInScan" FontSize="50" IsReadOnly="True" Width="700" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="3" Grid.Column="3" Grid.ColumnSpan="3" />
<Button Content="确认入库" Grid.Row="4" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="InRawBaseLocaltion_Click"/> <Button Content="确认入库" Grid.Row="4" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="InRawBaseLocaltion_Click"/>
<Button Content="一键收料" Grid.Row="5" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="callPlc_Click"/> <Button Content="一键收料" Grid.Row="5" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="callPlc_Click"/>
<TextBlock Grid.Row="6" Text="提示信息:" HorizontalAlignment="Center" Grid.Column="1" Grid.ColumnSpan="1" Width="250" Height="100" FontSize="50" Foreground="White" />
<TextBlock x:Name="MsgText" Grid.Row="6" FontSize="40" Grid.ColumnSpan="5" Width="800" Height="60" Foreground="White" HorizontalAlignment="Right" />
<Button Content="执行CTU入库任务" Visibility="Hidden" Click="btnCtuInConfirmBox_Click" Grid.Row="5" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White"/> <Button Content="执行CTU入库任务" Visibility="Hidden" Click="btnCtuInConfirmBox_Click" Grid.Row="5" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</TabItem> </TabItem>
<TabItem x:Name="ScanReturnManager" Header="扫描退库" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5"> <TabItem x:Name="ScanReturnManager" Header="扫描退库" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5">

@ -12,6 +12,7 @@ using Khd.Core.Wpf.Scan;
using Khd.Core.Wpf.TaskForm; using Khd.Core.Wpf.TaskForm;
using Masuit.Tools; using Masuit.Tools;
using Masuit.Tools.Logging; using Masuit.Tools.Logging;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -1463,69 +1464,107 @@ namespace Khd.Core.Wpf.Form
{ {
using var scope = _host.Services.CreateScope(); using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>(); using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
decimal amount = decimal.Parse(txtInScan.Text);
if (amount <= 0)
{
MessageBox.Show("入库数量需大于0");
return;
}
var material = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == txtInBarCode.Text); var material = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == txtInBarCode.Text);
var container = dbContext.WmsBaseLocation.FirstOrDefault(t => t.containerCode == txtInBox.Text && t.warehouseId == 512); var container = dbContext.WmsBaseLocation.FirstOrDefault(t => t.containerCode == txtInBox.Text && t.warehouseId == 512);
List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock
.Where(t => txtInBarCode.Text == t.instockBatch) .Where(t => txtInBarCode.Text == t.instockBatch)
.Where(t => t.warehouseFloor == 5 && t.warehouseId == 512).ToList(); .Where(t => t.warehouseFloor == 5 && t.warehouseId == 512).ToList();
if (wmsRawStocks.Count > 0)
{
MessageBox.Show($"该条码已入库!料箱号为{wmsRawStocks.First().palletInfoCode},库位号为{wmsRawStocks.First().locationCode}");
txtInBarCode.Text = string.Empty;
txtInScan.Text = string.Empty;
return;
}
if (container == null) if (container == null)
{ {
MessageBox.Show("未查询到该容器!"); MsgText.Text = "未查询到该容器!";
txtInBox.Focus();
txtInBox.Text = string.Empty; txtInBox.Text = string.Empty;
txtInBarCode.Text = string.Empty;
txtInScan.Text = string.Empty;
return; return;
} }
if (material == null) if (material == null)
{ {
MessageBox.Show("未查询到该条码内容!"); MsgText.Text = "未查询到该条码内容!";
txtInBox.Text = string.Empty;
txtInBarCode.Text = string.Empty; txtInBarCode.Text = string.Empty;
txtInScan.Text = string.Empty; txtInScan.Text = string.Empty;
txtInBox.Focus();
return; return;
} }
var newRawStock = new WmsRawStock()
if (wmsRawStocks.Count > 0)
{ {
materialId = material.materialId, if (material.batchFlag != "1")
supplierId = material.manufacturerId, {
instockBatch = txtInBarCode.Text, MsgText.Text = $"该条码已入库!料箱号为{wmsRawStocks.First().palletInfoCode},库位号为{wmsRawStocks.First().locationCode}";
locationCode = container.locationCode, txtInBox.Text = string.Empty;
stockType = "1", txtInBarCode.Text = string.Empty;
palletInfoCode = container.containerCode, txtInScan.Text = string.Empty;
totalAmount = material.batchFlag == "1" ? material.amount : 1, txtInBox.Focus();
activeFlag = "1", return;
occupyAmount = 0, }
completeFlag = "1", else
frozenAmount = 0, {
instockDate = System.DateTime.Now, WmsRawStock wmsRawStock = wmsRawStocks.FirstOrDefault();
rawStockId = Global.SnowId.NextId(), wmsRawStock.totalAmount += amount;
saleOrderId = material.saleOrderId == null ? 0 : material.saleOrderId, dbContext.WmsRawStock.Update(wmsRawStock);
warehouseFloor = 5, dbContext.SaveChanges();
warehouseId = 512, }
createBy = "扫描入库",
createDate = System.DateTime.Now, }
safeFlag = material.safeFlag else
}; {
dbContext.WmsRawStock.Add(newRawStock); var newRawStock = new WmsRawStock()
dbContext.SaveChanges(); {
MessageBox.Show("入库成功!"); materialId = material.materialId,
supplierId = material.manufacturerId,
instockBatch = txtInBarCode.Text,
locationCode = container.locationCode,
stockType = "1",
palletInfoCode = container.containerCode,
totalAmount = material.batchFlag == "1" ? amount : 1,
activeFlag = "1",
occupyAmount = 0,
completeFlag = "1",
frozenAmount = 0,
instockDate = System.DateTime.Now,
rawStockId = Global.SnowId.NextId(),
saleOrderId = material.saleOrderId == null ? 0 : material.saleOrderId,
warehouseFloor = 5,
warehouseId = 512,
createBy = "扫描入库",
createDate = System.DateTime.Now,
safeFlag = material.safeFlag
};
dbContext.WmsRawStock.Add(newRawStock);
dbContext.SaveChanges();
}
txtInBox.Focus();
MsgText.Text = "入库成功!";
txtInBox.Text = string.Empty;
txtInBarCode.Text = string.Empty; txtInBarCode.Text = string.Empty;
txtInScan.Text = string.Empty; txtInScan.Text = string.Empty;
txtInBarCode.Focus(); txtInBarCode.Focus();
} }
else else
{ {
MessageBox.Show("请先扫描容器号和条码!"); MsgText.Text ="请先扫描容器号和条码!";
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
LogManager.Error(ex); LogManager.Error(ex);
MessageBox.Show("入库失败"); txtInBox.Text = string.Empty;
txtInBarCode.Text = string.Empty;
txtInScan.Text = string.Empty;
MsgText.Text = "入库失败";
txtInBarCode.Focus();
} }
} }
@ -1622,7 +1661,11 @@ namespace Khd.Core.Wpf.Form
{ {
try try
{ {
string containerCode = txtInBox.Text; string containerCode = txtInBox.Text;
if (containerCode.Length >= 1) MsgText.Text = string.Empty;
if (containerCode.Length < 15)
return;
if (!string.IsNullOrEmpty(containerCode)) if (!string.IsNullOrEmpty(containerCode))
{ {
using var scope = _host.Services.CreateScope(); using var scope = _host.Services.CreateScope();
@ -1630,7 +1673,7 @@ namespace Khd.Core.Wpf.Form
var container = dbContext.WmsBaseLocation.FirstOrDefault(t => t.containerCode == containerCode && t.warehouseId == 512); var container = dbContext.WmsBaseLocation.FirstOrDefault(t => t.containerCode == containerCode && t.warehouseId == 512);
if (container == null) if (container == null)
{ {
MessageBox.Show($"未查询到该容器{txtInBox.Text}!"); MsgText.Text = $"未查询到该容器{txtInBox.Text}!";
txtInBox.Text = string.Empty; txtInBox.Text = string.Empty;
txtInBox.Focus(); txtInBox.Focus();
} }
@ -1654,15 +1697,22 @@ namespace Khd.Core.Wpf.Form
{ {
try try
{ {
string barCode = txtInBarCode.Text; string barCode = txtInBarCode.Text;
if (barCode.Length < 19) return;
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
if (!string.IsNullOrEmpty(barCode)) if (!string.IsNullOrEmpty(barCode))
{ {
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var material = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == barCode); var material = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == barCode);
if (material == null) if (material == null)
{ {
MessageBox.Show("未查询到该条码内容!"); MsgText.Text = "未查询到该条码内容!";
txtInBarCode.Text = string.Empty; txtInBarCode.Text = string.Empty;
txtInScan.Text = string.Empty; txtInScan.Text = string.Empty;
txtInBarCode.Focus(); txtInBarCode.Focus();
@ -1672,14 +1722,17 @@ namespace Khd.Core.Wpf.Form
var mesBaseMaterialInfo = dbContext.MesBaseMaterialInfo.FirstOrDefault(t => t.MaterialId == material.materialId); var mesBaseMaterialInfo = dbContext.MesBaseMaterialInfo.FirstOrDefault(t => t.MaterialId == material.materialId);
if (mesBaseMaterialInfo == null) if (mesBaseMaterialInfo == null)
{ {
MessageBox.Show("未查询到该条码绑定的物料信息!"); MsgText.Text = "未查询到该条码绑定的物料信息!";
txtInBarCode.Text = string.Empty; txtInBarCode.Text = string.Empty;
txtInScan.Text = string.Empty; txtInScan.Text = string.Empty;
txtInBarCode.Focus(); txtInBarCode.Focus();
} }
else else
{ {
txtInScan.Text = (material.batchFlag == "1" ? material.amount : 1).ToString();
txtInScan.Text = (material.batchFlag == "1") ? "0.00" : "1.00";
if (mesBaseMaterialInfo.BatchFlag == "0") if (mesBaseMaterialInfo.BatchFlag == "0")
{ {
txtInScan.IsReadOnly = true; txtInScan.IsReadOnly = true;
@ -1714,7 +1767,7 @@ namespace Khd.Core.Wpf.Form
var container = dbContext.WmsBaseLocation.FirstOrDefault(t => t.containerCode == containerCode && t.warehouseId == 512); var container = dbContext.WmsBaseLocation.FirstOrDefault(t => t.containerCode == containerCode && t.warehouseId == 512);
if (container == null) if (container == null)
{ {
MessageBox.Show($"未查询到该容器{txtOutBox.Text}!"); MsgText.Text = $"未查询到该容器{txtOutBox.Text}!";
txtOutBox.Text = string.Empty; txtOutBox.Text = string.Empty;
txtOutBox.Focus(); txtOutBox.Focus();
} }
@ -1749,7 +1802,7 @@ namespace Khd.Core.Wpf.Form
var wmsRawStock = dbContext.WmsRawStock.FirstOrDefault(t => t.instockBatch == barCode && t.palletInfoCode == containerCode); var wmsRawStock = dbContext.WmsRawStock.FirstOrDefault(t => t.instockBatch == barCode && t.palletInfoCode == containerCode);
if (wmsRawStock == null) if (wmsRawStock == null)
{ {
MessageBox.Show("未在该容器中查询到该条码!"); MsgText.Text = "未在该容器中查询到该条码!";
txtOutBarCode.Text = string.Empty; txtOutBarCode.Text = string.Empty;
txtOutScan.Text = string.Empty; txtOutScan.Text = string.Empty;
txtOutBarCode.Focus(); txtOutBarCode.Focus();
@ -1759,7 +1812,7 @@ namespace Khd.Core.Wpf.Form
var mesBaseMaterialInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.materialId == wmsRawStock.materialId); var mesBaseMaterialInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.materialId == wmsRawStock.materialId);
if (mesBaseMaterialInfo == null) if (mesBaseMaterialInfo == null)
{ {
MessageBox.Show("未查询到该条码绑定的物料信息!"); MsgText.Text = "未查询到该条码绑定的物料信息!";
txtOutBarCode.Text = string.Empty; txtOutBarCode.Text = string.Empty;
txtOutScan.Text = string.Empty; txtOutScan.Text = string.Empty;
txtOutBarCode.Focus(); txtOutBarCode.Focus();
@ -1783,7 +1836,7 @@ namespace Khd.Core.Wpf.Form
{ {
if (!string.IsNullOrEmpty(barCode)) if (!string.IsNullOrEmpty(barCode))
{ {
MessageBox.Show("请先扫描容器号!"); MsgText.Text = "请先扫描容器号!";
txtOutBarCode.Text = string.Empty; txtOutBarCode.Text = string.Empty;
txtOutScan.Text = string.Empty; txtOutScan.Text = string.Empty;
} }

Loading…
Cancel
Save