fix(esppTemplateSyncer): добавлен Id Group для правильного формирования группированных значений %МАКС:...%

This commit is contained in:
Mikhail Kuznetsov
2026-01-12 11:06:47 +10:00
parent 1d618bb300
commit ba465f4b26
3 changed files with 26 additions and 0 deletions

View File

@@ -365,6 +365,18 @@ namespace PARR.DAL.DomainServices.Shortcodes
private async Task<string> ReplaceMaxShortcodesAsync(Guid jobGroupId, Guid unitId, string input, MatchCollection maxShortcodes)
{
if (jobGroupId == Guid.Empty)
{
logger.LogWarning("jobGroupId не задан. Пропускаем обработку %МАКС:...%");
return input;
}
if (unitId == Guid.Empty)
{
logger.LogWarning("unitId не задан. Пропускаем обработку %МАКС:...%");
return input;
}
var shortcodeToMatches = maxShortcodes
.Cast<Match>()
.GroupBy(m => m.Value, StringComparer.OrdinalIgnoreCase)
@@ -390,6 +402,18 @@ namespace PARR.DAL.DomainServices.Shortcodes
private async Task<string> GetMaxShortCodeFromCacheOrDbAsync(Guid jobGroupId, Guid unitId, string fullShortcode, string fieldName)
{
if (jobGroupId == Guid.Empty)
{
logger.LogWarning("jobGroupId не задан. Пропускаем обработку шорткода {Shortcode}", fullShortcode);
return "Нет данных";
}
if (unitId == Guid.Empty)
{
logger.LogWarning("unitId не задан. Пропускаем обработку шорткода {Shortcode}", fullShortcode);
return "Нет данных";
}
var cacheKey = $"gr_shcd_{jobGroupId:N}_{unitId:N}_{ComputeHash(fullShortcode)}";
var cachedData = await cacheService.GetCachedDataAsync<CachedGroupedShortCode>(cacheKey);

View File

@@ -101,6 +101,7 @@ namespace PARR.EsppSync
{
Group = template.Job.Group == null ? null : new JobGroupForShortcodes
{
Id = template.Job.GroupId,
GroupingUnitFieldId = template.Job.Group.GroupingUnitFieldId,
GroupType = template.Job.Group.GroupType == null ? null : new JobGroupTypeForShortcodes
{

View File

@@ -90,6 +90,7 @@ namespace PARR.TemplateGeneratorWorker
{
Group = job.Group == null ? null : new JobGroupForShortcodes
{
Id = job.GroupId,
GroupingUnitFieldId = job.Group.GroupingUnitFieldId,
GroupType = job.Group.GroupType == null ? null : new JobGroupTypeForShortcodes
{