|
@ -141,7 +141,7 @@ public class IncomingToWmsWorker : AsyncPeriodicBackgroundWorkerBase |
|
|
await incomingToWms.HandleAsnsAsync(workerContext).ConfigureAwait(false); |
|
|
await incomingToWms.HandleAsnsAsync(workerContext).ConfigureAwait(false); |
|
|
break; |
|
|
break; |
|
|
case EnumIncomingDataType.ProductReceipt: |
|
|
case EnumIncomingDataType.ProductReceipt: |
|
|
await SendProductReceipt(workerContext, incomingToWms); |
|
|
await SendProductReceipt(workerContext, incomingToWms).ConfigureAwait(false); |
|
|
break; |
|
|
break; |
|
|
case EnumIncomingDataType.MaterialRequest: |
|
|
case EnumIncomingDataType.MaterialRequest: |
|
|
await incomingToWms.HandleMaterialRequestsAsync(workerContext).ConfigureAwait(false); |
|
|
await incomingToWms.HandleMaterialRequestsAsync(workerContext).ConfigureAwait(false); |
|
@ -169,34 +169,44 @@ public class IncomingToWmsWorker : AsyncPeriodicBackgroundWorkerBase |
|
|
|
|
|
|
|
|
private async Task SendProductReceipt(PeriodicBackgroundWorkerContext workerContext, IncomingToWms incomingToWms) |
|
|
private async Task SendProductReceipt(PeriodicBackgroundWorkerContext workerContext, IncomingToWms incomingToWms) |
|
|
{ // 定义请求的 URL
|
|
|
{ // 定义请求的 URL
|
|
|
string apiUrl = "http://10.164.113.31:60085/api/wms/store/product-receipt-note"; |
|
|
// string apiUrl = "http://10.164.113.31:60085/api/wms/store/product-receipt-note";
|
|
|
|
|
|
|
|
|
var productReceiptJson = JsonSerializer.Deserialize<ProductReceiptNoteEditInput>(incomingToWms.DataContent); |
|
|
string apiUrl = _options.Value.IncomingOptions.apiUrl; |
|
|
try |
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(apiUrl)) |
|
|
{ |
|
|
{ |
|
|
|
|
|
var productReceiptJson = JsonSerializer.Deserialize<ProductReceiptNoteEditInput>(incomingToWms.DataContent); |
|
|
// 将参数转换为 JSON 格式
|
|
|
try |
|
|
string jsonContent = JsonSerializer.Serialize(productReceiptJson); |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
// 将参数转换为 JSON 格式
|
|
|
|
|
|
string jsonContent = JsonSerializer.Serialize(productReceiptJson); |
|
|
|
|
|
|
|
|
// 创建请求的内容
|
|
|
// 创建请求的内容
|
|
|
StringContent content = new StringContent(jsonContent, Encoding.UTF8, "application/json"); |
|
|
StringContent content = new StringContent(jsonContent, Encoding.UTF8, "application/json"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 发送 POST 请求
|
|
|
|
|
|
HttpResponseMessage response = await _httpClient.PostAsync(apiUrl, content); |
|
|
|
|
|
|
|
|
|
|
|
// 确保响应成功
|
|
|
// 发送 POST 请求
|
|
|
response.EnsureSuccessStatusCode(); |
|
|
HttpResponseMessage response = await _httpClient.PostAsync(apiUrl, content).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
// 读取响应内容并返回
|
|
|
// 确保响应成功
|
|
|
string responseBody = await response.Content.ReadAsStringAsync(); |
|
|
response.EnsureSuccessStatusCode(); |
|
|
|
|
|
|
|
|
|
|
|
// 读取响应内容并返回
|
|
|
|
|
|
string responseBody = await response.Content.ReadAsStringAsync().ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
catch (HttpRequestException ex) |
|
|
|
|
|
{ |
|
|
|
|
|
// 处理请求异常
|
|
|
|
|
|
// 可以记录日志或者抛出异常
|
|
|
|
|
|
Console.WriteLine(ex.Message); |
|
|
|
|
|
//incomingToWms.SetError(EnumExchangeDataErrorCode.Exception, ex.Message);
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
catch (HttpRequestException ex) |
|
|
else |
|
|
{ |
|
|
{ |
|
|
// 处理请求异常
|
|
|
Console.WriteLine("apiUrl未配置!"); |
|
|
// 可以记录日志或者抛出异常
|
|
|
|
|
|
Console.WriteLine(ex.Message); |
|
|
|
|
|
//incomingToWms.SetError(EnumExchangeDataErrorCode.Exception, ex.Message);
|
|
|
|
|
|
} |
|
|
} |
|
|
//finally
|
|
|
//finally
|
|
|
//{
|
|
|
//{
|
|
|