feat(api,dal): в таблицу Jobs добавлено поле ResponseAreaMask. В JobController добавлено поле ResponseAreaMask. В TemplateController отображается фактическая РК, ЗО шаблона. RobotTask ЗО отдается согласно ResponseAreaMask. ShortcodeService теперь умеет принимать Template.

This commit is contained in:
Mikhail Trubnikov
2026-01-13 14:36:07 +10:00
parent 43d40d950e
commit bd4ad918e3
21 changed files with 8438 additions and 87 deletions

View File

@@ -6,6 +6,7 @@ using PARR.DAL.Contracts;
using PARR.DAL.DomainModels;
using PARR.DAL.DomainServices.Interfaces;
using PARR.DAL.DomainServices.Shortcodes.Models;
using PARR.DAL.Models;
using PARR.DAL.Models.Unit;
using PARR.DAL.Services.Interfaces;
using PARR.DAL.Services.Interfaces.Job;
@@ -58,8 +59,51 @@ namespace PARR.DAL.DomainServices.Shortcodes
this.unitFilterService = unitFilterService;
}
public Task<string> ApplyShortcodesAsync(string str, Template template)
{
// Построим TemplateForShortcodes из уже загруженного template
var templateForShortcodes = new TemplateForShortcodes
{
Id = template.Id,
Index = template.Index,
JobId = template.JobId,
UnitId = template.UnitId,
Job = template.Job == null ? null : new JobForShortcodes
{
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
{
Code = template.Job.Group.GroupType.Code
},
GroupName = template.Job.Group.GroupName
},
Tnk = template.Job.Tnk == null ? null : new TnkForShortcodes
{
Name = template.Job.Tnk.Name,
ShortName = template.Job.Tnk.ShortName
},
WorkName = template.Job.WorkName,
Name = template.Job.Name
},
UnitsInTemplate = template.UnitsInTemplate?.Select(uit => new UnitInTemplateForShortcodes { UnitId = uit.UnitId }).ToList() ?? new List<UnitInTemplateForShortcodes>()
};
return ApplyShortcodesAsync(str, templateForShortcodes);
}
//todo: сделать private в перспективе
public async Task<string> ApplyShortcodesAsync(string str, TemplateForShortcodes template)
{
if (!IsAnyShortcodes(str))
{
logger.LogDebug("Строка не содержит шорткодов: {str}", str);
return str;
}
logger.LogDebug("Начата подстановка шорткодов. Вход: '{Input}', templateId={TemplateId}, index={Index}", str, template.Id, template.Index);
var job = template.Job;
@@ -228,7 +272,7 @@ namespace PARR.DAL.DomainServices.Shortcodes
return resultName;
}
public bool IsAnyShortcodes(string str)
private bool IsAnyShortcodes(string str)
{
return Regex.IsMatch(str, shortcodePattern) ||
Regex.IsMatch(str, maxShortcodePattern) ||
@@ -437,7 +481,7 @@ namespace PARR.DAL.DomainServices.Shortcodes
.Where(j => j.GroupId == jobGroupId)
.Join(
templateService.Get()
.Where(t => t.StatusTypeId == TemplateStatusTypeEnum.Used && t.UnitId == unitId)
.Where(t => t.StatusTypeId == TemplateStatusTypeEnum.Used && t.UnitId == unitId)
.Include(t => t.UnitsInTemplate),
job => job.Id,
template => template.JobId,