修复bug

This commit is contained in:
18942506660
2024-11-15 14:45:39 +08:00
parent fd771b14d0
commit df9cdaa074

View File

@@ -180,8 +180,8 @@ namespace WMS.Web.Repositories
.GroupJoin(_context.InStockTaskDetails, p => p.detail.TaskDetailId, ts => ts.Id, (p, ts) => new { p.detail, p.order, p.box, ts }) .GroupJoin(_context.InStockTaskDetails, p => p.detail.TaskDetailId, ts => ts.Id, (p, ts) => new { p.detail, p.order, p.box, ts })
.SelectMany(x => x.ts.DefaultIfEmpty(), (p, taskDet) => new { p.detail, p.order, p.box, taskDet }) .SelectMany(x => x.ts.DefaultIfEmpty(), (p, taskDet) => new { p.detail, p.order, p.box, taskDet })
.GroupJoin(_context.InstockTaskBox, p => p.detail.BoxId, ts => ts.BoxId, (p, ts) => new { p.detail, p.order, p.box, p.taskDet, ts }) // .GroupJoin(_context.InstockTaskBox, p => p.detail.BoxId, ts => ts.BoxId, (p, ts) => new { p.detail, p.order, p.box, p.taskDet, ts })
.SelectMany(x => x.ts.DefaultIfEmpty(), (p, taskBox) => new { p.detail, p.order, p.box, p.taskDet, taskBox }) //.SelectMany(x => x.ts.DefaultIfEmpty(), (p, taskBox) => new { p.detail, p.order, p.box, p.taskDet, taskBox })
.Where(x => x.detail.TaskId == entity.Id).Select(x => new InStockTaskBoxInfoDto() .Where(x => x.detail.TaskId == entity.Id).Select(x => new InStockTaskBoxInfoDto()
{ {
DetailId = "instock_" + x.detail.Id, DetailId = "instock_" + x.detail.Id,
@@ -198,15 +198,28 @@ namespace WMS.Web.Repositories
ReceiveQty = x.detail.Qty, ReceiveQty = x.detail.Qty,
ShelfTime = x.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), ShelfTime = x.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
Shelfer = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, x.order.CreatorId), Shelfer = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, x.order.CreatorId),
Receiver = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, x.taskBox.ReceiverId ?? 0), //Receiver = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, x.taskBox.ReceiverId ?? 0),
ReceiveTime = x.taskBox.CreateTime.HasValue ? x.taskBox.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", //ReceiveTime = x.taskBox.CreateTime.HasValue ? x.taskBox.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
SerialNumbers = (string.Join(",", x.detail.SerialNumbers).TrimEnd(',')) SerialNumbers = (string.Join(",", x.detail.SerialNumbers).TrimEnd(','))
}).ToListAsync(); }).ToListAsync();
//左连接中 右表中的数据如果有多条,没办法清楚显示那一条 于是就显示了多条 数据就重复 //左连接中 右表中的数据如果有多条,没办法清楚显示那一条 于是就显示了多条 数据就重复
boxList = boxList.GroupBy(g => g.DetailId).Select(s => s.OrderByDescending(o=>o.ReceiveTime).First()).ToList(); //boxList = boxList.GroupBy(g => g.DetailId).Select(s => s.OrderByDescending(o => o.ReceiveTime).First()).ToList();
var boxIds = boxList.GroupBy(x => x.BoxId).Select(x => x.Key).ToList(); var boxIds = boxList.GroupBy(x => x.BoxId).Select(x => x.Key).ToList();
//左连接中 右表中的数据如果有多条,所以需要特殊处理
var instockTaskBoxList = await _context.InstockTaskBox.Where(w => boxIds.Contains(w.BoxId)).ToListAsync();
foreach (var bid in boxIds)
{
var resList = boxList.Where(w => w.BoxId == bid).OrderByDescending(x => x.ShelfTime).ToList();
for (int i = 0; i < resList.Count(); i++)
{
var bList = instockTaskBoxList.Where(w => w.BoxId == bid).OrderByDescending(x => x.CreateTime).ToList();
resList[i].Receiver = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, bList[i].ReceiverId ?? 0);
resList[i].ReceiveTime = bList[i].CreateTime.HasValue ? bList[i].CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
}
}
if (entity.Type == InstockType.Purchase) if (entity.Type == InstockType.Purchase)
{ {