feat(api,core,dal,domain,esppSync): В группу работ добавлено поле EkMask, обновлена логика синхронизации шаблонов и выдачи задания роботу. Обновлен реквест и респонс для группы работ и шаблонов.

This commit is contained in:
Mikhail Trubnikov
2026-10-21 11:21:36 +10:00
parent fdfd0f9363
commit 236ddee5ef
17 changed files with 4239 additions and 8 deletions

View File

@@ -36,6 +36,14 @@
public Guid? ScheduleExcludeTypeCalendarId { get; init; }
/// <summary>
/// Маска ЭК
/// </summary>
public required string EkMask { get; init; }
/// <summary>
/// Автораспределение включено
/// </summary>
public bool IsAutoDistributionEnabled { get; init; }
/// <summary>

View File

@@ -55,6 +55,11 @@
/// Юнит фильтры
/// </summary>
public List<UnitFilterResponse>? UnitFilters { get; set; }
/// <summary>
/// Маска ЭК
/// </summary>
public required string EkMask { get; set; }
}
public class JobGroupResponse : JobGroupWithDistributionConfigResponse

View File

@@ -33,6 +33,14 @@
/// </summary>
public string? ResponseArea { get; set; }
/// <summary>
/// ЭК согласно настроек маски группы работ, подставляется в шаблон ЕСПП
/// </summary>
public required string EsppEk { get; set; }
/// <summary>
/// Юнит привязанный к шаблону
/// </summary>
public UnitWithAttributesResponse? Unit { get; set; }
public TemplateStatusTypeResponse? StatusType { get; set; }

View File

@@ -184,7 +184,8 @@ namespace PARR.API.Controllers.V1
IsAutoDistributionEnabled = request.IsAutoDistributionEnabled,
IsResponseAreaTimezone = request.IsWorkGroupTimezone,
IsGroupByResponsible = request.IsGroupByResponsible,
UnitFilters = new List<JobGroupUnitFilter>()
UnitFilters = new List<JobGroupUnitFilter>(),
EkMask = request.EkMask,
//IsAgent = request.IsAgent,
//AgentName = request.AgentName,
//AgentTimeOutSec = request.AgentTimeOutSec,
@@ -319,6 +320,7 @@ namespace PARR.API.Controllers.V1
orig.IsResponseAreaTimezone = request.IsWorkGroupTimezone;
// IsGroupByResponsible - может быть значение, только если тип ГРУППОВОЙ
orig.IsGroupByResponsible = await GetIsGroupByResponsibleValue(request);
orig.EkMask = request.EkMask;
//orig.IsAgent = request.IsAgent;
//orig.AgentName = request.AgentName;
//orig.AgentTimeOutSec = request.AgentTimeOutSec;

View File

@@ -12,7 +12,6 @@ using PARR.API.Extensions;
using PARR.API.Services.Interfaces;
using PARR.Core.Common.Helpers;
using PARR.Core.Repositories.Interfaces;
using PARR.Core.Repositories.Interfaces.Schedule;
using PARR.Core.Services.Shortcodes;
using PARR.Domain.Common.Pagination;
using PARR.Domain.Common.Roles;
@@ -292,6 +291,7 @@ namespace PARR.API.Controllers.V1
{
response.WorkGroup = await _shortcodesService.ApplyShortcodesAsync(template.Job!.WorkGroupMask, template);
response.ResponseArea = await _shortcodesService.ApplyShortcodesAsync(template.Job!.ResponseAreaMask, template);
response.EsppEk = await _shortcodesService.ApplyShortcodesAsync(template.Job!.Group!.EkMask, template);
}

View File

@@ -153,6 +153,9 @@ namespace PARR.API.Validators
return false;
})
.WithMessage("Некорректные параметры автоконтроля");
RuleFor(t => t.EkMask)
.NotNull().NotEmpty();
}
}
}

View File

@@ -117,7 +117,8 @@ public class JobGroupCloneHelper
ScheduleExcludeTypeCalendarId = source.ScheduleExcludeTypeCalendarId,
DateCreated = DateTimeOffset.UtcNow,
Jobs = new HashSet<Job>(),
EsppSchValues = new HashSet<EsppSchValue>()
EsppSchValues = new HashSet<EsppSchValue>(),
EkMask = source.EkMask
};
}

View File

@@ -32,7 +32,9 @@ namespace PARR.Core.Infrastructure.Mapping.RobotTask
//.ForMember(d => d.Initiator, o => o.MapFrom<RobotTaskTemplateInitiatorResolver>())
//.ForMember(d => d.Category, o => o.MapFrom<RobotTaskTemplateCategoryResolver>())
.ForMember(d => d.WorkGroup, o => o.MapFrom(s => s.Template!.Job!.WorkGroupMask))
.ForMember(d => d.Ek, o => o.MapFrom(s => s.Template!.Unit!.Name))
//.ForMember(d => d.Ek, o => o.MapFrom(s => s.Template!.Unit!.Name))
// Берем ЭК на у юнита, а в группе работ, маску ЭК (шорткод)
.ForMember(d => d.Ek, o => o.MapFrom(s => s.Template!.Job!.Group!.EkMask))
.ForMember(d => d.Name, o => o.MapFrom(s => s.Template!.Name))
.ForMember(d => d.ProcessName, o => o.MapFrom(s => s.Template!.Job!.Tnk!.Subprocess!.Process!.Name))
.ForMember(d => d.ProcessEsppId, o => o.MapFrom(s => s.Template!.Job!.Tnk!.Subprocess!.Process!.EsppId))

