|
|
|
|
@ -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
|
|
|
|
|
{
|
|
|
|
|
|