Browse Source

暂存

Agv分支2024-11-19
赵新宇 5 months ago
parent
commit
1da38287a5
  1. 26
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/test/TestAppService.cs
  2. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/AgvJobs/IAgvJobAccount.cs
  3. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/IssueJobs/ProxyIssueJobDto.cs
  4. 60
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/AgvJobs/AgvJobAccountService.cs
  5. 94
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/AgvJobs/AgvJobOutputService.cs
  6. 155
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AgvJobs/AgvJobOutputService.cs
  7. 269
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AssembleIssueJobs/AssembleIssueJobAppService.cs
  8. 248
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs
  9. 86
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionIssueJobs/InjectionIssueJobAppService.cs
  10. 88
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs
  11. 81
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/SparePartIssueJobs/SparePartIssueJobAppService.cs
  12. 1
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/proxy/IssueJobToRestoClient.cs
  13. 80
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedIssueJobs/UnplannedIssueJobAppService.cs
  14. 89
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedReceiptJobs/UnplannedReceiptJobAppService.cs

26
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<AgvResultObject> pushOutTask4FW(AgvRequest request)
public async Task<AgvResultObject1> 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
/// <summary>
/// 发给立体库主表
/// </summary>
public class IssueJobToRestoDetailDTO
public class IssueJobToRestoDetailDTO1
{
public string WorkNo { set; get; }
public string TaskNo { set; get; }
@ -162,50 +162,50 @@ public class IssueJobToRestoDetailDTO
/// <summary>
/// 发给立体库子表
/// </summary>
public class IssueJobToRestoDTO
public class IssueJobToRestoDTO1
{
public Guid UUID { set; get; }
public string OperatorName { set; get; }
public List<IssueJobToRestoDetailDTO> Details { set; get; }
public List<IssueJobToRestoDetailDTO1> Details { set; get; }
}
/// <summary>
/// 返回结果
/// </summary>
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<AgvRequestHKDetail> Data { set; get; }
public List<AgvRequestHKDetail1> Data { set; get; }
}
public class AgvRequestInputHK
public class AgvRequestInputHK1
{
//[Display(Name = "请求编号")]
//public string ReqCode { set; get; }
[Display(Name = "明细")]
public List<AgvRequestHKDetail> Data { set; get; }
public List<AgvRequestHKDetail1> Data { set; get; }
}
public class AgvRequestHKDetail
public class AgvRequestHKDetail1
{
[Display(Name = "任务类型")]
public string OrderType { set; get; }
@ -244,7 +244,7 @@ public class AgvRequestHKDetail
/// <summary>
/// 闻荫调海康入参
/// </summary>
public class AgvRequest
public class AgvRequest1
{
[Display(Name = "任务类型")]
public string OrderType { set; get; }

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/AgvJobs/IAgvJobAccountService.cs → 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<AgvResultObject> AccountOutOrderAsync(AgvRequestOnlyJobHK request);

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/proxy/ProxyIssueJobDto.cs → 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;
/// <summary>
/// 喷涂主表
/// </summary>

60
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AgvJobs/AgvJobAccountService.cs → 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<AgvResultObject> 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<string> action, List<string> 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}没找到对应库位");
}
}
}
}

94
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<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;
}
}

155
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AgvJobs/AgvJobOutputService.cs

@ -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;
}
}

269
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<AssembleIssueJob, AssembleIssueJobDetail, AssembleIssueJobDTO, SfsJobRequestInputBase,
AssembleIssueJobCheckInput, AssembleIssueJobEditInput>,
IAssembleIssueJobAppService, ITransferLibCallback
IAssembleIssueJobAppService, ITransferLibCallback, IAgvJobAccount
{
protected IAssembleIssueRequestAppService AssembleIssueRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<IAssembleIssueRequestAppService>();
@ -50,24 +53,31 @@ public class AssembleIssueJobAppService
private readonly ILogger<AssembleIssueJobAppService> _logger;
private readonly ICurrentUser _currentUser;
private readonly UnitOfWorkManager _unitOfWorkManager;
private readonly IOptions<AgvOptions> _agvOptions;
private readonly IAgvJobOutputService _agvOutJob;
private readonly IPostionLocationAppService _postionLocationAppService;
public AssembleIssueJobAppService(
ILogger<AssembleIssueJobAppService> logger,
IAgvJobOutputService agvOutJob,
IAssembleIssueJobRepository repository, IAssembleIssueJobManager assembleIssueJobManager,
ILocationAppService locationAppService,
IAssembleIssueNoteAppService assembleIssueNoteAppService, IExpectOutAppService expectOutAppService
,IHttpClientFactory httpClientFactory
,IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService,
ICurrentUser currentUser, UnitOfWorkManager unitOfWorkManager) : base(
ICurrentUser currentUser, UnitOfWorkManager unitOfWorkManager
, IOptions<AgvOptions> 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<AssembleIssueJob>, List<AssembleIssueJobDTO>>(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<AssembleIssueJobDetailDTO>();
@ -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);
}
/// <summary>
/// 调用AgvOutPut出库
/// </summary>
/// <param name="job"></param>
/// <returns></returns>
private async Task<AgvResultObject> InvokeAgvOutput(AssembleIssueJobDTO job)
[HttpPost("PushOutTask")]
public async Task<AgvResultObject> 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<AgvResultObject> 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<string>();
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<AssembleIssueJob>, List<AssembleIssueJobDTO>>(entities);
foreach (var itm in dtos)
{
var arys = jobs.Where(p => p.OrderNum == itm.Number);
var itmDetails = itm.Details.ToList();
var details = new List<AssembleIssueJobDetailDTO>();
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
}

248
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<CoatingIssueJob, CoatingIssueJobDetail, CoatingIssueJobDTO, SfsJobRequestInputBase,
CoatingIssueJobCheckInput, CoatingIssueJobEditInput>,
ICoatingIssueJobAppService, ITransferLibCallback
ICoatingIssueJobAppService, ITransferLibCallback,IAgvJobAccount
{
private readonly ICoatingIssueJobManager _coatingIssueJobManager;
private readonly ILocationAppService _locationAppService;
@ -48,6 +50,9 @@ public class CoatingIssueJobAppService
private readonly ILogger<CoatingIssueJobAppService> _logger;
private readonly ICurrentUser _currentUser;
private readonly IAgvJobOutputService _agvOutJob;
private readonly UnitOfWorkManager _unitOfWorkManager;
private readonly IOptions<AgvOptions> _agvOptions;
private readonly IPostionLocationAppService _postionLocationAppService;
protected ICoatingIssueRequestAppService CoatingIssueRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<ICoatingIssueRequestAppService>();
@ -59,7 +64,10 @@ public class CoatingIssueJobAppService
ILocationAppService locationAppService,
ICoatingIssueNoteAppService coatingIssueNoteAppService, IExpectOutAppService expectOutAppService
, IHttpClientFactory httpClientFactory
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser) : base(
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser, IOptions<AgvOptions> 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);
}
/// <summary>
/// 调用AgvOutPut出库
/// </summary>
/// <param name="job"></param>
/// <returns></returns>
private async Task<AgvResultObject> InvokeAgvOutput(CoatingIssueJob job)
[HttpPost("PushOutTask")]
public async Task<AgvResultObject> 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<AgvResultObject> 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<string>();
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<CoatingIssueJob>, List<CoatingIssueJobDTO>>(entities);
foreach (var itm in dtos)
{
var arys = jobs.Where(p => p.OrderNum == itm.Number);
var itmDetails = itm.Details.ToList();
var details = new List<CoatingIssueJobDetailDTO>();
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;
}

86
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<RestoOptions> _options;
private readonly ICurrentUser _currentUser;
private readonly IAgvJobOutputService _agvOutJob;
private readonly UnitOfWorkManager _unitOfWorkManager;
private readonly IOptions<AgvOptions> _agvOptions;
private readonly IPostionLocationAppService _postionLocationAppService;
protected IInjectionIssueRequestAppService InjectionIssueRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<IInjectionIssueRequestAppService>();
@ -54,7 +57,10 @@ public class InjectionIssueJobAppService
ILocationAppService locationAppService,
IInjectionIssueNoteAppService injectionIssueNoteAppService, IExpectOutAppService expectOutAppService
, IHttpClientFactory httpClientFactory
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser) : base(
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser
, IOptions<AgvOptions> 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<InjectionIssueJobDTO> GetByNumber2Async(string number)
@ -673,22 +681,70 @@ public class InjectionIssueJobAppService
injectionIssueJobDetailDto.Status, injectionIssueJobDetailDto.HandledToLot,
handledToQty).ConfigureAwait(false);
}
/// <summary>
/// 调用AgvOutPut出库
/// </summary>
/// <param name="job"></param>
/// <returns></returns>
private async Task<AgvResultObject> InvokeAgvOutput(InjectionIssueJob job)
[HttpPost("PushOutTask")]
public async Task<AgvResultObject> 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
}

