|
|
@ -11,8 +11,10 @@ using Volo.Abp.BackgroundJobs; |
|
|
|
using Volo.Abp.Domain.Repositories; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
using WmsWebApi.BackgroundJob; |
|
|
|
using WmsWebApi.BackgroundJobs; |
|
|
|
using WmsWebApi.Domain; |
|
|
|
using WmsWebApi.EntityFrameworkCore; |
|
|
|
using WmsWebApi.Enums; |
|
|
|
using WmsWebApi.PPlan; |
|
|
|
using WmsWebApi.ProductRecieve; |
|
|
|
using WmsWebApi.Wms; |
|
|
@ -35,7 +37,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
private readonly ITaStoreLocationRepository _taStoreLocationRepository; |
|
|
|
private readonly IConfiguration _configuration; |
|
|
|
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager; |
|
|
|
private readonly IBackgroundJobManager _backgroundJobManager; |
|
|
|
private readonly IBackgroundJobRequestRetry _backgroundJobRequestRetry; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 是否是请求重试
|
|
|
@ -52,7 +54,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
TmPgWmsUpdate tmPgWmsUpdate, |
|
|
|
IConfiguration configuration, |
|
|
|
IUnitOfWorkManager unitOfWorkManager, |
|
|
|
IBackgroundJobManager backgroundJobManager) |
|
|
|
IBackgroundJobRequestRetry backgroundJobRequestRetry) |
|
|
|
{ |
|
|
|
_tsStockDetailRepository = tsStockDetailRepository; |
|
|
|
_tbProductReceiveRepository = tbProductReceiveRepository; |
|
|
@ -64,7 +66,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
_tmPgWmsUpdate = tmPgWmsUpdate; |
|
|
|
_configuration = configuration; |
|
|
|
_unitOfWorkManager = unitOfWorkManager; |
|
|
|
_backgroundJobManager = backgroundJobManager; |
|
|
|
_backgroundJobRequestRetry = backgroundJobRequestRetry; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("add")] |
|
|
@ -264,7 +266,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
|
|
|
|
if (IsRequestRetry == false) |
|
|
|
{ |
|
|
|
await AddBackgroundJobAsync(content.ToString()); |
|
|
|
await _backgroundJobRequestRetry.AddBackgroundJobAsync(EnumActionName.ProductRecieveAdd, content.ToString()); |
|
|
|
} |
|
|
|
|
|
|
|
throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex); |
|
|
@ -299,25 +301,4 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
await uow.SaveChangesAsync(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 添加后台工作者
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="strJson">Json参数</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task AddBackgroundJobAsync(string strJson) |
|
|
|
{ |
|
|
|
if (strJson == null || strJson == "") { return; } |
|
|
|
|
|
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false)) |
|
|
|
{ |
|
|
|
var requestRetryArgs = new RequestRetryArgs() |
|
|
|
{ |
|
|
|
ActionName = Enums.EnumActionName.ProductRecieveAdd, |
|
|
|
StrJson = strJson |
|
|
|
}; |
|
|
|
await _backgroundJobManager.EnqueueAsync(requestRetryArgs, priority: BackgroundJobPriority.Normal, delay: TimeSpan.FromSeconds(60)); |
|
|
|
await uow.SaveChangesAsync(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |