Browse Source

Merge branch 'Agv分支2024-11-19' of http://dev.ccwin-in.com:3000/BoXu.Zheng/WZC2 into Agv分支2024-11-19

Agv分支2024-11-19
郑勃旭 5 months ago
parent
commit
a5e0337222
  1. 33
      be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs
  2. 156
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AssembleIssueJobs/AssembleIssueJobAppService.cs
  3. 206
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs
  4. 152
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionIssueJobs/InjectionIssueJobAppService.cs
  5. 201
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs
  6. 153
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/SparePartIssueJobs/SparePartIssueJobAppService.cs
  7. 155
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedIssueJobs/UnplannedIssueJobAppService.cs
  8. 154
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedReceiptJobs/UnplannedReceiptJobAppService.cs
  9. 274
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs

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

@ -243,15 +243,36 @@ public enum EnumTransSubType
/// <summary> /// <summary>
///AGV冻结 ///AGV喷涂回库
/// </summary> /// </summary>
[Display(Name = "AGV冻结")] [Display(Name = "AGV喷涂回库")]
Agv_Freezed = 1513, Agv_Return_Coating = 1513,
/// <summary> /// <summary>
///AGV冻结 ///AGVKitting回库
/// </summary> /// </summary>
[Display(Name = "AGV解冻")] [Display(Name = "AGVKitting回库")]
Agv_UnFreezed = 1514 Agv_Return_Kitting = 1514,
/// <summary>
///AGV装配回库
/// </summary>
[Display(Name = "AGV装配回库")]
Agv_Return_Assemble = 1515,
/// <summary>
///AGV注塑回库
/// </summary>
[Display(Name = "AGV注塑回库")]
Agv_Return_Injection = 1516,
/// <summary>
///AGV备品回库
/// </summary>
[Display(Name = "AGV备品回库")]
Agv_Return_SparePart = 1517,
} }

156
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AssembleIssueJobs/AssembleIssueJobAppService.cs

@ -63,6 +63,7 @@ public class AssembleIssueJobAppService
private readonly IPostionLocationAppService _postionLocationAppService; private readonly IPostionLocationAppService _postionLocationAppService;
private readonly ILocationDeliveryAppService _locationDeliveryAppService; private readonly ILocationDeliveryAppService _locationDeliveryAppService;
private readonly IItemBasicAppService _itemBasicAppService; private readonly IItemBasicAppService _itemBasicAppService;
private readonly ITransferNoteAppService _transferNoteAppService;
public AssembleIssueJobAppService( public AssembleIssueJobAppService(
ILogger<AssembleIssueJobAppService> logger, ILogger<AssembleIssueJobAppService> logger,
@ -74,7 +75,10 @@ public class AssembleIssueJobAppService
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, , IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService,
ICurrentUser currentUser, UnitOfWorkManager unitOfWorkManager ICurrentUser currentUser, UnitOfWorkManager unitOfWorkManager
, IOptions<AgvOptions> agvOptions , IOptions<AgvOptions> agvOptions
, IPostionLocationAppService postionLocationAppService, ILocationDeliveryAppService locationDeliveryAppService) : base( , IPostionLocationAppService postionLocationAppService, ILocationDeliveryAppService locationDeliveryAppService
, ITransferNoteAppService transferNoteAppService
) : base(
repository, assembleIssueJobManager repository, assembleIssueJobManager
@ -95,6 +99,7 @@ public class AssembleIssueJobAppService
_agvOptions = agvOptions; _agvOptions = agvOptions;
_itemBasicAppService = itemBasicAppService; _itemBasicAppService = itemBasicAppService;
_transferNoteAppService = transferNoteAppService;
} }
[HttpPost("get-by-number-2")] [HttpPost("get-by-number-2")]
@ -1080,6 +1085,155 @@ public class AssembleIssueJobAppService
return ret; return ret;
} }
/// <summary>
/// Agv 回库 接口
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost("call-return-back-agv")]
public async Task<AgvResultObject> CallReturnBackAgvAsync(AgvRequestDto 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 ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = "",
};
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (request.Data.Count > 0)
{
var notes = request.Data;
foreach (var detail in notes)
{
TransferNoteEditInput transfer = new TransferNoteEditInput();
transfer.CallJobNumber = detail.OrderNum;
transfer.Type = EnumTransSubType.Agv_Return_Assemble.ToString();
transfer.Worker = "Agv";
transfer.UseOnTheWayLocation = false;
List<TransferNoteDetailInput> transferNoteDetailInputs = new List<TransferNoteDetailInput>();
TransferNoteDetailInput detailInput = new TransferNoteDetailInput();
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 item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
errors.Add($"零件号{detail.MatCode}的零件不存在!");
}
else
{
detailInput.ItemCode = item.Code;
detailInput.Uom = item.BasicUom;
detailInput.ItemName = item.Name;
detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty;
}
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.FromStatus = tolocation.DefaultInventoryStatus;
detailInput.Qty = detail.MatQty;
detailInput.ToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
detailInput.ToPackingCode = detail.PakingCode;
detailInput.FromWarehouseCode = fromlocation.WarehouseCode;
detailInput.FromLocationCode = fromlocation.Code;
detailInput.FromLocationGroup = fromlocation.LocationGroupCode;
detailInput.FromLocationArea = fromlocation.AreaCode;
detailInput.FromLocationErpCode = fromlocation.ErpLocationCode;
detailInput.ToStatus = fromlocation.DefaultInventoryStatus;
detailInput.Qty = detail.MatQty;
detailInput.FromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
detailInput.FromPackingCode = detail.PakingCode;
transfer.Details.Add(detailInput);
await _transferNoteAppService.CreateAsync(transfer).ConfigureAwait(false);
}
}
else
{
errors.Add("Agv确认单据里无数据! \n");
}
}
catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = "",
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = ""
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
return ret;
}
/// <summary> /// <summary>
/// 调用Agv接口实现 /// 调用Agv接口实现
/// </summary> /// </summary>

