|
|
|
|
@ -584,6 +584,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
List<long?> orderIds = wmsRawOutstocks.Select(t => t.rawOutstockId).ToList();
|
|
|
|
|
var endStations = wmsRawOutstocks.Select(t => new
|
|
|
|
|
{
|
|
|
|
|
t.rawOutstockId,
|
|
|
|
|
orderId = t.saleOrderId,
|
|
|
|
|
t.materialId,
|
|
|
|
|
t.endStationCode
|
|
|
|
|
@ -616,19 +617,20 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
|
|
|
|
|
// 根据 materialId 分组,并计算 outstockAmount 和 realOutstockAmount 的总和
|
|
|
|
|
var targetRawOutstocks = RawOutstocks
|
|
|
|
|
.GroupBy(t => new { t.materialId, t.saleOrderId })
|
|
|
|
|
.GroupBy(t => new { t.rawOutstockId, t.materialId, t.saleOrderId, t.outstockAmount, t.realOutstockAmount })
|
|
|
|
|
.Select(g => new
|
|
|
|
|
{
|
|
|
|
|
rawOutStocketId = g.Key.rawOutstockId,
|
|
|
|
|
materialId = g.Key.materialId,
|
|
|
|
|
saleOrderId = g.Key.saleOrderId,
|
|
|
|
|
//totalOutstockAmount = g.Sum(t => t.outstockAmount),
|
|
|
|
|
totalOutstockAmount = g.Sum(t => t.outstockAmount),
|
|
|
|
|
totalOutstockAmount = g.Key.outstockAmount,
|
|
|
|
|
//totalRealOutstockAmount = g.Sum(t => t.realOutstockAmount)
|
|
|
|
|
totalRealOutstockAmount = g.Sum(t => t.realOutstockAmount)
|
|
|
|
|
totalRealOutstockAmount = g.Key.realOutstockAmount
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
//本次所有任务出来的托盘号
|
|
|
|
|
List<WcsTask> wcsTasks = dbContext.WcsTask.Where(t => t.taskType == 30).Where(t => orderIds.Contains(t.orderId)).ToList();
|
|
|
|
|
List<WcsTask> wcsTasks = dbContext.WcsTask.Where(t => t.taskType == 30&& targetRawOutstocks.Select(d=>d.materialId).Contains(t.materialId)).ToList();
|
|
|
|
|
List<string> containerNos = wcsTasks.Select(t => t.containerNo).ToList();
|
|
|
|
|
//本次所有托盘携带的物料
|
|
|
|
|
List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock.Where(t => containerNos.Contains(t.palletInfoCode)).ToList();
|
|
|
|
|
@ -661,9 +663,18 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
.Where(pallet => pallet.MaterialId == order.materialId)
|
|
|
|
|
.Select(pallet => $"托盘{pallet.PalletInfoCode}数量{string.Format("{0:0.00}", pallet.canUseAmount)}")
|
|
|
|
|
),
|
|
|
|
|
EndStationCodes = string.Join(",", endStations.Where(t => t.materialId == order.materialId && t.orderId == order.saleOrderId).Select(t => t.endStationCode).ToList())
|
|
|
|
|
EndStationCodes = endStations.Where(t => t.rawOutstockId == order.rawOutStocketId).FirstOrDefault()?.endStationCode
|
|
|
|
|
//EndStationCodes = string.Join(",", endStations.Where(t => t.materialId == order.materialId && t.orderId == order.saleOrderId).Select(t => t.endStationCode).ToList())
|
|
|
|
|
}).ToList();
|
|
|
|
|
var list1 = new List<string>();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
list1 = JsonConvert.DeserializeObject<List<string>>(nowStationCode);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
List<long?> materialIds = RawOutstocks.Select(t => t.materialId).ToList();
|
|
|
|
|
List<MesBaseMaterialInfo> mesBaseMaterialInfos = dbContext.MesBaseMaterialInfo.Where(t => materialIds.Contains(t.MaterialId)).ToList();
|
|
|
|
|
|
|
|
|
|
@ -729,7 +740,14 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
|
|
|
|
|
Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
this.OutTaskNumber.ItemsSource = orderNumber;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
this.OutTaskNumber.ItemsSource = orderNumber.OrderBy(t => t.EndStationCodes.Contains(list1[0]) ? 1 : 99);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
this.OutTaskNumber.ItemsSource = orderNumber;
|
|
|
|
|
}
|
|
|
|
|
this.OutTaskNumber.Items.Refresh();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
@ -762,7 +780,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
{
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
var alarmInfo = dbContext.DmsBaseAlarmRule.Where(t => t.DeviceId ==- 1).ToList();
|
|
|
|
|
var alarmInfo = dbContext.DmsBaseAlarmRule.Where(t => t.DeviceId == -1).ToList();
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
@ -2777,13 +2795,8 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
}
|
|
|
|
|
if (wmsRawOutstocks.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
int index = 0;
|
|
|
|
|
var sort = list.Select(t => new
|
|
|
|
|
{
|
|
|
|
|
stationCode = t,
|
|
|
|
|
index = index++
|
|
|
|
|
});
|
|
|
|
|
wmsRawOutstocks = wmsRawOutstocks.OrderBy(t => sort.FirstOrDefault(s => s.stationCode == t.endStationCode) != null ? sort.FirstOrDefault(s => s.stationCode == t.endStationCode).index : 99).ToList();
|
|
|
|
|
|
|
|
|
|
wmsRawOutstocks = wmsRawOutstocks.OrderBy(t => list[0]==t.endStationCode?0:99).ToList();
|
|
|
|
|
decimal? sum = wmsRawOutstocks.Sum(t => (t.outstockAmount - t.realOutstockAmount));
|
|
|
|
|
if (outScan > sum)
|
|
|
|
|
{
|
|
|
|
|
@ -2792,11 +2805,16 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
}
|
|
|
|
|
foreach (var item in wmsRawOutstocks)
|
|
|
|
|
{
|
|
|
|
|
if (outScan <= 0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
decimal outAmount = 0;
|
|
|
|
|
if (item.outstockAmount - item.realOutstockAmount > outScan)
|
|
|
|
|
{
|
|
|
|
|
item.realOutstockAmount += outScan;
|
|
|
|
|
outAmount += outScan;
|
|
|
|
|
outScan = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@ -2940,6 +2958,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
outMaterialSpecTxt.Text = string.Empty;
|
|
|
|
|
outMaterialNameTxt.Text = string.Empty;
|
|
|
|
|
txtOutBox.Text = string.Empty;
|
|
|
|
|
remarks.Text = string.Empty;
|
|
|
|
|
txtOutBox.Focus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -3150,6 +3169,7 @@ namespace Khd.Core.Wpf.Form
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
scanOutMsg.Text = "出库失败"+ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
|