From 82c930b8d9f665eb7f9b48a8f6d6cfd353f1cc4a Mon Sep 17 00:00:00 2001 From: liuyunfeng Date: Mon, 15 Apr 2024 17:07:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E7=A7=BB=E5=BA=93-=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TransferNotes/DTOs/TransferNoteDTO.cs | 26 +++++++ .../Inputs/TransferNoteEditInput.cs | 27 ++++++++ .../InjectionJobs/InjectionJobAppService.cs | 7 +- .../TransferLibJobAppService.cs | 68 ++++++------------- .../TransferLibNotes/ITransferLibCallback.cs | 7 +- 5 files changed, 80 insertions(+), 55 deletions(-) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/TransferNotes/DTOs/TransferNoteDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/TransferNotes/DTOs/TransferNoteDTO.cs index 3dc2c2dde..5ce65e6eb 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/TransferNotes/DTOs/TransferNoteDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/TransferNotes/DTOs/TransferNoteDTO.cs @@ -44,4 +44,30 @@ public class TransferNoteDTO : SfsStoreDTOBase, IHasNumbe [Display(Name = "确认时间")] public DateTime? ConfirmTime { get; set; } + #region 回调服务相关 + /// + /// 回调服务名称 + /// + [Display(Name = "回调服务名称")] + public string CallServerName { get; set; } + + /// + /// 回调业务类型 + /// + [Display(Name = "回调业务类型")] + public string CallBusinessType { get; set; } + + /// + /// 调用者传入申请单号 + /// + [Display(Name = "传入申请单号")] + public string CallRequestNumber { get; set; } + + /// + /// 调用者传入任务单号 + /// + [Display(Name = "传入任务单号")] + public string CallJobNumber { get; set; } + #endregion + } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/TransferNotes/Inputs/TransferNoteEditInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/TransferNotes/Inputs/TransferNoteEditInput.cs index b1b084185..7e4075451 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/TransferNotes/Inputs/TransferNoteEditInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/TransferNotes/Inputs/TransferNoteEditInput.cs @@ -51,4 +51,31 @@ public class TransferNoteEditInput : SfsStoreCreateOrUpdateInputBase [Display(Name = "详情")] public List Details { get; set; } = new List(); + + #region 回调服务相关 + /// + /// 回调服务名称 + /// + [Display(Name = "回调服务名称")] + public string CallServerName { get; set; } + + /// + /// 回调业务类型 + /// + [Display(Name = "回调业务类型")] + public string CallBusinessType { get; set; } + + /// + /// 调用者传入申请单号 + /// + [Display(Name = "传入申请单号")] + public string CallRequestNumber { get; set; } + + /// + /// 调用者传入任务单号 + /// + [Display(Name = "传入任务单号")] + public string CallJobNumber { get; set; } + #endregion + } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionJobs/InjectionJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionJobs/InjectionJobAppService.cs index 677d30d58..d80af81be 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionJobs/InjectionJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionJobs/InjectionJobAppService.cs @@ -138,9 +138,9 @@ public class InjectionJobAppService } [HttpPost("Do-Call-Back")] - public async Task DoTransferLibCallbackAsync(string businessType, string requestNum, string jobNum) + public async Task DoTransferLibCallbackAsync(TransferLibJobDTO dto) { - var job = await _repository.FindAsync(p => p.Number == jobNum).ConfigureAwait(false); + var job = await _repository.FindAsync(p => p.Number == dto.JobNumber).ConfigureAwait(false); //todo 等云峰写好换成真实的 var transferLibJobDto= await _transferLibJobAppService.GetByNumberAsync("AAA").ConfigureAwait(false); @@ -181,8 +181,7 @@ public class InjectionJobAppService await _repository.UpdateAsync(job).ConfigureAwait(false); - //return new Tuple(true,"s"); - return new TransferLibJobDTO(); + return; } [HttpPost("test")] diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/TransferLibJobs/TransferLibJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/TransferLibJobs/TransferLibJobAppService.cs index 2ee0e6099..7fbf30d55 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/TransferLibJobs/TransferLibJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/TransferLibJobs/TransferLibJobAppService.cs @@ -38,8 +38,25 @@ public class TransferLibJobAppService [UnitOfWork] public override async Task CompleteAsync(Guid id, TransferLibJobDTO dto) { + string methodPrefix = "TransferLibJobAppService.CompleteAsync - "; + if (dto.CallServerName.IsNullOrEmpty()) + { + throw new UserFriendlyException($"{methodPrefix}CallServerName 不能为空"); + } + if (dto.CallBusinessType.IsNullOrEmpty()) + { + throw new UserFriendlyException($"{methodPrefix}CallBusinessType 不能为空"); + } + if (dto.CallRequestNumber.IsNullOrEmpty()) + { + throw new UserFriendlyException($"{methodPrefix}CallRequestNumber 不能为空"); + } + if (dto.CallJobNumber.IsNullOrEmpty()) + { + throw new UserFriendlyException($"{methodPrefix}CallJobNumber 不能为空"); + } - //校验 + #region 校验 foreach (var detailObj in dto.Details) { if (detailObj.IsPackingCodeFrom) @@ -153,25 +170,7 @@ public class TransferLibJobAppService } } } - - //var str = "Win_in.Sfs.Wms.Store.Application.InjectionJobAppService"; - string methodPrefix = "TransferLibJobAppService.CompleteAsync - "; - if (dto.CallServerName.IsNullOrEmpty()) - { - throw new UserFriendlyException($"{methodPrefix}CallServerName 不能为空"); - } - if (dto.CallBusinessType.IsNullOrEmpty()) - { - throw new UserFriendlyException($"{methodPrefix}CallBusinessType 不能为空"); - } - if (dto.CallRequestNumber.IsNullOrEmpty()) - { - throw new UserFriendlyException($"{methodPrefix}CallRequestNumber 不能为空"); - } - if (dto.CallJobNumber.IsNullOrEmpty()) - { - throw new UserFriendlyException($"{methodPrefix}CallJobNumber 不能为空"); - } + #endregion var ret = await base.CompleteAsync(id, dto).ConfigureAwait(false); if (ret != null) @@ -186,37 +185,12 @@ public class TransferLibJobAppService { throw new UserFriendlyException($"{methodPrefix}类型为{dto.CallServerName}的对象创建失败"); } - ITransferLibCallback transferLibCallback = (Win_in.Sfs.Wms.Store.Notes.ITransferLibCallback)instance; + ITransferLibCallback transferLibCallback = (ITransferLibCallback)instance; if (transferLibCallback == null) { throw new UserFriendlyException($"{methodPrefix}类型为{dto.CallServerName}的对象没有实现ITransferLibCallback接口"); } - TransferLibJobDTO callbackRet = await transferLibCallback.DoTransferLibCallbackAsync(dto.CallServerName, dto.CallRequestNumber, dto.CallJobNumber).ConfigureAwait(false); - if (callbackRet == null || callbackRet.Number == null) - { - throw new UserFriendlyException($"{methodPrefix}执行回调服务{dto.CallServerName}出错,返回实体为空!"); - } - //var assembly = Assembly.GetExecutingAssembly(); - //var ty = assembly.GetType(dto.CallServerName); - //if (ty == null) - //{ - // throw new UserFriendlyException($"{methodPrefix}没有找到类型为{dto.CallServerName}的对象"); - //} - //var instance = Activator.CreateInstance(ty); - //if (instance == null) - //{ - // throw new UserFriendlyException($"{methodPrefix}类型为{dto.CallServerName}的对象创建失败"); - //} - //ITransferLibCallback transferLibCallback = (ITransferLibCallback)instance; - //if (transferLibCallback == null) - //{ - // throw new UserFriendlyException($"{methodPrefix}类型为{dto.CallServerName}的对象没有实现ITransferLibCallback接口"); - //} - //Tuple callbackRet = transferLibCallback.DoTransferLibCallback(dto.CallServerName, dto.CallRequestNumber, dto.CallJobNumber); - //if (callbackRet != null && callbackRet.Item1 == false) - //{ - // throw new UserFriendlyException($"{methodPrefix}执行回调服务{dto.CallServerName}出错,返回错误信息:{callbackRet.Item2}"); - //} + await transferLibCallback.DoTransferLibCallbackAsync(dto).ConfigureAwait(false); } return ret; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferLibNotes/ITransferLibCallback.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferLibNotes/ITransferLibCallback.cs index b0da0ac6d..de4c5b1b2 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferLibNotes/ITransferLibCallback.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferLibNotes/ITransferLibCallback.cs @@ -9,7 +9,7 @@ using Win_in.Sfs.Wms.Store.Application.Contracts; namespace Win_in.Sfs.Wms.Store.Notes; public interface ITransferLibCallback { - Task DoTransferLibCallbackAsync(string businessType, string requestNum, string jobNum); + Task DoTransferLibCallbackAsync(TransferLibJobDTO dto); } public class TestTransferLibCallback : ITransferLibCallback @@ -18,9 +18,8 @@ public class TestTransferLibCallback : ITransferLibCallback { } - public async Task DoTransferLibCallbackAsync(string businessType, string requestNum, - string jobNum) + public async Task DoTransferLibCallbackAsync(TransferLibJobDTO dto) { - return new TransferLibJobDTO(); + await Task.Run(() => { }).ConfigureAwait(false); } }