|
@ -2,6 +2,9 @@ using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Linq.Expressions; |
|
|
using System.Linq.Expressions; |
|
|
|
|
|
using System.Net.Http.Headers; |
|
|
|
|
|
using System.Net.Http; |
|
|
|
|
|
using System.Text; |
|
|
using System.Threading; |
|
|
using System.Threading; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
@ -15,6 +18,9 @@ using Win_in.Sfs.Shared.Domain.Shared; |
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Store.Domain; |
|
|
using Win_in.Sfs.Wms.Store.Domain; |
|
|
using Win_in.Sfs.Wms.Store.Domain.Shared; |
|
|
using Win_in.Sfs.Wms.Store.Domain.Shared; |
|
|
|
|
|
using Win_in.Sfs.Wms.Store.Jobs.IssueJobs.proxy; |
|
|
|
|
|
using Win_in.Sfs.Wms.Store.Options; |
|
|
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
|
|
|
|
|
namespace Win_in.Sfs.Wms.Store.Application; |
|
|
namespace Win_in.Sfs.Wms.Store.Application; |
|
|
|
|
|
|
|
@ -26,14 +32,69 @@ public class IssueJobAppService |
|
|
IIssueJobAppService |
|
|
IIssueJobAppService |
|
|
{ |
|
|
{ |
|
|
private readonly IIssueJobManager _issueJobManager; |
|
|
private readonly IIssueJobManager _issueJobManager; |
|
|
|
|
|
private readonly IHttpClientFactory _httpClientFactory; |
|
|
|
|
|
private readonly IOptions<AgvOptions> _agvOptions; |
|
|
|
|
|
|
|
|
public IssueJobAppService( |
|
|
public IssueJobAppService( |
|
|
IIssueJobRepository repository, IIssueJobManager issueJobManager |
|
|
IIssueJobRepository repository, IIssueJobManager issueJobManager,IHttpClientFactory httpClientFactory, IOptions<AgvOptions> agvOptions |
|
|
) : base(repository, issueJobManager) |
|
|
) : base(repository, issueJobManager) |
|
|
{ |
|
|
{ |
|
|
_issueJobManager = issueJobManager; |
|
|
_issueJobManager = issueJobManager; |
|
|
|
|
|
_httpClientFactory = httpClientFactory; |
|
|
|
|
|
_agvOptions = agvOptions; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 余料回库
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="jobdto"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("NotifyOutTaskBack4FW")] |
|
|
|
|
|
public async Task<AgvResultObject> CallReturn(AgvRequestBack jobdto) |
|
|
|
|
|
{ |
|
|
|
|
|
var client = await GetAgvJobClient().ConfigureAwait(false); |
|
|
|
|
|
var ret = await client.NotifyOutTaskBack4FWAsync(jobdto).ConfigureAwait(false); |
|
|
|
|
|
return ret; |
|
|
|
|
|
} |
|
|
|
|
|
private async Task<AgvJobClient> GetAgvJobClient() |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
var httpclient = _httpClientFactory.CreateClient(); |
|
|
|
|
|
_agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address) |
|
|
|
|
|
? "http://7e42682n64.goho.co:21171/" |
|
|
|
|
|
: _agvOptions.Value.Address; //测试地址
|
|
|
|
|
|
_agvOptions.Value.Token = |
|
|
|
|
|
string.IsNullOrEmpty(_agvOptions.Value.Token) ? string.Empty : _agvOptions.Value.Token; //测试token
|
|
|
|
|
|
_agvOptions.Value.UserName = |
|
|
|
|
|
string.IsNullOrEmpty(_agvOptions.Value.UserName) ? "" : _agvOptions.Value.UserName; //测试用户名
|
|
|
|
|
|
_agvOptions.Value.Password = |
|
|
|
|
|
string.IsNullOrEmpty(_agvOptions.Value.Password) ? "" : _agvOptions.Value.Password; //测试密码
|
|
|
|
|
|
_agvOptions.Value.Path = string.IsNullOrEmpty(_agvOptions.Value.Path) |
|
|
|
|
|
? "zozocnApi/custom/receiveProductionPlan" |
|
|
|
|
|
: _agvOptions.Value.Path; //测试密码
|
|
|
|
|
|
var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_agvOptions.Value.Token)) |
|
|
|
|
|
{ |
|
|
|
|
|
var token = _agvOptions.Value.Token; |
|
|
|
|
|
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_agvOptions.Value.UserName) && !string.IsNullOrEmpty(_agvOptions.Value.Password)) |
|
|
|
|
|
{ |
|
|
|
|
|
var username = _agvOptions.Value.UserName; |
|
|
|
|
|
var password = _agvOptions.Value.Password; |
|
|
|
|
|
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", |
|
|
|
|
|
Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path); |
|
|
|
|
|
return client; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 根据物品和库位 检查是否存在发料任务
|
|
|
/// 根据物品和库位 检查是否存在发料任务
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|