fix(api): исправлена ошибка при запросе заданий роботу на обновление расписаний, получали null при запросе даты следующего запуска РР в include EsppSchTypeValues
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Constants;
|
using PARR.Constants;
|
||||||
using PARR.DAL.Contracts;
|
using PARR.DAL.Contracts;
|
||||||
using PARR.DAL.DomainModels;
|
using PARR.DAL.DomainModels;
|
||||||
@@ -134,13 +135,17 @@ namespace PARR.DAL.TransformServices
|
|||||||
|
|
||||||
public async Task<DateTimeOffset> GetNextDateAsync(Guid applicationInWorkId, DateTimeOffset lastRun)
|
public async Task<DateTimeOffset> GetNextDateAsync(Guid applicationInWorkId, DateTimeOffset lastRun)
|
||||||
{
|
{
|
||||||
var appInWork = await applicationsInWorkService.GetAsync(applicationInWorkId);
|
var appInWork = await applicationsInWorkService.Get()
|
||||||
|
.Include(aiw => aiw.EsppSchValues)
|
||||||
|
.ThenInclude(esv => esv.EsppSchTypeValue)
|
||||||
|
.ThenInclude(etv => etv!.DistributionPeriod)
|
||||||
|
.FirstOrDefaultAsync(t => t.Id == applicationInWorkId);
|
||||||
|
|
||||||
var esppSchedule = await GetEsppScheduleAsync(applicationInWorkId);
|
var esppSchedule = await GetEsppScheduleAsync(applicationInWorkId);
|
||||||
|
|
||||||
if (appInWork!.IsAutoDistributionEnabled)
|
if (appInWork!.IsAutoDistributionEnabled)
|
||||||
{
|
{
|
||||||
var period = esppSchedule!.Values.FirstOrDefault()!.Value!.DistributionPeriod;
|
var period = appInWork.EsppSchValues.FirstOrDefault()?.EsppSchTypeValue?.DistributionPeriod;
|
||||||
var periodType = ParseDistributionPeriodType(period!.Type);
|
var periodType = ParseDistributionPeriodType(period!.Type);
|
||||||
|
|
||||||
return GetNextDateForDistributionRun(lastRun, periodType, period.Duration);
|
return GetNextDateForDistributionRun(lastRun, periodType, period.Duration);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace PARR.TemplateDistributor
|
|||||||
// сохранить в БД
|
// сохранить в БД
|
||||||
//applicationInWorkId = Guid.Parse("bdfefd77-bce3-4f62-a484-5042c06f4467");
|
//applicationInWorkId = Guid.Parse("bdfefd77-bce3-4f62-a484-5042c06f4467");
|
||||||
|
|
||||||
//var appInWork = await applicationsInWorkService.Get()
|
var appInWork = await applicationsInWorkService.GetAsync(applicationInWorkId );
|
||||||
// .Include(aiw => aiw.EsppSchValues)
|
// .Include(aiw => aiw.EsppSchValues)
|
||||||
// .ThenInclude(esv => esv.EsppSchTypeValue)
|
// .ThenInclude(esv => esv.EsppSchTypeValue)
|
||||||
// .ThenInclude(etv => etv!.DistributionPeriod)
|
// .ThenInclude(etv => etv!.DistributionPeriod)
|
||||||
@@ -69,6 +69,13 @@ namespace PARR.TemplateDistributor
|
|||||||
if (!values.Any())
|
if (!values.Any())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
//Обновляем сразу время при необходимости
|
||||||
|
values.ForEach(t=>{
|
||||||
|
if (t.NextRun.TimeOfDay != appInWork!.ReferenceDate.TimeOfDay)
|
||||||
|
t.NextRun = new DateTimeOffset(t.NextRun.DateTime, new TimeSpan(appInWork!.ReferenceDate.Hour, appInWork!.ReferenceDate.Minute, appInWork!.ReferenceDate.Second));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
var distrTemplates = await DistributeTemplateAsync(values, applicationInWorkId, wgId);
|
var distrTemplates = await DistributeTemplateAsync(values, applicationInWorkId, wgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +115,10 @@ namespace PARR.TemplateDistributor
|
|||||||
if (existingTemplates.Count > 0)
|
if (existingTemplates.Count > 0)
|
||||||
templateToDistrib = GetTemplatesToDistribute(ref distrPlan, existingTemplates);
|
templateToDistrib = GetTemplatesToDistribute(ref distrPlan, existingTemplates);
|
||||||
|
|
||||||
templateToDistrib.AddRange(templates);
|
templateToDistrib.AddRange(templates.Where(t=>existingTemplates.Any(et=>et.Id==t.Id)==false));
|
||||||
|
|
||||||
|
if (!templateToDistrib.Any())
|
||||||
|
return new List<Template>();
|
||||||
|
|
||||||
var distributedTemplates = 0;
|
var distributedTemplates = 0;
|
||||||
|
|
||||||
@@ -224,7 +234,7 @@ namespace PARR.TemplateDistributor
|
|||||||
{
|
{
|
||||||
var wrokDateTimeOffset = new DateTimeOffset(
|
var wrokDateTimeOffset = new DateTimeOffset(
|
||||||
wd.Year, wd.Month, wd.Day,
|
wd.Year, wd.Month, wd.Day,
|
||||||
0, 0, 0,
|
appInWork.ReferenceDate.Hour, appInWork.ReferenceDate.Minute, appInWork.ReferenceDate.Second,
|
||||||
new TimeSpan(0, 0, 0));
|
new TimeSpan(0, 0, 0));
|
||||||
if (wrokDateTimeOffset < DateTimeOffset.UtcNow)
|
if (wrokDateTimeOffset < DateTimeOffset.UtcNow)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user