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

@@ -1,5 +1,6 @@
using PARR.DAL.DomainModels;
using PARR.DAL.DomainServices.Shortcodes.Models;
using PARR.DAL.Models;
namespace PARR.DAL.DomainServices.Shortcodes
{
@@ -7,7 +8,9 @@ namespace PARR.DAL.DomainServices.Shortcodes
{
Task<string> ApplyShortcodesAsync(string str, TemplateForShortcodes template);
bool IsAnyShortcodes(string str);
Task<string> ApplyShortcodesAsync(string str, Template template);
// bool IsAnyShortcodes(string str);
Task<List<ShortcodeInfoDto>> GetAvailableShortcodesAsync();
}

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,

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblJobsAddResponseArea : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ResponseArea",
schema: "job",
table: "Jobs",
type: "text",
nullable: false,
defaultValue: "%ЗО_РГ%");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ResponseArea",
schema: "job",
table: "Jobs");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblJobsRenameResponseArea : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "ResponseArea",
schema: "job",
table: "Jobs",
newName: "ResponseAreaMask");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "ResponseAreaMask",
schema: "job",
table: "Jobs",
newName: "ResponseArea");
}
}
}

View File

@@ -1570,6 +1570,10 @@ namespace PARR.DAL.Migrations
.IsRequired()
.HasColumnType("text");
b.Property<string>("ResponseAreaMask")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TemplateNameMask")
.IsRequired()
.HasColumnType("text");

View File

@@ -56,6 +56,11 @@ namespace PARR.DAL.Models.Job
/// </summary
public required string WorkGroupMask { get; set; }
/// <summary>
/// Зона ответственности
/// </summary>
public required string ResponseAreaMask { get; set; }
public Guid TnkId { get; set; }
public Guid GroupId { get; set; }

View File

@@ -45,7 +45,8 @@ namespace PARR.DAL.Services.Implementations
.ThenInclude(s => s!.Subprocess)
.ThenInclude(p => p!.Process)
.Include(t => t.Job)
.ThenInclude(t => t!.Group);
.ThenInclude(t => t!.Group)
.ThenInclude(t=>t.GroupType);
}
public override Task<bool> CreateAsync(Template obj)