This commit is contained in:
2021-08-03 19:05:02 +00:00
parent 769e76ffb1
commit a6ca72f11b

View File

@@ -4842,8 +4842,29 @@ namespace AyaNova.Biz
.Select(cl => new PMRestockListItem() { PartId = cl.First().PartId, WarehouseId = cl.First().WarehouseId, QuantityRequired = cl.Sum(c => c.QuantityRequired) });
//ok, should have all summarized partid/warehouseid required combos, can now build output
System.Text.StringBuilder sb = new System.Text.StringBuilder();
foreach (var i in sumList)
{
var part = await ct.Part.AsNoTracking().Where(x => x.Id == i.PartId).Select(x => x.PartNumber).FirstOrDefaultAsync();
var whs = await ct.PartWarehouse.AsNoTracking().Where(x => x.Id == i.WarehouseId).Select(x => x.Name).FirstOrDefaultAsync();
sb.AppendLine($"{part} {whs} - {i.QuantityRequired}");
}
if (sb.Length > 0)
{
NotifyEvent n = new NotifyEvent()
{
EventType = NotifyEventType.PMStopGeneratingDateReached,
UserId = sub.UserId,
AyaType = AyaType.PM,
ObjectId = p.Id,
NotifySubscriptionId = sub.Id,
Name = p.Serial.ToString(),
Message = sb.ToString()
};
await ct.NotifyEvent.AddAsync(n);
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
await ct.SaveChangesAsync();
}
}//each pmid