View File

@@ -70,6 +70,7 @@ namespace PARR.Core.Services.RobotTask.Implementations
task = task with { WorkName = await _shortcodesService.ApplyShortcodesAsync(task.WorkName, templateTask.Template!) };
task = task with { WorkGroup = await _shortcodesService.ApplyShortcodesAsync(task.WorkGroup, templateTask.Template!) };
task = task with { ResponseArea = await _shortcodesService.ApplyShortcodesAsync(task.ResponseArea, templateTask.Template!) };
task = task with { Ek = await _shortcodesService.ApplyShortcodesAsync(task.Ek, templateTask.Template!) };
task = task with { ClosingCode = _settingsFromDb.ClosingCode };
task = task with { Initiator = _settingsFromDb.Initiator };

View File

@@ -60,7 +60,8 @@ public class UnitFilterServiceTests
ReferenceDate = DateTimeOffset.UtcNow,
GroupTypeId = Guid.NewGuid(),
ScheduleExcludeTypeId = Guid.NewGuid(),
GroupType = BuildTestJobGroupType()
GroupType = BuildTestJobGroupType(),
EkMask = "%ЭК%"
};
private static JobAutoControl BuildTestAutoControl(Guid jobId) => new()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblJobGroupsAddEkMask : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "EkMask",
schema: "jobGroup",
table: "Groups",
type: "text",
nullable: false,
defaultValue: "%ЭК%",
comment: "Маска ЭК, допустимы шорткоды. По умолчанию %ЭК%");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "EkMask",
schema: "jobGroup",
table: "Groups");
}
}
}

View File

@@ -394,6 +394,11 @@ namespace PARR.DAL.Migrations
b.Property<DateTimeOffset?>("DateModified")
.HasColumnType("timestamp with time zone");
b.Property<string>("EkMask")
.IsRequired()
.HasColumnType("text")
.HasComment("Маска ЭК, допустимы шорткоды. По умолчанию %ЭК%");
b.Property<string>("FullDescription")
.IsRequired()
.HasColumnType("text");
@@ -3518,7 +3523,7 @@ namespace PARR.DAL.Migrations
modelBuilder.Entity("PARR.Domain.Entities.JobGroupEntities.JobGroupUnitFilter", b =>
{
b.HasOne("PARR.Domain.Entities.JobGroupEntities.JobGroup", "JobGroup")
.WithMany()
.WithMany("UnitFilters")
.HasForeignKey("JobGroupId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -3942,6 +3947,8 @@ namespace PARR.DAL.Migrations
b.Navigation("EsppSchValues");
b.Navigation("Jobs");
b.Navigation("UnitFilters");
});
modelBuilder.Entity("PARR.Domain.Entities.JobGroupEntities.JobGroupType", b =>

View File

@@ -29,6 +29,9 @@
public required string WorkGroup { get; init; }
/// <summary>
/// ЭК
/// </summary>
public required string Ek { get; init; }
public required string Name { get; init; }

View File

@@ -170,6 +170,11 @@ namespace PARR.Domain.Entities.JobGroupEntities
/// </summary>
public Guid? ScheduleExcludeTypeCalendarId { get; set; }
/// <summary>
/// Маска ЭК, допустимы шорткоды.
/// </summary>
[Comment("Маска ЭК, допустимы шорткоды. По умолчанию %ЭК%")]
public required string EkMask { get; set; } = "%ЭК%";
/// <summary>

View File

@@ -234,7 +234,7 @@ namespace PARR.EsppSync
/// <summary>
/// Применяем шорткоды
/// Применяем шорткоды ко всем полям
/// </summary>
/// <param name="dbObjectInEsppObject"></param>
/// <param name="template"></param>

View File

@@ -83,7 +83,9 @@ namespace PARR.EsppTemplateSync
//ResponseArea = template.Unit!.BaseFields!.ResponseArea!,
ResponseArea = template.Job.ResponseAreaMask,
Duration = template.Job.Group.TemplateDuration,
EK = template.Unit!.Name,
//EK = template.Unit!.Name,
// ЭК берем из группы работ, возможна маска или шорткод
EK = template.Job!.Group!.EkMask,
FullDescription = template.Job.Group.FullDescription,
Solution = template.Job.Group.Solution,
Process = template.Job.Tnk!.Subprocess!.Process!.Name,