добавлен warning
Tests / test (push) Successful in 2m4s

This commit is contained in:
gorbenko.pavel
2026-07-29 14:53:45 +05:00
parent a28a397205
commit 5476c1bab5
3 changed files with 105 additions and 2 deletions
@@ -197,14 +197,26 @@ public sealed class TemplateRouteService(
IReadOnlyList<ProjectExecutorInfo> projectExecutors, CancellationToken cancellationToken)
{
string? resolvedEmail;
string? warning = null;
if (!string.IsNullOrWhiteSpace(step.ExecutorEmail))
{
resolvedEmail = step.ExecutorEmail;
}
else if (!string.IsNullOrWhiteSpace(step.Position))
{
resolvedEmail = await portalClient.GetEmployeeByPositionAsync(step.Position, initiatorCompany, cancellationToken);
if (string.IsNullOrWhiteSpace(resolvedEmail))
warning = $"Не найден сотрудник на должности «{step.Position}» в компании «{initiatorCompany}».";
}
else if (step.ProjectRole is not (null or ProjectRole.None))
{
resolvedEmail = projectExecutors.FirstOrDefault(e => e.ProjectRole == step.ProjectRole)?.Email;
if (string.IsNullOrWhiteSpace(resolvedEmail))
warning = $"Не найден исполнитель с ролью в проекте «{step.ProjectRole}».";
}
else if (step.HeadType is not (null or HeadType.None))
{
resolvedEmail = step.HeadType switch
{
HeadType.Chief => await portalClient.GetManagerAsync(initiatorEmail, "chief", cancellationToken),
@@ -212,8 +224,14 @@ public sealed class TemplateRouteService(
HeadType.DirectorTansu => portalOptions.Value.DirectorTansuEmail,
_ => null
};
if (string.IsNullOrWhiteSpace(resolvedEmail))
warning = $"Не найден руководитель типа «{step.HeadType}».";
}
else
{
resolvedEmail = null;
warning = "Не удалось определить исполнителя шага: не заполнено ни одно из полей.";
}
string? resolvedPosition = null;
if (!string.IsNullOrWhiteSpace(resolvedEmail))
@@ -222,7 +240,7 @@ public sealed class TemplateRouteService(
resolvedPosition = resolvedEmployee?.Position;
}
return new ResolvedRouteStepDto(step.Id, step.OrderNo, resolvedEmail, resolvedPosition, step.AllowReassignToOtherApprovers);
return new ResolvedRouteStepDto(step.Id, step.OrderNo, resolvedEmail, resolvedPosition, step.AllowReassignToOtherApprovers, warning);
}
private static IReadOnlyList<ResolvedRouteStepDto> CollapseByExecutorEmail(IReadOnlyList<ResolvedRouteStepDto> steps)