206
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs

@ -54,7 +54,7 @@ public class CoatingIssueJobAppService
private readonly IOptions<AgvOptions> _agvOptions; private readonly IOptions<AgvOptions> _agvOptions;
private readonly IPostionLocationAppService _postionLocationAppService; private readonly IPostionLocationAppService _postionLocationAppService;
private readonly IItemBasicAppService _itemBasicAppService; private readonly IItemBasicAppService _itemBasicAppService;
private readonly ITransferNoteAppService _transferNoteAppService;
protected ICoatingIssueRequestAppService CoatingIssueRequestAppService => protected ICoatingIssueRequestAppService CoatingIssueRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<ICoatingIssueRequestAppService>(); LazyServiceProvider.LazyGetRequiredService<ICoatingIssueRequestAppService>();
@ -68,7 +68,7 @@ public class CoatingIssueJobAppService
, IHttpClientFactory httpClientFactory , IHttpClientFactory httpClientFactory
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser, IOptions<AgvOptions> agvOptions , IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser, IOptions<AgvOptions> agvOptions
, UnitOfWorkManager unitOfWorkManager , UnitOfWorkManager unitOfWorkManager
, IPostionLocationAppService postionLocationAppService, IItemBasicAppService _itemBasicAppService , IPostionLocationAppService postionLocationAppService, IItemBasicAppService _itemBasicAppService, ITransferNoteAppService transferNoteAppService
) : base( ) : base(
repository, coatingIssueJobManager) repository, coatingIssueJobManager)
{ {
@ -85,6 +85,7 @@ public class CoatingIssueJobAppService
_unitOfWorkManager = unitOfWorkManager; _unitOfWorkManager = unitOfWorkManager;
_agvOptions = agvOptions; _agvOptions = agvOptions;
_postionLocationAppService = postionLocationAppService; _postionLocationAppService = postionLocationAppService;
_transferLibRequestAppService= transferLibRequestAppService;
} }
[HttpPost("get-by-number-2")] [HttpPost("get-by-number-2")]
@ -1034,96 +1035,169 @@ public class CoatingIssueJobAppService
} }
/// <summary> /// <summary>
/// 调用Agv接口实现 /// Agv 回库 接口
/// </summary> /// </summary>
/// <param name="job"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
private async Task<AgvResultObject> SendInterFaceAsync(CoatingIssueJobDTO job) [HttpPost("call-return-back-agv")]
public async Task<AgvResultObject> CallReturnBackAgvAsync(AgvRequestDto request)
{ {
var json = JsonSerializer.Serialize(request);
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
_logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json);
#if DEBUG #if DEBUG
#endif #endif
var errors = new List<string>();
var ret = new AgvResultObject var ret = new AgvResultObject
{ {
Code = "0", Code = "0",
ReqCode = job.CoatingRequestNumber, Message = "OK",
Message = "OK" ReqCode = "",
}; };
using var unitOfWork = _unitOfWorkManager.Begin(); using var unitOfWork = _unitOfWorkManager.Begin();
try try
{ {
if (request.Data.Count > 0)
{
var notes = request.Data;
if (job.JobStatus == EnumJobStatus.Done) foreach (var detail in notes)
{ {
throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!"); TransferNoteEditInput transfer = new TransferNoteEditInput();
transfer.CallJobNumber = detail.OrderNum;
transfer.Type = EnumTransSubType.Agv_Return_Coating.ToString();
transfer.Worker = "Agv";
transfer.UseOnTheWayLocation = false;
List<TransferNoteDetailInput> transferNoteDetailInputs = new List<TransferNoteDetailInput>();
TransferNoteDetailInput detailInput = new TransferNoteDetailInput();
var fromloc = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false);
if (fromloc == null)
{
errors.Add($"来源起始点{detail.BeginPosition}没查到");
} }
LocationDTO fromlocation = null;
if (job.Details.Count == 0) if (fromloc != null)
{ {
throw new UserFriendlyException($"任务{job.Number}没有推荐库存!"); 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 item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
errors.Add($"零件号{detail.MatCode}的零件不存在!");
}
else
{
detailInput.ItemCode = item.Code;
detailInput.Uom = item.BasicUom;
detailInput.ItemName = item.Name;
detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty;
}
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.FromStatus = tolocation.DefaultInventoryStatus;
var first = job.Details.FirstOrDefault();
var request = new AgvRequest();
request.MatCode = first.ItemCode;
request.MatQty = first.HandledToQty;
request.OrderNum = job.Number;
request.OrderType = EnumJobType.CoatingIssueJob.ToString();
detailInput.Qty = detail.MatQty;
detailInput.ToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
detailInput.ToPackingCode = detail.PakingCode;
detailInput.FromWarehouseCode = fromlocation.WarehouseCode;
detailInput.FromLocationCode = fromlocation.Code;
detailInput.FromLocationGroup = fromlocation.LocationGroupCode;
detailInput.FromLocationArea = fromlocation.AreaCode;
detailInput.FromLocationErpCode = fromlocation.ErpLocationCode;
detailInput.ToStatus = fromlocation.DefaultInventoryStatus;
detailInput.Qty = detail.MatQty;
detailInput.FromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
detailInput.FromPackingCode = detail.PakingCode;
var httpclient = _httpClientFactory.CreateClient(); transfer.Details.Add(detailInput);
_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");
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)) await _transferNoteAppService.CreateAsync(transfer).ConfigureAwait(false);
}
}
else
{ {
var username = _agvOptions.Value.UserName; errors.Add("Agv确认单据里无数据! \n");
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); catch (Exception ex)
ret = await client.PushOutTask4FWAsync(request).ConfigureAwait(false); {
ret = new AgvResultObject
{
Code = "-1",
ReqCode = "",
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
} }
catch (Exception e)
if (errors.Count > 0)
{ {
ret = new AgvResultObject(); ret = new AgvResultObject
ret.Code = "1"; {
ret.Message = e.Message; Code = "-1",
ret.ReqCode = job.CoatingRequestNumber; Message = string.Join(",", errors.ToArray()),
ReqCode = ""
};
await unitOfWork.RollbackAsync().ConfigureAwait(false); await unitOfWork.RollbackAsync().ConfigureAwait(false);
throw new UserFriendlyException($"接口报错 错误信息{e.Message}");
} }
return ret; return ret;
} }
/// <summary> /// <summary>
/// 回库调用 /// 调用Agv接口实现
/// </summary> /// </summary>
/// <param name="job"></param> /// <param name="job"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="UserFriendlyException"></exception> private async Task<AgvResultObject> SendInterFaceAsync(CoatingIssueJobDTO job)
private async Task<AgvResultObject> ReturnBackAsync(CoatingIssueJobDTO job)
{ {
#if DEBUG
#endif
var ret = new AgvResultObject var ret = new AgvResultObject
{ {
Code = "0", Code = "0",
@ -1133,11 +1207,24 @@ public class CoatingIssueJobAppService
using var unitOfWork = _unitOfWorkManager.Begin(); using var unitOfWork = _unitOfWorkManager.Begin();
try try
{ {
if (job.JobStatus == EnumJobStatus.Done)
{
throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!");
}
if (job.Details.Count == 0)
{
throw new UserFriendlyException($"任务{job.Number}没有推荐库存!");
}
var first = job.Details.FirstOrDefault(); var first = job.Details.FirstOrDefault();
var request = new AgvRequestBack(); var request = new AgvRequest();
request.MatCode = first.ItemCode; request.MatCode = first.ItemCode;
request.ReturnQty = first.HandledToQty; request.MatQty = first.HandledToQty;
request.EndPosition = first.HandledToLocationCode; request.OrderNum = job.Number;
request.OrderType = EnumJobType.CoatingIssueJob.ToString();
var httpclient = _httpClientFactory.CreateClient(); var httpclient = _httpClientFactory.CreateClient();
@ -1170,7 +1257,7 @@ public class CoatingIssueJobAppService
} }
var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path); var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path);
ret = await client.NotifyOutTaskBack4FWAsync(request).ConfigureAwait(false); ret = await client.PushOutTask4FWAsync(request).ConfigureAwait(false);
} }
catch (Exception e) catch (Exception e)
@ -1184,5 +1271,6 @@ public class CoatingIssueJobAppService
} }
return ret; return ret;
} }
#endregion #endregion
} }

