|
|
@ -9,8 +9,10 @@ using System.Threading.Tasks; |
|
|
|
using Castle.Components.DictionaryAdapter; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using MyNamespace; |
|
|
|
using Omu.ValueInjecter; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.ObjectMapping; |
|
|
|
using Volo.Abp.Uow; |
|
|
@ -33,7 +35,7 @@ namespace Win_in.Sfs.Wms.Store.Application; |
|
|
|
public class SparePartIssueJobAppService |
|
|
|
: SfsJobAppServiceBase<SparePartIssueJob, SparePartIssueJobDetail, SparePartIssueJobDTO, SfsJobRequestInputBase, |
|
|
|
SparePartIssueJobCheckInput, SparePartIssueJobEditInput>, |
|
|
|
ISparePartIssueJobAppService, ITransferLibCallback |
|
|
|
ISparePartIssueJobAppService, ITransferLibCallback, IAgvJobAccountService |
|
|
|
{ |
|
|
|
private readonly ISparePartIssueJobManager _sparePartIssueJobManager; |
|
|
|
private readonly ILocationAppService _locationAppService; |
|
|
@ -47,6 +49,7 @@ public class SparePartIssueJobAppService |
|
|
|
private readonly UnitOfWorkManager _unitOfWorkManager; |
|
|
|
private readonly IOptions<AgvOptions> _agvOptions; |
|
|
|
private readonly IPostionLocationAppService _postionLocationAppService; |
|
|
|
private readonly ILogger<SparePartIssueJobAppService> _logger; |
|
|
|
|
|
|
|
protected ISparePartIssueRequestAppService SparePartIssueRequestAppService => |
|
|
|
LazyServiceProvider.LazyGetRequiredService<ISparePartIssueRequestAppService>(); |
|
|
@ -57,7 +60,7 @@ public class SparePartIssueJobAppService |
|
|
|
ILocationAppService locationAppService, |
|
|
|
ISparePartIssueNoteAppService sparePartIssueNoteAppService, IExpectOutAppService expectOutAppService |
|
|
|
, IHttpClientFactory httpClientFactory |
|
|
|
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser |
|
|
|
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser, ILogger<SparePartIssueJobAppService> logger |
|
|
|
, UnitOfWorkManager unitOfWorkManager, IOptions<AgvOptions> agvOptions |
|
|
|
) : base( |
|
|
|
repository, sparePartIssueJobManager) |
|
|
@ -72,7 +75,8 @@ public class SparePartIssueJobAppService |
|
|
|
_currentUser = currentUser; |
|
|
|
_agvOutJob = agvOutJob; |
|
|
|
_unitOfWorkManager = unitOfWorkManager; |
|
|
|
_agvOptions = agvOptions; |
|
|
|
_agvOptions = agvOptions; |
|
|
|
_logger = logger; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("get-by-number-2")] |
|
|
@ -734,6 +738,163 @@ public class SparePartIssueJobAppService |
|
|
|
} |
|
|
|
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.SparePartRequestNumber, |
|
|
|
|
|
|
|
}; |
|
|
|
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<SparePartIssueJob>, List<SparePartIssueJobDTO>>(entities); |
|
|
|
foreach (var itm in dtos) |
|
|
|
{ |
|
|
|
var arys = jobs.Where(p => p.OrderNum == itm.Number); |
|
|
|
var itmDetails = itm.Details.ToList(); |
|
|
|
var details = new List<SparePartIssueJobDetailDTO>(); |
|
|
|
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 SparePartIssueJobDetailDTO(); |
|
|
|
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.SparePartRequestNumber, |
|
|
|
Message = ex.Message, |
|
|
|
}; |
|
|
|
await unitOfWork.RollbackAsync(); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
if (errors.Count > 0) |
|
|
|
{ |
|
|
|
ret = new AgvResultObject |
|
|
|
{ |
|
|
|
Code = "-1", |
|
|
|
Message = string.Join(",", errors.ToArray()), |
|
|
|
ReqCode = job.SparePartRequestNumber |
|
|
|
}; |
|
|
|
} |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|