|
|
|
|
@ -52,8 +52,8 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
public decimal? qty { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<barcodeinfo> barcodeLsit = new List<barcodeinfo>();
|
|
|
|
|
|
|
|
|
|
public List<barcodeinfo> barcodeLsit = new List<barcodeinfo>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private string selectedId;
|
|
|
|
|
//FormShowSelect formSelect;
|
|
|
|
|
@ -244,83 +244,39 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
private void btnGetStocK_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
using (ExcelPackage package = new ExcelPackage(fileInfo))
|
|
|
|
|
{
|
|
|
|
|
ExcelWorksheet worksheet = package.Workbook.Worksheets.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (worksheet != null)
|
|
|
|
|
{
|
|
|
|
|
// 获取 Excel 表头
|
|
|
|
|
var columnHeaders = worksheet.Cells[1, 1, 1, worksheet.Dimension.End.Column]
|
|
|
|
|
.Select(cell => cell.Text)
|
|
|
|
|
.ToList();
|
|
|
|
|
BaseProductionOrderSplit orderMoedel = new();
|
|
|
|
|
// 映射数据库字段,这里需要根据你的实际需求进行调整
|
|
|
|
|
var columnMappings = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
// 添加映射
|
|
|
|
|
{columnHeaders[0],"production_sequence"},
|
|
|
|
|
{columnHeaders[1],"line_code"},
|
|
|
|
|
{columnHeaders[3],"prod_code"},
|
|
|
|
|
{columnHeaders[4],"Quantity"},
|
|
|
|
|
{columnHeaders[5],"order_code"}
|
|
|
|
|
};
|
|
|
|
|
int ordernum = 0;
|
|
|
|
|
// 获取实际的行数和列数
|
|
|
|
|
int rowCount = worksheet.Dimension.Rows;
|
|
|
|
|
int colCount = worksheet.Dimension.Columns;
|
|
|
|
|
// 遍历 Excel 数据行
|
|
|
|
|
for (int row = 2; row <= rowCount; row++)
|
|
|
|
|
{
|
|
|
|
|
// 创建 SQL 插入语句
|
|
|
|
|
//string insertCommand = $"INSERT INTO YourTableName ({string.Join(", ", columnMappings.Values)}) VALUES (";
|
|
|
|
|
List<string> values = new();
|
|
|
|
|
// 遍历 Excel 数据列
|
|
|
|
|
for (int col = 1; col <= colCount; col++)
|
|
|
|
|
{
|
|
|
|
|
string columnName = columnHeaders[col - 1];
|
|
|
|
|
string databaseColumnName;
|
|
|
|
|
// 映射 Excel 列名到数据库列名
|
|
|
|
|
if (columnMappings.TryGetValue(columnName, out databaseColumnName))
|
|
|
|
|
{
|
|
|
|
|
// 获取 Excel 单元格的值
|
|
|
|
|
var cellValue = worksheet.Cells[row, col].Text;
|
|
|
|
|
// 添加值到插入语句
|
|
|
|
|
values.Add(cellValue);
|
|
|
|
|
//values.Add($"'{cellValue.Replace("'", "''")}'");
|
|
|
|
|
//if (!string.IsNullOrWhiteSpace(cellValue))
|
|
|
|
|
//{
|
|
|
|
|
// values.Add(cellValue);
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 使用 LINQ 查询空值
|
|
|
|
|
bool containsNull = values.Any(item => item == "" || item == null);
|
|
|
|
|
if (containsNull)
|
|
|
|
|
{
|
|
|
|
|
//MessageBox.Show("Excel表格中存在空值,不执行导入操作!", "订单导入操作提示!");
|
|
|
|
|
//LogManager.Info($"订单导入按钮事件错误 >>> Excel表格中存在空值!不执行导入操作!");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
// 获得插入语句
|
|
|
|
|
//string fullInsertCommand = $"{insertCommand} {string.Join(", ", values)} )";
|
|
|
|
|
var xianbiename = Char.GetNumericValue(values[1][values[1].Length - 1]).ToString();
|
|
|
|
|
int orderSequence = int.Parse(values[0].Trim());
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
// var orderModel = dbContext.BaseProductionOrderSplit.OrderBy(t => t.productionSequence).ToList();
|
|
|
|
|
///var data = orderModel.Find(t => t.orderCode == values[4].Trim().ToUpper());
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageBox.Show($"{ordernum}条订单导入系统!", "订单导入操作提示!");
|
|
|
|
|
//LoadMaterial_GetMessage("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
var locationCode = lba_ThrifTtitle6.Text;
|
|
|
|
|
var materialCode = lba_ThrifTtitle5.Text;
|
|
|
|
|
var data = dbContext.WcsStock.Where(t => t.useFlag == 1 && t.materialCode.Contains(materialCode) && t.locationCode.Contains(locationCode)).ToList();
|
|
|
|
|
this.LoadMaterial1.ItemsSource = null;
|
|
|
|
|
this.LoadMaterial1.ItemsSource = data;
|
|
|
|
|
this.LoadMaterial1.Items.Refresh();
|
|
|
|
|
if (data.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("未查询到数据");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询指令信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void btnGetWcsCmd_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
GetWcsCmd();
|
|
|
|
|
}
|
|
|
|
|
private void GetWcsCmd()
|
|
|
|
|
{
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
var equipCode = txtEquipNo.Text;
|
|
|
|
|
var ContainNo = txtContainNo.Text;
|
|
|
|
|
var data = dbContext.WcsCmd.Where(t => t.useFlag == 1 && t.containerNo.Contains(ContainNo) && t.equipmentNo.Contains(equipCode)).ToList();
|
|
|
|
|
this.LoadMaterial.ItemsSource = null;
|
|
|
|
|
this.LoadMaterial.ItemsSource = data;
|
|
|
|
|
this.LoadMaterial.Items.Refresh();
|
|
|
|
|
if (data.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("未查询到数据");
|
|
|
|
|
}
|
|
|
|
|
@ -384,11 +340,11 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
//目的地
|
|
|
|
|
var endEquip = dbContext.BaseEquip.Where(t => t.equipNo == "FL05").FirstOrDefault();
|
|
|
|
|
//所有辅料库位
|
|
|
|
|
var wmsBaseLocation = dbContext.WmsBaseLocation.Where(t=> t.warehouseId== 5).ToList(); //五楼辅料库
|
|
|
|
|
var wmsBaseLocation = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 5).ToList(); //五楼辅料库
|
|
|
|
|
//有库存的库位
|
|
|
|
|
var wmsStock = dbContext.WcsStock.Where(t => t.useFlag == 1).Select(t=>t.locationCode).ToList();
|
|
|
|
|
var wmsStock = dbContext.WcsStock.Where(t => t.useFlag == 1).Select(t => t.locationCode).ToList();
|
|
|
|
|
var EmptyBox = wmsBaseLocation.Where(t => !t.locationCode.Contains(wmsStock)).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < num; i++)
|
|
|
|
|
{
|
|
|
|
|
var wcsTask = new WcsTask()
|
|
|
|
|
@ -412,12 +368,12 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
};
|
|
|
|
|
dbContext.Add(wcsTask);
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效的数字");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
@ -450,7 +406,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
barcodeinfo barcodeinfo = new barcodeinfo();
|
|
|
|
|
barcodeinfo.barcode=txtBarCode.Text;
|
|
|
|
|
barcodeinfo.barcode = txtBarCode.Text;
|
|
|
|
|
barcodeinfo.materialId = mesInfo.materialId;
|
|
|
|
|
barcodeinfo.qty = mesInfo.amount;
|
|
|
|
|
barcodeLsit.Add(barcodeinfo);
|
|
|
|
|
@ -472,7 +428,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
MessageBox.Show("容器号不能为空!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (barcodeLsit.Count==0)
|
|
|
|
|
if (barcodeLsit.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("未扫描条码!");
|
|
|
|
|
return;
|
|
|
|
|
@ -490,10 +446,10 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
instockType = "9",
|
|
|
|
|
materialId = barcodeLsit.FirstOrDefault().materialId,
|
|
|
|
|
palletInfoCode = txtBox.Text,
|
|
|
|
|
instockAmount = barcodeLsit.Sum(t=>t.qty),
|
|
|
|
|
executeStatus="0",
|
|
|
|
|
applyBy="扫描入库",
|
|
|
|
|
applyDate=System.DateTime.Now
|
|
|
|
|
instockAmount = barcodeLsit.Sum(t => t.qty),
|
|
|
|
|
executeStatus = "0",
|
|
|
|
|
applyBy = "扫描入库",
|
|
|
|
|
applyDate = System.DateTime.Now
|
|
|
|
|
};
|
|
|
|
|
dbContext.WmsRawInstock.Add(wmsRawInstock);
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
|