|
|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
using HandyControl.Tools.Extension;
|
|
|
|
|
using Jc.SnowId;
|
|
|
|
|
using Khd.Core.Domain.Auth;
|
|
|
|
|
using Khd.Core.Domain.Dto.webapi;
|
|
|
|
|
using Khd.Core.Domain.Models;
|
|
|
|
|
using Khd.Core.EntityFramework;
|
|
|
|
|
using Khd.Core.Library.Mapper;
|
|
|
|
|
@ -15,11 +16,13 @@ using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Drawing.Printing;
|
|
|
|
|
using System.IO.Ports;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
@ -116,6 +119,8 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void FormBoard_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
itemsControlItems = new ObservableCollection<SelectItemModel>();
|
|
|
|
|
@ -128,14 +133,14 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
{
|
|
|
|
|
Plc.S7.Plc plc;
|
|
|
|
|
plc = new Plc.S7.Plc(plcConfig.CpuType, plcConfig.IP, plcConfig.Port, plcConfig.Rack, plcConfig.Slot);
|
|
|
|
|
//try
|
|
|
|
|
//{
|
|
|
|
|
// plc.Open();
|
|
|
|
|
//}
|
|
|
|
|
//catch (Exception ex)
|
|
|
|
|
//{
|
|
|
|
|
// LogManager.Error(ex);
|
|
|
|
|
//}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
plc.Open();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogManager.Error(ex);
|
|
|
|
|
}
|
|
|
|
|
SystemData.PlcDic.TryAdd(plcConfig.Code, plc);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
@ -926,7 +931,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(this.locationStatus.SelectedItem?.ToString()))
|
|
|
|
|
{
|
|
|
|
|
if(this.locationStatus.SelectedItem is ComboBoxItem item&&!string.IsNullOrEmpty(item.Tag?.ToString()))
|
|
|
|
|
if (this.locationStatus.SelectedItem is ComboBoxItem item && !string.IsNullOrEmpty(item.Tag?.ToString()))
|
|
|
|
|
{
|
|
|
|
|
sql += " and t1.location_status = " + item.Tag + "";
|
|
|
|
|
}
|
|
|
|
|
@ -1804,6 +1809,25 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
WmsRawStock wmsRawStock = wmsRawStocks.First();
|
|
|
|
|
wmsRawStock.totalAmount += amount;
|
|
|
|
|
dbContext.WmsRawStock.Update(wmsRawStock);
|
|
|
|
|
|
|
|
|
|
var mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == txtInBarCode.Text);
|
|
|
|
|
WmsRawInstock wmsRawInstock = new WmsRawInstock()
|
|
|
|
|
{
|
|
|
|
|
beginTime = System.DateTime.Now,
|
|
|
|
|
endTime = DateTime.Now,
|
|
|
|
|
locationCode = container.locationCode,
|
|
|
|
|
executeStatus = "2",
|
|
|
|
|
instockAmount = amount,
|
|
|
|
|
instockType = "1",
|
|
|
|
|
materialBatchCode = txtInBarCode.Text,
|
|
|
|
|
materialId = material.materialId,
|
|
|
|
|
operationType = "2",
|
|
|
|
|
palletInfoCode = container.containerCode,
|
|
|
|
|
poNo = mesBaseBarcodeInfo.poNo,
|
|
|
|
|
warehouseId = 512
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
dbContext.WmsRawInstock.Add(wmsRawInstock);
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
totalMessage = wmsRawStock.totalAmount;
|
|
|
|
|
}
|
|
|
|
|
@ -1833,6 +1857,24 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
safeFlag = material.safeFlag
|
|
|
|
|
};
|
|
|
|
|
dbContext.WmsRawStock.Add(newRawStock);
|
|
|
|
|
|
|
|
|
|
var mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == txtInBarCode.Text);
|
|
|
|
|
WmsRawInstock wmsRawInstock = new WmsRawInstock()
|
|
|
|
|
{
|
|
|
|
|
beginTime = System.DateTime.Now,
|
|
|
|
|
endTime = DateTime.Now,
|
|
|
|
|
locationCode = container.locationCode,
|
|
|
|
|
executeStatus = "2",
|
|
|
|
|
instockAmount = amount,
|
|
|
|
|
instockType = "1",
|
|
|
|
|
materialBatchCode = txtInBarCode.Text,
|
|
|
|
|
materialId = material.materialId,
|
|
|
|
|
operationType = "2",
|
|
|
|
|
palletInfoCode = container.containerCode,
|
|
|
|
|
poNo = mesBaseBarcodeInfo.poNo,
|
|
|
|
|
warehouseId = 512
|
|
|
|
|
};
|
|
|
|
|
dbContext.WmsRawInstock.Add(wmsRawInstock);
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
totalMessage = newRawStock.totalAmount;
|
|
|
|
|
}
|
|
|
|
|
@ -2164,8 +2206,12 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
{
|
|
|
|
|
string containerCode = txtOutBox.Text;
|
|
|
|
|
|
|
|
|
|
if (containerCode.Length < 15)
|
|
|
|
|
if (containerCode.Length >= 1 && containerCode.Length < 15)
|
|
|
|
|
{
|
|
|
|
|
scanOutMsg.Text = "";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(containerCode))
|
|
|
|
|
{
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
@ -2173,7 +2219,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
var container = dbContext.WmsBaseLocation.FirstOrDefault(t => t.containerCode == containerCode && t.warehouseId == 512);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
MsgText.Text = $"未查询到该容器{txtOutBox.Text}!";
|
|
|
|
|
scanOutMsg.Text = $"未查询到该容器{txtOutBox.Text}!";
|
|
|
|
|
txtOutBox.Text = string.Empty;
|
|
|
|
|
txtOutBox.Focus();
|
|
|
|
|
}
|
|
|
|
|
@ -2197,8 +2243,10 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
txtTotalAmount.Text = "";
|
|
|
|
|
outMaterialNameTxt.Text = "";
|
|
|
|
|
outMaterialSpecTxt.Text = "";
|
|
|
|
|
txtOutScan.Text = "";
|
|
|
|
|
string barCode = txtOutBarCode.Text;
|
|
|
|
|
string containerCode = txtOutBox.Text;
|
|
|
|
|
if (barCode.Length < 19) return;
|
|
|
|
|
@ -2211,7 +2259,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
var wmsRawStock = dbContext.WmsRawStock.FirstOrDefault(t => t.instockBatch == barCode && t.palletInfoCode == containerCode);
|
|
|
|
|
if (wmsRawStock == null)
|
|
|
|
|
{
|
|
|
|
|
MsgText.Text = "未在该容器中查询到该条码!";
|
|
|
|
|
scanOutMsg.Text = "未在该容器中查询到该条码!";
|
|
|
|
|
txtOutBarCode.Text = string.Empty;
|
|
|
|
|
txtOutScan.Text = string.Empty;
|
|
|
|
|
txtOutBarCode.Focus();
|
|
|
|
|
@ -2221,7 +2269,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
var mesBaseMaterialInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == wmsRawStock.instockBatch);
|
|
|
|
|
if (mesBaseMaterialInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MsgText.Text = "未查询到该条码绑定的物料信息!";
|
|
|
|
|
scanOutMsg.Text = "未查询到该条码绑定的物料信息!";
|
|
|
|
|
txtOutBarCode.Text = string.Empty;
|
|
|
|
|
txtOutScan.Text = string.Empty;
|
|
|
|
|
txtOutBarCode.Focus();
|
|
|
|
|
@ -2236,15 +2284,17 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
outMaterialNameTxt.Text = materialInfo.MaterialName;
|
|
|
|
|
outMaterialSpecTxt.Text = materialInfo.MaterialSpec;
|
|
|
|
|
}
|
|
|
|
|
txtOutScan.Text = (mesBaseMaterialInfo.batchFlag == "1" ? (wmsRawStock.totalAmount - wmsRawStock.frozenAmount) : 1).ToString();
|
|
|
|
|
if (mesBaseMaterialInfo.batchFlag == "1")
|
|
|
|
|
{
|
|
|
|
|
txtOutScan.IsReadOnly = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txtOutScan.IsReadOnly = true;
|
|
|
|
|
}
|
|
|
|
|
txtTotalAmount.Text = string.Format("{0:0}", wmsRawStock.totalAmount - wmsRawStock.frozenAmount);
|
|
|
|
|
txtOutScan.Focus();
|
|
|
|
|
//txtOutScan.Text = string.Format("{0:0}", (mesBaseMaterialInfo.batchFlag == "1" ? (wmsRawStock.totalAmount - wmsRawStock.frozenAmount) : 1)) ;
|
|
|
|
|
//if (mesBaseMaterialInfo.batchFlag == "1")
|
|
|
|
|
//{
|
|
|
|
|
// txtOutScan.IsReadOnly = false;
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// txtOutScan.IsReadOnly = true;
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -2253,7 +2303,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(barCode))
|
|
|
|
|
{
|
|
|
|
|
MsgText.Text = "请先扫描容器号!";
|
|
|
|
|
scanOutMsg.Text = "请先扫描容器号!";
|
|
|
|
|
txtOutBarCode.Text = string.Empty;
|
|
|
|
|
txtOutScan.Text = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
@ -2286,19 +2336,19 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
.FirstOrDefault(t => t.instockBatch == txtOutBarCode.Text && t.palletInfoCode == txtOutBox.Text);
|
|
|
|
|
if (wmsRawStock == null)
|
|
|
|
|
{
|
|
|
|
|
HandyControl.Controls.MessageBox.Error("库存已经被清空!");
|
|
|
|
|
scanOutMsg.Text = "库存已经被清空!";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
decimal outScan = Convert.ToDecimal(this.txtOutScan.Text);
|
|
|
|
|
if (outScan != 1 && outScan > wmsRawStock.totalAmount - wmsRawStock.frozenAmount)
|
|
|
|
|
{
|
|
|
|
|
HandyControl.Controls.MessageBox.Error("出库数量不能大于库存数量!");
|
|
|
|
|
scanOutMsg.Text = "出库数量不能大于库存数量!";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var wcsTask = dbContext.WcsTask.Where(t => t.containerNo == txtOutBox.Text).FirstOrDefault();
|
|
|
|
|
if (wcsTask == null)
|
|
|
|
|
{
|
|
|
|
|
HandyControl.Controls.MessageBox.Error("出库失败,非CTU出库任务,无法出库!");
|
|
|
|
|
scanOutMsg.Text = "出库失败,非CTU出库任务,无法出库!";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
@ -2317,7 +2367,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
}
|
|
|
|
|
else if (wmsRawOutstock.realOutstockAmount > wmsRawOutstock.outstockAmount)
|
|
|
|
|
{
|
|
|
|
|
HandyControl.Controls.MessageBox.Error("出库数量不能大于申请单数量,当前出库数量为:" + (wmsRawOutstock.realOutstockAmount - outScan) + ",申请单数量为:" + wmsRawOutstock.outstockAmount + "!");
|
|
|
|
|
scanOutMsg.Text = "出库数量不能大于申请单数量,当前出库数量为:" + (wmsRawOutstock.realOutstockAmount - outScan) + ",申请单数量为:" + wmsRawOutstock.outstockAmount + "!";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
wmsRawStock.totalAmount -= outScan;
|
|
|
|
|
@ -2366,17 +2416,68 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
if (wmsRawStock.totalAmount == 0)
|
|
|
|
|
{
|
|
|
|
|
dbContext.WmsRawStock.Remove(wmsRawStock);
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dbContext.WmsRawStock.Update(wmsRawStock);
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#region 插入rawOutstock
|
|
|
|
|
string timeStamp = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
|
|
|
WmsRawOutstock newWmsRawOutstock = new WmsRawOutstock();
|
|
|
|
|
newWmsRawOutstock.taskCode = timeStamp + "CTU" + Random.Shared.Next(10, 99);
|
|
|
|
|
newWmsRawOutstock.warehouseId = 512;
|
|
|
|
|
newWmsRawOutstock.locationCode = wcsTask.currPointNo;
|
|
|
|
|
newWmsRawOutstock.stationId = 512;
|
|
|
|
|
newWmsRawOutstock.materialId = mesBaseBarcodeInfo.materialId;
|
|
|
|
|
newWmsRawOutstock.materialBatch = mesBaseBarcodeInfo.barcodeInfo;
|
|
|
|
|
newWmsRawOutstock.palletInfoCode = wcsTask.containerNo;
|
|
|
|
|
newWmsRawOutstock.outstockAmount = outScan;
|
|
|
|
|
newWmsRawOutstock.realOutstockAmount = outScan;
|
|
|
|
|
newWmsRawOutstock.operationType = "1";
|
|
|
|
|
newWmsRawOutstock.taskType = "1";
|
|
|
|
|
newWmsRawOutstock.auditStatus = "1";
|
|
|
|
|
newWmsRawOutstock.applyBy = "CtuGun";
|
|
|
|
|
newWmsRawOutstock.executeStatus = "2";
|
|
|
|
|
newWmsRawOutstock.saleOrderId = mesBaseBarcodeInfo.saleOrderId;
|
|
|
|
|
newWmsRawOutstock.updateDate = DateTime.Now;
|
|
|
|
|
newWmsRawOutstock.beginTime = DateTime.Now;
|
|
|
|
|
newWmsRawOutstock.endTime = DateTime.Now;
|
|
|
|
|
dbContext.WmsRawOutstock.Add(newWmsRawOutstock);
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
#endregion
|
|
|
|
|
//if (mesBaseBarcodeInfo != null)
|
|
|
|
|
//{
|
|
|
|
|
// WmsRawOutstockDetail wmsProductOutstockDetail = new WmsRawOutstockDetail()
|
|
|
|
|
// {
|
|
|
|
|
// rawOutstockDetailId = Global.SnowId.NextId(),
|
|
|
|
|
// rawOutstockId = 0,
|
|
|
|
|
// materialId = mesBaseBarcodeInfo.materialId,
|
|
|
|
|
// createDate = DateTime.Now,
|
|
|
|
|
// createBy = "WCS",
|
|
|
|
|
// taskCode = wcsTask.objid.ToString(),
|
|
|
|
|
// executeStatus = "2",
|
|
|
|
|
// locationCode = wcsTask.currPointNo,
|
|
|
|
|
// outstockAmount = outScan,
|
|
|
|
|
// planAmount = outScan,
|
|
|
|
|
// warehouseId = 512,
|
|
|
|
|
// materialBarcode = mesBaseBarcodeInfo.barcodeInfo,
|
|
|
|
|
// instockBatch = mesBaseBarcodeInfo.batchCode,
|
|
|
|
|
// stackAmount = outScan,
|
|
|
|
|
// outstockPerson = "WCS",
|
|
|
|
|
// outstockTime = DateTime.Now,
|
|
|
|
|
// outstockWay = "2",
|
|
|
|
|
// materialProductionDate = mesBaseBarcodeInfo.productionDate
|
|
|
|
|
// };
|
|
|
|
|
// dbContext.WmsRawOutstockDetail.Add(wmsProductOutstockDetail);
|
|
|
|
|
//}
|
|
|
|
|
// dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HandyControl.Controls.MessageBox.Error("该条码的销售订单不正确");
|
|
|
|
|
scanOutMsg.Text = "该条码的销售订单不正确";
|
|
|
|
|
txtOutScan.Text = string.Empty;
|
|
|
|
|
txtOutBarCode.Text = string.Empty;
|
|
|
|
|
outMaterialSpecTxt.Text = string.Empty;
|
|
|
|
|
@ -2387,7 +2488,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HandyControl.Controls.MessageBox.Success("出库成功!");
|
|
|
|
|
scanOutMsg.Text = "出库成功!";
|
|
|
|
|
txtOutScan.Text = string.Empty;
|
|
|
|
|
txtOutBarCode.Text = string.Empty;
|
|
|
|
|
outMaterialSpecTxt.Text = string.Empty;
|
|
|
|
|
@ -2397,13 +2498,13 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HandyControl.Controls.MessageBox.Error("未查询到该条码信息!");
|
|
|
|
|
scanOutMsg.Text = "未查询到该条码信息!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HandyControl.Controls.MessageBox.Info("请先扫描容器号和条码!");
|
|
|
|
|
scanOutMsg.Text = "请先扫描容器号和条码!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
@ -2416,18 +2517,22 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void SelectButton_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
private async void SelectButton_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CallSelectedItem.Clear();
|
|
|
|
|
GetPersonCallMaterialData();
|
|
|
|
|
await GetPersonCallMaterialData();
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取人员呼叫的物料数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void GetPersonCallMaterialData()
|
|
|
|
|
private async Task GetPersonCallMaterialData()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
int pageNumber = this.Pagination2.PageIndex;
|
|
|
|
|
// 计算跳过的记录数
|
|
|
|
|
int skip = (pageNumber - 1) * pageCount;
|
|
|
|
|
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
List<long?> materialIds = new List<long?>();
|
|
|
|
|
@ -2437,11 +2542,14 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
materialInfos = dbContext.MesBaseMaterialInfo.Where(t => t.MaterialName.Contains(MaterialName.Text) || t.MaterialCode.Contains(MaterialName.Text) || t.MaterialSpec.Contains(MaterialName.Text)).ToList();
|
|
|
|
|
materialIds = materialInfos.Select(t => t.MaterialId).ToList();
|
|
|
|
|
}
|
|
|
|
|
List<WmsRawStock> wmsRawStocks = null;
|
|
|
|
|
|
|
|
|
|
wmsRawStocks = dbContext.WmsRawStock
|
|
|
|
|
.Where(t => t.warehouseId == 512)
|
|
|
|
|
.WhereIf(materialIds.Count > 0, t => materialIds.Contains(t.materialId))
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var wmsRawStocks = dbContext.WmsRawStock
|
|
|
|
|
.Where(t => t.warehouseId == 512)
|
|
|
|
|
.WhereIf(materialIds.Count > 0, t => materialIds.Contains(t.materialId))
|
|
|
|
|
.ToList();
|
|
|
|
|
var groupWmsRawStock = wmsRawStocks.GroupBy(t => new { t.materialId, t.palletInfoCode }).Select(t =>
|
|
|
|
|
new
|
|
|
|
|
{
|
|
|
|
|
@ -2450,6 +2558,10 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
totalAmount = t.Sum(x => x.totalAmount),
|
|
|
|
|
frozenAmount = t.Sum(x => x.frozenAmount),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
int totalRecords = groupWmsRawStock.Count();
|
|
|
|
|
Pagination2.MaxPageCount = (totalRecords / pageCount) + (totalRecords % pageCount == 0 ? 0 : 1);
|
|
|
|
|
groupWmsRawStock = groupWmsRawStock.Skip(skip).Take(pageCount);
|
|
|
|
|
//.GroupBy(t => t.palletInfoCode)
|
|
|
|
|
//.Select(t => new
|
|
|
|
|
//{
|
|
|
|
|
@ -2458,14 +2570,15 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
// frozenAmount = string.Join("\n", t.Select(x => x.frozenAmount)),
|
|
|
|
|
// materialId = string.Join("\n", t.Select(x => x.materialId)),
|
|
|
|
|
//}).ToList();
|
|
|
|
|
var palletInfoCodes = wmsRawStocks.Select(t => t.palletInfoCode).Distinct().ToList();
|
|
|
|
|
var wmsBaseLocations = dbContext.WmsBaseLocation
|
|
|
|
|
var palletInfoCodes = groupWmsRawStock.Select(t => t.palletInfoCode).Distinct().ToList();
|
|
|
|
|
var wmsBaseLocations = await dbContext.WmsBaseLocation
|
|
|
|
|
.Where(t => t.ContainerStatus == "1")
|
|
|
|
|
.Where(t => t.warehouseId == 512)
|
|
|
|
|
.Where(t => palletInfoCodes.Contains(t.containerCode)).ToList();
|
|
|
|
|
.Where(t => palletInfoCodes.Contains(t.containerCode)).ToListAsync();
|
|
|
|
|
if (string.IsNullOrEmpty(MaterialName.Text))
|
|
|
|
|
{
|
|
|
|
|
materialInfos = dbContext.MesBaseMaterialInfo.ToList();
|
|
|
|
|
var tempMaterialIds = groupWmsRawStock.Select(x => x.materialId).Distinct().ToList();
|
|
|
|
|
materialInfos = await dbContext.MesBaseMaterialInfo.Where(x => tempMaterialIds.Contains(x.MaterialId)).ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
var bill = from a in wmsBaseLocations
|
|
|
|
|
from b in groupWmsRawStock
|
|
|
|
|
@ -2486,6 +2599,9 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
frozenAmount = b.frozenAmount,
|
|
|
|
|
IsSelected = CallSelectedItem.Contains(a.locationId)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var bills = bill.GroupBy(t => new { t.baseLocationId, t.palletInfoCode, t.locationCode, t.IsSelected })
|
|
|
|
|
.Select(t => new
|
|
|
|
|
{
|
|
|
|
|
@ -2503,9 +2619,11 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
materialSpecSrc = string.Join("\n", t.Select(x => x.materialSpec))
|
|
|
|
|
}).ToList();
|
|
|
|
|
bills = bills.OrderBy(t => t.palletInfoCode).ThenBy(t => t.materialId).ToList();
|
|
|
|
|
PersonCallMaterial.ItemsSource = bills.Skip((this.Pagination2.PageIndex - 1) * this.pageCount).Take(this.pageCount);
|
|
|
|
|
// PersonCallMaterial.ItemsSource = bills.Skip((this.Pagination2.PageIndex - 1) * this.pageCount).Take(this.pageCount);
|
|
|
|
|
PersonCallMaterial.ItemsSource = bills;
|
|
|
|
|
int sum = bills.Count();
|
|
|
|
|
Pagination2.MaxPageCount = (sum / pageCount) + (sum % pageCount == 0 ? 0 : 1);
|
|
|
|
|
// Pagination2.MaxPageCount = (sum / pageCount) + (sum % pageCount == 0 ? 0 : 1);
|
|
|
|
|
|
|
|
|
|
if (bills.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
HandyControl.Controls.MessageBox.Show("未查询到数据");
|
|
|
|
|
@ -2521,9 +2639,9 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void Pagination2_PageUpdated(object sender, HandyControl.Data.FunctionEventArgs<int> e)
|
|
|
|
|
private async void Pagination2_PageUpdated(object sender, HandyControl.Data.FunctionEventArgs<int> e)
|
|
|
|
|
{
|
|
|
|
|
GetPersonCallMaterialData();
|
|
|
|
|
await GetPersonCallMaterialData();
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 页码改变时
|
|
|
|
|
@ -2740,6 +2858,29 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
// HandyControl.Controls.HandyControl.Controls.MessageBox.Show("当前CTU入库任务已满6个,请等待任务完成后再叫空箱!");
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
#region 出库创建taskmanual,如果有之前的出库任务, 弹框提示有未完成的出库任务,是否继续出库,如果继续,删除之前的出库任务
|
|
|
|
|
var removeList = dbContext.WcsTask.Where(x => x.taskType == 30 && x.taskStatus == 6).ToList();
|
|
|
|
|
if (removeList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder stringContainers = new StringBuilder();
|
|
|
|
|
stringContainers.AppendLine("以下料箱有未完成的出库任务:");
|
|
|
|
|
removeList.ForEach(x => stringContainers.AppendLine($"料箱号{x.containerNo}\n"));
|
|
|
|
|
stringContainers.AppendLine("是否删除任务继续出库?");
|
|
|
|
|
MessageBoxResult isContinueCreateResult = HandyControl.Controls.MessageBox.Show(stringContainers.ToString(), "提示", MessageBoxButton.YesNo);
|
|
|
|
|
if (isContinueCreateResult == MessageBoxResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
dbContext.WcsTask.RemoveRange(removeList);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var wmsBaseLocation = dbContext.WmsBaseLocation
|
|
|
|
|
.Where(t => t.locationStatus == "1")
|
|
|
|
|
.Where(t => t.warehouseId == 512 && t.ContainerStatus == "1")
|
|
|
|
|
@ -2837,6 +2978,28 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
MessageBoxResult MessageBoxResult = HandyControl.Controls.MessageBox.Show(stringBuilder.ToString(), "提示", MessageBoxButton.YesNo);
|
|
|
|
|
if (MessageBoxResult == MessageBoxResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#region 出库创建taskmanual,如果有之前的出库任务, 弹框提示有未完成的出库任务,是否继续出库,如果继续,删除之前的出库任务
|
|
|
|
|
var removeList = dbContext.WcsTask.Where(x => x.taskType == 30 && x.taskStatus == 6).ToList();
|
|
|
|
|
if (removeList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder stringContainers = new StringBuilder();
|
|
|
|
|
stringContainers.AppendLine("以下料箱有未完成的出库任务:");
|
|
|
|
|
removeList.ForEach(x => stringContainers.AppendLine($"料箱号{x.containerNo}\n"));
|
|
|
|
|
stringContainers.AppendLine("是否删除任务继续出库?");
|
|
|
|
|
MessageBoxResult isContinueCreateResult = HandyControl.Controls.MessageBox.Show(stringContainers.ToString(), "提示", MessageBoxButton.YesNo);
|
|
|
|
|
if (isContinueCreateResult == MessageBoxResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
dbContext.WcsTask.RemoveRange(removeList);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<WcsTaskManual> addList = new List<WcsTaskManual>();
|
|
|
|
|
foreach (var item in wmsBaseLocation)
|
|
|
|
|
{
|
|
|
|
|
@ -4062,7 +4225,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
#region 移库方法
|
|
|
|
|
private void rawSourceBox_TextChanged(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.rawSourceBox.Text.Length >=1 && this.rawSourceBox.Text.Length < 15)
|
|
|
|
|
if (this.rawSourceBox.Text.Length >= 1 && this.rawSourceBox.Text.Length < 15)
|
|
|
|
|
{
|
|
|
|
|
this.RemoveMsg.Text = "";
|
|
|
|
|
return;
|
|
|
|
|
@ -4074,7 +4237,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
//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;
|
|
|
|
|
@ -4111,13 +4274,13 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
.FirstOrDefault();
|
|
|
|
|
if (wmsRawStock == null)
|
|
|
|
|
{
|
|
|
|
|
RemoveMsg.Text = $"未在{this.rawSourceBox.Text}托盘中找到{barCode}条码!" ;
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
@ -4158,7 +4321,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
{
|
|
|
|
|
removeSourceBarCode.Focus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -4206,7 +4369,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
{
|
|
|
|
|
removeSourceMaterialName.Text = mesBaseMaterialInfo.MaterialName;
|
|
|
|
|
removeSourceMaterialSpec.Text = mesBaseMaterialInfo.MaterialSpec;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -4252,14 +4415,14 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
//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)
|
|
|
|
|
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"))
|
|
|
|
|
if (targetStock == null || (targetStock != null && removeBarcodeInfo.batchFlag == "0"))
|
|
|
|
|
{
|
|
|
|
|
// 更新 WmsRawStock 中的记录
|
|
|
|
|
dbContext.WmsRawStock
|
|
|
|
|
@ -4277,7 +4440,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
dbContext.WmsRawStock.Update(targetStock);
|
|
|
|
|
}
|
|
|
|
|
#region 插入移库记录
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
@ -4407,6 +4570,28 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 取消预调度
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void CancelPreScheduling_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// 调用取消预调度接口
|
|
|
|
|
|
|
|
|
|
string executeResult = HttpHelper.SendPostMessage("172.16.12.100", 5001, "wcs/RecieveRcs/CancelPreScheduling", null, "application/Json");
|
|
|
|
|
// string executeResult = HttpHelper.SendPostMessage("127.0.0.1", 5001, "wcs/RecieveRcs/CancelPreScheduling", null, "application/Json");
|
|
|
|
|
var executeReponse = JsonConvert.DeserializeObject<ReponseMessage>(executeResult);
|
|
|
|
|
if (executeReponse != null && executeReponse.code == "0")
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("取消预调度成功!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show($"取消预调度失败!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|