152
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionIssueJobs/InjectionIssueJobAppService.cs

@ -52,6 +52,7 @@ public class InjectionIssueJobAppService
private readonly IPostionLocationAppService _postionLocationAppService; private readonly IPostionLocationAppService _postionLocationAppService;
private readonly ILogger<InjectionIssueJobAppService> _logger; private readonly ILogger<InjectionIssueJobAppService> _logger;
private readonly IItemBasicAppService _itemBasicAppService; private readonly IItemBasicAppService _itemBasicAppService;
private readonly ITransferNoteAppService _transferNoteAppService;
protected IInjectionIssueRequestAppService InjectionIssueRequestAppService => protected IInjectionIssueRequestAppService InjectionIssueRequestAppService =>
@ -971,6 +972,157 @@ public class InjectionIssueJobAppService
} }
return ret; return ret;
} }
/// <summary>
/// Agv 回库 接口
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost("call-return-back-agv")]
public async Task<AgvResultObject> CallReturnBackAgvAsync(AgvRequestDto 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 ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = "",
};
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (request.Data.Count > 0)
{
var notes = request.Data;
foreach (var detail in notes)
{
TransferNoteEditInput transfer = new TransferNoteEditInput();
transfer.CallJobNumber = detail.OrderNum;
transfer.Type = EnumTransSubType.Agv_Return_Injection.ToString();
transfer.Worker = "Agv";
transfer.UseOnTheWayLocation = false;
List<TransferNoteDetailInput> transferNoteDetailInputs = new List<TransferNoteDetailInput>();
TransferNoteDetailInput detailInput = new TransferNoteDetailInput();
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 item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
errors.Add($"零件号{detail.MatCode}的零件不存在!");
}
else
{
detailInput.ItemCode = item.Code;
detailInput.Uom = item.BasicUom;
detailInput.ItemName = item.Name;
detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty;
}
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.FromStatus = tolocation.DefaultInventoryStatus;
detailInput.Qty = detail.MatQty;
detailInput.ToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
detailInput.ToPackingCode = detail.PakingCode;
detailInput.FromWarehouseCode = fromlocation.WarehouseCode;
detailInput.FromLocationCode = fromlocation.Code;
detailInput.FromLocationGroup = fromlocation.LocationGroupCode;
detailInput.FromLocationArea = fromlocation.AreaCode;
detailInput.FromLocationErpCode = fromlocation.ErpLocationCode;
detailInput.ToStatus = fromlocation.DefaultInventoryStatus;
detailInput.Qty = detail.MatQty;
detailInput.FromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
detailInput.FromPackingCode = detail.PakingCode;
transfer.Details.Add(detailInput);
await _transferNoteAppService.CreateAsync(transfer).ConfigureAwait(false);
}
}
else
{
errors.Add("Agv确认单据里无数据! \n");
}
}
catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = "",
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = ""
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
return ret;
}
/// <summary> /// <summary>
/// 调用Agv接口实现 /// 调用Agv接口实现

