14 changed files with 1004 additions and 277 deletions
@ -0,0 +1,94 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Net.Http.Headers; |
|||
using System.Net.Http; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using MyNamespace; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Uow; |
|||
using Volo.Abp.Users; |
|||
using Win_in.Sfs.Basedata.Application.Contracts; |
|||
using Win_in.Sfs.Basedata.Domain; |
|||
using Win_in.Sfs.Basedata.Domain.Shared; |
|||
using Win_in.Sfs.Shared.Domain.Shared; |
|||
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
|||
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
using Win_in.Sfs.Wms.Store.Domain.Shared; |
|||
using Win_in.Sfs.Wms.Store.Jobs.IssueJobs.proxy; |
|||
using Microsoft.Extensions.Options; |
|||
using Win_in.Sfs.Wms.Store.Options; |
|||
using Microsoft.Extensions.Logging; |
|||
using Win_in.Sfs.Shared.Application.Contracts; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Jobs.AgvJobs; |
|||
[AllowAnonymous] |
|||
[Route($"{StoreConsts.RootPath}agv-job-in")] |
|||
public class AgvJobOutputService : ApplicationService, IAgvJobOutputService |
|||
{ |
|||
private readonly UnitOfWorkManager _unitOfWorkManager; |
|||
private readonly IHttpClientFactory _httpClientFactory; |
|||
private readonly IOptions<AgvOptions> _options; |
|||
private readonly ILogger<AgvJobOutputService> _logger; |
|||
|
|||
public AgvJobOutputService( |
|||
UnitOfWorkManager unitOfWorkManager, |
|||
IHttpClientFactory httpClientFactory, |
|||
IOptions<AgvOptions> options, |
|||
ILogger<AgvJobOutputService> logger |
|||
|
|||
) |
|||
{ |
|||
_logger = logger; |
|||
_unitOfWorkManager = unitOfWorkManager; |
|||
_httpClientFactory = httpClientFactory; |
|||
_options = options; |
|||
} |
|||
|
|||
|
|||
|
|||
[HttpPost("out-put-task")] |
|||
public async Task<AgvResultObject> OutPutTaskAsync(AgvRequest request) |
|||
{ |
|||
var httpclient = _httpClientFactory.CreateClient(); |
|||
_options.Value.Address = string.IsNullOrEmpty(_options.Value.Address) |
|||
? "http://7e42682n64.goho.co:21171/" |
|||
: _options.Value.Address; //测试地址
|
|||
_options.Value.Token = |
|||
string.IsNullOrEmpty(_options.Value.Token) ? string.Empty : _options.Value.Token; //测试token
|
|||
_options.Value.UserName = |
|||
string.IsNullOrEmpty(_options.Value.UserName) ? "" : _options.Value.UserName; //测试用户名
|
|||
_options.Value.Password = |
|||
string.IsNullOrEmpty(_options.Value.Password) ? "" : _options.Value.Password; //测试密码
|
|||
_options.Value.Path = string.IsNullOrEmpty(_options.Value.Path) |
|||
? "zozocnApi/custom/receiveProductionPlan" |
|||
: _options.Value.Path; //测试密码
|
|||
var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); |
|||
// _logger.LogInformation($"标志{flag}开始调用高通WMS:传递值{JsonSerializer.Serialize(main)}");
|
|||
if (!string.IsNullOrEmpty(_options.Value.Token)) |
|||
{ |
|||
var token = _options.Value.Token; |
|||
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); |
|||
} |
|||
|
|||
if (!string.IsNullOrEmpty(_options.Value.UserName) && !string.IsNullOrEmpty(_options.Value.Password)) |
|||
{ |
|||
var username = _options.Value.UserName; |
|||
var password = _options.Value.Password; |
|||
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", |
|||
Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); |
|||
} |
|||
|
|||
var client = new AgvJobClient(_options.Value.Address, httpclient, _options.Value.Path); |
|||
var ret = await client.PushOutTask4FWAsync(request).ConfigureAwait(false); |
|||
|
|||
return ret; |
|||
|
|||
} |
|||
|
|||
|
|||
} |
@ -1,155 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Net.Http.Headers; |
|||
using System.Net.Http; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using MyNamespace; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Uow; |
|||
using Volo.Abp.Users; |
|||
using Win_in.Sfs.Basedata.Application.Contracts; |
|||
using Win_in.Sfs.Basedata.Domain; |
|||
using Win_in.Sfs.Basedata.Domain.Shared; |
|||
using Win_in.Sfs.Shared.Domain.Shared; |
|||
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
|||
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
using Win_in.Sfs.Wms.Store.Domain.Shared; |
|||
using Win_in.Sfs.Wms.Store.Jobs.IssueJobs.proxy; |
|||
using Microsoft.Extensions.Options; |
|||
using Win_in.Sfs.Wms.Store.Options; |
|||
using Microsoft.Extensions.Logging; |
|||
using Win_in.Sfs.Shared.Application.Contracts; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Jobs.IssueJobs.AgvServices; |
|||
[AllowAnonymous] |
|||
[Route($"{StoreConsts.RootPath}agv-job-in")] |
|||
public class AgvJobOutputService : ApplicationService, IAgvJobOutputService |
|||
{ |
|||
private readonly UnitOfWorkManager _unitOfWorkManager; |
|||
private readonly IHttpClientFactory _httpClientFactory; |
|||
private readonly IOptions<AgvOptions> _options; |
|||
private readonly ILogger<AgvJobOutputService> _logger; |
|||
|
|||
public AgvJobOutputService( |
|||
UnitOfWorkManager unitOfWorkManager, |
|||
IHttpClientFactory httpClientFactory, |
|||
IOptions<AgvOptions> options, |
|||
ILogger<AgvJobOutputService> logger |
|||
|
|||
) |
|||
{ |
|||
_logger = logger; |
|||
_unitOfWorkManager = unitOfWorkManager; |
|||
_httpClientFactory = httpClientFactory; |
|||
_options = options; |
|||
} |
|||
|
|||
|
|||
//public async Task<AgvResultObject> OutPutTaskAsync<T, TDetail>(T entity) where T : SfsJobDTOBase<TDetail>
|
|||
// where TDetail : SfsDetailDTOBase
|
|||
//{
|
|||
// if (entity is CoatingIssueJobDTO)
|
|||
// {
|
|||
// var coating = entity as CoatingIssueJobDTO;
|
|||
// var first = coating.Details.FirstOrDefault();
|
|||
// var requst = new AgvRequest();
|
|||
// requst.MatCode = first.ItemCode;
|
|||
// requst.MatQty = first.HandledToQty;
|
|||
// requst.OrderNum = entity.Number;
|
|||
// requst.OrderType = "1";
|
|||
// await OutPutTaskAsync(requst).ConfigureAwait(false);
|
|||
// }
|
|||
// else if (entity is AssembleIssueJobDTO)
|
|||
// {
|
|||
// var assemble = entity as AssembleIssueJobDTO;
|
|||
// var first = assemble.Details.FirstOrDefault();
|
|||
// var requst = new AgvRequest();
|
|||
// requst.MatCode = first.ItemCode;
|
|||
// requst.MatQty = first.HandledToQty;
|
|||
// requst.OrderNum = entity.Number;
|
|||
// requst.OrderType = "2";
|
|||
// return await OutPutTaskAsync(requst).ConfigureAwait(false);
|
|||
// }
|
|||
// else if (entity is InjectionIssueJobDTO)
|
|||
// {
|
|||
// var injection = entity as InjectionIssueJobDTO;
|
|||
// var first = injection.Details.FirstOrDefault();
|
|||
// var requst = new AgvRequest();
|
|||
// requst.MatCode = first.ItemCode;
|
|||
// requst.MatQty = first.HandledToQty;
|
|||
// requst.OrderNum = entity.Number;
|
|||
// requst.OrderType = "3";
|
|||
|
|||
// return await OutPutTaskAsync(requst).ConfigureAwait(false);
|
|||
// }
|
|||
// else if (entity is KittingIssueJobDTO)
|
|||
// {
|
|||
// var kitting = entity as KittingIssueJobDTO;
|
|||
// var first = kitting.Details.FirstOrDefault();
|
|||
// var requst = new AgvRequest();
|
|||
// requst.MatCode = first.ItemCode;
|
|||
// requst.MatQty = first.HandledToQty;
|
|||
// requst.OrderNum = entity.Number;
|
|||
// requst.OrderType = "4";
|
|||
|
|||
// return await OutPutTaskAsync(requst).ConfigureAwait(false);
|
|||
// }
|
|||
// else if (entity is SparePartIssueJobDTO)
|
|||
// {
|
|||
// var sparePart = entity as SparePartIssueJobDTO;
|
|||
// var first = sparePart.Details.FirstOrDefault();
|
|||
// var requst = new AgvRequest();
|
|||
// requst.MatCode = first.ItemCode;
|
|||
// requst.MatQty = first.HandledToQty;
|
|||
// requst.OrderNum = entity.Number;
|
|||
// requst.OrderType = "1";
|
|||
|
|||
// await OutPutTaskAsync(requst).ConfigureAwait(false);
|
|||
// }
|
|||
//}
|
|||
[HttpPost("out-put-task")] |
|||
public async Task<AgvResultObject> OutPutTaskAsync(AgvRequest request) |
|||
{ |
|||
var httpclient = _httpClientFactory.CreateClient(); |
|||
_options.Value.Address = string.IsNullOrEmpty(_options.Value.Address) |
|||
? "http://7e42682n64.goho.co:21171/" |
|||
: _options.Value.Address; //测试地址
|
|||
_options.Value.Token = |
|||
string.IsNullOrEmpty(_options.Value.Token) ? string.Empty : _options.Value.Token; //测试token
|
|||
_options.Value.UserName = |
|||
string.IsNullOrEmpty(_options.Value.UserName) ? "" : _options.Value.UserName; //测试用户名
|
|||
_options.Value.Password = |
|||
string.IsNullOrEmpty(_options.Value.Password) ? "" : _options.Value.Password; //测试密码
|
|||
_options.Value.Path = string.IsNullOrEmpty(_options.Value.Path) |
|||
? "zozocnApi/custom/receiveProductionPlan" |
|||
: _options.Value.Path; //测试密码
|
|||
var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); |
|||
// _logger.LogInformation($"标志{flag}开始调用高通WMS:传递值{JsonSerializer.Serialize(main)}");
|
|||
if (!string.IsNullOrEmpty(_options.Value.Token)) |
|||
{ |
|||
var token = _options.Value.Token; |
|||
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); |
|||
} |
|||
|
|||
if (!string.IsNullOrEmpty(_options.Value.UserName) && !string.IsNullOrEmpty(_options.Value.Password)) |
|||
{ |
|||
var username = _options.Value.UserName; |
|||
var password = _options.Value.Password; |
|||
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", |
|||
Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); |
|||
} |
|||
|
|||
var client = new AgvJobClient(_options.Value.Address, httpclient, _options.Value.Path); |
|||
var ret = await client.PushOutTask4FWAsync(request).ConfigureAwait(false); |
|||
|
|||
return ret; |
|||
|
|||
} |
|||
|
|||
|
|||
} |
Loading…
Reference in new issue