Browse Source

记录请求Json数据

master
bin.jiang 2 years ago
parent
commit
732b9ae5e3
  1. 2466
      host/WmsWebApi.HttpApi.Host/Logs/logs20230227.txt
  2. 2
      host/WmsWebApi.HttpApi.Host/Startup.cs
  3. 68
      src/WmsWebApi.Application/OtherZll/OtherZllService.cs
  4. 122
      src/WmsWebApi.Application/ZlldcjLogs/ZlldcjLogAppService.cs

2466
host/WmsWebApi.HttpApi.Host/Logs/logs20230227.txt

File diff suppressed because it is too large

2
host/WmsWebApi.HttpApi.Host/Startup.cs

@ -16,10 +16,8 @@ namespace WmsWebApi
services.AddControllersWithViews(options =>
{
//options.Filters.AddService(typeof(AbpExceptionFilter));
options.Filters.Add(typeof(AbpExceptionFilterExtension));
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)

68
src/WmsWebApi.Application/OtherZll/OtherZllService.cs

@ -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();
}
}
}

122
src/WmsWebApi.Application/ZlldcjLogs/ZlldcjLogAppService.cs

@ -107,10 +107,9 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService
foreach (var dj in djList)
{
var _zlldcjList = _ZlldcjLogs.Where(p => p.ZLLDJ == dj).ToList();
//var ret = await _zlldcjLogManager.AddAsync(_zlldcjList);
//检查是否为存在
var tbBill = await _tbBillRepository.FirstOrDefaultAsync(p => p.BillNum == dj);
//tbBill.CheckIsNotExist();
if (tbBill != null)
{
result.TYPE = 'E';
@ -177,19 +176,35 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService
askList.Add(ask);
item.IType = "新增";
}
try
{
//新增本地单据
await _tbBillRepository.InsertAsync(tbBill, true);
await _tbOtherInOutAskRepository.InsertManyAsync(askList);
}
catch (Exception ex)
{
foreach (var item in _zlldcjList)
{
item.IType = ex.GetBaseException().Message;
}
throw new Exception("操作数据库失败,请稍后重试。", ex);
}
finally
{
//新增日志记录
await AddZlldcjAsync(_zlldcjList);
}
}
else
{
foreach (var item in _zlldcjList)
{
item.IType = "WMS 不需要的接口";
}
}
//新增日志记录
await _zlldcjLogManager.AddZlldcjAsync(_zlldcjList);
await AddZlldcjAsync(_zlldcjList);
}
}
}
}
@ -197,15 +212,10 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService
{
bErr = true;
result.TYPE = 'E';
result.MESSAGE = ex.Message;
throw new UserFriendlyException(ex.Message, null, null, ex);
result.MESSAGE = ex.GetBaseException().Message;
throw;
}
finally
{
}
try
{
WmsWebApiZLLDCJDTO zlldcjdto = new WmsWebApiZLLDCJDTO()
{
@ -219,13 +229,7 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService
{
zlldcjdto.ITYPE = result.MESSAGE;
}
await _zlldcjLogManager.AddDtoAsync(zlldcjdto);
}
catch (Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = ex.GetBaseException().Message;
await AddDtoAsync(zlldcjdto);
}
return result;
@ -353,86 +357,4 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService
}
return result;
}
[HttpPost("test/shiwu")]
public async Task<ReturnResult> TestShiWu()
{
var result = new ReturnResult();
result.TYPE = 'E';
result.MESSAGE = "测试返回结构";
//throw new UserFriendlyException("经过进一步包装的异常", null, null);
throw new Exception("经过进一步包装的异常");
return result;
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
{
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();
}
}
}
Loading…
Cancel
Save