201
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs

@ -53,6 +53,7 @@ public class KittingIssueJobAppService
private readonly IPostionLocationAppService _postionLocationAppService; private readonly IPostionLocationAppService _postionLocationAppService;
private readonly ILogger<KittingIssueJobAppService> _logger; private readonly ILogger<KittingIssueJobAppService> _logger;
private readonly IItemBasicAppService _itemBasicAppService; private readonly IItemBasicAppService _itemBasicAppService;
private readonly ITransferNoteAppService _transferNoteAppService;
protected IKittingIssueRequestAppService KittingIssueRequestAppService => protected IKittingIssueRequestAppService KittingIssueRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<IKittingIssueRequestAppService>(); LazyServiceProvider.LazyGetRequiredService<IKittingIssueRequestAppService>();
@ -980,95 +981,164 @@ public class KittingIssueJobAppService
} }
/// <summary> /// <summary>
/// 调用Agv接口实现 /// Agv 回库 接口
/// </summary> /// </summary>
/// <param name="job"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
private async Task<AgvResultObject> SendInterFaceAsync(KittingIssueJobDTO job) [HttpPost("call-return-back-agv")]
public async Task<AgvResultObject> CallReturnBackAgvAsync(AgvRequestDto request)
{ {
var json = JsonSerializer.Serialize(request);
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
_logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json);
#if DEBUG #if DEBUG
#endif #endif
var errors = new List<string>();
var ret = new AgvResultObject var ret = new AgvResultObject
{ {
Code = "0", Code = "0",
ReqCode = job.KittingRequestNumber, Message = "OK",
Message = "OK" ReqCode = "",
}; };
using var unitOfWork = _unitOfWorkManager.Begin(); using var unitOfWork = _unitOfWorkManager.Begin();
try try
{ {
if (request.Data.Count > 0)
{
var notes = request.Data;
if (job.JobStatus == EnumJobStatus.Done) foreach (var detail in notes)
{ {
throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!"); TransferNoteEditInput transfer = new TransferNoteEditInput();
transfer.CallJobNumber = detail.OrderNum;
transfer.Type = EnumTransSubType.Agv_Return_Kitting.ToString();
transfer.Worker = "Agv";
transfer.UseOnTheWayLocation = false;
List<TransferNoteDetailInput> transferNoteDetailInputs = new List<TransferNoteDetailInput>();
TransferNoteDetailInput detailInput = new TransferNoteDetailInput();
var fromloc = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false);
if (fromloc == null)
{
errors.Add($"来源起始点{detail.BeginPosition}没查到");
} }
LocationDTO fromlocation = null;
if (job.Details.Count == 0) if (fromloc != null)
{ {
throw new UserFriendlyException($"任务{job.Number}没有推荐库存!"); fromlocation = await _locationAppService.GetByCodeAsync(fromloc.LocationCode).ConfigureAwait(false);
} }
var first = job.Details.FirstOrDefault(); if (fromlocation == null)
var request = new AgvRequest();
request.MatCode = first.ItemCode;
request.MatQty = first.HandledToQty;
request.OrderNum = job.Number;
request.OrderType = EnumJobType.KittingIssueJob.ToString();
request.BeginPosition = first.HandledFromLocationCode;
request.EndPosition = first.HandledToLocationCode;
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");
if (!string.IsNullOrEmpty(_agvOptions.Value.Token))
{ {
var token = _agvOptions.Value.Token; errors.Add($"来源起始点{detail.BeginPosition}库位没查到");
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
} }
var toloc = await _postionLocationAppService.GetByCodeAsync(detail.EndPosition)
if (!string.IsNullOrEmpty(_agvOptions.Value.UserName) && !string.IsNullOrEmpty(_agvOptions.Value.Password)) .ConfigureAwait(false);
if (toloc == null)
{ {
var username = _agvOptions.Value.UserName; errors.Add($"结束点{detail.EndPosition}没查到");
var password = _agvOptions.Value.Password; }
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", LocationDTO tolocation = null;
Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); if (toloc != null)
{
tolocation = await _locationAppService.GetByCodeAsync(toloc.LocationCode).ConfigureAwait(false);
}
if (tolocation == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
errors.Add($"零件号{detail.MatCode}的零件不存在!");
} }
else
{
detailInput.ItemCode = item.Code;
detailInput.Uom = item.BasicUom;
detailInput.ItemName = item.Name;
detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty;
}
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.FromStatus = tolocation.DefaultInventoryStatus;
var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path);
ret = await client.PushOutTask4FWAsync(request).ConfigureAwait(false);
detailInput.Qty = detail.MatQty;
detailInput.ToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
detailInput.ToPackingCode = detail.PakingCode;
detailInput.FromWarehouseCode = fromlocation.WarehouseCode;
detailInput.FromLocationCode = fromlocation.Code;
detailInput.FromLocationGroup = fromlocation.LocationGroupCode;
detailInput.FromLocationArea = fromlocation.AreaCode;
detailInput.FromLocationErpCode = fromlocation.ErpLocationCode;
detailInput.ToStatus = fromlocation.DefaultInventoryStatus;
detailInput.Qty = detail.MatQty;
detailInput.FromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
detailInput.FromPackingCode = detail.PakingCode;
transfer.Details.Add(detailInput);
await _transferNoteAppService.CreateAsync(transfer).ConfigureAwait(false);
} }
catch (Exception e) }
else
{ {
ret = new AgvResultObject(); errors.Add("Agv确认单据里无数据! \n");
ret.Code = "1"; }
ret.Message = e.Message; }
ret.ReqCode = job.KittingRequestNumber; catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = "",
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = ""
};
await unitOfWork.RollbackAsync().ConfigureAwait(false); await unitOfWork.RollbackAsync().ConfigureAwait(false);
throw new UserFriendlyException($"接口报错 错误信息{e.Message}");
} }
return ret; return ret;
} }
/// <summary> /// <summary>
/// 回库调用 /// 调用Agv接口实现
/// </summary> /// </summary>
/// <param name="job"></param> /// <param name="job"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="UserFriendlyException"></exception> private async Task<AgvResultObject> SendInterFaceAsync(KittingIssueJobDTO job)
private async Task<AgvResultObject> ReturnBackAsync(KittingIssueJobDTO job)
{ {
#if DEBUG
#endif
var ret = new AgvResultObject var ret = new AgvResultObject
{ {
Code = "0", Code = "0",
@ -1078,13 +1148,25 @@ public class KittingIssueJobAppService
using var unitOfWork = _unitOfWorkManager.Begin(); using var unitOfWork = _unitOfWorkManager.Begin();
try try
{ {
if (job.JobStatus == EnumJobStatus.Done)
{
throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!");
}
if (job.Details.Count == 0)
{
throw new UserFriendlyException($"任务{job.Number}没有推荐库存!");
}
var first = job.Details.FirstOrDefault(); var first = job.Details.FirstOrDefault();
var request = new AgvRequestBack(); var request = new AgvRequest();
request.MatCode = first.ItemCode; request.MatCode = first.ItemCode;
request.ReturnQty = first.HandledToQty; request.MatQty = first.HandledToQty;
request.OrderNum = job.Number;
request.OrderType = EnumJobType.KittingIssueJob.ToString();
request.BeginPosition = first.HandledFromLocationCode;
request.EndPosition = first.HandledToLocationCode; request.EndPosition = first.HandledToLocationCode;
var httpclient = _httpClientFactory.CreateClient(); var httpclient = _httpClientFactory.CreateClient();
_agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address) _agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address)
? "http://7e42682n64.goho.co:21171/" ? "http://7e42682n64.goho.co:21171/"
@ -1115,7 +1197,7 @@ public class KittingIssueJobAppService
} }
var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path); var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path);
ret = await client.NotifyOutTaskBack4FWAsync(request).ConfigureAwait(false); ret = await client.PushOutTask4FWAsync(request).ConfigureAwait(false);
} }
catch (Exception e) catch (Exception e)
@ -1131,5 +1213,6 @@ public class KittingIssueJobAppService
} }
#endregion #endregion
} }

