分组
This commit is contained in:
@@ -78,28 +78,36 @@ namespace WMS.Web.Domain.Services
|
||||
List<ErpMaterialDto> materials = new List<ErpMaterialDto>();
|
||||
if (materials_result.IsSuccess)
|
||||
materials = materials_result.Data.ToList();
|
||||
//获取店铺
|
||||
var sellerList = await _lingXingService.GetSeller();
|
||||
//合并
|
||||
var group = resInventory.Data.GroupBy(g => (g.StockId, g.SKU, g.SellerId));
|
||||
|
||||
List<ProductInventory> inventoryList = new List<ProductInventory>();
|
||||
foreach (var item in resInventory.Data)
|
||||
foreach (var item in group)
|
||||
{
|
||||
//如果物料不匹配 过滤
|
||||
var m = materials.FirstOrDefault(f => f.Specifications.Equals(item.SKU));
|
||||
var m = materials.FirstOrDefault(f => f.Specifications.Equals(item.Key.SKU));
|
||||
if (m == null) continue;
|
||||
//找仓库
|
||||
var l_stock = resStock.Data.FirstOrDefault(f => f.Id == item.StockId);
|
||||
var l_stock = resStock.Data.FirstOrDefault(f => f.Id == item.Key.StockId);
|
||||
if (l_stock == null) continue;
|
||||
var stock = r.FirstOrDefault(f => f.WarehouseCodeOfLingxing.Equals(l_stock.Name));
|
||||
if (stock == null) continue;
|
||||
|
||||
//店铺
|
||||
var seller = sellerList.Data.FirstOrDefault(f=>f.Id== item.Key.SellerId);
|
||||
if (seller == null) continue;
|
||||
var pList = resInventory.Data.Where(w => w.SKU == item.Key.SKU
|
||||
&& w.StockId == item.Key.StockId && w.SellerId == item.Key.SellerId).ToList();
|
||||
var entity = new ProductInventory()
|
||||
{
|
||||
Type=ProductInventoryType.LingXing,
|
||||
Type = ProductInventoryType.LingXing,
|
||||
MaterialNumber = m.MaterialNumber,
|
||||
Customer = item.SellerId,
|
||||
Customer = seller.Name,
|
||||
OrgCode = stock.Code,
|
||||
StockCode = stock.ErpOrgCode,
|
||||
Qty = item.Product_Valid_Num,
|
||||
BeforeQty = item.Product_Total
|
||||
Qty = pList.Sum(s => s.Product_Valid_Num),
|
||||
BeforeQty = pList.Sum(s => s.Product_Total)
|
||||
};
|
||||
inventoryList.Add(entity);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user