This commit is contained in:
18942506660
2024-10-31 11:57:49 +08:00
parent 0e2b6c259e
commit 21d7595a36
4 changed files with 26 additions and 11 deletions

View File

@@ -4075,6 +4075,11 @@
仓库Id 1,3,234,33
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.LingXing.LingXingInventoryRequest.sku">
<summary>
物料规格型号
</summary>
</member>
<member name="T:WMS.Web.Core.Dto.LingXing.LingXingInventoryResponse">
<summary>
领星即时库存

View File

@@ -16,5 +16,11 @@ namespace WMS.Web.Core.Dto.LingXing
/// </summary>
[JsonProperty("wid")]
public string wid { get; set; }
/// <summary>
/// 物料规格型号
/// </summary>
[JsonProperty("sku")]
public string sku { get; set; }
}
}

View File

@@ -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<ProductInventory> inventoryList = new List<ProductInventory>();
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);
}

View File

@@ -129,6 +129,7 @@ namespace WMS.Web.Domain.Services.Public
/// <exception cref="NotImplementedException"></exception>
public async Task<Result<List<LingXingInventoryResponse>>> GetInventory(LingXingInventoryRequest dto)
{
//dto.sku = "NTONPOWER-OSP-3A2U-US-BK-4.6M";
var resUrl = await GetStr<LingXingInventoryRequest>("/erp/sc/routing/data/local_inventory/inventoryDetails", dto);
if (!resUrl.IsSuccess) return Result<List<LingXingInventoryResponse>>.ReFailure(ResultCodes.LingXingUrlError);
List<LingXingInventoryResponse> list = new List<LingXingInventoryResponse>();
@@ -136,26 +137,28 @@ namespace WMS.Web.Domain.Services.Public
if (res.Code != 0)
{
_logger.LogInformation($"领星获取数据失败{res.Message}");
return Result<List<LingXingInventoryResponse>>.ReFailure(ResultCodes.LingXingDataError);
return Result<List<LingXingInventoryResponse>>.ReFailure(ResultCodes.LingXingDataError);
}
list.AddRange(JsonConvert.DeserializeObject<List<LingXingInventoryResponse>>(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<LingXingInventoryRequest>("/erp/sc/routing/data/local_inventory/inventoryDetails", dto);
if (!resUrl.IsSuccess) return Result<List<LingXingInventoryResponse>>.ReFailure(ResultCodes.LingXingUrlError);
res = await _httpClientService.PostAsync<LingXingResponse>(resUrl.Data, JsonConvert.SerializeObject(dto), null);
if (res.Code != 0)
var resUrl_f = await GetStr<LingXingInventoryRequest>("/erp/sc/routing/data/local_inventory/inventoryDetails", dto);
if (!resUrl_f.IsSuccess) return Result<List<LingXingInventoryResponse>>.ReFailure(ResultCodes.LingXingUrlError);
var res_f = await _httpClientService.PostAsync<LingXingResponse>(resUrl_f.Data, JsonConvert.SerializeObject(dto), null);
if (res_f.Code != 0)
{
_logger.LogInformation($"领星获取数据失败{res.Message}");
return Result<List<LingXingInventoryResponse>>.ReFailure(ResultCodes.LingXingDataError);
}
list.AddRange(JsonConvert.DeserializeObject<List<LingXingInventoryResponse>>(res.Data.ToString()));
list.AddRange(JsonConvert.DeserializeObject<List<LingXingInventoryResponse>>(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<List<LingXingInventoryResponse>>.ReSuccess(list.Where(w => w.Product_Total > 0 && w.Product_Valid_Num > 0).ToList());
}
#region