2023-10-11 11:10:35 +10:00
|
|
|
|
using AutoMapper;
|
|
|
|
|
|
using PARR.API.Contracts.V1.Responses;
|
|
|
|
|
|
using PARR.DAL.Models;
|
|
|
|
|
|
using PARR.DAL.Services.Interfaces;
|
2026-02-03 16:15:19 +10:00
|
|
|
|
|
2023-10-11 11:10:35 +10:00
|
|
|
|
|
|
|
|
|
|
namespace PARR.API.MappingProfiles.Resolvers
|
|
|
|
|
|
{
|
|
|
|
|
|
public class RobotTaskScheduleSchResolver : IValueResolver<RobotConfiguration, RobotTaskScheduleResponse, List<RobotTaskScheduleSchResponse>?>
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IEsppSchTypeConfigService esppConfigService;
|
2023-10-12 12:06:47 +10:00
|
|
|
|
private readonly ILogger<RobotTaskScheduleSchResolver> logger;
|
2023-10-11 11:10:35 +10:00
|
|
|
|
|
2023-10-12 12:06:47 +10:00
|
|
|
|
public RobotTaskScheduleSchResolver(
|
|
|
|
|
|
IEsppSchTypeConfigService esppConfigService,
|
2026-02-03 16:15:19 +10:00
|
|
|
|
ILogger<RobotTaskScheduleSchResolver> logger
|
2023-10-12 12:06:47 +10:00
|
|
|
|
)
|
2023-10-11 11:10:35 +10:00
|
|
|
|
{
|
|
|
|
|
|
this.esppConfigService = esppConfigService;
|
2023-10-12 12:06:47 +10:00
|
|
|
|
this.logger = logger;
|
2023-10-11 11:10:35 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<RobotTaskScheduleSchResponse>? Resolve(RobotConfiguration source, RobotTaskScheduleResponse destination, List<RobotTaskScheduleSchResponse>? destMember, ResolutionContext context)
|
|
|
|
|
|
{
|
2025-06-27 13:42:13 +10:00
|
|
|
|
var jobGroupId = source.Template!.Job!.GroupId;
|
2023-10-11 11:10:35 +10:00
|
|
|
|
|
2025-06-27 13:42:13 +10:00
|
|
|
|
var schedule = esppConfigService.GetEsppScheduleDto(jobGroupId);
|
2023-10-11 11:10:35 +10:00
|
|
|
|
|
2023-10-12 12:06:47 +10:00
|
|
|
|
if (schedule == null)
|
|
|
|
|
|
{
|
2025-06-27 13:42:13 +10:00
|
|
|
|
logger.LogError($"RobotTaskScheduleSchResolver: Не смог замапить расписание для робота, так как оно null. jobGroupId: {jobGroupId}");
|
2023-10-12 12:06:47 +10:00
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var response = schedule.Values.Select(t => new RobotTaskScheduleSchResponse
|
|
|
|
|
|
{
|
|
|
|
|
|
Order = t.Order,
|
|
|
|
|
|
Type = t.Type.Name,
|
|
|
|
|
|
TypeCode = t.Type.Id,
|
|
|
|
|
|
Value = t.Value.Value
|
2024-07-16 12:06:46 +10:00
|
|
|
|
}).OrderBy(t => t.Order).ToList();
|
2023-10-11 11:10:35 +10:00
|
|
|
|
|
2026-02-03 16:15:19 +10:00
|
|
|
|
////Если задача относится к распределенной модели исполнения за период месяц устанавливаем день равный NextRun
|
|
|
|
|
|
////УСТАРЕВШЕЕ
|
|
|
|
|
|
//if (source.Template!.Job!.Group!.IsAutoDistributionEnabled && schedule.TypeSchedule.Id == (int)EsppSchTypeScheduleEnum.Monthly)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var nextRunForRobot = nextRunModifierService.GetNextRunByAccountRobotTimeZone(source.Template.NextRun);
|
2024-07-16 12:06:46 +10:00
|
|
|
|
|
2026-02-03 16:15:19 +10:00
|
|
|
|
// //response.First().Value = source.Template.NextRun.Day.ToString();
|
|
|
|
|
|
// response.First().Value = nextRunForRobot.Day.ToString();
|
|
|
|
|
|
//}
|
2024-07-16 12:06:46 +10:00
|
|
|
|
|
|
|
|
|
|
return response;
|
2023-10-11 11:10:35 +10:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|