|
|
@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Net.Http; |
|
|
|
using System.Net.Http.Headers; |
|
|
|
using System.Text; |
|
|
@ -17,6 +18,7 @@ using Volo.Abp.Threading; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
using Win_in.Sfs.Wms.DataExchange.Domain; |
|
|
|
using Win_in.Sfs.Wms.DataExchange.Domain.Shared; |
|
|
|
using Win_in.Sfs.Wms.DataExchange.Wms; |
|
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|
|
|
using static IdentityServer4.Models.IdentityResources; |
|
|
|
|
|
|
@ -156,24 +158,69 @@ public class IncomingToWmsWorker : AsyncPeriodicBackgroundWorkerBase |
|
|
|
await incomingToWms.HandleInventoryLabelsAsync(workerContext).ConfigureAwait(false); |
|
|
|
break; |
|
|
|
case EnumIncomingDataType.BackFlush: |
|
|
|
await incomingToWms.HandleBackFlushsAsync(workerContext).ConfigureAwait(false); |
|
|
|
|
|
|
|
// await incomingToWms.HandleBackFlushsAsync(workerContext).ConfigureAwait(false);
|
|
|
|
await SendBackFlush(workerContext, incomingToWms).ConfigureAwait(false); |
|
|
|
break; |
|
|
|
case EnumIncomingDataType.None: |
|
|
|
default: |
|
|
|
throw new ArgumentOutOfRangeException(); |
|
|
|
} |
|
|
|
|
|
|
|
if( incomingToWms.Status != EnumExchangeDataStatus.Error) |
|
|
|
{ |
|
|
|
incomingToWms.SetSuccess(); |
|
|
|
} |
|
|
|
} |
|
|
|
private async Task SendBackFlush(PeriodicBackgroundWorkerContext workerContext, IncomingToWms incomingToWms) |
|
|
|
{ // 定义请求的 URL
|
|
|
|
// string apiUrl = "http://10.164.113.31:60085/api/wms/store/product-receipt-note";
|
|
|
|
|
|
|
|
string apiUrl = _options.Value.IncomingOptions.apiUrl+ "api/wms/store/backFlush-note/create-many"; |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_options.Value.IncomingOptions.apiUrl)) |
|
|
|
{ |
|
|
|
var backflushJson = JsonSerializer.Deserialize<BackFlushNoteEditInput>(incomingToWms.DataContent); |
|
|
|
List<BackFlushNoteEditInput> backflush = new List<BackFlushNoteEditInput>(); |
|
|
|
backflush.Add(backflushJson); |
|
|
|
try |
|
|
|
{ |
|
|
|
|
|
|
|
// 将参数转换为 JSON 格式
|
|
|
|
string jsonContent = JsonSerializer.Serialize(backflush); |
|
|
|
|
|
|
|
// 创建请求的内容
|
|
|
|
StringContent content = new StringContent(jsonContent, Encoding.UTF8, "application/json"); |
|
|
|
|
|
|
|
|
|
|
|
// 发送 POST 请求
|
|
|
|
HttpResponseMessage response = await _httpClient.PostAsync(apiUrl, content).ConfigureAwait(false); |
|
|
|
|
|
|
|
// 确保响应成功
|
|
|
|
response.EnsureSuccessStatusCode(); |
|
|
|
|
|
|
|
// 读取响应内容并返回
|
|
|
|
string responseBody = await response.Content.ReadAsStringAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
catch (HttpRequestException ex) |
|
|
|
{ |
|
|
|
// 处理请求异常
|
|
|
|
// 可以记录日志或者抛出异常
|
|
|
|
Console.WriteLine(ex.Message); |
|
|
|
incomingToWms.SetError(EnumExchangeDataErrorCode.Exception, ex.Message); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Console.WriteLine("apiUrl未配置!"); |
|
|
|
incomingToWms.SetError(EnumExchangeDataErrorCode.Exception, "apiUrl未配置!"); |
|
|
|
} |
|
|
|
} |
|
|
|
private async Task SendProductReceipt(PeriodicBackgroundWorkerContext workerContext, IncomingToWms incomingToWms) |
|
|
|
{ // 定义请求的 URL
|
|
|
|
// string apiUrl = "http://10.164.113.31:60085/api/wms/store/product-receipt-note";
|
|
|
|
|
|
|
|
string apiUrl = _options.Value.IncomingOptions.apiUrl; |
|
|
|
string apiUrl = _options.Value.IncomingOptions.apiUrl + "api/wms/store/product-receipt-note"; |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(apiUrl)) |
|
|
|
if (!string.IsNullOrEmpty(_options.Value.IncomingOptions.apiUrl)) |
|
|
|
{ |
|
|
|
var productReceiptJson = JsonSerializer.Deserialize<ProductReceiptNoteEditInput>(incomingToWms.DataContent); |
|
|
|
productReceiptJson.Worker = "Mes"; |
|
|
@ -201,13 +248,13 @@ public class IncomingToWmsWorker : AsyncPeriodicBackgroundWorkerBase |
|
|
|
// 处理请求异常
|
|
|
|
// 可以记录日志或者抛出异常
|
|
|
|
Console.WriteLine(ex.Message); |
|
|
|
//incomingToWms.SetError(EnumExchangeDataErrorCode.Exception, ex.Message);
|
|
|
|
incomingToWms.SetError(EnumExchangeDataErrorCode.Exception, ex.Message); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Console.WriteLine("apiUrl未配置!"); |
|
|
|
|
|
|
|
incomingToWms.SetError(EnumExchangeDataErrorCode.Exception, "apiUrl未配置!"); |
|
|
|
} |
|
|
|
//finally
|
|
|
|
//{
|
|
|
|