diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/test/TestAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/test/TestAppService.cs index c07f8a8ae..a31ae087b 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/test/TestAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/test/TestAppService.cs @@ -108,11 +108,11 @@ public class TestService:ApplicationService //} [HttpPost("pushOutTask4FW")] - public async Task pushOutTask4FW(AgvRequest request) + public async Task pushOutTask4FW(AgvRequest1 request) { - AgvResultObject reusltObject = new AgvResultObject(); + AgvResultObject1 reusltObject = new AgvResultObject1(); reusltObject.Code = "0"; reusltObject.Message = "OK"; reusltObject.ReqCode = "T6000001970"; @@ -151,7 +151,7 @@ public class TestService:ApplicationService /// /// 发给立体库主表 /// -public class IssueJobToRestoDetailDTO +public class IssueJobToRestoDetailDTO1 { public string WorkNo { set; get; } public string TaskNo { set; get; } @@ -162,50 +162,50 @@ public class IssueJobToRestoDetailDTO /// /// 发给立体库子表 /// -public class IssueJobToRestoDTO +public class IssueJobToRestoDTO1 { public Guid UUID { set; get; } public string OperatorName { set; get; } - public List Details { set; get; } + public List Details { set; get; } } /// /// 返回结果 /// -public class ReusltObject +public class ReusltObject1 { public string Code { set; get; } public string Message { set; get; } public string OperateTime { set; get; } } -public class AgvResultObject +public class AgvResultObject1 { public string Code { set; get; } public string Message { set; get; } public string ReqCode { set; get; } } #region AGV -public class AgvRequestHK +public class AgvRequestHK1 { [Display(Name ="请求编号")] public string ReqCode { set; get; } [Display(Name ="明细")] - public List Data { set; get; } + public List Data { set; get; } } -public class AgvRequestInputHK +public class AgvRequestInputHK1 { //[Display(Name = "请求编号")] //public string ReqCode { set; get; } [Display(Name = "明细")] - public List Data { set; get; } + public List Data { set; get; } } -public class AgvRequestHKDetail +public class AgvRequestHKDetail1 { [Display(Name = "任务类型")] public string OrderType { set; get; } @@ -244,7 +244,7 @@ public class AgvRequestHKDetail /// /// 闻荫调海康入参 /// -public class AgvRequest +public class AgvRequest1 { [Display(Name = "任务类型")] public string OrderType { set; get; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/AgvJobs/IAgvJobAccountService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/AgvJobs/IAgvJobAccount.cs similarity index 83% rename from be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/AgvJobs/IAgvJobAccountService.cs rename to be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/AgvJobs/IAgvJobAccount.cs index f1bbb2ead..b1936ea13 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/AgvJobs/IAgvJobAccountService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/AgvJobs/IAgvJobAccount.cs @@ -7,7 +7,7 @@ using Volo.Abp; using Volo.Abp.Application.Services; namespace Win_in.Sfs.Wms.Store.Application.Contracts; -public interface IAgvJobAccountService: IApplicationService +public interface IAgvJobAccount { Task AccountOutOrderAsync(AgvRequestOnlyJobHK request); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/proxy/ProxyIssueJobDto.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/IssueJobs/ProxyIssueJobDto.cs similarity index 98% rename from be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/proxy/ProxyIssueJobDto.cs rename to be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/IssueJobs/ProxyIssueJobDto.cs index 924054049..fbda13458 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/proxy/ProxyIssueJobDto.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/IssueJobs/ProxyIssueJobDto.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Win_in.Sfs.Wms.Store.Jobs.IssueJobs.proxy; +namespace Win_in.Sfs.Wms.Store.Application.Contracts; /// /// 喷涂主表 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AgvJobs/AgvJobAccountService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/AgvJobs/AgvJobAccountService.cs similarity index 61% rename from be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AgvJobs/AgvJobAccountService.cs rename to be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/AgvJobs/AgvJobAccountService.cs index 6b91fc539..7bed59019 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AgvJobs/AgvJobAccountService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/AgvJobs/AgvJobAccountService.cs @@ -17,58 +17,66 @@ using Win_in.Sfs.Wms.Inventory.Application.Contracts; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain.Shared; -namespace Win_in.Sfs.Wms.Store.Jobs.IssueJobs.AgvServices; +namespace Win_in.Sfs.Wms.Store.Jobs.AgvJobs; [AllowAnonymous] [Route($"{StoreConsts.RootPath}agv-job-Account")] -public class AgvJobAccountService : ApplicationService, IAgvJobAccountService +public class AgvJobAccountService : ApplicationService { private IAssembleIssueJobAppService _assembleIssueJobAppService; private ICoatingIssueJobAppService _coatingIssueJobAppService; private IInjectionIssueJobAppService _injectionIssueJobAppService; private IKittingIssueJobAppService _kittingIssueJobAppService; private ISparePartIssueJobAppService _sparePartIssueJobAppService; - + private IProductionLineAppService _productionLineAppService; + public AgvJobAccountService( IAssembleIssueJobAppService assembleIssueJobAppService, ICoatingIssueJobAppService coatingIssueJobAppService, - IInjectionIssueJobAppService injectionIssueJobAppService, + IInjectionIssueJobAppService injectionIssueJobAppService, IKittingIssueJobAppService kittingIssueJobAppService, - ISparePartIssueJobAppService sparePartIssueJobAppService - + ISparePartIssueJobAppService sparePartIssueJobAppService, + IProductionLineAppService productionLineAppService ) { _assembleIssueJobAppService = assembleIssueJobAppService; - _coatingIssueJobAppService= coatingIssueJobAppService; - _injectionIssueJobAppService= injectionIssueJobAppService; + _coatingIssueJobAppService = coatingIssueJobAppService; + _injectionIssueJobAppService = injectionIssueJobAppService; _kittingIssueJobAppService = kittingIssueJobAppService; - _sparePartIssueJobAppService= sparePartIssueJobAppService; + _sparePartIssueJobAppService = sparePartIssueJobAppService; + _productionLineAppService = productionLineAppService; } public async Task AccountOutOrderAsync(AgvRequestOnlyJobHK request) { - var res=new AgvResultObject(); + var res = new AgvResultObject(); res.Code = "0"; - foreach (var itm in request.Data) { switch (itm.OrderType) { case "1": + var assemblejob = new AssembleIssueJobDTO(); + var assemb = await _assembleIssueJobAppService.GetByNumberAsync(itm.OrderNum).ConfigureAwait(false); + var assembDetail = assemb.Details.FirstOrDefault(); - var assemblejob= new AssembleIssueJobDTO(); foreach (var detail in request.Data) { + var begin = detail.BeginPosition; + var end = detail.EndPosition; + + await _productionLineAppService.GetByCodeAsync(begin).ConfigureAwait(false); + await _productionLineAppService.GetByCodeAsync(end).ConfigureAwait(false); } - - var assemb=await _assembleIssueJobAppService.GetByNumberAsync(itm.OrderNum).ConfigureAwait(false); + + await _assembleIssueJobAppService.CompleteAsync(assemb.Id).ConfigureAwait(false); res.ReqCode = assemb.AssembleRequestNumber; res.Message = "OK"; @@ -93,6 +101,30 @@ public class AgvJobAccountService : ApplicationService, IAgvJobAccountService } } + return res; + + } + private async Task CheckPostionLocation(AgvRequestOnlyJobHK request, Action action, List errors) + { + foreach (var detail in request.Data) + { + + + + var begin = detail.BeginPosition; + var end = detail.EndPosition; + var beginLocation = await _productionLineAppService.GetByCodeAsync(begin).ConfigureAwait(false); + if (beginLocation == null) + { + errors.Add($"任务号:{detail.OrderNum}开始工作位置号:{begin}没找到对应库位"); + } + var endLocation = await _productionLineAppService.GetByCodeAsync(end).ConfigureAwait(false); + if (endLocation == null) + { + errors.Add($"任务号:{detail.OrderNum}结束工作位置号:{end}没找到对应库位"); + } + } } + } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/AgvJobs/AgvJobOutputService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/AgvJobs/AgvJobOutputService.cs new file mode 100644 index 000000000..4ebaffb6d --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/AgvJobs/AgvJobOutputService.cs @@ -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 _options; + private readonly ILogger _logger; + + public AgvJobOutputService( + UnitOfWorkManager unitOfWorkManager, + IHttpClientFactory httpClientFactory, + IOptions options, + ILogger logger + + ) + { + _logger = logger; + _unitOfWorkManager = unitOfWorkManager; + _httpClientFactory = httpClientFactory; + _options = options; + } + + + + [HttpPost("out-put-task")] + public async Task 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; + + } + + +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AgvJobs/AgvJobOutputService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AgvJobs/AgvJobOutputService.cs deleted file mode 100644 index a4db72739..000000000 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AgvJobs/AgvJobOutputService.cs +++ /dev/null @@ -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 _options; - private readonly ILogger _logger; - - public AgvJobOutputService( - UnitOfWorkManager unitOfWorkManager, - IHttpClientFactory httpClientFactory, - IOptions options, - ILogger logger - - ) - { - _logger = logger; - _unitOfWorkManager = unitOfWorkManager; - _httpClientFactory = httpClientFactory; - _options = options; - } - - - //public async Task OutPutTaskAsync(T entity) where T : SfsJobDTOBase - // 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 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; - - } - - -} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AssembleIssueJobs/AssembleIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AssembleIssueJobs/AssembleIssueJobAppService.cs index 0a6e7c99a..38671265c 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AssembleIssueJobs/AssembleIssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AssembleIssueJobs/AssembleIssueJobAppService.cs @@ -7,12 +7,15 @@ using System.Text; using System.Text.Json; using System.Threading.Tasks; using Castle.Components.DictionaryAdapter; +using DocumentFormat.OpenXml.Spreadsheet; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using MyNamespace; using Omu.ValueInjecter; +using Org.BouncyCastle.Asn1.Ocsp; using Volo.Abp; using Volo.Abp.Domain.Entities; using Volo.Abp.Uow; @@ -35,7 +38,7 @@ namespace Win_in.Sfs.Wms.Store.Application; public class AssembleIssueJobAppService : SfsJobAppServiceBase, - IAssembleIssueJobAppService, ITransferLibCallback + IAssembleIssueJobAppService, ITransferLibCallback, IAgvJobAccount { protected IAssembleIssueRequestAppService AssembleIssueRequestAppService => LazyServiceProvider.LazyGetRequiredService(); @@ -50,24 +53,31 @@ public class AssembleIssueJobAppService private readonly ILogger _logger; private readonly ICurrentUser _currentUser; private readonly UnitOfWorkManager _unitOfWorkManager; + private readonly IOptions _agvOptions; + - private readonly IAgvJobOutputService _agvOutJob; + private readonly IPostionLocationAppService _postionLocationAppService; public AssembleIssueJobAppService( ILogger logger, - IAgvJobOutputService agvOutJob, + IAssembleIssueJobRepository repository, IAssembleIssueJobManager assembleIssueJobManager, ILocationAppService locationAppService, IAssembleIssueNoteAppService assembleIssueNoteAppService, IExpectOutAppService expectOutAppService ,IHttpClientFactory httpClientFactory ,IOptions options, ITransferLibRequestAppService transferLibRequestAppService, - ICurrentUser currentUser, UnitOfWorkManager unitOfWorkManager) : base( + ICurrentUser currentUser, UnitOfWorkManager unitOfWorkManager + , IOptions agvOptions + , IPostionLocationAppService postionLocationAppService + + ) : base( repository, assembleIssueJobManager ) { + _postionLocationAppService= postionLocationAppService; _assembleIssueJobManager = assembleIssueJobManager; _locationAppService = locationAppService; _assembleIssueNoteAppService = assembleIssueNoteAppService; @@ -78,8 +88,8 @@ public class AssembleIssueJobAppService _currentUser = currentUser; _unitOfWorkManager = unitOfWorkManager; _logger = logger; - _agvOutJob = agvOutJob; - + + _agvOptions = agvOptions; } [HttpPost("get-by-number-2")] @@ -594,11 +604,6 @@ public class AssembleIssueJobAppService var dtos = ObjectMapper.Map, List>(entities); - - - - - if (input.Jobs.Count != entities.Count) { errors.Add("立体库提交出库任务和WMS任务不符,请核对! \n"); @@ -606,7 +611,6 @@ public class AssembleIssueJobAppService foreach (var itm in dtos) { - var first = jobs.FirstOrDefault(p => p.JobNumber == itm.Number); var itmDetails = itm.Details.ToList(); var details = new List(); @@ -618,18 +622,13 @@ public class AssembleIssueJobAppService { errors.Add($"来源库位{detail.FromLocationCode}没查到"); } - - var toloc = await _locationAppService.GetByCodeAsync(detail.ToLocationCode) .ConfigureAwait(false); if (toloc == null) { errors.Add($"目标库位{detail.ToLocationCode}没查到"); } - - var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.ItemCode); - if (entity == null) { errors.Add($"物料号{detail.ItemCode}不在任务明细内!"); @@ -911,26 +910,234 @@ public class AssembleIssueJobAppService assembleIssueJobDetailDto.Status, assembleIssueJobDetailDto.HandledToLot, handledToQty).ConfigureAwait(false); } - - /// - /// 调用AgvOutPut出库 - /// - /// - /// - private async Task InvokeAgvOutput(AssembleIssueJobDTO job) + + + [HttpPost("PushOutTask")] + public async Task PushOutTaskAsync(AssembleIssueJobDTO job) { + var ret = new AgvResultObject + { + Code = "0", + ReqCode=job.AssembleRequestNumber, + Message = "OK" + }; + using var unitOfWork = _unitOfWorkManager.Begin(); + try + { + var first = job.Details.FirstOrDefault(); + var request = new AgvRequest(); + request.MatCode = first.ItemCode; + request.MatQty = first.HandledToQty; + request.OrderNum = job.Number; + request.OrderType = "2"; + + 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"); + // _logger.LogInformation($"标志{flag}开始调用高通WMS:传递值{JsonSerializer.Serialize(main)}"); + 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); + ret = await client.PushOutTask4FWAsync(request).ConfigureAwait(false); + + } + catch (Exception e) + { + ret = new AgvResultObject(); + ret.Code = "1"; + ret.Message = e.Message; + ret.ReqCode = job.AssembleRequestNumber; + await unitOfWork.RollbackAsync().ConfigureAwait(false); + + } + return ret; + } + + [HttpPost("accountOutOrder")] + public async Task AccountOutOrderAsync(AgvRequestOnlyJobHK request) + { + var json = JsonSerializer.Serialize(request); + var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); + _logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json); +#if DEBUG +#endif + var errors = new List(); + var first = request.Data.FirstOrDefault(); + var job=await _repository.GetAsync(p => p.Number == first.OrderNum).ConfigureAwait(false); + + var ret = new AgvResultObject + { + Code = "0", + Message = "OK", + ReqCode = job.AssembleRequestNumber, + + }; + using var unitOfWork = _unitOfWorkManager.Begin(); + try + { + if (request.Data.Count > 0) + { + var jobs = request.Data; + var numbers = jobs.Select(p => p.OrderNum); + var query = _repository.WithDetails() + .Where(p => numbers.Contains(p.Number) && p.JobStatus != EnumJobStatus.Done); + var entities = query.ToList(); + if (entities.Count == 0) + { + errors.Add($"任务号{string.Join(",", numbers)}不存在!"); + } + + var dtos = ObjectMapper.Map, List>(entities); + foreach (var itm in dtos) + { + var arys = jobs.Where(p => p.OrderNum == itm.Number); + var itmDetails = itm.Details.ToList(); + var details = new List(); + foreach (var detail in arys) + { - var first = job.Details.FirstOrDefault(); - var requst = new AgvRequest(); - requst.MatCode = first.ItemCode; - requst.MatQty = first.HandledToQty; - requst.OrderNum = job.Number; - requst.OrderType = "2"; - return await _agvOutJob.OutPutTaskAsync(requst).ConfigureAwait(false); + var fromloc = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false); + if (fromloc == null) + { + errors.Add($"来源起始点{detail.BeginPosition}没查到"); + } + + LocationDTO fromlocation = null; + + if (fromloc != null) + { + fromlocation = await _locationAppService.GetByCodeAsync(fromloc.Code).ConfigureAwait(false); + } + if (fromlocation == null) + { + errors.Add($"来源起始点{detail.BeginPosition}库位没查到"); + } + + var toloc = await _postionLocationAppService.GetByCodeAsync(detail.EndPosition) + .ConfigureAwait(false); + if (toloc == null) + { + errors.Add($"结束点{detail.EndPosition}库位没查到"); + } + + LocationDTO tolocation = null; + + if (toloc != null) + { + tolocation = await _locationAppService.GetByCodeAsync(toloc.Code).ConfigureAwait(false); + } + if (tolocation == null) + { + errors.Add($"结束点{detail.EndPosition}库位没查到"); + } + + + var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.MatCode); + if (entity == null) + { + errors.Add($"物料号{detail.MatCode}不在任务明细内!"); + } + + var dto = new AssembleIssueJobDetailDTO(); + dto.InjectFrom(entity); + dto.HandledToLocationCode = toloc.Code; + dto.HandledToLocationGroup = tolocation.LocationGroupCode; + dto.HandledToLocationArea = tolocation.AreaCode; + dto.HandledToLocationErpCode = tolocation.ErpLocationCode; + + dto.HandledToWarehouseCode = tolocation.WarehouseCode; + dto.HandledToQty = detail.MatQty; + dto.HandledToLot =!string.IsNullOrEmpty(detail.BatchAttr07)? detail.BatchAttr07: string.Empty; + dto.HandledToPackingCode = string.Empty; + + dto.HandledFromWarehouseCode = fromlocation.WarehouseCode; + dto.HandledFromLocationCode = fromlocation.Code; + dto.HandledFromLocationGroup = fromlocation.LocationGroupCode; + dto.HandledFromLocationArea = fromlocation.AreaCode; + dto.HandledFromLocationErpCode = fromlocation.ErpLocationCode; + dto.HandledFromQty = detail.MatQty; + dto.HandledFromLot = string.Empty; + dto.HandledFromPackingCode = string.Empty; + details.Add(dto); + + + + + + //await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false); + } + + if (errors.Count > 0) + { + ret = new AgvResultObject() + { + Code = "-1", + ReqCode="", + Message = string.Join(",", errors.ToArray()) + }; + } + itm.Worker = "AGV"; + itm.Details = details; + + _logger.LogInformation($"{flag}接收Agv确认单据内容:" + json + "Agv任务完成"); + } + } + else + { + errors.Add("Agv确认单据里无数据! \n"); + } + } + catch (Exception ex) + { + ret = new AgvResultObject + { + Code = "-1", + ReqCode=job.AssembleRequestNumber, + Message = ex.Message, + }; + await unitOfWork.RollbackAsync(); + return ret; + } + + if (errors.Count > 0) + { + ret = new AgvResultObject + { + Code = "-1", + Message = string.Join(",", errors.ToArray()), + ReqCode=job.AssembleRequestNumber + }; + } + return ret; } + + #endregion } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs index 7037b6de8..2add5f9a5 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs @@ -13,11 +13,13 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using MyNamespace; +using Omu.ValueInjecter; using Volo.Abp; using Volo.Abp.Domain.Entities; using Volo.Abp.ObjectMapping; using Volo.Abp.Uow; using Volo.Abp.Users; +using Win_in.Sfs.Basedata.Application; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Shared.Domain.Shared.Enums.Store; @@ -36,7 +38,7 @@ namespace Win_in.Sfs.Wms.Store.Application; public class CoatingIssueJobAppService : SfsJobAppServiceBase, - ICoatingIssueJobAppService, ITransferLibCallback + ICoatingIssueJobAppService, ITransferLibCallback,IAgvJobAccount { private readonly ICoatingIssueJobManager _coatingIssueJobManager; private readonly ILocationAppService _locationAppService; @@ -48,6 +50,9 @@ public class CoatingIssueJobAppService private readonly ILogger _logger; private readonly ICurrentUser _currentUser; private readonly IAgvJobOutputService _agvOutJob; + private readonly UnitOfWorkManager _unitOfWorkManager; + private readonly IOptions _agvOptions; + private readonly IPostionLocationAppService _postionLocationAppService; protected ICoatingIssueRequestAppService CoatingIssueRequestAppService => LazyServiceProvider.LazyGetRequiredService(); @@ -59,7 +64,10 @@ public class CoatingIssueJobAppService ILocationAppService locationAppService, ICoatingIssueNoteAppService coatingIssueNoteAppService, IExpectOutAppService expectOutAppService , IHttpClientFactory httpClientFactory - , IOptions options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser) : base( + , IOptions options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser, IOptions agvOptions + , UnitOfWorkManager unitOfWorkManager + , IPostionLocationAppService postionLocationAppService + ) : base( repository, coatingIssueJobManager) { _coatingIssueJobManager = coatingIssueJobManager; @@ -72,6 +80,9 @@ public class CoatingIssueJobAppService _currentUser = currentUser; _logger = logger; _agvOutJob = agvOutJob; + _unitOfWorkManager = unitOfWorkManager; + _agvOptions = agvOptions; + _postionLocationAppService = postionLocationAppService; } [HttpPost("get-by-number-2")] @@ -724,21 +735,226 @@ public class CoatingIssueJobAppService coatingIssueJobDetailDto.Status, coatingIssueJobDetailDto.HandledToLot, handledToQty).ConfigureAwait(false); } - /// - /// 调用AgvOutPut出库 - /// - /// - /// - private async Task InvokeAgvOutput(CoatingIssueJob job) + + [HttpPost("PushOutTask")] + public async Task PushOutTaskAsync(CoatingIssueJobDTO job) { - - var first = job.Details.FirstOrDefault(); - var requst = new AgvRequest(); - requst.MatCode = first.ItemCode; - requst.MatQty = first.HandledToQty; - requst.OrderNum = job.Number; - requst.OrderType = "2"; - return await _agvOutJob.OutPutTaskAsync(requst).ConfigureAwait(false); + var ret = new AgvResultObject + { + Code = "0", + ReqCode = job.CoatingRequestNumber, + Message = "OK" + }; + using var unitOfWork = _unitOfWorkManager.Begin(); + try + { + var first = job.Details.FirstOrDefault(); + var request = new AgvRequest(); + request.MatCode = first.ItemCode; + request.MatQty = first.HandledToQty; + request.OrderNum = job.Number; + request.OrderType = "2"; + + 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"); + // _logger.LogInformation($"标志{flag}开始调用高通WMS:传递值{JsonSerializer.Serialize(main)}"); + 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); + ret = await client.PushOutTask4FWAsync(request).ConfigureAwait(false); + + } + catch (Exception e) + { + ret = new AgvResultObject(); + ret.Code = "1"; + ret.Message = e.Message; + ret.ReqCode = job.CoatingRequestNumber; + await unitOfWork.RollbackAsync().ConfigureAwait(false); + + } + return ret; + } + [HttpPost("accountOutOrder")] + public async Task AccountOutOrderAsync(AgvRequestOnlyJobHK request) + { + var json = JsonSerializer.Serialize(request); + var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); + _logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json); +#if DEBUG +#endif + var errors = new List(); + var first = request.Data.FirstOrDefault(); + var job = await _repository.GetAsync(p => p.Number == first.OrderNum).ConfigureAwait(false); + + var ret = new AgvResultObject + { + Code = "0", + Message = "OK", + ReqCode = job.CoatingRequestNumber, + + }; + using var unitOfWork = _unitOfWorkManager.Begin(); + try + { + if (request.Data.Count > 0) + { + var jobs = request.Data; + var numbers = jobs.Select(p => p.OrderNum); + var query = _repository.WithDetails() + .Where(p => numbers.Contains(p.Number) && p.JobStatus != EnumJobStatus.Done); + var entities = query.ToList(); + if (entities.Count == 0) + { + errors.Add($"任务号{string.Join(",", numbers)}不存在!"); + } + + var dtos = ObjectMapper.Map, List>(entities); + foreach (var itm in dtos) + { + var arys = jobs.Where(p => p.OrderNum == itm.Number); + var itmDetails = itm.Details.ToList(); + var details = new List(); + foreach (var detail in arys) + { + + var fromloc = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false); + if (fromloc == null) + { + errors.Add($"来源起始点{detail.BeginPosition}没查到"); + } + + LocationDTO fromlocation = null; + + if (fromloc != null) + { + fromlocation = await _locationAppService.GetByCodeAsync(fromloc.Code).ConfigureAwait(false); + } + if (fromlocation == null) + { + errors.Add($"来源起始点{detail.BeginPosition}库位没查到"); + } + + var toloc = await _postionLocationAppService.GetByCodeAsync(detail.EndPosition) + .ConfigureAwait(false); + if (toloc == null) + { + errors.Add($"结束点{detail.EndPosition}库位没查到"); + } + + LocationDTO tolocation = null; + + if (toloc != null) + { + tolocation = await _locationAppService.GetByCodeAsync(toloc.Code).ConfigureAwait(false); + } + if (tolocation == null) + { + errors.Add($"结束点{detail.EndPosition}库位没查到"); + } + + + var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.MatCode); + if (entity == null) + { + errors.Add($"物料号{detail.MatCode}不在任务明细内!"); + } + + var dto = new CoatingIssueJobDetailDTO(); + dto.InjectFrom(entity); + dto.HandledToLocationCode = toloc.Code; + dto.HandledToLocationGroup = tolocation.LocationGroupCode; + dto.HandledToLocationArea = tolocation.AreaCode; + dto.HandledToLocationErpCode = tolocation.ErpLocationCode; + + dto.HandledToWarehouseCode = tolocation.WarehouseCode; + dto.HandledToQty = detail.MatQty; + dto.HandledToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty; + dto.HandledToPackingCode = string.Empty; + + dto.HandledFromWarehouseCode = fromlocation.WarehouseCode; + dto.HandledFromLocationCode = fromlocation.Code; + dto.HandledFromLocationGroup = fromlocation.LocationGroupCode; + dto.HandledFromLocationArea = fromlocation.AreaCode; + dto.HandledFromLocationErpCode = fromlocation.ErpLocationCode; + dto.HandledFromQty = detail.MatQty; + dto.HandledFromLot = string.Empty; + dto.HandledFromPackingCode = string.Empty; + details.Add(dto); + + + + + + //await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false); + } + + if (errors.Count > 0) + { + ret = new AgvResultObject() + { + Code = "-1", + ReqCode = "", + Message = string.Join(",", errors.ToArray()) + }; + } + itm.Worker = "AGV"; + itm.Details = details; + + _logger.LogInformation($"{flag}接收Agv确认单据内容:" + json + "Agv任务完成"); + } + } + else + { + errors.Add("Agv确认单据里无数据! \n"); + } + } + catch (Exception ex) + { + ret = new AgvResultObject + { + Code = "-1", + ReqCode = job.CoatingRequestNumber, + Message = ex.Message, + }; + await unitOfWork.RollbackAsync(); + return ret; + } + + if (errors.Count > 0) + { + ret = new AgvResultObject + { + Code = "-1", + Message = string.Join(",", errors.ToArray()), + ReqCode = job.CoatingRequestNumber + }; + } + return ret; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionIssueJobs/InjectionIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionIssueJobs/InjectionIssueJobAppService.cs index 306e2a1be..c296836b0 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionIssueJobs/InjectionIssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionIssueJobs/InjectionIssueJobAppService.cs @@ -44,6 +44,9 @@ public class InjectionIssueJobAppService private readonly IOptions _options; private readonly ICurrentUser _currentUser; private readonly IAgvJobOutputService _agvOutJob; + private readonly UnitOfWorkManager _unitOfWorkManager; + private readonly IOptions _agvOptions; + private readonly IPostionLocationAppService _postionLocationAppService; protected IInjectionIssueRequestAppService InjectionIssueRequestAppService => LazyServiceProvider.LazyGetRequiredService(); @@ -54,7 +57,10 @@ public class InjectionIssueJobAppService ILocationAppService locationAppService, IInjectionIssueNoteAppService injectionIssueNoteAppService, IExpectOutAppService expectOutAppService , IHttpClientFactory httpClientFactory - , IOptions options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser) : base( + , IOptions options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser + , IOptions agvOptions + , UnitOfWorkManager unitOfWorkManager + ) : base( repository, injectionIssueJobManager) { _injectionIssueJobManager = injectionIssueJobManager; @@ -65,7 +71,9 @@ public class InjectionIssueJobAppService _options = options; _transferLibRequestAppService = transferLibRequestAppService; _currentUser = currentUser; - _agvOutJob = agvOutJob; + _agvOutJob = agvOutJob; + _unitOfWorkManager = unitOfWorkManager; + _agvOptions = agvOptions; } [HttpPost("get-by-number-2")] public async Task GetByNumber2Async(string number) @@ -673,22 +681,70 @@ public class InjectionIssueJobAppService injectionIssueJobDetailDto.Status, injectionIssueJobDetailDto.HandledToLot, handledToQty).ConfigureAwait(false); } - /// - /// 调用AgvOutPut出库 - /// - /// - /// - private async Task InvokeAgvOutput(InjectionIssueJob job) + [HttpPost("PushOutTask")] + public async Task PushOutTaskAsync(InjectionIssueJobDTO job) { + var ret = new AgvResultObject + { + Code = "0", + ReqCode = job.InjectionRequestNumber, + Message = "OK" + }; + using var unitOfWork = _unitOfWorkManager.Begin(); + try + { + var first = job.Details.FirstOrDefault(); + var request = new AgvRequest(); + request.MatCode = first.ItemCode; + request.MatQty = first.HandledToQty; + request.OrderNum = job.Number; + request.OrderType = "2"; - var first = job.Details.FirstOrDefault(); - var requst = new AgvRequest(); - requst.MatCode = first.ItemCode; - requst.MatQty = first.HandledToQty; - requst.OrderNum = job.Number; - requst.OrderType = "2"; - return await _agvOutJob.OutPutTaskAsync(requst).ConfigureAwait(false); + 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"); + // _logger.LogInformation($"标志{flag}开始调用高通WMS:传递值{JsonSerializer.Serialize(main)}"); + 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); + ret = await client.PushOutTask4FWAsync(request).ConfigureAwait(false); + + } + catch (Exception e) + { + ret = new AgvResultObject(); + ret.Code = "1"; + ret.Message = e.Message; + ret.ReqCode = job.InjectionRequestNumber; + await unitOfWork.RollbackAsync().ConfigureAwait(false); + + } + return ret; } + #endregion } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs index a0b973a8e..acf3e7bc7 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs @@ -39,11 +39,15 @@ public class KittingIssueJobAppService private readonly ILocationAppService _locationAppService; private readonly IKittingIssueNoteAppService _kittingIssueNoteAppService; private readonly IExpectOutAppService _expectOutAppService; - private readonly IHttpClientFactory _httpClientFactory; + private readonly ITransferLibRequestAppService _transferLibRequestAppService; private readonly IOptions _options; private readonly ICurrentUser _currentUser; private readonly IAgvJobOutputService _agvOutJob; + private readonly UnitOfWorkManager _unitOfWorkManager; + private readonly IHttpClientFactory _httpClientFactory; + private readonly IOptions _agvOptions; + private readonly IPostionLocationAppService _postionLocationAppService; protected IKittingIssueRequestAppService KittingIssueRequestAppService => LazyServiceProvider.LazyGetRequiredService(); @@ -54,7 +58,12 @@ public class KittingIssueJobAppService ILocationAppService locationAppService, IKittingIssueNoteAppService kittingIssueNoteAppService, IExpectOutAppService expectOutAppService , IHttpClientFactory httpClientFactory - , IOptions options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser) : base( + , IOptions options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser + ,IOptions agvOptions, + + + UnitOfWorkManager unitOfWorkManager + ) : base( repository, kittingIssueJobManager) { _agvOutJob = agvOutJob; @@ -67,6 +76,8 @@ public class KittingIssueJobAppService _transferLibRequestAppService = transferLibRequestAppService; _currentUser = currentUser; _agvOutJob = agvOutJob; + _unitOfWorkManager = unitOfWorkManager; + _agvOptions = agvOptions; } [HttpPost("get-by-number-2")] @@ -684,21 +695,68 @@ public class KittingIssueJobAppService kittingIssueJobDetailDto.Status, kittingIssueJobDetailDto.HandledToLot, handledToQty).ConfigureAwait(false); } - /// - /// 调用AgvOutPut出库 - /// - /// - /// - private async Task InvokeAgvOutput(KittingIssueJobDTO job) + [HttpPost("PushOutTask")] + public async Task PushOutTaskAsync(KittingIssueJobDTO job) { + var ret = new AgvResultObject + { + Code = "0", + ReqCode = job.KittingRequestNumber, + Message = "OK" + }; + using var unitOfWork = _unitOfWorkManager.Begin(); + try + { + var first = job.Details.FirstOrDefault(); + var request = new AgvRequest(); + request.MatCode = first.ItemCode; + request.MatQty = first.HandledToQty; + request.OrderNum = job.Number; + request.OrderType = "2"; + + 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"); + // _logger.LogInformation($"标志{flag}开始调用高通WMS:传递值{JsonSerializer.Serialize(main)}"); + 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 first = job.Details.FirstOrDefault(); - var requst = new AgvRequest(); - requst.MatCode = first.ItemCode; - requst.MatQty = first.HandledToQty; - requst.OrderNum = job.Number; - requst.OrderType = "2"; - return await _agvOutJob.OutPutTaskAsync(requst).ConfigureAwait(false); + var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path); + ret = await client.PushOutTask4FWAsync(request).ConfigureAwait(false); + + } + catch (Exception e) + { + ret = new AgvResultObject(); + ret.Code = "1"; + ret.Message = e.Message; + ret.ReqCode = job.KittingRequestNumber; + await unitOfWork.RollbackAsync().ConfigureAwait(false); + + } + return ret; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/SparePartIssueJobs/SparePartIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/SparePartIssueJobs/SparePartIssueJobAppService.cs index 36339dbc1..a0515bfef 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/SparePartIssueJobs/SparePartIssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/SparePartIssueJobs/SparePartIssueJobAppService.cs @@ -44,6 +44,9 @@ public class SparePartIssueJobAppService private readonly IOptions _options; private readonly ICurrentUser _currentUser; private readonly IAgvJobOutputService _agvOutJob; + private readonly UnitOfWorkManager _unitOfWorkManager; + private readonly IOptions _agvOptions; + private readonly IPostionLocationAppService _postionLocationAppService; protected ISparePartIssueRequestAppService SparePartIssueRequestAppService => LazyServiceProvider.LazyGetRequiredService(); @@ -54,7 +57,9 @@ public class SparePartIssueJobAppService ILocationAppService locationAppService, ISparePartIssueNoteAppService sparePartIssueNoteAppService, IExpectOutAppService expectOutAppService , IHttpClientFactory httpClientFactory - , IOptions options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser) : base( + , IOptions options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser + , UnitOfWorkManager unitOfWorkManager, IOptions agvOptions + ) : base( repository, sparePartIssueJobManager) { _sparePartIssueJobManager = sparePartIssueJobManager; @@ -66,6 +71,8 @@ public class SparePartIssueJobAppService _transferLibRequestAppService = transferLibRequestAppService; _currentUser = currentUser; _agvOutJob = agvOutJob; + _unitOfWorkManager = unitOfWorkManager; + _agvOptions = agvOptions; } [HttpPost("get-by-number-2")] @@ -665,21 +672,67 @@ public class SparePartIssueJobAppService handledToQty).ConfigureAwait(false); } - /// - /// 调用AgvOutPut出库 - /// - /// - /// - private async Task InvokeAgvOutput(SparePartIssueJobDTO job) + [HttpPost("PushOutTask")] + public async Task PushOutTaskAsync(SparePartIssueJobDTO job) { + var ret = new AgvResultObject + { + Code = "0", + ReqCode = job.SparePartRequestNumber, + Message = "OK" + }; + using var unitOfWork = _unitOfWorkManager.Begin(); + try + { + var first = job.Details.FirstOrDefault(); + var request = new AgvRequest(); + request.MatCode = first.ItemCode; + request.MatQty = first.HandledToQty; + request.OrderNum = job.Number; + request.OrderType = "2"; + + 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"); + // _logger.LogInformation($"标志{flag}开始调用高通WMS:传递值{JsonSerializer.Serialize(main)}"); + if (!string.IsNullOrEmpty(_agvOptions.Value.Token)) + { + var token = _agvOptions.Value.Token; + httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + } - var first = job.Details.FirstOrDefault(); - var requst = new AgvRequest(); - requst.MatCode = first.ItemCode; - requst.MatQty = first.HandledToQty; - requst.OrderNum = job.Number; - requst.OrderType = "2"; - return await _agvOutJob.OutPutTaskAsync(requst).ConfigureAwait(false); + 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); + ret = await client.PushOutTask4FWAsync(request).ConfigureAwait(false); + } + catch (Exception e) + { + ret = new AgvResultObject(); + ret.Code = "1"; + ret.Message = e.Message; + ret.ReqCode = job.SparePartRequestNumber; + await unitOfWork.RollbackAsync().ConfigureAwait(false); + + } + return ret; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/proxy/IssueJobToRestoClient.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/proxy/IssueJobToRestoClient.cs index 26101a196..2b7ce5e24 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/proxy/IssueJobToRestoClient.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/proxy/IssueJobToRestoClient.cs @@ -19,6 +19,7 @@ namespace MyNamespace { + using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Jobs.IssueJobs; using Win_in.Sfs.Wms.Store.Jobs.IssueJobs.proxy; using System = global::System; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedIssueJobs/UnplannedIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedIssueJobs/UnplannedIssueJobAppService.cs index e6fad894d..99326d80f 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedIssueJobs/UnplannedIssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedIssueJobs/UnplannedIssueJobAppService.cs @@ -1,6 +1,9 @@ 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 Castle.Components.DictionaryAdapter; using Irony; @@ -17,6 +20,9 @@ using Win_in.Sfs.Wms.Inventory.Application.Contracts; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; 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; namespace Win_in.Sfs.Wms.Store.Application; @@ -38,12 +44,18 @@ public class UnplannedIssueJobAppService private readonly ILogger _logger; private readonly IItemBasicAppService _itemBasicAppService; + private readonly IOptions _agvOptions; + private readonly IHttpClientFactory _httpClientFactory; + public UnplannedIssueJobAppService( IUnplannedIssueJobRepository repository, IUnplannedIssueJobManager unplannedIssueJobManager, ILocationAppService locationAppService, IBalanceAppService balanceAppService, IExpectOutAppService expectOutAppService, IUnitOfWorkManager unitOfWorkManager, ILogger logger, - IItemBasicAppService itemBasicAppService) : base(repository, unplannedIssueJobManager) + IItemBasicAppService itemBasicAppService, IOptions agvOptions + + , IHttpClientFactory httpClientFactory + ) : base(repository, unplannedIssueJobManager) { _unplannedIssueJobManager = unplannedIssueJobManager; _locationAppService = locationAppService; @@ -52,6 +64,8 @@ public class UnplannedIssueJobAppService _unitOfWorkManager = unitOfWorkManager; _logger = logger; _itemBasicAppService = itemBasicAppService; + _agvOptions = agvOptions; + _httpClientFactory = httpClientFactory; } /// @@ -631,4 +645,68 @@ public class UnplannedIssueJobAppService return handleDto; } + [HttpPost("PushOutTask")] + public async Task PushOutTaskAsync(UnplannedIssueJobDTO job) + { + var ret = new AgvResultObject + { + Code = "0", + ReqCode = job.UnplannedIssueRequestNumber, + Message = "OK" + }; + using var unitOfWork = _unitOfWorkManager.Begin(); + try + { + var first = job.Details.FirstOrDefault(); + var request = new AgvRequest(); + request.MatCode = first.ItemCode; + request.MatQty = first.HandledQty; + request.OrderNum = job.Number; + request.OrderType = "2"; + + 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"); + // _logger.LogInformation($"标志{flag}开始调用高通WMS:传递值{JsonSerializer.Serialize(main)}"); + 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); + ret = await client.PushOutTask4FWAsync(request).ConfigureAwait(false); + } + catch (Exception e) + { + ret = new AgvResultObject(); + ret.Code = "1"; + ret.Message = e.Message; + ret.ReqCode = job.UnplannedIssueRequestNumber; + await unitOfWork.RollbackAsync().ConfigureAwait(false); + + } + return ret; + } + + } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedReceiptJobs/UnplannedReceiptJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedReceiptJobs/UnplannedReceiptJobAppService.cs index 0fd0d5e92..0acea3b7f 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedReceiptJobs/UnplannedReceiptJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedReceiptJobs/UnplannedReceiptJobAppService.cs @@ -15,6 +15,9 @@ using Win_in.Sfs.Wms.Store.Domain.Shared; namespace Win_in.Sfs.Wms.Store.Application; using System.Linq; +using System.Net.Http.Headers; +using System.Net.Http; +using System.Text; using System.Text.Json; using Castle.Components.DictionaryAdapter; @@ -25,6 +28,10 @@ using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.Domain; using Win_in.Sfs.Shared.Event; using Win_in.Sfs.Wms.Inventory.Application.Contracts; +using Win_in.Sfs.Wms.Store.Jobs.IssueJobs.proxy; +using Win_in.Sfs.Wms.Store.Options; +using Microsoft.Extensions.Options; +using Volo.Abp.Uow; [Authorize] [Route($"{StoreConsts.RootPath}unplanned-receipt-job")] @@ -41,18 +48,31 @@ public class UnplannedReceiptJobAppService private readonly IBalanceAppService _balanceAppService; private readonly IExpectOutAppService _expectOutAppService; private readonly IItemBasicAppService _itemBasicAppService; + private readonly IOptions _agvOptions; + private readonly IHttpClientFactory _httpClientFactory; + private readonly IUnitOfWorkManager _unitOfWorkManager; + public UnplannedReceiptJobAppService( IUnplannedReceiptJobRepository repository, IUnplannedReceiptJobManager UnplannedReceiptJobManager, ILocationAppService locationAppService, IBalanceAppService balanceAppService, - IExpectOutAppService expectOutAppService, IItemBasicAppService itemBasicAppService) : base(repository, UnplannedReceiptJobManager) + IExpectOutAppService expectOutAppService, IItemBasicAppService itemBasicAppService, + IOptions agvOptions, + IHttpClientFactory httpClientFactory, + IUnitOfWorkManager unitOfWorkManager + + + ) : base(repository, UnplannedReceiptJobManager) { _unplannedReceiptJobManager = UnplannedReceiptJobManager; _locationAppService = locationAppService; _balanceAppService = balanceAppService; _expectOutAppService = expectOutAppService; _itemBasicAppService = itemBasicAppService; + _agvOptions = agvOptions; + _httpClientFactory = httpClientFactory; + _unitOfWorkManager = unitOfWorkManager; } @@ -295,4 +315,71 @@ public class UnplannedReceiptJobAppService } return true; } + /// + /// + /// + /// + /// + [HttpPost("PushOutTask")] + public async Task PushOutTaskAsync(UnplannedReceiptJobDTO job) + { + var ret = new AgvResultObject + { + Code = "0", + ReqCode = job.UnplannedReceiptRequestNumber, + Message = "OK" + }; + using var unitOfWork = _unitOfWorkManager.Begin(); + try + { + var first = job.Details.FirstOrDefault(); + var request = new AgvRequest(); + request.MatCode = first.ItemCode; + request.MatQty = first.HandledQty; + request.OrderNum = job.Number; + request.OrderType = "2"; + + 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"); + // _logger.LogInformation($"标志{flag}开始调用高通WMS:传递值{JsonSerializer.Serialize(main)}"); + 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); + ret = await client.PushOutTask4FWAsync(request).ConfigureAwait(false); + } + catch (Exception e) + { + ret = new AgvResultObject(); + ret.Code = "1"; + ret.Message = e.Message; + ret.ReqCode = job.UnplannedReceiptRequestNumber; + await unitOfWork.RollbackAsync().ConfigureAwait(false); + + } + return ret; + } }