153
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/SparePartIssueJobs/SparePartIssueJobAppService.cs

@ -52,6 +52,7 @@ public class SparePartIssueJobAppService
private readonly IPostionLocationAppService _postionLocationAppService; private readonly IPostionLocationAppService _postionLocationAppService;
private readonly ILogger<SparePartIssueJobAppService> _logger; private readonly ILogger<SparePartIssueJobAppService> _logger;
private readonly IItemBasicAppService _itemBasicAppService; private readonly IItemBasicAppService _itemBasicAppService;
private readonly ITransferNoteAppService _transferNoteAppService;
protected ISparePartIssueRequestAppService SparePartIssueRequestAppService => protected ISparePartIssueRequestAppService SparePartIssueRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<ISparePartIssueRequestAppService>(); LazyServiceProvider.LazyGetRequiredService<ISparePartIssueRequestAppService>();
@ -63,7 +64,7 @@ public class SparePartIssueJobAppService
ISparePartIssueNoteAppService sparePartIssueNoteAppService, IExpectOutAppService expectOutAppService ISparePartIssueNoteAppService sparePartIssueNoteAppService, IExpectOutAppService expectOutAppService
, IHttpClientFactory httpClientFactory , IHttpClientFactory httpClientFactory
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser, ILogger<SparePartIssueJobAppService> logger , IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser, ILogger<SparePartIssueJobAppService> logger
, UnitOfWorkManager unitOfWorkManager, IOptions<AgvOptions> agvOptions, IItemBasicAppService itemBasicAppService , UnitOfWorkManager unitOfWorkManager, IOptions<AgvOptions> agvOptions, IItemBasicAppService itemBasicAppService, ITransferNoteAppService transferNoteAppService
) : base( ) : base(
repository, sparePartIssueJobManager) repository, sparePartIssueJobManager)
{ {
@ -80,6 +81,7 @@ public class SparePartIssueJobAppService
_agvOptions = agvOptions; _agvOptions = agvOptions;
_logger = logger; _logger = logger;
_itemBasicAppService = itemBasicAppService; _itemBasicAppService = itemBasicAppService;
_transferNoteAppService = transferNoteAppService;
} }
[HttpPost("get-by-number-2")] [HttpPost("get-by-number-2")]
@ -953,6 +955,155 @@ public class SparePartIssueJobAppService
} }
return ret; return ret;
} }
/// <summary>
/// Agv 回库 接口
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost("call-return-back-agv")]
public async Task<AgvResultObject> CallReturnBackAgvAsync(AgvRequestDto 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 ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = "",
};
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (request.Data.Count > 0)
{
var notes = request.Data;
foreach (var detail in notes)
{
TransferNoteEditInput transfer = new TransferNoteEditInput();
transfer.CallJobNumber = detail.OrderNum;
transfer.Type = EnumTransSubType.Agv_Return_SparePart.ToString();
transfer.Worker = "Agv";
transfer.UseOnTheWayLocation = false;
List<TransferNoteDetailInput> transferNoteDetailInputs = new List<TransferNoteDetailInput>();
TransferNoteDetailInput detailInput = new TransferNoteDetailInput();
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 item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
errors.Add($"零件号{detail.MatCode}的零件不存在!");
}
else
{
detailInput.ItemCode = item.Code;
detailInput.Uom = item.BasicUom;
detailInput.ItemName = item.Name;
detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty;
}
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.FromStatus = tolocation.DefaultInventoryStatus;
detailInput.Qty = detail.MatQty;
detailInput.ToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
detailInput.ToPackingCode = detail.PakingCode;
detailInput.FromWarehouseCode = fromlocation.WarehouseCode;
detailInput.FromLocationCode = fromlocation.Code;
detailInput.FromLocationGroup = fromlocation.LocationGroupCode;
detailInput.FromLocationArea = fromlocation.AreaCode;
detailInput.FromLocationErpCode = fromlocation.ErpLocationCode;
detailInput.ToStatus = fromlocation.DefaultInventoryStatus;
detailInput.Qty = detail.MatQty;
detailInput.FromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
detailInput.FromPackingCode =detail.PakingCode;
transfer.Details.Add(detailInput);
await _transferNoteAppService.CreateAsync(transfer).ConfigureAwait(false);
}
}
else
{
errors.Add("Agv确认单据里无数据! \n");
}
}
catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = "",
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = ""
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
return ret;
}
/// <summary> /// <summary>
/// 调用Agv接口实现 /// 调用Agv接口实现

