|
|
@ -10,6 +10,7 @@ using Volo.Abp.Domain.Repositories; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
using WmsWebApi.Domain; |
|
|
|
using WmsWebApi.EntityFrameworkCore; |
|
|
|
using WmsWebApi.PPlan; |
|
|
|
using WmsWebApi.ProductRecieve; |
|
|
|
using WmsWebApi.Wms; |
|
|
|
|
|
|
@ -27,6 +28,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
private readonly ITaPartRepository _taPartRepository; |
|
|
|
private readonly ITaStoreLocationRepository _taStoreLocationRepository; |
|
|
|
private readonly IConfiguration _configuration; |
|
|
|
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager; |
|
|
|
|
|
|
|
public ProductRecieveService(ITsStockDetailRepository tsStockDetailRepository, |
|
|
|
ITbProductReceiveRepository tbProductReceiveRepository, |
|
|
@ -36,7 +38,8 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
ITLTransactionRepository tlTransactionRepository, |
|
|
|
IProductRecieveManager productRecieveManager, |
|
|
|
TmPgWmsUpdate tmPgWmsUpdate, |
|
|
|
IConfiguration configuration) |
|
|
|
IConfiguration configuration, |
|
|
|
IUnitOfWorkManager unitOfWorkManager) |
|
|
|
{ |
|
|
|
_tsStockDetailRepository = tsStockDetailRepository; |
|
|
|
_tbProductReceiveRepository = tbProductReceiveRepository; |
|
|
@ -47,26 +50,28 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
_productRecieveManager = productRecieveManager; |
|
|
|
_tmPgWmsUpdate = tmPgWmsUpdate; |
|
|
|
_configuration = configuration; |
|
|
|
_unitOfWorkManager = unitOfWorkManager; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("add")] |
|
|
|
public async Task<ReturnResult> AddAsync([FromBody] object content) |
|
|
|
{ |
|
|
|
var result = new ReturnResult(); |
|
|
|
result.MESSAGE = ""; |
|
|
|
PRDto _PRDto; |
|
|
|
//bool bUpdate = false,bOtherWork = false, bDel = false,bNotFind = false, bPartGroup = false;
|
|
|
|
bool bErr = false; |
|
|
|
try |
|
|
|
{ |
|
|
|
_PRDto = JsonConvert.DeserializeObject<PRDto>(content.ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
result.TYPE = 'E'; |
|
|
|
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message; |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
List<TB_BILL> _billList = new List<TB_BILL>(); |
|
|
@ -89,9 +94,16 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
BillType = 201, |
|
|
|
SubBillType = 10100, |
|
|
|
State = 2, |
|
|
|
Remark = "AGVProductRecieve", |
|
|
|
AccountDate = DateTime.ParseExact(_PRDto.AccountDate, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture) |
|
|
|
Remark = "AGVProductRecieve" |
|
|
|
}; |
|
|
|
try |
|
|
|
{ |
|
|
|
tbBill.AccountDate = DateTime.ParseExact(_PRDto.AccountDate, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture); |
|
|
|
} |
|
|
|
catch (Exception) |
|
|
|
{ |
|
|
|
tbBill.AccountDate = DateTime.Parse(_PRDto.AccountDate); |
|
|
|
} |
|
|
|
_billList.Add(tbBill); |
|
|
|
#endregion
|
|
|
|
|
|
|
@ -171,8 +183,8 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
|
|
|
|
var stock = await _tsStockDetailRepository.FirstOrDefaultAsync(p => p.BarCode == _barcode |
|
|
|
&& p.LocCode == part.DefaultReceiveLocCode |
|
|
|
&& p.State == EnumStockState.合格); |
|
|
|
|
|
|
|
&& p.State == EnumStockState.合格); |
|
|
|
|
|
|
|
if (stock == null) |
|
|
|
{ |
|
|
|
_stockList.Add(tsStock); |
|
|
@ -181,7 +193,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
{ |
|
|
|
_stockUpdateList.Add(tsStock); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//插入tl_transaction
|
|
|
|
var tlTrans = new TL_TRANSACTION |
|
|
|
{ |
|
|
@ -214,9 +226,17 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
if (_stockUpdateList != null && _stockUpdateList.Count() > 0) |
|
|
|
await _tmPgWmsUpdate.UpdateTsStock(_stockUpdateList); |
|
|
|
await _tlTransactionRepository.AddAsync(_transList); |
|
|
|
} |
|
|
|
|
|
|
|
//var pParts = boms.Select(p => p.MATNR).ToList().ToString();
|
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
bErr = true; |
|
|
|
result.TYPE = 'E'; |
|
|
|
result.MESSAGE = ex.Message; |
|
|
|
throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex); |
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
WmsWebApiProductRecieveDTO apiPRdto = new WmsWebApiProductRecieveDTO() |
|
|
|
{ |
|
|
|
AccountDate = _PRDto.AccountDate, |
|
|
@ -234,15 +254,24 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService |
|
|
|
result.TYPE = 'E'; |
|
|
|
apiPRdto.ITYPE = result.MESSAGE; |
|
|
|
} |
|
|
|
await _productRecieveManager.AddAsync(apiPRdto); |
|
|
|
await AddWmsWebApiProductRecieveDTONowUnitOfWorkAsync(apiPRdto); |
|
|
|
} |
|
|
|
catch(Exception ex) |
|
|
|
|
|
|
|
if (bErr == false) |
|
|
|
{ |
|
|
|
result.TYPE = 'E'; |
|
|
|
result.MESSAGE = ex.Message; |
|
|
|
result.MESSAGE = "接收成功!"; |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private async Task AddWmsWebApiProductRecieveDTONowUnitOfWorkAsync(WmsWebApiProductRecieveDTO wmsWebApiProductRecieveDTO) |
|
|
|
{ |
|
|
|
if (wmsWebApiProductRecieveDTO == null) { return; } |
|
|
|
|
|
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false)) |
|
|
|
{ |
|
|
|
await _productRecieveManager.AddAsync(wmsWebApiProductRecieveDTO); |
|
|
|
await uow.SaveChangesAsync(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |