测试
This commit is contained in:
Binary file not shown.
@@ -26,6 +26,6 @@ namespace WMS.Web.Domain.IService.Public
|
|||||||
/// 获取即时库存
|
/// 获取即时库存
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task<Result<List<LingXingInventoryResponse>>> GetInventory(LingXingInventoryRequest dto);
|
public Task<Result<List<LingXingInventoryResponse>>> GetInventory(List<int> ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ namespace WMS.Web.Domain.Services
|
|||||||
var ids = resStock.Data.Where(w => listNames.Contains(w.Name)).Select(s => s.Id).ToList();
|
var ids = resStock.Data.Where(w => listNames.Contains(w.Name)).Select(s => s.Id).ToList();
|
||||||
string strIds = string.Join(",", ids);
|
string strIds = string.Join(",", ids);
|
||||||
//获取领星库存
|
//获取领星库存
|
||||||
var resInventory = await _lingXingService.GetInventory(new Core.Dto.LingXing.LingXingInventoryRequest() { wid = strIds });
|
var resInventory = await _lingXingService.GetInventory(ids);
|
||||||
_logger.LogInformation($"拉取领星数据结果:{resInventory.IsSuccess} {resInventory.Message}");
|
_logger.LogInformation($"拉取领星数据结果:{resInventory.IsSuccess} {resInventory.Message}");
|
||||||
if (!resInventory.IsSuccess) return resStock;
|
if (!resInventory.IsSuccess) return resStock;
|
||||||
|
|
||||||
|
|||||||
@@ -142,41 +142,47 @@ namespace WMS.Web.Domain.Services.Public
|
|||||||
/// <param name="dto"></param>
|
/// <param name="dto"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
public async Task<Result<List<LingXingInventoryResponse>>> GetInventory(LingXingInventoryRequest dto)
|
public async Task<Result<List<LingXingInventoryResponse>>> GetInventory(List<int> ids)
|
||||||
{
|
{
|
||||||
//dto.length = 50;
|
|
||||||
//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>();
|
List<LingXingInventoryResponse> list = new List<LingXingInventoryResponse>();
|
||||||
var res = await _httpClientService.PostAsync<LingXingResponse>(resUrl.Data, JsonConvert.SerializeObject(dto), null);
|
foreach (var id in ids)
|
||||||
if (res.Code != 0)
|
|
||||||
{
|
{
|
||||||
_logger.LogInformation($"领星获取数据失败{res.Message}");
|
LingXingInventoryRequest dto = new LingXingInventoryRequest();
|
||||||
return Result<List<LingXingInventoryResponse>>.ReFailure(ResultCodes.LingXingDataError);
|
dto.wid = id.ToString();
|
||||||
}
|
//dto.length = 50;
|
||||||
list.AddRange(JsonConvert.DeserializeObject<List<LingXingInventoryResponse>>(res.Data.ToString()));
|
//dto.sku = "NTONPOWER-OSP-3A2U-US-BK-4.6M";
|
||||||
//var b = list.Where(w => w.SKU.Equals("NTONPOWER-OSP-3A2U-US-BK-4.6M")).ToList();
|
var resUrl = await GetStr<LingXingInventoryRequest>("/erp/sc/routing/data/local_inventory/inventoryDetails", dto);
|
||||||
int num = res.Total / 800;
|
if (!resUrl.IsSuccess) return Result<List<LingXingInventoryResponse>>.ReFailure(ResultCodes.LingXingUrlError);
|
||||||
for (int i = 1; i <= num; i++)
|
|
||||||
{
|
var res = await _httpClientService.PostAsync<LingXingResponse>(resUrl.Data, JsonConvert.SerializeObject(dto), null);
|
||||||
Thread.Sleep(1000);//怕拉取过于频繁接口限制
|
if (res.Code != 0)
|
||||||
dto.offset = i * 800;
|
|
||||||
if (i == num) dto.length = res.Total - (num * 800);
|
|
||||||
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}");
|
_logger.LogInformation($"领星获取数据失败{res.Message}");
|
||||||
return Result<List<LingXingInventoryResponse>>.ReFailure(ResultCodes.LingXingDataError);
|
return Result<List<LingXingInventoryResponse>>.ReFailure(ResultCodes.LingXingDataError);
|
||||||
}
|
}
|
||||||
var d = JsonConvert.DeserializeObject<List<LingXingInventoryResponse>>(res_f.Data.ToString());
|
list.AddRange(JsonConvert.DeserializeObject<List<LingXingInventoryResponse>>(res.Data.ToString()));
|
||||||
//var bc = d.Where(w => w.SKU.Equals("NTONPOWER-OSP-3A2U-US-BK-4.6M")).Any();
|
//var b = list.Where(w => w.SKU.Equals("NTONPOWER-OSP-3A2U-US-BK-4.6M")).ToList();
|
||||||
//_logger.LogInformation($"次数:{i} 是否存在{bc}");
|
int num = res.Total / 800;
|
||||||
|
for (int i = 1; i <= num; i++)
|
||||||
|
{
|
||||||
|
Thread.Sleep(1000);//怕拉取过于频繁接口限制
|
||||||
|
dto.offset = i * 800;
|
||||||
|
if (i == num) dto.length = res.Total - (num * 800);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
var d = JsonConvert.DeserializeObject<List<LingXingInventoryResponse>>(res_f.Data.ToString());
|
||||||
|
//var bc = d.Where(w => w.SKU.Equals("NTONPOWER-OSP-3A2U-US-BK-4.6M")).Any();
|
||||||
|
//_logger.LogInformation($"次数:{i} 是否存在{bc}");
|
||||||
|
|
||||||
list.AddRange(d);
|
list.AddRange(d);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//var bcd = 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());
|
return Result<List<LingXingInventoryResponse>>.ReSuccess(list.Where(w => w.Product_Total > 0 && w.Product_Valid_Num > 0).ToList());
|
||||||
|
|||||||
Reference in New Issue
Block a user