|
|
@ -15,8 +15,10 @@ using WmsWebApi.BackgroundJobs; |
|
|
|
using WmsWebApi.Domain; |
|
|
|
using WmsWebApi.EntityFrameworkCore; |
|
|
|
using WmsWebApi.Jsons; |
|
|
|
using WmsWebApi.Repositories; |
|
|
|
using WmsWebApi.Wms; |
|
|
|
using WmsWebApi.WMS; |
|
|
|
using WmsWebApi.WMS.IRepository; |
|
|
|
|
|
|
|
namespace WmsWebApi.ProductRecieve; |
|
|
|
|
|
|
@ -39,6 +41,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
private readonly IBackgroundJobRequestRetry _backgroundJobRequestRetry; |
|
|
|
private readonly IProductRecieveJsonRepository _productRecieveJsonRepository; |
|
|
|
private readonly AsyncRetryPolicy _asyncRetryPolicy; |
|
|
|
private readonly ITSUNIAPIRepository _tSUNIAPIRepository; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 是否是请求重试
|
|
|
@ -56,7 +59,8 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
IConfiguration configuration, |
|
|
|
IUnitOfWorkManager unitOfWorkManager, |
|
|
|
IBackgroundJobRequestRetry backgroundJobRequestRetry, |
|
|
|
IProductRecieveJsonRepository productRecieveJsonRepository) |
|
|
|
IProductRecieveJsonRepository productRecieveJsonRepository, |
|
|
|
ITSUNIAPIRepository tSUNIAPIRepository) |
|
|
|
{ |
|
|
|
_tsStockDetailRepository = tsStockDetailRepository; |
|
|
|
_tbProductReceiveRepository = tbProductReceiveRepository; |
|
|
@ -80,6 +84,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
{ |
|
|
|
Logger.LogInformation($"执行失败,第 {retryCount} 次重试"); |
|
|
|
}); |
|
|
|
_tSUNIAPIRepository = tSUNIAPIRepository; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("add/IF01")] |
|
|
@ -257,6 +262,42 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
TransType = 1 |
|
|
|
}; |
|
|
|
_transList.Add(tlTrans); |
|
|
|
|
|
|
|
//插入TS_UNI_API
|
|
|
|
listTSUNIAPI.Add(new TS_UNI_API() |
|
|
|
{ |
|
|
|
InterfaceType = "BackFlush", |
|
|
|
TableName = "xxwms_bk_mstr", |
|
|
|
BillType = 201, |
|
|
|
SubBillType = tbBill.SubBillType, |
|
|
|
BillNum = tbBill.BillNum, |
|
|
|
PartCode = item.PartCode, |
|
|
|
Batch = item.Batch, |
|
|
|
FromLoc = "", |
|
|
|
ToLoc = tbRecieve.ToLocCode, |
|
|
|
FromErpLoc = "", |
|
|
|
ToErpLoc = "", |
|
|
|
Qty = item.Qty, |
|
|
|
State = 0, |
|
|
|
CreateOper = "AGV", |
|
|
|
CreateTime = DateTime.Now, |
|
|
|
PutTime = DateTime.Now, |
|
|
|
CustId = "", |
|
|
|
VendId = "", |
|
|
|
PoUnit = "", |
|
|
|
LocUnit = "", |
|
|
|
ValidDate = DateTime.Now, |
|
|
|
ErpBillNum = tbBill.BillNum, |
|
|
|
ErpLineNum = 0, |
|
|
|
EqptCode = "", |
|
|
|
EqptType = "B", |
|
|
|
VendBatch = item.Batch, |
|
|
|
SourceBillNum = tbBill.SourceBillNum, |
|
|
|
ProcessId = 0, |
|
|
|
GoodQty = item.Qty, |
|
|
|
ScrapQty = 0, |
|
|
|
InvalidQty = 0 |
|
|
|
}); |
|
|
|
} |
|
|
|
if (!bErr) |
|
|
|
{ |
|
|
@ -269,6 +310,10 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
await _tsStockDetailRepository.AddAsync(_stockList); |
|
|
|
if (_stockUpdateList != null && _stockUpdateList.Count() > 0) |
|
|
|
await _tmPgWmsUpdate.UpdateTsStock(_stockUpdateList); |
|
|
|
if (listTSUNIAPI != null && listTSUNIAPI.Count() > 0) |
|
|
|
{ |
|
|
|
await _tSUNIAPIRepository.InsertManyAsync(listTSUNIAPI); |
|
|
|
} |
|
|
|
await _tlTransactionRepository.AddAsync(_transList); |
|
|
|
} |
|
|
|
await CurrentUnitOfWork.SaveChangesAsync(); |
|
|
@ -280,14 +325,14 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
result.TYPE = 'E'; |
|
|
|
result.MESSAGE = ex.Message; |
|
|
|
|
|
|
|
if (IsRequestRetry == false) |
|
|
|
if (IsRequestRetry == false) |
|
|
|
{ |
|
|
|
//await _backgroundJobRequestRetry.AddBackgroundJobAsync(EnumActionName.ProductRecieveAdd, content.ToString());
|
|
|
|
} |
|
|
|
|
|
|
|
throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex); |
|
|
|
} |
|
|
|
finally |
|
|
|
finally |
|
|
|
{ |
|
|
|
if (IsRequestRetry == false) |
|
|
|
{ |
|
|
@ -298,7 +343,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
result.TYPE = 'E'; |
|
|
|
apiPRdto.ITYPE = result.MESSAGE; |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
result.MESSAGE = "成功"; |
|
|
|
apiPRdto.ITYPE = "成功"; |
|
|
@ -325,7 +370,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
|
|
|
|
if (bErr == false) |
|
|
|
{ |
|
|
|
result.MESSAGE = "接收成功!"; |
|
|
|
result.MESSAGE = "成功!"; |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|