Browse Source

提交修改AGV完工转储

Agv分支2024-11-19
赵新宇 5 months ago
parent
commit
65360992d0
  1. 9
      be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs
  2. 331
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs
  3. 1
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/TransferNotes/TransferNote.cs

9
be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs

@ -232,5 +232,12 @@ public enum EnumTransSubType
/// 立库出库线边仓领料 /// 立库出库线边仓领料
/// </summary> /// </summary>
[Display(Name = "立库出库线边仓领料")] [Display(Name = "立库出库线边仓领料")]
Depot_Issue_WIP = 1511 Depot_Issue_WIP = 1511,
/// <summary>
///AGV出库线边仓调拨
/// </summary>
[Display(Name = "AGV出库线边仓调拨")]
Agv_Transfer_WIP = 1512
} }

331
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs

@ -29,6 +29,8 @@ using Win_in.Sfs.Wms.Store.Jobs.IssueJobs.proxy;
using Win_in.Sfs.Wms.Store.Options; using Win_in.Sfs.Wms.Store.Options;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Volo.Abp.ObjectMapping;
using NUglify.Helpers;
namespace Win_in.Sfs.Wms.Store.Application; namespace Win_in.Sfs.Wms.Store.Application;
@ -54,10 +56,10 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase
private readonly IExpectOutAppService _expectOutAppService; // private readonly IExpectOutAppService _expectOutAppService; //
private readonly IInventoryLabelAppService _inventoryLabelAppService; private readonly IInventoryLabelAppService _inventoryLabelAppService;
private readonly IHttpClientFactory _httpClientFactory; private readonly IHttpClientFactory _httpClientFactory;
private readonly IItemBasicAppService _itemBasicAppService;
private readonly IOptions<AgvOptions> _agvOptions; private readonly IOptions<AgvOptions> _agvOptions;
private readonly ILogger<AssembleIssueJobAppService> _logger; private readonly ILogger<TransferNoteAppService> _logger;
private readonly IPostionLocationAppService _postionLocationAppService; private readonly IPostionLocationAppService _postionLocationAppService;
@ -76,6 +78,10 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase
IIssueJobAppService issueJobAppService, IIssueJobAppService issueJobAppService,
IInventoryLabelAppService inventoryLabelAppService, IInventoryLabelAppService inventoryLabelAppService,
IHttpClientFactory _httpClientFactory, IHttpClientFactory _httpClientFactory,
ILogger<TransferNoteAppService> logger,
IOptions<AgvOptions> agvOptions,
IPostionLocationAppService postionLocationAppService,
IItemBasicAppService itemBasicAppService,
IExpectOutAppService expectOutAppService) : base(repository) IExpectOutAppService expectOutAppService) : base(repository)
{ {
_transferNoteManager = transferNoteManager; _transferNoteManager = transferNoteManager;
@ -88,6 +94,10 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase
_issueJobAppService = issueJobAppService; _issueJobAppService = issueJobAppService;
_inventoryLabelAppService = inventoryLabelAppService; _inventoryLabelAppService = inventoryLabelAppService;
_expectOutAppService = expectOutAppService; _expectOutAppService = expectOutAppService;
_logger = logger;
_agvOptions = agvOptions;
_postionLocationAppService = postionLocationAppService;
_itemBasicAppService = itemBasicAppService;
} }
#region 东阳使用 #region 东阳使用
@ -666,124 +676,243 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase
#if DEBUG #if DEBUG
#endif #endif
var errors = new List<string>(); var errors = new List<string>();
var first = request.Data.FirstOrDefault(); //var first = request.Data.FirstOrDefault();
var job = await _repository.GetAsync(p => p.Number == first.OrderNum).ConfigureAwait(false); //var job = await _repository.GetAsync(p => p.Number == first.OrderNum).ConfigureAwait(false);
var ret = new AgvResultObject var ret = new AgvResultObject
{ {
Code = "0", Code = "0",
Message = "OK", Message = "OK",
ReqCode = job.RequestNumber, ReqCode = "",
}; };
// using var unitOfWork = _unitOfWorkManager.Begin(); // using var unitOfWork = _unitOfWorkManager.Begin();
try try
{ {
if (request.Data.Count > 0) if (request.Data.Count > 0)
{ {
var jobs = request.Data; var notes = request.Data;
var numbers = jobs.Select(p => p.OrderNum); var numbers = notes.Select(p => p.OrderNum);
var query = _repository.WithDetails() foreach (var number in numbers)
.Where(p => numbers.Contains(p.Number) );
var entities = query.ToList();
if (entities.Count == 0)
{
errors.Add($"任务号{string.Join(",", numbers)}不存在!");
}
var dtos = ObjectMapper.Map<List<TransferNote>, List<TransferNoteDTO>>(entities);
foreach (var itm in dtos)
{ {
var arys = jobs.Where(p => p.OrderNum == itm.Number); var details= notes.Where(p => p.OrderNum == number).ToList();
var itmDetails = itm.Details.ToList(); TransferNoteEditInput transfer= new TransferNoteEditInput();
var details = new List<TransferNoteDetailDTO>(); transfer.CallJobNumber = number;
foreach (var detail in arys) transfer.Type= EnumTransSubType.Agv_Transfer_WIP.ToString();
transfer.Worker = "Agv";
transfer.UseOnTheWayLocation = false;
foreach (var detail in details)
{ {
var fromloc = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false);
if (fromloc == null) List<TransferNoteDetailInput> transferNoteDetailInputs = new List<TransferNoteDetailInput>();
{
errors.Add($"来源起始点{detail.BeginPosition}没查到"); TransferNoteDetailInput detailInput = new TransferNoteDetailInput();
} var fromloc = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false);
LocationDTO fromlocation = null; if (fromloc == null)
if (fromloc != null) {
{ errors.Add($"来源起始点{detail.BeginPosition}没查到");
fromlocation = await _locationAppService.GetByCodeAsync(fromloc.LocationCode).ConfigureAwait(false); }
} LocationDTO fromlocation = null;
if (fromlocation == null) if (fromloc != null)
{ {
errors.Add($"来源起始点{detail.BeginPosition}库位没查到"); fromlocation = await _locationAppService.GetByCodeAsync(fromloc.LocationCode).ConfigureAwait(false);
} }
var toloc = await _postionLocationAppService.GetByCodeAsync(detail.EndPosition) if (fromlocation == null)
.ConfigureAwait(false); {
if (toloc == null) errors.Add($"来源起始点{detail.BeginPosition}库位没查到");
{ }
errors.Add($"结束点{detail.EndPosition}没查到"); var toloc = await _postionLocationAppService.GetByCodeAsync(detail.EndPosition)
} .ConfigureAwait(false);
LocationDTO tolocation = null; if (toloc == null)
if (toloc != null) {
{ errors.Add($"结束点{detail.EndPosition}没查到");
tolocation = await _locationAppService.GetByCodeAsync(toloc.LocationCode).ConfigureAwait(false); }
} LocationDTO tolocation = null;
if (tolocation == null) if (toloc != null)
{ {
errors.Add($"结束点{detail.EndPosition}库位没查到"); tolocation = await _locationAppService.GetByCodeAsync(toloc.LocationCode).ConfigureAwait(false);
} }
var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.MatCode); if (tolocation == null)
if (entity == null) {
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
var item =await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{ {
errors.Add($"物料号{detail.MatCode}不在任务明细内!");
errors.Add($"零件号{detail.MatCode}的零件不存在!");
} }
if (errors.Count > 0) else
{ {
return ret = new AgvResultObject() detailInput.ItemCode = item.Code;
{ detailInput.Uom = item.BasicUom;
Code = "-1", detailInput.ItemName = item.Name;
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
} }
var dto = new TransferNoteDetailDTO();
dto.InjectFrom(entity);
dto.ToLocationCode = toloc.Code;
dto.ToLocationGroup = tolocation.LocationGroupCode;
dto.ToLocationArea = tolocation.AreaCode;
dto.ToLocationErpCode = tolocation.ErpLocationCode;
dto.ToWarehouseCode = tolocation.WarehouseCode;
dto.Qty = detail.MatQty;
dto.ToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
dto.ToPackingCode = string.Empty;
dto.FromWarehouseCode = fromlocation.WarehouseCode;
dto.FromLocationCode = fromlocation.Code;
dto.FromLocationGroup = fromlocation.LocationGroupCode;
dto.FromLocationArea = fromlocation.AreaCode;
dto.FromLocationErpCode = fromlocation.ErpLocationCode;
dto.Qty = detail.MatQty;
dto.FromLot = string.Empty;
dto.FromPackingCode = string.Empty;
details.Add(dto);
if (errors.Count > 0)
{
return ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
detailInput.ToLocationCode = tolocation.Code;
detailInput.ToLocationGroup = tolocation.LocationGroupCode;
detailInput.ToLocationArea = tolocation.AreaCode;
detailInput.ToLocationErpCode = tolocation.ErpLocationCode;
detailInput.ToWarehouseCode = tolocation.WarehouseCode;
detailInput.Qty = detail.MatQty;
detailInput.ToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
detailInput.ToPackingCode = string.Empty;
detailInput.FromWarehouseCode = fromlocation.WarehouseCode;
detailInput.FromLocationCode = fromlocation.Code;
detailInput.FromLocationGroup = fromlocation.LocationGroupCode;
detailInput.FromLocationArea = fromlocation.AreaCode;
detailInput.FromLocationErpCode = fromlocation.ErpLocationCode;
detailInput.Qty = detail.MatQty;
detailInput.FromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
detailInput.FromPackingCode = string.Empty;
transfer.Details.Add(detailInput);
}
await CreateAsync(transfer).ConfigureAwait(false);
}
//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任务完成"); //var query = _repository.WithDetails()
} // .Where(p => numbers.Contains(p.Number));
//var query = _repository.WithDetails()
// .Where(p => numbers.Contains(p.Number) );
//var entities = query.ToList();
//if (entities.Count == 0)
//{
// errors.Add($"任务号{string.Join(",", numbers)}不存在!");
//}
//var dtos = ObjectMapper.Map<List<TransferNote>, List<TransferNoteDTO>>(entities);
//List<TransferNote> notelist = new List<TransferNote>();
//foreach (var itm in dtos)
//{
// var note = ObjectMapper.Map<TransferNoteDTO, TransferNote>(itm);
// itm.Type = EnumTransSubType.Agv_Transfer_WIP.ToString();
// var arys = jobs.Where(p => p.OrderNum == itm.Number);
// var itmDetails = itm.Details.ToList();
// var details = new List<TransferNoteDetailDTO>();
// 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.LocationCode).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.LocationCode).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}不在任务明细内!");
// }
// if (errors.Count > 0)
// {
// return ret = new AgvResultObject()
// {
// Code = "-1",
// ReqCode = "",
// Message = string.Join(",", errors.ToArray())
// };
// }
// var dto = new TransferNoteDetailDTO();
// dto.InjectFrom(entity);
// dto.ToLocationCode = toloc.Code;
// dto.ToLocationGroup = tolocation.LocationGroupCode;
// dto.ToLocationArea = tolocation.AreaCode;
// dto.ToLocationErpCode = tolocation.ErpLocationCode;
// dto.ToWarehouseCode = tolocation.WarehouseCode;
// dto.Qty = detail.MatQty;
// dto.ToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
// dto.ToPackingCode = string.Empty;
// dto.FromWarehouseCode = fromlocation.WarehouseCode;
// dto.FromLocationCode = fromlocation.Code;
// dto.FromLocationGroup = fromlocation.LocationGroupCode;
// dto.FromLocationArea = fromlocation.AreaCode;
// dto.FromLocationErpCode = fromlocation.ErpLocationCode;
// dto.Qty = detail.MatQty;
// dto.FromLot = string.Empty;
// dto.FromPackingCode = string.Empty;
// details.Add(dto);
// //var details=
// //note.Details.Add()
// //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 else
{ {
errors.Add("Agv确认单据里无数据! \n"); errors.Add("Agv确认单据里无数据! \n");
@ -791,11 +920,13 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase
} }
catch (Exception ex) catch (Exception ex)
{ {
ret = new AgvResultObject ret = new AgvResultObject
{ {
Code = "-1", Code = "-1",
ReqCode = job.RequestNumber, ReqCode ="",
Message = ex.Message, Message = ex.Message
}; };
//await unitOfWork.RollbackAsync(); //await unitOfWork.RollbackAsync();
return ret; return ret;
@ -807,7 +938,7 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase
{ {
Code = "-1", Code = "-1",
Message = string.Join(",", errors.ToArray()), Message = string.Join(",", errors.ToArray()),
ReqCode = job.RequestNumber ReqCode = ""
}; };
} }
return ret; return ret;

1
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/TransferNotes/TransferNote.cs

@ -33,6 +33,7 @@ public class TransferNote : SfsStoreAggregateRootBase<TransferNoteDetail>, IHasJ
/// <summary> /// <summary>
/// 使用中间库 /// 使用中间库
///
/// </summary> /// </summary>
[Display(Name = "使用中间库")] [Display(Name = "使用中间库")]
public bool UseOnTheWayLocation { get; set; } public bool UseOnTheWayLocation { get; set; }

Loading…
Cancel
Save