|
|
@ -2,6 +2,7 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Abp.Domain.Uow; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using Volo.Abp; |
|
|
@ -25,6 +26,7 @@ public class OtherZllService : ApplicationService, IOtherZllService |
|
|
|
private readonly IOtherZllManager _otherZllManager; |
|
|
|
private readonly ITLTransactionRepository _tlTransactionRepository; |
|
|
|
private readonly TmPgWmsUpdate _tmPgWmsUpdate; |
|
|
|
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager; |
|
|
|
|
|
|
|
public OtherZllService(ITsStockDetailRepository tsStockDetailRepository, |
|
|
|
ITbProductReceiveRepository tbProductReceiveRepository, |
|
|
@ -33,7 +35,8 @@ public class OtherZllService : ApplicationService, IOtherZllService |
|
|
|
ITaStoreLocationRepository taStoreLocationRepository, |
|
|
|
IOtherZllManager otherZllManager, |
|
|
|
ITLTransactionRepository tlTransactionRepository, |
|
|
|
TmPgWmsUpdate tmPgWmsUpdate) |
|
|
|
TmPgWmsUpdate tmPgWmsUpdate |
|
|
|
, Volo.Abp.Uow.IUnitOfWorkManager unitOfWorkManager) |
|
|
|
{ |
|
|
|
_tsStockDetailRepository = tsStockDetailRepository; |
|
|
|
_tbProductReceiveRepository = tbProductReceiveRepository; |
|
|
@ -43,6 +46,7 @@ public class OtherZllService : ApplicationService, IOtherZllService |
|
|
|
_otherZllManager = otherZllManager; |
|
|
|
_tlTransactionRepository = tlTransactionRepository; |
|
|
|
_tmPgWmsUpdate = tmPgWmsUpdate; |
|
|
|
_unitOfWorkManager = unitOfWorkManager; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("add")] |
|
|
@ -62,11 +66,14 @@ public class OtherZllService : ApplicationService, IOtherZllService |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
WmsWebApiOtherZLLDTO dto = new WmsWebApiOtherZLLDTO(); |
|
|
|
dto.JSON = content.ToString(); |
|
|
|
dto.SetId(GuidGenerator); |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
if (_dtoList[0].ZDJLX == "20") |
|
|
|
{ |
|
|
|
|
|
|
|
var _dtoDetails = _dtoList.Where(p => p.WERKS == "1000").ToList(); |
|
|
|
if (_dtoDetails == null || _dtoDetails.Count() == 0) |
|
|
|
{ |
|
|
@ -75,6 +82,11 @@ public class OtherZllService : ApplicationService, IOtherZllService |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
dto.ZLLDJ = _dtoDetails[0].ZLLDJ; |
|
|
|
dto.MBLNR = _dtoDetails[0].MBLNR; |
|
|
|
dto.MJAHR = _dtoDetails[0].MJAHR; |
|
|
|
dto.ZLLR = _dtoDetails[0].ZLLR; |
|
|
|
|
|
|
|
var _billNumList = _dtoDetails.Select(p => p.MBLNR).Distinct().ToList(); |
|
|
|
foreach (var _billNum in _billNumList) |
|
|
|
{ |
|
|
@ -267,6 +279,8 @@ public class OtherZllService : ApplicationService, IOtherZllService |
|
|
|
_transList.Add(tlTrans); |
|
|
|
} |
|
|
|
if (!bErr) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
if (_recieveList.Count > 0) |
|
|
|
{ |
|
|
@ -281,6 +295,12 @@ public class OtherZllService : ApplicationService, IOtherZllService |
|
|
|
await _tmPgWmsUpdate.DeleteTsStock(_stockDelList); |
|
|
|
await _tlTransactionRepository.AddAsync(_transList); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
dto.ITYPE = ex.GetBaseException().Message; |
|
|
|
throw new Exception("操作数据库失败,请稍后重试。", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@ -291,48 +311,38 @@ public class OtherZllService : ApplicationService, IOtherZllService |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//var pParts = boms.Select(p => p.MATNR).ToList().ToString();
|
|
|
|
|
|
|
|
WmsWebApiOtherZLLDTO dto = new WmsWebApiOtherZLLDTO() |
|
|
|
{ |
|
|
|
JSON = content.ToString() |
|
|
|
}; |
|
|
|
if (_dtoDetails != null && _dtoDetails.Count > 0) |
|
|
|
{ |
|
|
|
dto.ZLLDJ = _dtoDetails[0].ZLLDJ; |
|
|
|
dto.MBLNR = _dtoDetails[0].MBLNR; |
|
|
|
dto.MJAHR = _dtoDetails[0].MJAHR; |
|
|
|
dto.ZLLR = _dtoDetails[0].ZLLR; |
|
|
|
} |
|
|
|
dto.SetId(GuidGenerator); |
|
|
|
|
|
|
|
if (bErr || bTypeErr) |
|
|
|
{ |
|
|
|
dto.ITYPE = result.MESSAGE; |
|
|
|
} |
|
|
|
await _otherZllManager.AddAsync(dto); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
result.MESSAGE = "err:非物流领料单"; |
|
|
|
WmsWebApiOtherZLLDTO dto = new WmsWebApiOtherZLLDTO() |
|
|
|
{ |
|
|
|
JSON = content.ToString(), |
|
|
|
ITYPE = "err:非物流领料单", |
|
|
|
}; |
|
|
|
dto.SetId(GuidGenerator); |
|
|
|
|
|
|
|
await _otherZllManager.AddAsync(dto); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
result.TYPE = 'E'; |
|
|
|
result.MESSAGE = ex.Message; |
|
|
|
throw new UserFriendlyException(ex.Message, null, null, ex); |
|
|
|
dto.ITYPE = ex.GetBaseException().Message; |
|
|
|
throw; |
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
await AddOtherZLLDtoNowUnitOfWorkAsync(dto); |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private async Task AddOtherZLLDtoNowUnitOfWorkAsync(WmsWebApiOtherZLLDTO wmsWebApiOtherZLLDTO) |
|
|
|
{ |
|
|
|
if (wmsWebApiOtherZLLDTO == null) { return; } |
|
|
|
|
|
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false)) |
|
|
|
{ |
|
|
|
await _otherZllManager.AddAsync(wmsWebApiOtherZLLDTO); |
|
|
|
await uow.SaveChangesAsync(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |