From 135c32e0a84eee74cfa53bc02b6c971656d1730a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Thu, 5 Dec 2024 09:14:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TransferNotes/TransferNoteAppService.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs index 0da04e799..380f69695 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs @@ -31,6 +31,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Volo.Abp.ObjectMapping; using NUglify.Helpers; +using Volo.Abp.Uow; namespace Win_in.Sfs.Wms.Store.Application; @@ -64,7 +65,7 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase private readonly IPostionLocationAppService _postionLocationAppService; - + private readonly UnitOfWorkManager _unitOfWorkManager; public TransferNoteAppService( ITransferNoteRepository repository, @@ -82,8 +83,10 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase IOptions agvOptions, IPostionLocationAppService postionLocationAppService, IItemBasicAppService itemBasicAppService, + UnitOfWorkManager unitOfWorkManager, IExpectOutAppService expectOutAppService) : base(repository) { + _unitOfWorkManager = unitOfWorkManager; _transferNoteManager = transferNoteManager; _balanceAppService = balanceAppService; _locationAppService = locationAppService; @@ -682,12 +685,13 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase 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(); @@ -752,10 +756,10 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase 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; @@ -788,8 +792,8 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase ReqCode = "", Message = ex.Message }; - //await unitOfWork.RollbackAsync(); - return ret; + await unitOfWork.RollbackAsync().ConfigureAwait(false); + } if (errors.Count > 0) @@ -800,6 +804,7 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase Message = string.Join(",", errors.ToArray()), ReqCode = "" }; + await unitOfWork.RollbackAsync().ConfigureAwait(false); } return ret; }