feat(templateMatcher,dal): Первая реализация SyncTemplatesForJobGroup для сгруппированных типов групп регламентных работ.

This commit is contained in:
Mikhail Kuznetsov
2025-12-19 19:15:58 +10:00
parent cc104c30b1
commit 7ca536ce52
20 changed files with 687 additions and 71 deletions

View File

@@ -48,7 +48,7 @@ namespace PARR.DAL.DomainServices.Implementations
this.unitFilterService = unitFilterService;
}
public async Task<string> ApplyShortcodesAsync(string str, Guid unitId, Guid jobId)
public async Task<string> ApplyShortcodesAsync(string str, Guid unitId, Guid jobId, int? index = null)
{
logger.LogDebug("Начата подстановка шорткодов. Вход: '{Input}', unitId={UnitId}, jobId={JobId}", str, unitId, jobId);
@@ -95,7 +95,7 @@ namespace PARR.DAL.DomainServices.Implementations
// Делаем замену
var oldResult = resultName;
resultName = ReplaceStandardShortcodes(job, unit, resultName);
resultName = ReplaceStandardShortcodes(job, unit, resultName, index);
iteration++;
// Защита от "бесполезных" итераций (строка не изменилась)
@@ -262,14 +262,15 @@ namespace PARR.DAL.DomainServices.Implementations
}
private static string ReplaceStandardShortcodes(Job job, Unit unit, string input)
private static string ReplaceStandardShortcodes(Job job, Unit unit, string input, int? index = null)
{
return input
.Replace("%ЭК%", unit.Name, StringComparison.OrdinalIgnoreCase)
.Replace("%ГРУППА_РАБОТ%", job.Group?.GroupName ?? "", StringComparison.OrdinalIgnoreCase)
.Replace("%РАБОТА%", job.WorkName, StringComparison.OrdinalIgnoreCase)
.Replace("%ТНК%", job.Tnk?.Name ?? "", StringComparison.OrdinalIgnoreCase)
.Replace("%ТНК-КРАТКО%", job.Tnk?.ShortName ?? "", StringComparison.OrdinalIgnoreCase);
.Replace("%ТНК-КРАТКО%", job.Tnk?.ShortName ?? "", StringComparison.OrdinalIgnoreCase)
.Replace("%ИНДЕКС%", index?.ToString() ?? "", StringComparison.OrdinalIgnoreCase);
}

View File

@@ -4,7 +4,7 @@ namespace PARR.DAL.DomainServices.Interfaces
{
public interface IShortcodesService
{
Task<string> ApplyShortcodesAsync(string str, Guid unitId, Guid jobId);
Task<string> ApplyShortcodesAsync(string str, Guid unitId, Guid jobId, int? index = null);
bool IsAnyShortcodes(string str);