155
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedIssueJobs/UnplannedIssueJobAppService.cs

@ -50,6 +50,7 @@ public class UnplannedIssueJobAppService
private readonly IOptions<AgvOptions> _agvOptions; private readonly IOptions<AgvOptions> _agvOptions;
private readonly IHttpClientFactory _httpClientFactory; private readonly IHttpClientFactory _httpClientFactory;
private readonly IPostionLocationAppService _postionLocationAppService; private readonly IPostionLocationAppService _postionLocationAppService;
private readonly ITransferNoteAppService _transferNoteAppService;
public UnplannedIssueJobAppService( public UnplannedIssueJobAppService(
@ -58,7 +59,8 @@ public class UnplannedIssueJobAppService
IBalanceAppService balanceAppService, IExpectOutAppService expectOutAppService, IBalanceAppService balanceAppService, IExpectOutAppService expectOutAppService,
IUnitOfWorkManager unitOfWorkManager, ILogger<UnplannedIssueJobAppService> logger, IUnitOfWorkManager unitOfWorkManager, ILogger<UnplannedIssueJobAppService> logger,
IItemBasicAppService itemBasicAppService, IOptions<AgvOptions> agvOptions, IItemBasicAppService itemBasicAppService, IOptions<AgvOptions> agvOptions,
IPostionLocationAppService postionLocationAppService IPostionLocationAppService postionLocationAppService,
ITransferNoteAppService transferNoteAppService
, IHttpClientFactory httpClientFactory , IHttpClientFactory httpClientFactory
) : base(repository, unplannedIssueJobManager) ) : base(repository, unplannedIssueJobManager)
@ -72,6 +74,7 @@ public class UnplannedIssueJobAppService
_itemBasicAppService = itemBasicAppService; _itemBasicAppService = itemBasicAppService;
_agvOptions = agvOptions; _agvOptions = agvOptions;
_httpClientFactory = httpClientFactory; _httpClientFactory = httpClientFactory;
_transferNoteAppService= transferNoteAppService;
_postionLocationAppService = postionLocationAppService; _postionLocationAppService = postionLocationAppService;
} }
@ -860,6 +863,156 @@ public class UnplannedIssueJobAppService
return ret; return ret;
} }
/// <summary>
/// Agv 回库 接口
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost("call-return-back-agv")]
public async Task<AgvResultObject> CallReturnBackAgvAsync(AgvRequestDto 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 ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = "",
};
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (request.Data.Count > 0)
{
var notes = request.Data;
foreach (var detail in notes)
{
TransferNoteEditInput transfer = new TransferNoteEditInput();
transfer.CallJobNumber = detail.OrderNum;
transfer.Type = EnumTransSubType.Agv_Transfer_WIP.ToString();
transfer.Worker = "Agv";
transfer.UseOnTheWayLocation = false;
List<TransferNoteDetailInput> transferNoteDetailInputs = new List<TransferNoteDetailInput>();
TransferNoteDetailInput detailInput = new TransferNoteDetailInput();
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 item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
errors.Add($"零件号{detail.MatCode}的零件不存在!");
}
else
{
detailInput.ItemCode = item.Code;
detailInput.Uom = item.BasicUom;
detailInput.ItemName = item.Name;
detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty;
}
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.FromStatus = tolocation.DefaultInventoryStatus;
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.ToStatus = fromlocation.DefaultInventoryStatus;
detailInput.Qty = detail.MatQty;
detailInput.FromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
detailInput.FromPackingCode = string.Empty;
transfer.Details.Add(detailInput);
await _transferNoteAppService.CreateAsync(transfer).ConfigureAwait(false);
}
}
else
{
errors.Add("Agv确认单据里无数据! \n");
}
}
catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = "",
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = ""
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
return ret;
}
/// <summary> /// <summary>
/// 调用Agv接口实现 /// 调用Agv接口实现
/// </summary> /// </summary>

