修复bug

This commit is contained in:
18942506660
2024-11-15 15:36:10 +08:00
parent cbc55ac889
commit 24e4eb4bce

View File

@@ -198,8 +198,8 @@ 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 = "",
//ReceiveTime = x.taskBox.CreateTime.HasValue ? x.taskBox.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", ReceiveTime = "",
SerialNumbers = (string.Join(",", x.detail.SerialNumbers).TrimEnd(',')) SerialNumbers = (string.Join(",", x.detail.SerialNumbers).TrimEnd(','))
}).ToListAsync(); }).ToListAsync();
@@ -207,16 +207,46 @@ namespace WMS.Web.Repositories
//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();
//左连接中 右表中的数据如果有多条,所以需要特殊处理 if (entity.Type == InstockType.Purchase)
var instockTaskBoxList = await _context.InstockTaskBox.Where(w => w.TaskId == entity.Id && boxIds.Contains(w.BoxId)).ToListAsync();
foreach (var bid in boxIds)
{ {
var resList = boxList.Where(w => w.BoxId == bid).OrderBy(x => x.ShelfTime).ToList(); //左连接中 右表中的数据如果有多条,所以需要特殊处理
for (int i = 0; i < resList.Count(); i++) var instockTaskBoxList = await _context.InstockTaskBox.Include(x => x.Details).Where(w => w.TaskId == entity.Id && boxIds.Contains(w.BoxId)).ToListAsync();
foreach (var bid in boxIds)
{ {
var bList = instockTaskBoxList.Where(w => w.BoxId == bid).OrderBy(x => x.CreateTime).ToList(); var resList = boxList.Where(w => w.BoxId == bid).OrderBy(x => x.ShelfTime).ToList();
resList[i].Receiver = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, bList[i].ReceiverId ?? 0); for (int i = 0; i < resList.Count(); i++)
resList[i].ReceiveTime = bList[i].CreateTime.HasValue ? bList[i].CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""; {
var bList = instockTaskBoxList.Where(w => w.BoxId == bid).OrderBy(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 (resList.Count() < instockTaskBoxList.Where(w => w.BoxId == bid).Count())
{
var boxd = instockTaskBoxList.Where(w => w.BoxId == bid).OrderByDescending(x => x.CreateTime).First();
foreach (var boxdetail in boxd.Details)
{
boxList.Add(new InStockTaskBoxInfoDto()
{
DetailId = "instocktask_" + boxdetail.Id,
BoxId = boxd.BoxId,
BoxBillNo = boxd.BoxBillNo,
SaleBillNo = resList[0].SaleBillNo,
Method = InventoryInOutMethod.Box.GetRemark(),
MethodForInt = (int)InventoryInOutMethod.Box,
Qty = boxdetail.ReceiveQty,
ReceiveQty = boxdetail.ReceiveQty,
RealityQty = 0,
MaterialNumber = boxdetail.MaterialNumber,
Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, boxdetail.MaterialNumber),
ShelfTime = "",
Shelfer = "",
ReceiveTime = boxd.CreateTime.HasValue ? boxd.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
Receiver = boxd.ReceiverId.HasValue ? _singleDataService.GetSingleData(SingleAction.Staffs, companyId, boxd.ReceiverId.Value) : "",
SerialNumbers = boxdetail.SerialNumbers != null && boxdetail.SerialNumbers.Count() > 0 ? (string.Join(",", boxdetail.SerialNumbers).TrimEnd(',')) : "",
});
}
}
} }
} }