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; }