|
|
|
|
@ -12,6 +12,7 @@ using Khd.Core.Wpf.Scan;
|
|
|
|
|
using Khd.Core.Wpf.TaskForm;
|
|
|
|
|
using Masuit.Tools;
|
|
|
|
|
using Masuit.Tools.Logging;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
@ -1463,69 +1464,107 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
{
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
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 container = dbContext.WmsBaseLocation.FirstOrDefault(t => t.containerCode == txtInBox.Text && t.warehouseId == 512);
|
|
|
|
|
List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock
|
|
|
|
|
.Where(t => txtInBarCode.Text == t.instockBatch)
|
|
|
|
|
.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)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("未查询到该容器!");
|
|
|
|
|
MsgText.Text = "未查询到该容器!";
|
|
|
|
|
txtInBox.Focus();
|
|
|
|
|
txtInBox.Text = string.Empty;
|
|
|
|
|
txtInBarCode.Text = string.Empty;
|
|
|
|
|
txtInScan.Text = string.Empty;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (material == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("未查询到该条码内容!");
|
|
|
|
|
MsgText.Text = "未查询到该条码内容!";
|
|
|
|
|
txtInBox.Text = string.Empty;
|
|
|
|
|
txtInBarCode.Text = string.Empty;
|
|
|
|
|
txtInScan.Text = string.Empty;
|
|
|
|
|
txtInBox.Focus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var newRawStock = new WmsRawStock()
|
|
|
|
|
|
|
|
|
|
if (wmsRawStocks.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
materialId = material.materialId,
|
|
|
|
|
supplierId = material.manufacturerId,
|
|
|
|
|
instockBatch = txtInBarCode.Text,
|
|
|
|
|
locationCode = container.locationCode,
|
|
|
|
|
stockType = "1",
|
|
|
|
|
palletInfoCode = container.containerCode,
|
|
|
|
|
totalAmount = material.batchFlag == "1" ? material.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();
|
|
|
|
|
MessageBox.Show("入库成功!");
|
|
|
|
|
if (material.batchFlag != "1")
|
|
|
|
|
{
|
|
|
|
|
MsgText.Text = $"该条码已入库!料箱号为{wmsRawStocks.First().palletInfoCode},库位号为{wmsRawStocks.First().locationCode}";
|
|
|
|
|
txtInBox.Text = string.Empty;
|
|
|
|
|
txtInBarCode.Text = string.Empty;
|
|
|
|
|
txtInScan.Text = string.Empty;
|
|
|
|
|
txtInBox.Focus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
WmsRawStock wmsRawStock = wmsRawStocks.FirstOrDefault();
|
|
|
|
|
wmsRawStock.totalAmount += amount;
|
|
|
|
|
dbContext.WmsRawStock.Update(wmsRawStock);
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var newRawStock = new WmsRawStock()
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
txtInScan.Text = string.Empty;
|
|
|
|
|
txtInBarCode.Focus();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请先扫描容器号和条码!");
|
|
|
|
|
MsgText.Text ="请先扫描容器号和条码!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception 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
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string containerCode = txtInBox.Text;
|
|
|
|
|
if (containerCode.Length >= 1) MsgText.Text = string.Empty;
|
|
|
|
|
if (containerCode.Length < 15)
|
|
|
|
|
return;
|
|
|
|
|
if (!string.IsNullOrEmpty(containerCode))
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show($"未查询到该容器{txtInBox.Text}!");
|
|
|
|
|
MsgText.Text = $"未查询到该容器{txtInBox.Text}!";
|
|
|
|
|
txtInBox.Text = string.Empty;
|
|
|
|
|
txtInBox.Focus();
|
|
|
|
|
}
|
|
|
|
|
@ -1654,15 +1697,22 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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))
|
|
|
|
|
{
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var material = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == barCode);
|
|
|
|
|
if (material == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("未查询到该条码内容!");
|
|
|
|
|
MsgText.Text = "未查询到该条码内容!";
|
|
|
|
|
txtInBarCode.Text = string.Empty;
|
|
|
|
|
txtInScan.Text = string.Empty;
|
|
|
|
|
txtInBarCode.Focus();
|
|
|
|
|
@ -1672,14 +1722,17 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
var mesBaseMaterialInfo = dbContext.MesBaseMaterialInfo.FirstOrDefault(t => t.MaterialId == material.materialId);
|
|
|
|
|
if (mesBaseMaterialInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("未查询到该条码绑定的物料信息!");
|
|
|
|
|
MsgText.Text = "未查询到该条码绑定的物料信息!";
|
|
|
|
|
txtInBarCode.Text = string.Empty;
|
|
|
|
|
txtInScan.Text = string.Empty;
|
|
|
|
|
txtInBarCode.Focus();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txtInScan.Text = (material.batchFlag == "1" ? material.amount : 1).ToString();
|
|
|
|
|
|
|
|
|
|
txtInScan.Text = (material.batchFlag == "1") ? "0.00" : "1.00";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mesBaseMaterialInfo.BatchFlag == "0")
|
|
|
|
|
{
|
|
|
|
|
txtInScan.IsReadOnly = true;
|
|
|
|
|
@ -1714,7 +1767,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
var container = dbContext.WmsBaseLocation.FirstOrDefault(t => t.containerCode == containerCode && t.warehouseId == 512);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show($"未查询到该容器{txtOutBox.Text}!");
|
|
|
|
|
MsgText.Text = $"未查询到该容器{txtOutBox.Text}!";
|
|
|
|
|
txtOutBox.Text = string.Empty;
|
|
|
|
|
txtOutBox.Focus();
|
|
|
|
|
}
|
|
|
|
|
@ -1749,7 +1802,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
var wmsRawStock = dbContext.WmsRawStock.FirstOrDefault(t => t.instockBatch == barCode && t.palletInfoCode == containerCode);
|
|
|
|
|
if (wmsRawStock == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("未在该容器中查询到该条码!");
|
|
|
|
|
MsgText.Text = "未在该容器中查询到该条码!";
|
|
|
|
|
txtOutBarCode.Text = string.Empty;
|
|
|
|
|
txtOutScan.Text = string.Empty;
|
|
|
|
|
txtOutBarCode.Focus();
|
|
|
|
|
@ -1759,7 +1812,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
var mesBaseMaterialInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.materialId == wmsRawStock.materialId);
|
|
|
|
|
if (mesBaseMaterialInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("未查询到该条码绑定的物料信息!");
|
|
|
|
|
MsgText.Text = "未查询到该条码绑定的物料信息!";
|
|
|
|
|
txtOutBarCode.Text = string.Empty;
|
|
|
|
|
txtOutScan.Text = string.Empty;
|
|
|
|
|
txtOutBarCode.Focus();
|
|
|
|
|
@ -1783,7 +1836,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(barCode))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请先扫描容器号!");
|
|
|
|
|
MsgText.Text = "请先扫描容器号!";
|
|
|
|
|
txtOutBarCode.Text = string.Empty;
|
|
|
|
|
txtOutScan.Text = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|