From 21d7595a363c6cfc5bdb0be5aa9cccc7c291bd15 Mon Sep 17 00:00:00 2001 From: 18942506660 <18942506660@A18942506660> Date: Thu, 31 Oct 2024 11:57:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml | 5 +++++ .../Dto/LingXing/LingXingInventoryRequest.cs | 6 ++++++ .../Services/ProductInventoryService.cs | 9 +++++---- .../Services/Public/LingXingService.cs | 17 ++++++++++------- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml index c2dee348..5f2cd6fd 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml @@ -4075,6 +4075,11 @@ 仓库Id 1,3,234,33 + + + 物料规格型号 + + 领星即时库存 diff --git a/src/WMS.Web.Core/Dto/LingXing/LingXingInventoryRequest.cs b/src/WMS.Web.Core/Dto/LingXing/LingXingInventoryRequest.cs index 580423a4..9d770042 100644 --- a/src/WMS.Web.Core/Dto/LingXing/LingXingInventoryRequest.cs +++ b/src/WMS.Web.Core/Dto/LingXing/LingXingInventoryRequest.cs @@ -16,5 +16,11 @@ namespace WMS.Web.Core.Dto.LingXing /// [JsonProperty("wid")] public string wid { get; set; } + /// + /// 物料规格型号 + /// + [JsonProperty("sku")] + public string sku { get; set; } + } } diff --git a/src/WMS.Web.Domain/Services/ProductInventoryService.cs b/src/WMS.Web.Domain/Services/ProductInventoryService.cs index 5a749c36..0646e2e6 100644 --- a/src/WMS.Web.Domain/Services/ProductInventoryService.cs +++ b/src/WMS.Web.Domain/Services/ProductInventoryService.cs @@ -247,6 +247,7 @@ namespace WMS.Web.Domain.Services var sellerList = await _lingXingService.GetSeller(); //合并 var group = resInventory.Data.GroupBy(g => (g.StockId, g.SKU, g.SellerId)); + //int cc = group.Count(); List inventoryList = new List(); foreach (var item in group) @@ -262,8 +263,8 @@ namespace WMS.Web.Domain.Services //店铺 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 first = resInventory.Data.Where(w => w.SKU == item.Key.SKU + && w.StockId == item.Key.StockId && w.SellerId == item.Key.SellerId).First(); var entity = new ProductInventory() { Type = ProductInventoryType.LingXing, @@ -271,8 +272,8 @@ namespace WMS.Web.Domain.Services Customer = seller.Name, OrgCode = stock.ErpOrgCode, StockCode = stock.Code, - Qty = pList.Sum(s => s.Product_Valid_Num), - BeforeQty = pList.Sum(s => s.Product_Total) + Qty = first.Product_Valid_Num,//pList.Sum(s => s.Product_Valid_Num), + BeforeQty = first.Product_Total//pList.Sum(s => s.Product_Total) }; inventoryList.Add(entity); } diff --git a/src/WMS.Web.Domain/Services/Public/LingXingService.cs b/src/WMS.Web.Domain/Services/Public/LingXingService.cs index 2c097ac7..3fa38da3 100644 --- a/src/WMS.Web.Domain/Services/Public/LingXingService.cs +++ b/src/WMS.Web.Domain/Services/Public/LingXingService.cs @@ -129,6 +129,7 @@ namespace WMS.Web.Domain.Services.Public /// public async Task>> GetInventory(LingXingInventoryRequest dto) { + //dto.sku = "NTONPOWER-OSP-3A2U-US-BK-4.6M"; var resUrl = await GetStr("/erp/sc/routing/data/local_inventory/inventoryDetails", dto); if (!resUrl.IsSuccess) return Result>.ReFailure(ResultCodes.LingXingUrlError); List list = new List(); @@ -136,26 +137,28 @@ namespace WMS.Web.Domain.Services.Public if (res.Code != 0) { _logger.LogInformation($"领星获取数据失败{res.Message}"); - return Result>.ReFailure(ResultCodes.LingXingDataError); + return Result>.ReFailure(ResultCodes.LingXingDataError); } list.AddRange(JsonConvert.DeserializeObject>(res.Data.ToString())); - + //var b = list.Where(w => w.SKU.Equals("NTONPOWER-OSP-3A2U-US-BK-4.6M")).ToList(); int num = res.Total / 800; for (int i = 1; i <= num; i++) { Thread.Sleep(1000);//怕拉取过于频繁接口限制 dto.offset = i; if (i == num) dto.length = res.Total - (num * 800); - resUrl = await GetStr("/erp/sc/routing/data/local_inventory/inventoryDetails", dto); - if (!resUrl.IsSuccess) return Result>.ReFailure(ResultCodes.LingXingUrlError); - res = await _httpClientService.PostAsync(resUrl.Data, JsonConvert.SerializeObject(dto), null); - if (res.Code != 0) + var resUrl_f = await GetStr("/erp/sc/routing/data/local_inventory/inventoryDetails", dto); + if (!resUrl_f.IsSuccess) return Result>.ReFailure(ResultCodes.LingXingUrlError); + var res_f = await _httpClientService.PostAsync(resUrl_f.Data, JsonConvert.SerializeObject(dto), null); + if (res_f.Code != 0) { _logger.LogInformation($"领星获取数据失败{res.Message}"); return Result>.ReFailure(ResultCodes.LingXingDataError); } - list.AddRange(JsonConvert.DeserializeObject>(res.Data.ToString())); + list.AddRange(JsonConvert.DeserializeObject>(res_f.Data.ToString())); + //var bc = list.Where(w => w.SKU.Equals("NTONPOWER-OSP-3A2U-US-BK-4.6M")).ToList(); } + //var bcd = list.Where(w => w.SKU.Equals("NTONPOWER-OSP-3A2U-US-BK-4.6M")).ToList(); return Result>.ReSuccess(list.Where(w => w.Product_Total > 0 && w.Product_Valid_Num > 0).ToList()); } #region 基础函数