feat(api, dal): в настройки в БД добавлено поле EsppRobotAccountTimeZoneHour со значением 3, обновлено ScheduleTimezone на MSK. В api в задании роботу по расписаниям, время выдается с учетом таймзоны робота.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using AutoMapper;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.BLL.Helpers;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.TransformServices;
|
||||
|
||||
namespace PARR.API.MappingProfiles.Resolvers
|
||||
{
|
||||
public class RobotTaskScheduleGenerationTimeResolver : IValueResolver<RobotConfiguration, RobotTaskScheduleResponse, string>
|
||||
{
|
||||
private readonly SettingsFromDb settingsFromDb;
|
||||
private readonly INextRunModifierService nextRunModifierService;
|
||||
|
||||
public RobotTaskScheduleGenerationTimeResolver(SettingsFromDb settingsFromDb, INextRunModifierService nextRunModifierService)
|
||||
{
|
||||
this.settingsFromDb = settingsFromDb;
|
||||
this.nextRunModifierService = nextRunModifierService;
|
||||
}
|
||||
|
||||
public string Resolve(RobotConfiguration source, RobotTaskScheduleResponse destination, string destMember, ResolutionContext context)
|
||||
{
|
||||
var nextRunForRobot = nextRunModifierService.GetNextRunByAccountRobotTimeZone(source.Template!.NextRun);
|
||||
|
||||
return EsppScheduleHelpers.GetGenerationTime(nextRunForRobot);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using AutoMapper;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.BLL.Helpers;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.TransformServices;
|
||||
|
||||
namespace PARR.API.MappingProfiles.Resolvers
|
||||
{
|
||||
public class RobotTaskScheduleNextStartResolver : IValueResolver<RobotConfiguration, RobotTaskScheduleResponse, string>
|
||||
{
|
||||
private readonly SettingsFromDb settingsFromDb;
|
||||
private readonly INextRunModifierService nextRunModifierService;
|
||||
|
||||
public RobotTaskScheduleNextStartResolver(SettingsFromDb settingsFromDb, INextRunModifierService nextRunModifierService)
|
||||
{
|
||||
this.settingsFromDb = settingsFromDb;
|
||||
this.nextRunModifierService = nextRunModifierService;
|
||||
}
|
||||
|
||||
public string Resolve(RobotConfiguration source, RobotTaskScheduleResponse destination, string destMember, ResolutionContext context)
|
||||
{
|
||||
var nextRunForRobot = nextRunModifierService.GetNextRunByAccountRobotTimeZone(source.Template!.NextRun);
|
||||
|
||||
return EsppScheduleHelpers.GetNextRun(nextRunForRobot);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using System.Threading.Tasks;
|
||||
using PARR.DAL.TransformServices;
|
||||
|
||||
namespace PARR.API.MappingProfiles.Resolvers
|
||||
{
|
||||
@@ -11,14 +11,17 @@ namespace PARR.API.MappingProfiles.Resolvers
|
||||
{
|
||||
private readonly IEsppSchTypeConfigService esppConfigService;
|
||||
private readonly ILogger<RobotTaskScheduleSchResolver> logger;
|
||||
private readonly INextRunModifierService nextRunModifierService;
|
||||
|
||||
public RobotTaskScheduleSchResolver(
|
||||
IEsppSchTypeConfigService esppConfigService,
|
||||
ILogger<RobotTaskScheduleSchResolver> logger
|
||||
ILogger<RobotTaskScheduleSchResolver> logger,
|
||||
INextRunModifierService nextRunModifierService
|
||||
)
|
||||
{
|
||||
this.esppConfigService = esppConfigService;
|
||||
this.logger = logger;
|
||||
this.nextRunModifierService = nextRunModifierService;
|
||||
}
|
||||
|
||||
public List<RobotTaskScheduleSchResponse>? Resolve(RobotConfiguration source, RobotTaskScheduleResponse destination, List<RobotTaskScheduleSchResponse>? destMember, ResolutionContext context)
|
||||
@@ -42,10 +45,13 @@ namespace PARR.API.MappingProfiles.Resolvers
|
||||
}).OrderBy(t => t.Order).ToList();
|
||||
|
||||
//Если задача относится к распределенной модели исполнения за период месяц устанавливаем день равный NextRun
|
||||
if (source.Template!.ApplicationsInWork!.IsAutoDistributionEnabled &&
|
||||
schedule.TypeSchedule.Id == (int)EsppSchTypeScheduleEnum.Monthly)
|
||||
response.First().Value = source.Template.NextRun.Day.ToString();
|
||||
if (source.Template!.ApplicationsInWork!.IsAutoDistributionEnabled && schedule.TypeSchedule.Id == (int)EsppSchTypeScheduleEnum.Monthly)
|
||||
{
|
||||
var nextRunForRobot = nextRunModifierService.GetNextRunByAccountRobotTimeZone(source.Template.NextRun);
|
||||
|
||||
//response.First().Value = source.Template.NextRun.Day.ToString();
|
||||
response.First().Value = nextRunForRobot.Day.ToString();
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user