feat(api,templateActivator): обновлена логика templateActivator

This commit is contained in:
Mikhail Trubnikov
2025-11-26 14:34:03 +10:00
parent 2823823784
commit 276f534636
19 changed files with 520 additions and 313 deletions

View File

@@ -118,6 +118,9 @@ namespace PARR.API.Controllers.V1
[HttpPut(ApiRoutes.Template.ChangeState)]
public async Task<IActionResult> ChangeState([FromRoute] Guid id, [FromBody] TemplateChangeStateRequest request)
{
//TODO:!!! Возможно тут не надо сразу менять, а отправить запрос в TemplateActivator и пусть он сам занимается своей работой!!!
var template = await templateService.GetWithIncludes()
.Include(t => t.Unit).ThenInclude(t => t!.UnitValues).ThenInclude(t => t.Field)
.Include(t => t.Unit).ThenInclude(t => t!.UnitValues).ThenInclude(t => t.Value)
@@ -135,16 +138,16 @@ namespace PARR.API.Controllers.V1
{
template.IsActiveTemplate = request.IsActiveTemplate;
//необходимо обновить шаблон
var config = robotConfigurationService.GetFromTemplateByRobotCode(RobotsEnum.TemplateOrder, ref template);
robotConfigurationService.ChangeTaskStatus(TaskStatusEnum.Updating, ref config);
var config = robotConfigurationService.GetFromTemplateByRobotCode(RobotsEnum.TemplateOrder, template);
robotConfigurationService.ChangeTaskStatus(TaskStatusEnum.Updating, config);
}
if (template.IsActiveSchedule != request.IsActiveSchedule)
{
template.IsActiveSchedule = request.IsActiveSchedule;
//необходимо обновить расписание
var config = robotConfigurationService.GetFromTemplateByRobotCode(RobotsEnum.ScheduleOrder, ref template);
robotConfigurationService.ChangeTaskStatus(TaskStatusEnum.Updating, ref config);
var config = robotConfigurationService.GetFromTemplateByRobotCode(RobotsEnum.ScheduleOrder, template);
robotConfigurationService.ChangeTaskStatus(TaskStatusEnum.Updating, config);
}
if (!await templateService.CommitAsync(new HistoryInitiator { InitiatorComment = "Изменён статус шаблона/расписания", InitiatorIp = clientService.GetClientIp()?.ToString(), InitiatorParrComponentId = ParrComponentsEnum.Api }))