154
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedReceiptJobs/UnplannedReceiptJobAppService.cs

@ -56,6 +56,7 @@ public class UnplannedReceiptJobAppService
private readonly IUnitOfWorkManager _unitOfWorkManager; private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IPostionLocationAppService _postionLocationAppService; private readonly IPostionLocationAppService _postionLocationAppService;
private readonly ILogger<UnplannedReceiptJobAppService> _logger; private readonly ILogger<UnplannedReceiptJobAppService> _logger;
private readonly ITransferNoteAppService _transferNoteAppService;
public UnplannedReceiptJobAppService( public UnplannedReceiptJobAppService(
@ -66,7 +67,8 @@ public class UnplannedReceiptJobAppService
IOptions<AgvOptions> agvOptions, IOptions<AgvOptions> agvOptions,
IHttpClientFactory httpClientFactory, IHttpClientFactory httpClientFactory,
IUnitOfWorkManager unitOfWorkManager, IUnitOfWorkManager unitOfWorkManager,
ILogger<UnplannedReceiptJobAppService> logger ILogger<UnplannedReceiptJobAppService> logger,
ITransferNoteAppService transferNoteAppService
) : base(repository, UnplannedReceiptJobManager) ) : base(repository, UnplannedReceiptJobManager)
@ -81,6 +83,7 @@ public class UnplannedReceiptJobAppService
_unitOfWorkManager = unitOfWorkManager; _unitOfWorkManager = unitOfWorkManager;
_logger = logger; _logger = logger;
_postionLocationAppService = postionLocationAppService; _postionLocationAppService = postionLocationAppService;
_transferNoteAppService = transferNoteAppService;
} }
@ -521,6 +524,155 @@ public class UnplannedReceiptJobAppService
} }
return ret; return ret;
} }
/// <summary>
/// Agv 回库 接口
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost("call-return-back-agv")]
public async Task<AgvResultObject> CallReturnBackAgvAsync(AgvRequestDto 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 ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = "",
};
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (request.Data.Count > 0)
{
var notes = request.Data;
foreach (var detail in notes)
{
TransferNoteEditInput transfer = new TransferNoteEditInput();
transfer.CallJobNumber = detail.OrderNum;
transfer.Type = EnumTransSubType.Agv_Transfer_WIP.ToString();
transfer.Worker = "Agv";
transfer.UseOnTheWayLocation = false;
List<TransferNoteDetailInput> transferNoteDetailInputs = new List<TransferNoteDetailInput>();
TransferNoteDetailInput detailInput = new TransferNoteDetailInput();
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 item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
errors.Add($"零件号{detail.MatCode}的零件不存在!");
}
else
{
detailInput.ItemCode = item.Code;
detailInput.Uom = item.BasicUom;
detailInput.ItemName = item.Name;
detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty;
}
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.FromStatus = tolocation.DefaultInventoryStatus;
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.ToStatus = fromlocation.DefaultInventoryStatus;
detailInput.Qty = detail.MatQty;
detailInput.FromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
detailInput.FromPackingCode = string.Empty;
transfer.Details.Add(detailInput);
await _transferNoteAppService.CreateAsync(transfer).ConfigureAwait(false);
}
}
else
{
errors.Add("Agv确认单据里无数据! \n");
}
}
catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = "",
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = ""
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
return ret;
}
/// <summary> /// <summary>
/// 调用Agv接口实现 /// 调用Agv接口实现

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

