|
@ -11,6 +11,8 @@ using Volo.Abp.Uow; |
|
|
using WmsWebApi.EntityFrameworkCore; |
|
|
using WmsWebApi.EntityFrameworkCore; |
|
|
using WmsWebApi.Wms; |
|
|
using WmsWebApi.Wms; |
|
|
using Abp.Web.Models; |
|
|
using Abp.Web.Models; |
|
|
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
|
|
using Abp.Domain.Uow; |
|
|
|
|
|
|
|
|
namespace WmsWebApi.ZlldcjLogs; |
|
|
namespace WmsWebApi.ZlldcjLogs; |
|
|
|
|
|
|
|
@ -22,21 +24,24 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService |
|
|
private readonly ITmSapMoveTypeRepository _tbSapMoveTypeRepository; |
|
|
private readonly ITmSapMoveTypeRepository _tbSapMoveTypeRepository; |
|
|
private readonly ITmOtherAskRepository _tbOtherInOutAskRepository; |
|
|
private readonly ITmOtherAskRepository _tbOtherInOutAskRepository; |
|
|
private readonly TmOtherAskRepositoryUpdate _tmOtherAskRepositoryUpdate; |
|
|
private readonly TmOtherAskRepositoryUpdate _tmOtherAskRepositoryUpdate; |
|
|
|
|
|
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager; |
|
|
|
|
|
|
|
|
public ZlldcjLogAppService(ZlldcjLogManager zlldcjLogManager |
|
|
public ZlldcjLogAppService(ZlldcjLogManager zlldcjLogManager |
|
|
, ITbBillRepository tbBillRepository |
|
|
, ITbBillRepository tbBillRepository |
|
|
, ITmSapMoveTypeRepository tbSapMoveTypeRepository |
|
|
, ITmSapMoveTypeRepository tbSapMoveTypeRepository |
|
|
, ITmOtherAskRepository tbOtherInOutAskRepository |
|
|
, ITmOtherAskRepository tbOtherInOutAskRepository |
|
|
, TmOtherAskRepositoryUpdate tmOtherAskRepositoryUpdate) |
|
|
, TmOtherAskRepositoryUpdate tmOtherAskRepositoryUpdate |
|
|
|
|
|
, Volo.Abp.Uow.IUnitOfWorkManager unitOfWorkManager) |
|
|
{ |
|
|
{ |
|
|
_zlldcjLogManager = zlldcjLogManager; |
|
|
_zlldcjLogManager = zlldcjLogManager; |
|
|
_tbBillRepository = tbBillRepository; |
|
|
_tbBillRepository = tbBillRepository; |
|
|
_tbSapMoveTypeRepository = tbSapMoveTypeRepository; |
|
|
_tbSapMoveTypeRepository = tbSapMoveTypeRepository; |
|
|
_tbOtherInOutAskRepository = tbOtherInOutAskRepository; |
|
|
_tbOtherInOutAskRepository = tbOtherInOutAskRepository; |
|
|
_tmOtherAskRepositoryUpdate = tmOtherAskRepositoryUpdate; |
|
|
_tmOtherAskRepositoryUpdate = tmOtherAskRepositoryUpdate; |
|
|
|
|
|
_unitOfWorkManager = unitOfWorkManager; |
|
|
} |
|
|
} |
|
|
[HttpPost("add")] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost("add")] |
|
|
public async Task<ReturnResult> AddAsync(List<ZlldcjLogDto> dto) |
|
|
public async Task<ReturnResult> AddAsync(List<ZlldcjLogDto> dto) |
|
|
{ |
|
|
{ |
|
|
var result = new ReturnResult(); |
|
|
var result = new ReturnResult(); |
|
@ -81,23 +86,23 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var dtoList = dtos.Where(p => p.WERKS == "1000").ToList(); |
|
|
try |
|
|
if (dtoList == null || dtoList.Count == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
bErr = true; |
|
|
|
|
|
result.MESSAGE = "err:没有1000工厂数据"; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
{ |
|
|
foreach (var dtoItem in dtos) |
|
|
var dtoList = dtos.Where(p => p.WERKS == "1000").ToList(); |
|
|
|
|
|
if (dtoList == null || dtoList.Count == 0) |
|
|
{ |
|
|
{ |
|
|
var entity = ObjectMapper.Map<ZlldcjLogDto, ZlldcjLog>(dtoItem); |
|
|
bErr = true; |
|
|
entity.SetId(GuidGenerator); |
|
|
result.MESSAGE = "err:没有1000工厂数据"; |
|
|
_ZlldcjLogs.Add(entity); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
else |
|
|
try |
|
|
|
|
|
{ |
|
|
{ |
|
|
|
|
|
foreach (var dtoItem in dtos) |
|
|
|
|
|
{ |
|
|
|
|
|
var entity = ObjectMapper.Map<ZlldcjLogDto, ZlldcjLog>(dtoItem); |
|
|
|
|
|
entity.SetId(GuidGenerator); |
|
|
|
|
|
_ZlldcjLogs.Add(entity); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var djList = _ZlldcjLogs.Select(p => p.ZLLDJ).Distinct(); |
|
|
var djList = _ZlldcjLogs.Select(p => p.ZLLDJ).Distinct(); |
|
|
foreach (var dj in djList) |
|
|
foreach (var dj in djList) |
|
|
{ |
|
|
{ |
|
@ -106,7 +111,7 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService |
|
|
//检查是否为存在
|
|
|
//检查是否为存在
|
|
|
var tbBill = await _tbBillRepository.FirstOrDefaultAsync(p => p.BillNum == dj); |
|
|
var tbBill = await _tbBillRepository.FirstOrDefaultAsync(p => p.BillNum == dj); |
|
|
//tbBill.CheckIsNotExist();
|
|
|
//tbBill.CheckIsNotExist();
|
|
|
if(tbBill != null) |
|
|
if (tbBill != null) |
|
|
{ |
|
|
{ |
|
|
result.TYPE = 'E'; |
|
|
result.TYPE = 'E'; |
|
|
bErr = true; |
|
|
bErr = true; |
|
@ -127,8 +132,8 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService |
|
|
}; |
|
|
}; |
|
|
//确定SubBillType
|
|
|
//确定SubBillType
|
|
|
var sapMoveType = await _tbSapMoveTypeRepository.FirstOrDefaultAsync(p => p.SAPBillType == _zlldcjList[0].ZDJLX |
|
|
var sapMoveType = await _tbSapMoveTypeRepository.FirstOrDefaultAsync(p => p.SAPBillType == _zlldcjList[0].ZDJLX |
|
|
&& p.GetOrBack == _zlldcjList[0].ZLTLX |
|
|
&& p.GetOrBack == _zlldcjList[0].ZLTLX |
|
|
&& p.MoveType == _zlldcjList[0].BWART); |
|
|
&& p.MoveType == _zlldcjList[0].BWART); |
|
|
var sapBillDesc = ""; |
|
|
var sapBillDesc = ""; |
|
|
if (sapMoveType != null) |
|
|
if (sapMoveType != null) |
|
|
{ |
|
|
{ |
|
@ -140,7 +145,7 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService |
|
|
foreach (var item in _zlldcjList) |
|
|
foreach (var item in _zlldcjList) |
|
|
{ |
|
|
{ |
|
|
var hasdetail = await _tbOtherInOutAskRepository.FirstOrDefaultAsync(p => p.BillNum == item.ZLLDJ && p.BillLineID == item.ZLLITEM.ToString()); |
|
|
var hasdetail = await _tbOtherInOutAskRepository.FirstOrDefaultAsync(p => p.BillNum == item.ZLLDJ && p.BillLineID == item.ZLLITEM.ToString()); |
|
|
if(hasdetail != null) |
|
|
if (hasdetail != null) |
|
|
{ |
|
|
{ |
|
|
throw new UserFriendlyException($"单号 {item.ZLLDJ},行号 {item.ZLLITEM} 已存在!"); |
|
|
throw new UserFriendlyException($"单号 {item.ZLLDJ},行号 {item.ZLLITEM} 已存在!"); |
|
|
} |
|
|
} |
|
@ -173,9 +178,8 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService |
|
|
item.IType = "新增"; |
|
|
item.IType = "新增"; |
|
|
} |
|
|
} |
|
|
//新增本地单据
|
|
|
//新增本地单据
|
|
|
await _tbBillRepository.InsertAsync(tbBill,true); |
|
|
await _tbBillRepository.InsertAsync(tbBill, true); |
|
|
await _tbOtherInOutAskRepository.InsertManyAsync(askList); |
|
|
await _tbOtherInOutAskRepository.InsertManyAsync(askList); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
@ -188,13 +192,19 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService |
|
|
await _zlldcjLogManager.AddZlldcjAsync(_zlldcjList); |
|
|
await _zlldcjLogManager.AddZlldcjAsync(_zlldcjList); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
catch (Exception ex) |
|
|
|
|
|
{ |
|
|
|
|
|
bErr = true; |
|
|
|
|
|
result.TYPE = 'E'; |
|
|
|
|
|
result.MESSAGE = ex.Message; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
catch (Exception ex) |
|
|
|
|
|
{ |
|
|
|
|
|
bErr = true; |
|
|
|
|
|
result.TYPE = 'E'; |
|
|
|
|
|
result.MESSAGE = ex.Message; |
|
|
|
|
|
throw new UserFriendlyException(ex.Message, null, null, ex); |
|
|
|
|
|
} |
|
|
|
|
|
finally |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
WmsWebApiZLLDCJDTO zlldcjdto = new WmsWebApiZLLDCJDTO() |
|
|
WmsWebApiZLLDCJDTO zlldcjdto = new WmsWebApiZLLDCJDTO() |
|
@ -221,6 +231,28 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService |
|
|
return result; |
|
|
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")] |
|
|
[HttpPost("close")] |
|
|
//[UnitOfWork(false)]
|
|
|
//[UnitOfWork(false)]
|
|
|
public async Task<ReturnResult> CloseAsync([FromBody] object content)//ZlldcjLogDto dto
|
|
|
public async Task<ReturnResult> CloseAsync([FromBody] object content)//ZlldcjLogDto dto
|
|
@ -321,4 +353,79 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService |
|
|
} |
|
|
} |
|
|
return result; |
|
|
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();
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |