|
|
@ -168,30 +168,19 @@ public class IncomingToWmsWorker : AsyncPeriodicBackgroundWorkerBase |
|
|
|
|
|
|
|
private async Task SendProductReceipt(PeriodicBackgroundWorkerContext workerContext, IncomingToWms incomingToWms) |
|
|
|
{ // 定义请求的 URL
|
|
|
|
string apiUrl = "http://localhost:59095/api/wms/store/product-receipt-note"; |
|
|
|
string apiUrl = "http://dev.ccwin-in.com:60085/api/wms/store/product-receipt-note"; |
|
|
|
string authUrl = "http://dev.ccwin-in.com:60083"; |
|
|
|
var productReceiptJson = JsonSerializer.Deserialize<ProductReceiptNoteEditInput>(incomingToWms.DataContent); |
|
|
|
try |
|
|
|
{ |
|
|
|
Thread.Sleep(60000); |
|
|
|
|
|
|
|
// 将参数转换为 JSON 格式
|
|
|
|
string jsonContent = JsonSerializer.Serialize(productReceiptJson); |
|
|
|
|
|
|
|
// 创建请求的内容
|
|
|
|
StringContent content = new StringContent(jsonContent, Encoding.UTF8, "application/json"); |
|
|
|
|
|
|
|
var result = await _httpClientFactory.CreateClient().RequestPasswordTokenAsync(new PasswordTokenRequest |
|
|
|
{ |
|
|
|
Address = $"{authUrl.TrimEnd('/')}/connect/token", |
|
|
|
GrantType = "password", |
|
|
|
ClientId = "Auth_App", |
|
|
|
ClientSecret = "1q2w3E*", |
|
|
|
UserName = "jiekou1", |
|
|
|
Password = "1q2w3E*" |
|
|
|
}).ConfigureAwait(false); |
|
|
|
|
|
|
|
// 添加 Token 到请求头部
|
|
|
|
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken); |
|
|
|
|
|
|
|
// 发送 POST 请求
|
|
|
|
HttpResponseMessage response = await _httpClient.PostAsync(apiUrl, content); |
|
|
|
|
|
|
@ -205,9 +194,21 @@ public class IncomingToWmsWorker : AsyncPeriodicBackgroundWorkerBase |
|
|
|
{ |
|
|
|
// 处理请求异常
|
|
|
|
// 可以记录日志或者抛出异常
|
|
|
|
Console.WriteLine(ex.Message); |
|
|
|
Console.WriteLine(ex.Message); |
|
|
|
incomingToWms.SetError(EnumExchangeDataErrorCode.Exception, ex.Message); |
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
//Resolve dependencies
|
|
|
|
var incomingToWmsManager = workerContext.ServiceProvider.GetRequiredService<IIncomingToWmsManager>(); |
|
|
|
//Do the work
|
|
|
|
var incomingToWmsList = await incomingToWmsManager.GetToBeProcessedListAsync().ConfigureAwait(false); |
|
|
|
//归档并删除
|
|
|
|
await incomingToWmsManager.ArchiveAutoSaveAsync(incomingToWms).ConfigureAwait(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// await incomingToWms.HandleProductReceiptsAsync(workerContext).ConfigureAwait(false);
|
|
|
|
|
|
|
|
await incomingToWms.HandleProductReceiptsAsync(workerContext).ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|