diff --git a/src/WMS.Web.Repositories/InStockTaskRepositories.cs b/src/WMS.Web.Repositories/InStockTaskRepositories.cs index 84af6ad1..373c9348 100644 --- a/src/WMS.Web.Repositories/InStockTaskRepositories.cs +++ b/src/WMS.Web.Repositories/InStockTaskRepositories.cs @@ -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 }) .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 }) - .SelectMany(x => x.ts.DefaultIfEmpty(), (p, taskBox) => new { p.detail, p.order, p.box, p.taskDet, taskBox }) + // .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 }) .Where(x => x.detail.TaskId == entity.Id).Select(x => new InStockTaskBoxInfoDto() { DetailId = "instock_" + x.detail.Id, @@ -198,15 +198,28 @@ namespace WMS.Web.Repositories ReceiveQty = x.detail.Qty, ShelfTime = x.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), Shelfer = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, x.order.CreatorId), - 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") : "", + //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") : "", SerialNumbers = (string.Join(",", x.detail.SerialNumbers).TrimEnd(',')) }).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 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) {