|
|
@ -11,6 +11,8 @@ using Volo.Abp.Uow; |
|
|
|
using WmsWebApi.EntityFrameworkCore; |
|
|
|
using WmsWebApi.Wms; |
|
|
|
using Abp.Web.Models; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using Abp.Domain.Uow; |
|
|
|
|
|
|
|
namespace WmsWebApi.ZlldcjLogs; |
|
|
|
|
|
|
@ -22,21 +24,24 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService |
|
|
|
private readonly ITmSapMoveTypeRepository _tbSapMoveTypeRepository; |
|
|
|
private readonly ITmOtherAskRepository _tbOtherInOutAskRepository; |
|
|
|
private readonly TmOtherAskRepositoryUpdate _tmOtherAskRepositoryUpdate; |
|
|
|
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager; |
|
|
|
|
|
|
|
public ZlldcjLogAppService(ZlldcjLogManager zlldcjLogManager |
|
|
|
, ITbBillRepository tbBillRepository |
|
|
|
, ITmSapMoveTypeRepository tbSapMoveTypeRepository |
|
|
|
, ITmOtherAskRepository tbOtherInOutAskRepository |
|
|
|
, TmOtherAskRepositoryUpdate tmOtherAskRepositoryUpdate) |
|
|
|
, TmOtherAskRepositoryUpdate tmOtherAskRepositoryUpdate |
|
|
|
, Volo.Abp.Uow.IUnitOfWorkManager unitOfWorkManager) |
|
|
|
{ |
|
|
|
_zlldcjLogManager = zlldcjLogManager; |
|
|
|
_tbBillRepository = tbBillRepository; |
|
|
|
_tbSapMoveTypeRepository = tbSapMoveTypeRepository; |
|
|
|
_tbOtherInOutAskRepository = tbOtherInOutAskRepository; |
|
|
|
_tmOtherAskRepositoryUpdate = tmOtherAskRepositoryUpdate; |
|
|
|
_unitOfWorkManager = unitOfWorkManager; |
|
|
|
} |
|
|
|
[HttpPost("add")] |
|
|
|
|
|
|
|
[HttpPost("add")] |
|
|
|
public async Task<ReturnResult> AddAsync(List<ZlldcjLogDto> dto) |
|
|
|
{ |
|
|
|
var result = new ReturnResult(); |
|
|
@ -81,6 +86,8 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
var dtoList = dtos.Where(p => p.WERKS == "1000").ToList(); |
|
|
|
if (dtoList == null || dtoList.Count == 0) |
|
|
|
{ |
|
|
@ -96,8 +103,6 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService |
|
|
|
_ZlldcjLogs.Add(entity); |
|
|
|
} |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
var djList = _ZlldcjLogs.Select(p => p.ZLLDJ).Distinct(); |
|
|
|
foreach (var dj in djList) |
|
|
|
{ |
|
|
@ -175,7 +180,6 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService |
|
|
|
//新增本地单据
|
|
|
|
await _tbBillRepository.InsertAsync(tbBill, true); |
|
|
|
await _tbOtherInOutAskRepository.InsertManyAsync(askList); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@ -188,13 +192,19 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService |
|
|
|
await _zlldcjLogManager.AddZlldcjAsync(_zlldcjList); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
bErr = true; |
|
|
|
result.TYPE = 'E'; |
|
|
|
result.MESSAGE = ex.Message; |
|
|
|
throw new UserFriendlyException(ex.Message, null, null, ex); |
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
WmsWebApiZLLDCJDTO zlldcjdto = new WmsWebApiZLLDCJDTO() |
|
|
@ -221,6 +231,28 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private async Task AddDtoAsync(WmsWebApiZLLDCJDTO dto) |
|
|
|
{ |
|
|
|
if (dto == null) { return; } |
|
|
|
|
|
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false)) |
|
|
|
{ |
|
|
|
await _zlldcjLogManager.AddDtoAsync(dto); |
|
|
|
await uow.SaveChangesAsync(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private async Task AddZlldcjAsync(List<ZlldcjLog> dtos) |
|
|
|
{ |
|
|
|
if (dtos == null || dtos.Count <= 0) { return; } |
|
|
|
|
|
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false)) |
|
|
|
{ |
|
|
|
await _zlldcjLogManager.AddZlldcjAsync(dtos); |
|
|
|
await uow.SaveChangesAsync(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("close")] |
|
|
|
//[UnitOfWork(false)]
|
|
|
|
public async Task<ReturnResult> CloseAsync([FromBody] object content)//ZlldcjLogDto dto
|
|
|
@ -321,4 +353,79 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("test/shiwu")] |
|
|
|
public async Task<ReturnResult> TestShiWu() |
|
|
|
{ |
|
|
|
var result = new ReturnResult(); |
|
|
|
var dateTime = DateTime.Now; |
|
|
|
var tbBill = new TB_BILL() |
|
|
|
{ |
|
|
|
BillNum = dateTime.ToString("yyyyMMddHHmmss"), |
|
|
|
State = 0, |
|
|
|
BillType = 0, |
|
|
|
SubBillType = 0, |
|
|
|
BillTime = dateTime, |
|
|
|
OperName = dateTime.ToString("yyyyMMddHHmmss"), |
|
|
|
DetailQty = 0, |
|
|
|
Guid = GuidGenerator.Create() |
|
|
|
}; |
|
|
|
|
|
|
|
List<TM_PG_OTHER_INOUT_ASK> askList = new List<TM_PG_OTHER_INOUT_ASK>(); |
|
|
|
for (int i = 0; i < 2; i++) |
|
|
|
{ |
|
|
|
askList.Add(new TM_PG_OTHER_INOUT_ASK() |
|
|
|
{ |
|
|
|
BillNum = dateTime.ToString("yyyyMMddHHmmss"), |
|
|
|
BillLineID = i.ToString(), |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
var dbContext = await _tbBillRepository.GetDbContextAsync(); |
|
|
|
dbContext.Database.SetCommandTimeout(120); |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
await _tbBillRepository.InsertAsync(tbBill); |
|
|
|
throw new Exception("异常了"); |
|
|
|
await _tbOtherInOutAskRepository.InsertManyAsync(askList); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
result.TYPE = 'E'; |
|
|
|
result.MESSAGE = ex.GetBaseException().Message; |
|
|
|
throw new UserFriendlyException("经过进一步包装的异常", null, null, ex); |
|
|
|
//throw new Exception("经过进一步包装的异常", ex);
|
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
result.TYPE = 'E'; |
|
|
|
await SaveLogsAsync(); |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private async Task SaveLogsAsync() |
|
|
|
{ |
|
|
|
var dateTime = DateTime.Now; |
|
|
|
var tbBill = new TB_BILL() |
|
|
|
{ |
|
|
|
BillNum = dateTime.ToString("yyyyMMddHHmmss") + "log", |
|
|
|
State = 0, |
|
|
|
BillType = 0, |
|
|
|
SubBillType = 0, |
|
|
|
BillTime = dateTime, |
|
|
|
OperName = dateTime.ToString("yyyyMMddHHmmss"), |
|
|
|
DetailQty = 0, |
|
|
|
Guid = GuidGenerator.Create() |
|
|
|
}; |
|
|
|
using (var uow = _unitOfWorkManager.Begin( |
|
|
|
requiresNew: true, isTransactional: false |
|
|
|
)) |
|
|
|
{ |
|
|
|
await _tbBillRepository.InsertAsync(tbBill, true); |
|
|
|
//await uow.SaveChangesAsync();
|
|
|
|
} |
|
|
|
} |
|
|
|
} |