88
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<RestoOptions> _options;
private readonly ICurrentUser _currentUser;
private readonly IAgvJobOutputService _agvOutJob;
private readonly UnitOfWorkManager _unitOfWorkManager;
private readonly IHttpClientFactory _httpClientFactory;
private readonly IOptions<AgvOptions> _agvOptions;
private readonly IPostionLocationAppService _postionLocationAppService;
protected IKittingIssueRequestAppService KittingIssueRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<IKittingIssueRequestAppService>();
@ -54,7 +58,12 @@ public class KittingIssueJobAppService
ILocationAppService locationAppService,
IKittingIssueNoteAppService kittingIssueNoteAppService, IExpectOutAppService expectOutAppService
, IHttpClientFactory httpClientFactory
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser) : base(
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser
,IOptions<AgvOptions> 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);
}
/// <summary>
/// 调用AgvOutPut出库
/// </summary>
/// <param name="job"></param>
/// <returns></returns>
private async Task<AgvResultObject> InvokeAgvOutput(KittingIssueJobDTO job)
[HttpPost("PushOutTask")]
public async Task<AgvResultObject> 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;
}

81
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<RestoOptions> _options;
private readonly ICurrentUser _currentUser;
private readonly IAgvJobOutputService _agvOutJob;
private readonly UnitOfWorkManager _unitOfWorkManager;
private readonly IOptions<AgvOptions> _agvOptions;
private readonly IPostionLocationAppService _postionLocationAppService;
protected ISparePartIssueRequestAppService SparePartIssueRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<ISparePartIssueRequestAppService>();
@ -54,7 +57,9 @@ public class SparePartIssueJobAppService
ILocationAppService locationAppService,
ISparePartIssueNoteAppService sparePartIssueNoteAppService, IExpectOutAppService expectOutAppService
, IHttpClientFactory httpClientFactory
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser) : base(
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser
, UnitOfWorkManager unitOfWorkManager, IOptions<AgvOptions> 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);
}
/// <summary>
/// 调用AgvOutPut出库
/// </summary>
/// <param name="job"></param>
/// <returns></returns>
private async Task<AgvResultObject> InvokeAgvOutput(SparePartIssueJobDTO job)
[HttpPost("PushOutTask")]
public async Task<AgvResultObject> 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;
}

1
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;

80
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<UnplannedIssueJobAppService> _logger;
private readonly IItemBasicAppService _itemBasicAppService;
private readonly IOptions<AgvOptions> _agvOptions;
private readonly IHttpClientFactory _httpClientFactory;
public UnplannedIssueJobAppService(
IUnplannedIssueJobRepository repository, IUnplannedIssueJobManager unplannedIssueJobManager,
ILocationAppService locationAppService,
IBalanceAppService balanceAppService, IExpectOutAppService expectOutAppService,
IUnitOfWorkManager unitOfWorkManager, ILogger<UnplannedIssueJobAppService> logger,
IItemBasicAppService itemBasicAppService) : base(repository, unplannedIssueJobManager)
IItemBasicAppService itemBasicAppService, IOptions<AgvOptions> 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;
}
/// <summary>
@ -631,4 +645,68 @@ public class UnplannedIssueJobAppService
return handleDto;
}
[HttpPost("PushOutTask")]
public async Task<AgvResultObject> 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;
}
}

89
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> _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> 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;
}
/// <summary>
///
/// </summary>
/// <param name="job"></param>
/// <returns></returns>
[HttpPost("PushOutTask")]
public async Task<AgvResultObject> 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;
}
}

Loading…
Cancel
Save