Browse Source

超时问题,方案一

HQ
liuyunfeng 7 months ago
parent
commit
ea965197bd
  1. 52
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/EdiReceive/ImportRecordAppService.cs
  2. 4
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/EdiReceive/Services/EdiParseDomainService.cs
  3. 2
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/EdiReceive/Services/LastImportHostSNDomainService.cs
  4. 2
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.EntityFrameworkCore/EntityFrameworkCore/NewJitDbContext.cs

52
src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/EdiReceive/ImportRecordAppService.cs

@ -11,6 +11,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.BlobStoring; using Volo.Abp.BlobStoring;
@ -428,9 +429,9 @@ namespace WY.NewJit.EdiReceive
/// <param name="files">导入文件</param> /// <param name="files">导入文件</param>
/// <param name="forceExecute">校验出错时,是否强制执行</param> /// <param name="forceExecute">校验出错时,是否强制执行</param>
/// <returns>执行成功返回真</returns> /// <returns>执行成功返回真</returns>
[UnitOfWork(IsDisabled =true)] //[UnitOfWork(IsDisabled =true)]
//[UnitOfWork(isTransactional: false)] //[UnitOfWork(false)] //[UnitOfWork(isTransactional: false)] //[UnitOfWork(false)]
//[UnitOfWork] [UnitOfWork]
[HttpPost] [HttpPost]
[Route("import")] [Route("import")]
[DisableRequestSizeLimit] [DisableRequestSizeLimit]
@ -472,36 +473,38 @@ namespace WY.NewJit.EdiReceive
return ret; return ret;
} }
using (var uow = _unitOfWorkManager.Begin(requiresNew:true)) //using (var uow = _unitOfWorkManager.Begin())
//{
var srcLst = impResult.Data.AsEnumerable().ToList();
var tarLst = ObjectMapper.Map<List<ImportRecordDto>, List<ImportRecord>>(srcLst);
foreach (var tar in tarLst)
{ {
var srcLst = impResult.Data.AsEnumerable().ToList(); //tar.CreatePerson = "导入";
var tarLst = ObjectMapper.Map<List<ImportRecordDto>, List<ImportRecord>>(srcLst); tar.CreateTime = ServerHelper.CurrentDateTime;
foreach (var tar in tarLst)
{
//tar.CreatePerson = "导入";
tar.CreateTime = ServerHelper.CurrentDateTime;
}
//报文解析
ObjectResultDto ret2 = await _ediParseDomainService.ParseEdi(tarLst, forceExecute);
if (ret2.Status == false)
{
return ret2;
}
if (ret2.Status == true && ret2.Message.HasValue())
{
return ret2;
}
await uow.CompleteAsync();
ret.Status = true;
return ret;
} }
//报文解析
ObjectResultDto ret2 = await _ediParseDomainService.ParseEdi(tarLst, forceExecute);
if (ret2.Status == false)
{
return ret2;
}
if (ret2.Status == true && ret2.Message.HasValue())
{
return ret2;
}
//await uow.CompleteAsync();
ret.Status = true;
return ret;
//}
} }
catch (Exception ex) catch (Exception ex)
{ {
ret.Status = false; ret.Status = false;
ret.Message = _errorMessagePrefix + "ImportAsync 执行出错:" + ex.Message; ret.Message = _errorMessagePrefix + "ImportAsync 执行出错:" + ex.Message;
_logger.LogError(ret.Message); _logger.LogError(ret.Message);
return ret; throw new BusinessException("1001", ret.Message);
//return ret;
} }
} }
@ -515,6 +518,7 @@ namespace WY.NewJit.EdiReceive
[Route("print-timeout-remind")] [Route("print-timeout-remind")]
public virtual async Task<TimeOutRemindResultDto> PrintTimeoutRemind() public virtual async Task<TimeOutRemindResultDto> PrintTimeoutRemind()
{ {
//return new TimeOutRemindResultDto();
TimeOutRemindResultDto retObj = new TimeOutRemindResultDto(); TimeOutRemindResultDto retObj = new TimeOutRemindResultDto();
retObj.ConfigMinutes = _configuration[$"ConfigDic:ProductLineTimeoutRemind_New:{"Record"}"].TryToInt() ?? 40; retObj.ConfigMinutes = _configuration[$"ConfigDic:ProductLineTimeoutRemind_New:{"Record"}"].TryToInt() ?? 40;
var qry = await _importRecordRepository.MaxAsync(itm => itm.CreateTime); var qry = await _importRecordRepository.MaxAsync(itm => itm.CreateTime);

4
src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/EdiReceive/Services/EdiParseDomainService.cs

@ -190,7 +190,7 @@ namespace WY.NewJit.EdiReceive.Services
_hqCacheManagerDomainService.InitLoadCache(); _hqCacheManagerDomainService.InitLoadCache();
//批量插入 导入记录 //批量插入 导入记录
await _importRecordRepository.InsertManyAsync(notRepeatOrder); await _importRecordRepository.InsertManyAsync(notRepeatOrder, true);
//过滤掉其它厂家的订单,只取派格订单 //过滤掉其它厂家的订单,只取派格订单
var paigeOrderLst = notRepeatOrder.Where(itm => itm.VehicleModelCode.Substring(0, 2) == _vehicleModelPrefix).OrderBy(itm => itm.HostSN).ToList(); var paigeOrderLst = notRepeatOrder.Where(itm => itm.VehicleModelCode.Substring(0, 2) == _vehicleModelPrefix).OrderBy(itm => itm.HostSN).ToList();
@ -206,7 +206,7 @@ namespace WY.NewJit.EdiReceive.Services
if (isRepeat == true) if (isRepeat == true)
{ {
#region 重复报文 #region 重复报文
var succObj = InsertM100RepeatBill(orderItem, m100Obj); var succObj = await InsertM100RepeatBill(orderItem, m100Obj);
_logger.LogDebug(_errorMessagePrefix + $"流水号{orderItem.HostSN}是重复报文"); _logger.LogDebug(_errorMessagePrefix + $"流水号{orderItem.HostSN}是重复报文");
ret.Status = (succObj != null); ret.Status = (succObj != null);
return ret; return ret;

2
src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/EdiReceive/Services/LastImportHostSNDomainService.cs

@ -60,7 +60,7 @@ namespace WY.NewJit.EdiReceive.Services
/// </summary> /// </summary>
/// <param name="productLine"></param> /// <param name="productLine"></param>
/// <returns></returns> /// <returns></returns>
public async Task<int> GetLastImportMaxHostSN() public virtual async Task<int> GetLastImportMaxHostSN()
{ {
var lst = await _lastImportHostSNRepository.GetListAsync(); var lst = await _lastImportHostSNRepository.GetListAsync();
if (lst.Count > 0) if (lst.Count > 0)

2
src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.EntityFrameworkCore/EntityFrameworkCore/NewJitDbContext.cs

@ -169,7 +169,7 @@ namespace WY.NewJit.EntityFrameworkCore
public NewJitDbContext(DbContextOptions<NewJitDbContext> options) public NewJitDbContext(DbContextOptions<NewJitDbContext> options)
: base(options) : base(options)
{ {
this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(120));
} }
protected override void OnModelCreating(ModelBuilder builder) protected override void OnModelCreating(ModelBuilder builder)

Loading…
Cancel
Save