|
@ -10,10 +10,12 @@ using Castle.Components.DictionaryAdapter; |
|
|
using DocumentFormat.OpenXml.Spreadsheet; |
|
|
using DocumentFormat.OpenXml.Spreadsheet; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
|
|
using Microsoft.Extensions.Hosting; |
|
|
using Microsoft.Extensions.Logging; |
|
|
using Microsoft.Extensions.Logging; |
|
|
using Microsoft.Extensions.Options; |
|
|
using Microsoft.Extensions.Options; |
|
|
using MyNamespace; |
|
|
using MyNamespace; |
|
|
using Omu.ValueInjecter; |
|
|
using Omu.ValueInjecter; |
|
|
|
|
|
using Org.BouncyCastle.Asn1.Ocsp; |
|
|
using Volo.Abp; |
|
|
using Volo.Abp; |
|
|
using Volo.Abp.Domain.Entities; |
|
|
using Volo.Abp.Domain.Entities; |
|
|
using Volo.Abp.Uow; |
|
|
using Volo.Abp.Uow; |
|
@ -36,7 +38,7 @@ namespace Win_in.Sfs.Wms.Store.Application; |
|
|
public class AssembleIssueJobAppService |
|
|
public class AssembleIssueJobAppService |
|
|
: SfsJobAppServiceBase<AssembleIssueJob, AssembleIssueJobDetail, AssembleIssueJobDTO, SfsJobRequestInputBase, |
|
|
: SfsJobAppServiceBase<AssembleIssueJob, AssembleIssueJobDetail, AssembleIssueJobDTO, SfsJobRequestInputBase, |
|
|
AssembleIssueJobCheckInput, AssembleIssueJobEditInput>, |
|
|
AssembleIssueJobCheckInput, AssembleIssueJobEditInput>, |
|
|
IAssembleIssueJobAppService, ITransferLibCallback |
|
|
IAssembleIssueJobAppService, ITransferLibCallback, IAgvJobAccountService |
|
|
{ |
|
|
{ |
|
|
protected IAssembleIssueRequestAppService AssembleIssueRequestAppService => |
|
|
protected IAssembleIssueRequestAppService AssembleIssueRequestAppService => |
|
|
LazyServiceProvider.LazyGetRequiredService<IAssembleIssueRequestAppService>(); |
|
|
LazyServiceProvider.LazyGetRequiredService<IAssembleIssueRequestAppService>(); |
|
@ -51,24 +53,31 @@ public class AssembleIssueJobAppService |
|
|
private readonly ILogger<AssembleIssueJobAppService> _logger; |
|
|
private readonly ILogger<AssembleIssueJobAppService> _logger; |
|
|
private readonly ICurrentUser _currentUser; |
|
|
private readonly ICurrentUser _currentUser; |
|
|
private readonly UnitOfWorkManager _unitOfWorkManager; |
|
|
private readonly UnitOfWorkManager _unitOfWorkManager; |
|
|
|
|
|
private readonly IOptions<AgvOptions> _agvOptions; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private readonly IAgvJobOutputService _agvOutJob; |
|
|
|
|
|
|
|
|
private readonly IPostionLocationAppService _postionLocationAppService; |
|
|
|
|
|
|
|
|
public AssembleIssueJobAppService( |
|
|
public AssembleIssueJobAppService( |
|
|
ILogger<AssembleIssueJobAppService> logger, |
|
|
ILogger<AssembleIssueJobAppService> logger, |
|
|
IAgvJobOutputService agvOutJob, |
|
|
|
|
|
IAssembleIssueJobRepository repository, IAssembleIssueJobManager assembleIssueJobManager, |
|
|
IAssembleIssueJobRepository repository, IAssembleIssueJobManager assembleIssueJobManager, |
|
|
ILocationAppService locationAppService, |
|
|
ILocationAppService locationAppService, |
|
|
IAssembleIssueNoteAppService assembleIssueNoteAppService, IExpectOutAppService expectOutAppService |
|
|
IAssembleIssueNoteAppService assembleIssueNoteAppService, IExpectOutAppService expectOutAppService |
|
|
,IHttpClientFactory httpClientFactory |
|
|
,IHttpClientFactory httpClientFactory |
|
|
,IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, |
|
|
,IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, |
|
|
ICurrentUser currentUser, UnitOfWorkManager unitOfWorkManager) : base( |
|
|
ICurrentUser currentUser, UnitOfWorkManager unitOfWorkManager |
|
|
|
|
|
, IOptions<AgvOptions> agvOptions |
|
|
|
|
|
, IPostionLocationAppService postionLocationAppService |
|
|
|
|
|
|
|
|
|
|
|
) : base( |
|
|
repository, assembleIssueJobManager |
|
|
repository, assembleIssueJobManager |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
) |
|
|
) |
|
|
{ |
|
|
{ |
|
|
|
|
|
_postionLocationAppService= postionLocationAppService; |
|
|
_assembleIssueJobManager = assembleIssueJobManager; |
|
|
_assembleIssueJobManager = assembleIssueJobManager; |
|
|
_locationAppService = locationAppService; |
|
|
_locationAppService = locationAppService; |
|
|
_assembleIssueNoteAppService = assembleIssueNoteAppService; |
|
|
_assembleIssueNoteAppService = assembleIssueNoteAppService; |
|
@ -79,8 +88,8 @@ public class AssembleIssueJobAppService |
|
|
_currentUser = currentUser; |
|
|
_currentUser = currentUser; |
|
|
_unitOfWorkManager = unitOfWorkManager; |
|
|
_unitOfWorkManager = unitOfWorkManager; |
|
|
_logger = logger; |
|
|
_logger = logger; |
|
|
_agvOutJob = agvOutJob; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_agvOptions = agvOptions; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[HttpPost("get-by-number-2")] |
|
|
[HttpPost("get-by-number-2")] |
|
@ -655,11 +664,6 @@ public class AssembleIssueJobAppService |
|
|
var dtos = ObjectMapper.Map<List<AssembleIssueJob>, List<AssembleIssueJobDTO>>(entities); |
|
|
var dtos = ObjectMapper.Map<List<AssembleIssueJob>, List<AssembleIssueJobDTO>>(entities); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (input.Jobs.Count != entities.Count) |
|
|
if (input.Jobs.Count != entities.Count) |
|
|
{ |
|
|
{ |
|
|
errors.Add("立体库提交出库任务和WMS任务不符,请核对! \n"); |
|
|
errors.Add("立体库提交出库任务和WMS任务不符,请核对! \n"); |
|
@ -679,18 +683,13 @@ public class AssembleIssueJobAppService |
|
|
{ |
|
|
{ |
|
|
errors.Add($"来源库位{detail.FromLocationCode}没查到"); |
|
|
errors.Add($"来源库位{detail.FromLocationCode}没查到"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var toloc = await _locationAppService.GetByCodeAsync(detail.ToLocationCode) |
|
|
var toloc = await _locationAppService.GetByCodeAsync(detail.ToLocationCode) |
|
|
.ConfigureAwait(false); |
|
|
.ConfigureAwait(false); |
|
|
if (toloc == null) |
|
|
if (toloc == null) |
|
|
{ |
|
|
{ |
|
|
errors.Add($"目标库位{detail.ToLocationCode}没查到"); |
|
|
errors.Add($"目标库位{detail.ToLocationCode}没查到"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.ItemCode); |
|
|
var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.ItemCode); |
|
|
|
|
|
|
|
|
if (entity == null) |
|
|
if (entity == null) |
|
|
{ |
|
|
{ |
|
|
errors.Add($"物料号{detail.ItemCode}不在任务明细内!"); |
|
|
errors.Add($"物料号{detail.ItemCode}不在任务明细内!"); |
|
@ -985,23 +984,231 @@ public class AssembleIssueJobAppService |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 调用AgvOutPut出库
|
|
|
[HttpPost("PushOutTask")] |
|
|
/// </summary>
|
|
|
public async Task<AgvResultObject> PushOutTaskAsync(AssembleIssueJobDTO job) |
|
|
/// <param name="job"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
private async Task<AgvResultObject> InvokeAgvOutput(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); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var first = job.Details.FirstOrDefault(); |
|
|
if (!string.IsNullOrEmpty(_agvOptions.Value.UserName) && !string.IsNullOrEmpty(_agvOptions.Value.Password)) |
|
|
var requst = new AgvRequest(); |
|
|
{ |
|
|
requst.MatCode = first.ItemCode; |
|
|
var username = _agvOptions.Value.UserName; |
|
|
requst.MatQty = first.HandledToQty; |
|
|
var password = _agvOptions.Value.Password; |
|
|
requst.OrderNum = job.Number; |
|
|
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", |
|
|
requst.OrderType = "2"; |
|
|
Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); |
|
|
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.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 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
|
|
|
#endregion
|
|
|
} |
|
|
} |
|
|