@ -670,281 +670,7 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase
} }
[HttpPost("call-back-unfreezed-agv")]
public async Task<AgvResultObject> CallUnFreezedAgvAsync(AgvRequestDto 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 ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = "",
};
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (request.Data.Count > 0)
{
var notes = request.Data;
foreach (var detail in notes)
{
TransferNoteEditInput transfer = new TransferNoteEditInput();
transfer.CallJobNumber = detail.OrderNum;
transfer.Type = EnumTransSubType.Agv_Transfer_WIP.ToString();
transfer.Worker = "Agv";
transfer.UseOnTheWayLocation = false;
List<TransferNoteDetailInput> transferNoteDetailInputs = new List<TransferNoteDetailInput>();
TransferNoteDetailInput detailInput = new TransferNoteDetailInput();
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 item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
errors.Add($"零件号{detail.MatCode}的零件不存在!");
}
else
{
detailInput.ItemCode = item.Code;
detailInput.Uom = item.BasicUom;
detailInput.ItemName = item.Name;
detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty;
}
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.ToStatus = tolocation.DefaultInventoryStatus;
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.FromStatus = EnumInventoryStatus.FROZEN;
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);
}
}
else
{
errors.Add("Agv确认单据里无数据! \n");
}
}
catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = "",
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = ""
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
return ret;
}
[HttpPost("call-back-freezed-agv")]
public async Task<AgvResultObject> CallFreezedAgvAsync(AgvRequestDto 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 ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = "",
};
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (request.Data.Count > 0)
{
var notes = request.Data;
foreach (var detail in notes)
{
TransferNoteEditInput transfer = new TransferNoteEditInput();
transfer.CallJobNumber = detail.OrderNum;
transfer.Type = EnumTransSubType.Agv_Freezed.ToString();
transfer.Worker = "Agv";
transfer.UseOnTheWayLocation = false;
List<TransferNoteDetailInput> transferNoteDetailInputs = new List<TransferNoteDetailInput>();
TransferNoteDetailInput detailInput = new TransferNoteDetailInput();
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 item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
errors.Add($"零件号{detail.MatCode}的零件不存在!");
}
else
{
detailInput.ItemCode = item.Code;
detailInput.Uom = item.BasicUom;
detailInput.ItemName = item.Name;
detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty;
}
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.ToStatus = EnumInventoryStatus.FROZEN;
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.FromStatus = EnumInventoryStatus.OK;
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);
}
}
else
{
errors.Add("Agv确认单据里无数据! \n");
}
}
catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = "",
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = ""
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
return ret;
}

Loading…
Cancel
Save