@ -1869,6 +1869,16 @@ namespace Khd.Core.Wpf.Form
{
{
this . removeSourceBox . Text = string . Empty ;
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>
/// 入库扫描
/// 入库扫描
/// </summary>
/// </summary>
@ -2996,6 +3006,7 @@ namespace Khd.Core.Wpf.Form
select t1 . location_id locationId ,
select t1 . location_id locationId ,
t1 . container_code containerCode ,
t1 . container_code containerCode ,
t1 . location_code locationCode
t1 . location_code locationCode
from wms_base_location t1
from wms_base_location t1
left join wms_raw_stock t2
left join wms_raw_stock t2
on t1 . location_code = t2 . location_code
on t1 . location_code = t2 . location_code
@ -3003,6 +3014,8 @@ namespace Khd.Core.Wpf.Form
and t1 . container_status = 1 and t1 . warehouse_id = 512
and t1 . container_status = 1 and t1 . warehouse_id = 512
order by t1 . loc_column , t1 . loc_row
order by t1 . loc_column , t1 . loc_row
");
");
var wmsLocation = dbContext . WmsBaseLocation . FirstOrDefault ( t = > t . locationId = = idList [ 0 ] & & t . locationStatus = = "1" ) ;
var wmsLocation = dbContext . WmsBaseLocation . FirstOrDefault ( t = > t . locationId = = idList [ 0 ] & & t . locationStatus = = "1" ) ;
if ( wmsLocation = = null )
if ( wmsLocation = = null )
{
{
@ -3017,7 +3030,8 @@ namespace Khd.Core.Wpf.Form
MessageBoxResult messageBoxResult = HandyControl . Controls . MessageBox . Show ( "选择了一个移库料箱,需要出空料箱,是否确认?" , "提示" , MessageBoxButton . YesNo , MessageBoxImage . Question ) ;
MessageBoxResult messageBoxResult = HandyControl . Controls . MessageBox . Show ( "选择了一个移库料箱,需要出空料箱,是否确认?" , "提示" , MessageBoxButton . YesNo , MessageBoxImage . Question ) ;
if ( messageBoxResult = = MessageBoxResult . Yes )
if ( messageBoxResult = = MessageBoxResult . Yes )
{
{
WmsBaseLocation emptyLocation = emptyLocations . First ( ) ;
var emptyLocation = dbContext . WmsBaseLocation . FirstOrDefault ( t = > t . locationId = = emptyLocations . First ( ) . locationId ) ;
//WmsBaseLocation emptyLocation = emptyLocations.First();
emptyLocation . locationStatus = "4" ;
emptyLocation . locationStatus = "4" ;
emptyLocation . ContainerStatus = "2" ;
emptyLocation . ContainerStatus = "2" ;
wmsLocation . locationStatus = "4" ;
wmsLocation . locationStatus = "4" ;
@ -4046,92 +4060,162 @@ namespace Khd.Core.Wpf.Form
}
}
#region 移库方法
#region 移库方法
private void r emoveSourceBox_LostFocus ( object sender , RoutedEventArgs e )
private void r awSourceBox_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 ;
return ;
}
}
try
try
{
{
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 > ( ) ;
WcsTask ? wcsTask = dbContext . WcsTask . Where ( t = > t . containerNo = = this . removeSourceBox . Text ) . FirstOrDefault ( ) ;
//WcsTask? wcsTask = dbContext.WcsTask.Where(t => t.containerNo == this.rawSourceBox.Text).FirstOrDefault();
if ( wcsTask = = null )
//if (wcsTask == null)
//{
// this.RemoveMsg.Text = $"未找到该托盘{this.rawSourceBox.Text}的移库任务!";
// this.rawSourceBox.Text = "";
// return;
//}
//else
{
{
HandyControl . Controls . MessageBox . Show ( "未找到该托盘!" ) ;
rawSourceBarCode . Focus ( ) ;
this . removeSourceBox . Text = "" ;
return ;
}
}
}
}
catch
catch ( Exception ex )
{
{
this . RemoveMsg . Text = ex . Message ;
}
}
}
}
private void rawSourceB ox_LostFocus ( object sender , RoutedEventArgs e )
private void rawSourceB arCode_TextChanged ( object sender , RoutedEventArgs e )
{
{
if ( string . IsNullOrEmpty ( this . rawSourceBox . Text ) )
if ( this . rawSourceBarCode . Text . Length < 19 )
{
{
rawSourceMaterialName . Text = "" ;
rawSourceMaterialSpec . Text = "" ;
removeScan . Text = "" ;
return ;
return ;
}
}
string barCode = rawSourceBarCode . Text ;
try
try
{
{
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 > ( ) ;
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 )
WmsRawStock ? wmsRawStock = dbContext . WmsRawStock . Where ( t = > t . palletInfoCode = = this . rawSourceBox . Text )
. Where ( t = > t . instockBatch = = this . removeBarCode . Text )
. Where ( t = > t . instockBatch = = barCode )
. FirstOrDefault ( ) ;
. FirstOrDefault ( ) ;
if ( wmsRawStock = = null )
if ( wmsRawStock = = null )
{
{
HandyControl . Controls . MessageBox . Show ( $"未在{this.rawSourceBox.Text}托盘中找到{this.removeBarCode.Text}条码!" ) ;
RemoveMsg . Text = $"未在{this.rawSourceBox.Text}托盘中找到{barCode}条码!" ;
this . removeBarCode . Text = "" ;
rawSourceBarCode . Text = string . Empty ;
this . removeScan . Text = string . Empty ;
rawSourceMaterialName . Text = "" ;
rawSourceMaterialSpec . Text = "" ;
return ;
return ;
}
}
var material = dbContext . MesBaseBarcodeInfo . FirstOrDefault ( t = > t . barcodeInfo = = barCode ) ;
if ( material = = null )
{
RemoveMsg . Text = $"未查询{barCode}条码内容!" ;
rawSourceBarCode . Text = string . Empty ;
}
else
else
{
{
this . removeScan . Text = 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 = "" ;
}
}
}
}
@ -4140,17 +4224,22 @@ namespace Khd.Core.Wpf.Form
if ( string . IsNullOrEmpty ( this . rawSourceBox . Text ) )
if ( string . IsNullOrEmpty ( this . rawSourceBox . Text ) )
{
{
HandyControl . Controls . MessageBox . Show ( "请先选择移库源托盘!" ) ;
this . RemoveMsg . Text = "请先选择原托盘!" ;
return ;
}
if ( string . IsNullOrEmpty ( this . rawSourceBarCode . Text ) )
{
this . RemoveMsg . Text = "请先选择原条码!" ;
return ;
return ;
}
}
if ( string . IsNullOrEmpty ( this . removeSourceBox . Text ) )
if ( string . IsNullOrEmpty ( this . removeSourceBox . Text ) )
{
{
HandyControl . Controls . MessageBox . Show ( "请先选择移库条码!" ) ;
this . RemoveMsg . Text = "请先选择移库目标托盘!" ;
return ;
return ;
}
}
if ( string . IsNullOrEmpty ( this . remove BarCode. Text ) )
if ( string . IsNullOrEmpty ( this . remove Source BarCode. Text ) )
{
{
HandyControl . Controls . MessageBox . Show ( "请先扫码移库数量!" ) ;
this . RemoveMsg . Text = "请先选择移库目标条码!" ;
return ;
return ;
}
}
using var scope = _host . Services . CreateScope ( ) ;
using var scope = _host . Services . CreateScope ( ) ;
@ -4159,15 +4248,48 @@ namespace Khd.Core.Wpf.Form
{
{
WmsBaseLocation removeLocation = dbContext . WmsBaseLocation . Where ( t = > t . containerCode = = this . removeSourceBox . Text ) . First ( ) ;
WmsBaseLocation removeLocation = dbContext . WmsBaseLocation . Where ( t = > t . containerCode = = this . removeSourceBox . Text ) . First ( ) ;
WmsBaseLocation rawLocation = dbContext . WmsBaseLocation . Where ( t = > t . containerCode = = this . rawSourceBox . Text ) . First ( ) ;
WmsBaseLocation rawLocation = dbContext . WmsBaseLocation . Where ( t = > t . containerCode = = this . rawSourceBox . Text ) . First ( ) ;
dbContext . WmsRawStock . Where ( t = > t . locationCode = = rawLocation . locationCode )
. Where ( t = > t . instockBatch = = this . removeBarCode . Text )
//1.先校验物料类型是否一致
. Update ( t = > new WmsRawStock
var rawBarcodeInfo = dbContext . MesBaseBarcodeInfo . FirstOrDefault ( t = > t . barcodeInfo = = this . rawSourceBarCode . Text ) ;
{
var removeBarcodeInfo = dbContext . MesBaseBarcodeInfo . FirstOrDefault ( t = > t . barcodeInfo = = this . removeSourceBarCode . Text ) ;
locationCode = removeLocation . locationCode ,
if ( rawBarcodeInfo . materialId ! = removeBarcodeInfo . materialId )
} ) ;
{
HandyControl . Controls . MessageBox . Show ( "移库成功!" ) ;
this . RemoveMsg . Text = "两个条码物料类型不同,请更换目标条码!" ;
this . removeBarCode . Text = "" ;
return ;
this . removeScan . Text = string . Empty ;
}
//判断目标库位是否有该物料
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
catch
{
{