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