|
|
@ -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")] |
|
|
@ -54,7 +58,7 @@ public class OtherZllService : ApplicationService, IOtherZllService |
|
|
|
try |
|
|
|
{ |
|
|
|
_dtoList = JsonConvert.DeserializeObject<List<OtherZllDto>>(content.ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
result.TYPE = 'E'; |
|
|
@ -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) |
|
|
|
{ |
|
|
@ -268,18 +280,26 @@ public class OtherZllService : ApplicationService, IOtherZllService |
|
|
|
} |
|
|
|
if (!bErr) |
|
|
|
{ |
|
|
|
if (_recieveList.Count > 0) |
|
|
|
try |
|
|
|
{ |
|
|
|
await _tbBillRepository.AddManyAsync(_billList); |
|
|
|
await _tbProductReceiveRepository.AddAsync(_recieveList); |
|
|
|
if (_recieveList.Count > 0) |
|
|
|
{ |
|
|
|
await _tbBillRepository.AddManyAsync(_billList); |
|
|
|
await _tbProductReceiveRepository.AddAsync(_recieveList); |
|
|
|
} |
|
|
|
if (_stockList != null && _stockList.Count() > 0) |
|
|
|
await _tsStockDetailRepository.AddAsync(_stockList); |
|
|
|
if (_stockUpdateList != null && _stockUpdateList.Count() > 0) |
|
|
|
await _tmPgWmsUpdate.UpdateTsStock(_stockUpdateList); |
|
|
|
if (_stockDelList != null && _stockDelList.Count() > 0) |
|
|
|
await _tmPgWmsUpdate.DeleteTsStock(_stockDelList); |
|
|
|
await _tlTransactionRepository.AddAsync(_transList); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
dto.ITYPE = ex.GetBaseException().Message; |
|
|
|
throw new Exception("操作数据库失败,请稍后重试。", ex); |
|
|
|
} |
|
|
|
if (_stockList != null && _stockList.Count() > 0) |
|
|
|
await _tsStockDetailRepository.AddAsync(_stockList); |
|
|
|
if (_stockUpdateList != null && _stockUpdateList.Count() > 0) |
|
|
|
await _tmPgWmsUpdate.UpdateTsStock(_stockUpdateList); |
|
|
|
if (_stockDelList != null && _stockDelList.Count() > 0) |
|
|
|
await _tmPgWmsUpdate.DeleteTsStock(_stockDelList); |
|
|
|
await _tlTransactionRepository.AddAsync(_transList); |
|
|
|
} |
|
|
|
} |
|
|
|
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(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |