feat(api,dal): в таблицу Jobs добавлено поле ResponseAreaMask. В JobController добавлено поле ResponseAreaMask. В TemplateController отображается фактическая РК, ЗО шаблона. RobotTask ЗО отдается согласно ResponseAreaMask. ShortcodeService теперь умеет принимать Template.
This commit is contained in:
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
public required string WorkName { get; set; }
|
public required string WorkName { get; set; }
|
||||||
|
|
||||||
|
public required string ResponseAreaMask { get; set; }
|
||||||
|
|
||||||
#region AutoControl
|
#region AutoControl
|
||||||
|
|
||||||
public bool IsEnableAutoControl { get; set; }
|
public bool IsEnableAutoControl { get; set; }
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
public required string WorkName { get; set; }
|
public required string WorkName { get; set; }
|
||||||
|
|
||||||
public required string WorkGroupMask { get; set; }
|
public required string WorkGroupMask { get; set; }
|
||||||
|
|
||||||
|
public required string ResponseAreaMask { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,16 @@
|
|||||||
|
|
||||||
public required string TemplateDuration { get; set; }
|
public required string TemplateDuration { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Рабочая группа (формируется из шорткода)
|
||||||
|
/// </summary>
|
||||||
|
public required string WorkGroup { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ЗО, формируется из шорткода
|
||||||
|
/// </summary>
|
||||||
|
public required string ResponseArea { get; set; }
|
||||||
|
|
||||||
public TemplateAgentResponse? Agent { get; set; }
|
public TemplateAgentResponse? Agent { get; set; }
|
||||||
|
|
||||||
public DateTimeOffset? LastRun { get; set; }
|
public DateTimeOffset? LastRun { get; set; }
|
||||||
|
|||||||
@@ -286,6 +286,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
orig.WorkGroupMask = request.WorkGroupMask.Trim();
|
orig.WorkGroupMask = request.WorkGroupMask.Trim();
|
||||||
orig.TnkId = request.TnkId;
|
orig.TnkId = request.TnkId;
|
||||||
orig.GroupId = request.GroupId;
|
orig.GroupId = request.GroupId;
|
||||||
|
orig.ResponseAreaMask = request.ResponseAreaMask;
|
||||||
|
|
||||||
if (orig.AutoControl != null)
|
if (orig.AutoControl != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -197,47 +197,48 @@ namespace PARR.API.Controllers.V1
|
|||||||
//TODO Вынести в отдельный метод ShortcodesService
|
//TODO Вынести в отдельный метод ShortcodesService
|
||||||
|
|
||||||
// Построим TemplateForShortcodes из уже загруженного task.Template
|
// Построим TemplateForShortcodes из уже загруженного task.Template
|
||||||
var templateForShortcodes = new TemplateForShortcodes
|
//var templateForShortcodes = new TemplateForShortcodes
|
||||||
{
|
//{
|
||||||
Id = task.Template!.Id,
|
// Id = task.Template!.Id,
|
||||||
Index = task.Template.Index,
|
// Index = task.Template.Index,
|
||||||
JobId = task.Template.JobId,
|
// JobId = task.Template.JobId,
|
||||||
UnitId = task.Template.UnitId,
|
// UnitId = task.Template.UnitId,
|
||||||
Job = task.Template.Job == null ? null : new JobForShortcodes
|
// Job = task.Template.Job == null ? null : new JobForShortcodes
|
||||||
{
|
// {
|
||||||
Group = task.Template.Job.Group == null ? null : new JobGroupForShortcodes
|
// Group = task.Template.Job.Group == null ? null : new JobGroupForShortcodes
|
||||||
{
|
// {
|
||||||
Id = task.Template.Job.Group.Id,
|
// Id = task.Template.Job.Group.Id,
|
||||||
GroupingUnitFieldId = task.Template.Job.Group.GroupingUnitFieldId,
|
// GroupingUnitFieldId = task.Template.Job.Group.GroupingUnitFieldId,
|
||||||
GroupType = task.Template.Job.Group.GroupType == null ? null : new JobGroupTypeForShortcodes
|
// GroupType = task.Template.Job.Group.GroupType == null ? null : new JobGroupTypeForShortcodes
|
||||||
{
|
// {
|
||||||
Code = task.Template.Job.Group.GroupType.Code
|
// Code = task.Template.Job.Group.GroupType.Code
|
||||||
},
|
// },
|
||||||
GroupName = task.Template.Job.Group.GroupName
|
// GroupName = task.Template.Job.Group.GroupName
|
||||||
},
|
// },
|
||||||
Tnk = task.Template.Job.Tnk == null ? null : new TnkForShortcodes
|
// Tnk = task.Template.Job.Tnk == null ? null : new TnkForShortcodes
|
||||||
{
|
// {
|
||||||
Name = task.Template.Job.Tnk.Name,
|
// Name = task.Template.Job.Tnk.Name,
|
||||||
ShortName = task.Template.Job.Tnk.ShortName ?? ""
|
// ShortName = task.Template.Job.Tnk.ShortName ?? ""
|
||||||
},
|
// },
|
||||||
WorkName = task.Template.Job.WorkName,
|
// WorkName = task.Template.Job.WorkName,
|
||||||
Name = task.Template.Job.Name
|
// Name = task.Template.Job.Name
|
||||||
},
|
// },
|
||||||
UnitsInTemplate = task.Template.UnitsInTemplate?.Select(uit => new UnitInTemplateForShortcodes { UnitId = uit.UnitId }).ToList() ?? new List<UnitInTemplateForShortcodes>()
|
// UnitsInTemplate = task.Template.UnitsInTemplate?.Select(uit => new UnitInTemplateForShortcodes { UnitId = uit.UnitId }).ToList() ?? new List<UnitInTemplateForShortcodes>()
|
||||||
};
|
//};
|
||||||
|
|
||||||
if (shortcodesService.IsAnyShortcodes(robotTaskTemplateResponse.FullDescription))
|
//if (shortcodesService.IsAnyShortcodes(robotTaskTemplateResponse.FullDescription))
|
||||||
robotTaskTemplateResponse.FullDescription = await shortcodesService.ApplyShortcodesAsync(robotTaskTemplateResponse.FullDescription, templateForShortcodes);
|
robotTaskTemplateResponse.FullDescription = await shortcodesService.ApplyShortcodesAsync(robotTaskTemplateResponse.FullDescription, task.Template!);
|
||||||
if (shortcodesService.IsAnyShortcodes(robotTaskTemplateResponse.ShortDescription))
|
//if (shortcodesService.IsAnyShortcodes(robotTaskTemplateResponse.ShortDescription))
|
||||||
robotTaskTemplateResponse.ShortDescription = await shortcodesService.ApplyShortcodesAsync(robotTaskTemplateResponse.ShortDescription, templateForShortcodes);
|
robotTaskTemplateResponse.ShortDescription = await shortcodesService.ApplyShortcodesAsync(robotTaskTemplateResponse.ShortDescription, task.Template!);
|
||||||
if (shortcodesService.IsAnyShortcodes(robotTaskTemplateResponse.Solution))
|
//if (shortcodesService.IsAnyShortcodes(robotTaskTemplateResponse.Solution))
|
||||||
robotTaskTemplateResponse.Solution = await shortcodesService.ApplyShortcodesAsync(robotTaskTemplateResponse.Solution, templateForShortcodes);
|
robotTaskTemplateResponse.Solution = await shortcodesService.ApplyShortcodesAsync(robotTaskTemplateResponse.Solution, task.Template!);
|
||||||
if (shortcodesService.IsAnyShortcodes(robotTaskTemplateResponse.TnkName))
|
//if (shortcodesService.IsAnyShortcodes(robotTaskTemplateResponse.TnkName))
|
||||||
robotTaskTemplateResponse.TnkName = await shortcodesService.ApplyShortcodesAsync(robotTaskTemplateResponse.TnkName, templateForShortcodes);
|
robotTaskTemplateResponse.TnkName = await shortcodesService.ApplyShortcodesAsync(robotTaskTemplateResponse.TnkName, task.Template!);
|
||||||
if (shortcodesService.IsAnyShortcodes(robotTaskTemplateResponse.WorkName))
|
//if (shortcodesService.IsAnyShortcodes(robotTaskTemplateResponse.WorkName))
|
||||||
robotTaskTemplateResponse.WorkName = await shortcodesService.ApplyShortcodesAsync(robotTaskTemplateResponse.WorkName, templateForShortcodes);
|
robotTaskTemplateResponse.WorkName = await shortcodesService.ApplyShortcodesAsync(robotTaskTemplateResponse.WorkName, task.Template!);
|
||||||
if (shortcodesService.IsAnyShortcodes(robotTaskTemplateResponse.WorkGroup))
|
//if (shortcodesService.IsAnyShortcodes(robotTaskTemplateResponse.WorkGroup))
|
||||||
robotTaskTemplateResponse.WorkGroup = await shortcodesService.ApplyShortcodesAsync(robotTaskTemplateResponse.WorkGroup, templateForShortcodes);
|
robotTaskTemplateResponse.WorkGroup = await shortcodesService.ApplyShortcodesAsync(robotTaskTemplateResponse.WorkGroup, task.Template!);
|
||||||
|
robotTaskTemplateResponse.ResponseArea = await shortcodesService.ApplyShortcodesAsync(robotTaskTemplateResponse.ResponseArea, task.Template!);
|
||||||
|
|
||||||
return Ok(new Response<RobotTaskTemplateResponse>(robotTaskTemplateResponse, true));
|
return Ok(new Response<RobotTaskTemplateResponse>(robotTaskTemplateResponse, true));
|
||||||
}
|
}
|
||||||
@@ -248,37 +249,38 @@ namespace PARR.API.Controllers.V1
|
|||||||
//RobotTaskScheduleResponse
|
//RobotTaskScheduleResponse
|
||||||
var robotTaskScheduleResponse = mapper.Map<RobotTaskScheduleResponse>(task);
|
var robotTaskScheduleResponse = mapper.Map<RobotTaskScheduleResponse>(task);
|
||||||
|
|
||||||
// Построим TemplateForShortcodes из уже загруженного task.Template
|
//// Построим TemplateForShortcodes из уже загруженного task.Template
|
||||||
var templateForShortcodes = new TemplateForShortcodes
|
//var templateForShortcodes = new TemplateForShortcodes
|
||||||
{
|
//{
|
||||||
Id = task.Template!.Id,
|
// Id = task.Template!.Id,
|
||||||
Index = task.Template.Index,
|
// Index = task.Template.Index,
|
||||||
JobId = task.Template.JobId,
|
// JobId = task.Template.JobId,
|
||||||
UnitId = task.Template.UnitId,
|
// UnitId = task.Template.UnitId,
|
||||||
Job = task.Template.Job == null ? null : new JobForShortcodes
|
// Job = task.Template.Job == null ? null : new JobForShortcodes
|
||||||
{
|
// {
|
||||||
Group = task.Template.Job.Group == null ? null : new JobGroupForShortcodes
|
// Group = task.Template.Job.Group == null ? null : new JobGroupForShortcodes
|
||||||
{
|
// {
|
||||||
GroupingUnitFieldId = task.Template.Job.Group.GroupingUnitFieldId,
|
// GroupingUnitFieldId = task.Template.Job.Group.GroupingUnitFieldId,
|
||||||
GroupType = task.Template.Job.Group.GroupType == null ? null : new JobGroupTypeForShortcodes
|
// GroupType = task.Template.Job.Group.GroupType == null ? null : new JobGroupTypeForShortcodes
|
||||||
{
|
// {
|
||||||
Code = task.Template.Job.Group.GroupType.Code
|
// Code = task.Template.Job.Group.GroupType.Code
|
||||||
},
|
// },
|
||||||
GroupName = task.Template.Job.Group.GroupName
|
// GroupName = task.Template.Job.Group.GroupName
|
||||||
},
|
// },
|
||||||
Tnk = task.Template.Job.Tnk == null ? null : new TnkForShortcodes
|
// Tnk = task.Template.Job.Tnk == null ? null : new TnkForShortcodes
|
||||||
{
|
// {
|
||||||
Name = task.Template.Job.Tnk.Name,
|
// Name = task.Template.Job.Tnk.Name,
|
||||||
ShortName = task.Template.Job.Tnk.ShortName
|
// ShortName = task.Template.Job.Tnk.ShortName
|
||||||
},
|
// },
|
||||||
WorkName = task.Template.Job.WorkName,
|
// WorkName = task.Template.Job.WorkName,
|
||||||
Name = task.Template.Job.Name
|
// Name = task.Template.Job.Name
|
||||||
},
|
// },
|
||||||
UnitsInTemplate = task.Template.UnitsInTemplate?.Select(uit => new UnitInTemplateForShortcodes { UnitId = uit.UnitId }).ToList() ?? new List<UnitInTemplateForShortcodes>()
|
// UnitsInTemplate = task.Template.UnitsInTemplate?.Select(uit => new UnitInTemplateForShortcodes { UnitId = uit.UnitId }).ToList() ?? new List<UnitInTemplateForShortcodes>()
|
||||||
};
|
//};
|
||||||
|
|
||||||
if (shortcodesService.IsAnyShortcodes(robotTaskScheduleResponse.WorkGroup))
|
//if (shortcodesService.IsAnyShortcodes(robotTaskScheduleResponse.WorkGroup))
|
||||||
robotTaskScheduleResponse.WorkGroup = await shortcodesService.ApplyShortcodesAsync(robotTaskScheduleResponse.WorkGroup, templateForShortcodes);
|
robotTaskScheduleResponse.WorkGroup = await shortcodesService.ApplyShortcodesAsync(robotTaskScheduleResponse.WorkGroup, task.Template!);
|
||||||
|
robotTaskScheduleResponse.ResponseArea = await shortcodesService.ApplyShortcodesAsync(robotTaskScheduleResponse.ResponseArea, task.Template!);
|
||||||
|
|
||||||
return Ok(new Response<RobotTaskScheduleResponse>(robotTaskScheduleResponse, true));
|
return Ok(new Response<RobotTaskScheduleResponse>(robotTaskScheduleResponse, true));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using PARR.Common.Domain;
|
|||||||
using PARR.Constants;
|
using PARR.Constants;
|
||||||
using PARR.DAL.Contracts;
|
using PARR.DAL.Contracts;
|
||||||
using PARR.DAL.DomainModels;
|
using PARR.DAL.DomainModels;
|
||||||
|
using PARR.DAL.DomainServices.Shortcodes;
|
||||||
using PARR.DAL.Models;
|
using PARR.DAL.Models;
|
||||||
using PARR.DAL.Services.Interfaces;
|
using PARR.DAL.Services.Interfaces;
|
||||||
|
|
||||||
@@ -31,13 +32,15 @@ namespace PARR.API.Controllers.V1
|
|||||||
private readonly IRobotConfigurationService robotConfigurationService;
|
private readonly IRobotConfigurationService robotConfigurationService;
|
||||||
private readonly IClientService clientService;
|
private readonly IClientService clientService;
|
||||||
private readonly ILogger<TemplateController> logger;
|
private readonly ILogger<TemplateController> logger;
|
||||||
|
private readonly IShortcodesService shortcodesService;
|
||||||
|
|
||||||
public TemplateController(
|
public TemplateController(
|
||||||
IMapper mapper,
|
IMapper mapper,
|
||||||
ITemplateService templateService,
|
ITemplateService templateService,
|
||||||
IRobotConfigurationService robotConfigurationService,
|
IRobotConfigurationService robotConfigurationService,
|
||||||
IClientService clientService,
|
IClientService clientService,
|
||||||
ILogger<TemplateController> logger
|
ILogger<TemplateController> logger,
|
||||||
|
IShortcodesService shortcodesService
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
@@ -45,6 +48,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
this.robotConfigurationService = robotConfigurationService;
|
this.robotConfigurationService = robotConfigurationService;
|
||||||
this.clientService = clientService;
|
this.clientService = clientService;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
this.shortcodesService = shortcodesService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -106,6 +110,11 @@ namespace PARR.API.Controllers.V1
|
|||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
var templateResponse = mapper.Map<List<TemplateResponse>>(templates);
|
var templateResponse = mapper.Map<List<TemplateResponse>>(templates);
|
||||||
|
foreach (var responseItem in templateResponse)
|
||||||
|
{
|
||||||
|
await ApplyTemplateShortcodesAsync(responseItem, templates.First(t => t.Id == responseItem.Id));
|
||||||
|
}
|
||||||
|
|
||||||
var paginationResponse = new PagedResponse<TemplateResponse>(templateResponse, true).GetPaginatedProps(paginationFilter, query);
|
var paginationResponse = new PagedResponse<TemplateResponse>(templateResponse, true).GetPaginatedProps(paginationFilter, query);
|
||||||
|
|
||||||
return Ok(paginationResponse);
|
return Ok(paginationResponse);
|
||||||
@@ -136,6 +145,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
var response = mapper.Map<TemplateResponse>(template);
|
var response = mapper.Map<TemplateResponse>(template);
|
||||||
|
await ApplyTemplateShortcodesAsync(response, template);
|
||||||
|
|
||||||
return Ok(new Response<TemplateResponse>(response, true));
|
return Ok(new Response<TemplateResponse>(response, true));
|
||||||
}
|
}
|
||||||
@@ -198,12 +208,20 @@ namespace PARR.API.Controllers.V1
|
|||||||
.Include(t => t.Job).ThenInclude(t => t.Group).ThenInclude(t => t.ScheduleExcludeType)
|
.Include(t => t.Job).ThenInclude(t => t.Group).ThenInclude(t => t.ScheduleExcludeType)
|
||||||
.Include(t => t.Job).ThenInclude(t => t.Group).ThenInclude(t => t.ScheduleExcludeTypeCalendar)
|
.Include(t => t.Job).ThenInclude(t => t.Group).ThenInclude(t => t.ScheduleExcludeTypeCalendar)
|
||||||
.AsSplitQuery()
|
.AsSplitQuery()
|
||||||
.FirstOrDefaultAsync(t => t.Id == id);
|
.FirstAsync(t => t.Id == id);
|
||||||
|
|
||||||
var response = mapper.Map<TemplateResponse>(templateToResponse);
|
var response = mapper.Map<TemplateResponse>(templateToResponse);
|
||||||
|
await ApplyTemplateShortcodesAsync(response, templateToResponse);
|
||||||
|
|
||||||
return Ok(new Response<TemplateResponse>(response, true));
|
return Ok(new Response<TemplateResponse>(response, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task ApplyTemplateShortcodesAsync(TemplateResponse response, Template template)
|
||||||
|
{
|
||||||
|
response.WorkGroup = await shortcodesService.ApplyShortcodesAsync(template.Job.WorkGroupMask, template);
|
||||||
|
response.ResponseArea = await shortcodesService.ApplyShortcodesAsync(template.Job.ResponseAreaMask, template);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ namespace PARR.API.Validators
|
|||||||
|
|
||||||
RuleFor(t => t.MaxValueRelationships)
|
RuleFor(t => t.MaxValueRelationships)
|
||||||
.GreaterThanOrEqualTo(t => t.MinValueRelationships);
|
.GreaterThanOrEqualTo(t => t.MinValueRelationships);
|
||||||
|
|
||||||
|
RuleFor(t => t.ResponseAreaMask)
|
||||||
|
.NotNull().NotEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> IsUnitFiltersCorrect(JobRequest entity)
|
private async Task<bool> IsUnitFiltersCorrect(JobRequest entity)
|
||||||
|
|||||||
@@ -144,7 +144,8 @@ namespace PARR.DAL.IntegrationTests
|
|||||||
GroupId = group.Id,
|
GroupId = group.Id,
|
||||||
TnkId = Guid.NewGuid(),
|
TnkId = Guid.NewGuid(),
|
||||||
Group = group,
|
Group = group,
|
||||||
DateCreated = now
|
DateCreated = now,
|
||||||
|
ResponseAreaMask = "%ЗО_РГ%"
|
||||||
};
|
};
|
||||||
var unitFilter1Id = Guid.NewGuid();
|
var unitFilter1Id = Guid.NewGuid();
|
||||||
job1.UnitFilters = new List<JobUnitFilter>
|
job1.UnitFilters = new List<JobUnitFilter>
|
||||||
@@ -204,7 +205,8 @@ namespace PARR.DAL.IntegrationTests
|
|||||||
GroupId = group.Id,
|
GroupId = group.Id,
|
||||||
TnkId = Guid.NewGuid(),
|
TnkId = Guid.NewGuid(),
|
||||||
Group = group,
|
Group = group,
|
||||||
DateCreated = now
|
DateCreated = now,
|
||||||
|
ResponseAreaMask= "%ЗО_РГ%"
|
||||||
};
|
};
|
||||||
var unitFilter2Id = Guid.NewGuid();
|
var unitFilter2Id = Guid.NewGuid();
|
||||||
job2.UnitFilters = new List<JobUnitFilter>
|
job2.UnitFilters = new List<JobUnitFilter>
|
||||||
|
|||||||
@@ -145,7 +145,8 @@ namespace PARR.DAL.Tests
|
|||||||
GroupId = group.Id,
|
GroupId = group.Id,
|
||||||
TnkId = Guid.NewGuid(),
|
TnkId = Guid.NewGuid(),
|
||||||
Group = group,
|
Group = group,
|
||||||
DateCreated = now
|
DateCreated = now,
|
||||||
|
ResponseAreaMask = "%ЗО_РГ%"
|
||||||
};
|
};
|
||||||
var unitFilter1Id = Guid.NewGuid();
|
var unitFilter1Id = Guid.NewGuid();
|
||||||
job1.UnitFilters = new List<JobUnitFilter>
|
job1.UnitFilters = new List<JobUnitFilter>
|
||||||
@@ -205,7 +206,8 @@ namespace PARR.DAL.Tests
|
|||||||
GroupId = group.Id,
|
GroupId = group.Id,
|
||||||
TnkId = Guid.NewGuid(),
|
TnkId = Guid.NewGuid(),
|
||||||
Group = group,
|
Group = group,
|
||||||
DateCreated = now
|
DateCreated = now,
|
||||||
|
ResponseAreaMask = "%ЗО_РГ%"
|
||||||
};
|
};
|
||||||
var unitFilter2Id = Guid.NewGuid();
|
var unitFilter2Id = Guid.NewGuid();
|
||||||
job2.UnitFilters = new List<JobUnitFilter>
|
job2.UnitFilters = new List<JobUnitFilter>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using PARR.DAL.DomainModels;
|
using PARR.DAL.DomainModels;
|
||||||
using PARR.DAL.DomainServices.Shortcodes.Models;
|
using PARR.DAL.DomainServices.Shortcodes.Models;
|
||||||
|
using PARR.DAL.Models;
|
||||||
|
|
||||||
namespace PARR.DAL.DomainServices.Shortcodes
|
namespace PARR.DAL.DomainServices.Shortcodes
|
||||||
{
|
{
|
||||||
@@ -7,7 +8,9 @@ namespace PARR.DAL.DomainServices.Shortcodes
|
|||||||
{
|
{
|
||||||
Task<string> ApplyShortcodesAsync(string str, TemplateForShortcodes template);
|
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();
|
Task<List<ShortcodeInfoDto>> GetAvailableShortcodesAsync();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using PARR.DAL.Contracts;
|
|||||||
using PARR.DAL.DomainModels;
|
using PARR.DAL.DomainModels;
|
||||||
using PARR.DAL.DomainServices.Interfaces;
|
using PARR.DAL.DomainServices.Interfaces;
|
||||||
using PARR.DAL.DomainServices.Shortcodes.Models;
|
using PARR.DAL.DomainServices.Shortcodes.Models;
|
||||||
|
using PARR.DAL.Models;
|
||||||
using PARR.DAL.Models.Unit;
|
using PARR.DAL.Models.Unit;
|
||||||
using PARR.DAL.Services.Interfaces;
|
using PARR.DAL.Services.Interfaces;
|
||||||
using PARR.DAL.Services.Interfaces.Job;
|
using PARR.DAL.Services.Interfaces.Job;
|
||||||
@@ -58,8 +59,51 @@ namespace PARR.DAL.DomainServices.Shortcodes
|
|||||||
this.unitFilterService = unitFilterService;
|
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)
|
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);
|
logger.LogDebug("Начата подстановка шорткодов. Вход: '{Input}', templateId={TemplateId}, index={Index}", str, template.Id, template.Index);
|
||||||
|
|
||||||
var job = template.Job;
|
var job = template.Job;
|
||||||
@@ -228,7 +272,7 @@ namespace PARR.DAL.DomainServices.Shortcodes
|
|||||||
return resultName;
|
return resultName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsAnyShortcodes(string str)
|
private bool IsAnyShortcodes(string str)
|
||||||
{
|
{
|
||||||
return Regex.IsMatch(str, shortcodePattern) ||
|
return Regex.IsMatch(str, shortcodePattern) ||
|
||||||
Regex.IsMatch(str, maxShortcodePattern) ||
|
Regex.IsMatch(str, maxShortcodePattern) ||
|
||||||
@@ -437,7 +481,7 @@ namespace PARR.DAL.DomainServices.Shortcodes
|
|||||||
.Where(j => j.GroupId == jobGroupId)
|
.Where(j => j.GroupId == jobGroupId)
|
||||||
.Join(
|
.Join(
|
||||||
templateService.Get()
|
templateService.Get()
|
||||||
.Where(t => t.StatusTypeId == TemplateStatusTypeEnum.Used && t.UnitId == unitId)
|
.Where(t => t.StatusTypeId == TemplateStatusTypeEnum.Used && t.UnitId == unitId)
|
||||||
.Include(t => t.UnitsInTemplate),
|
.Include(t => t.UnitsInTemplate),
|
||||||
job => job.Id,
|
job => job.Id,
|
||||||
template => template.JobId,
|
template => template.JobId,
|
||||||
|
|||||||
4095
PARR.DAL/Migrations/20260113000345_tblJobsAddResponseArea.Designer.cs
generated
Normal file
4095
PARR.DAL/Migrations/20260113000345_tblJobsAddResponseArea.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
31
PARR.DAL/Migrations/20260113000345_tblJobsAddResponseArea.cs
Normal file
31
PARR.DAL/Migrations/20260113000345_tblJobsAddResponseArea.cs
Normal 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
4095
PARR.DAL/Migrations/20260113021048_tblJobsRenameResponseArea.Designer.cs
generated
Normal file
4095
PARR.DAL/Migrations/20260113021048_tblJobsRenameResponseArea.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1570,6 +1570,10 @@ namespace PARR.DAL.Migrations
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ResponseAreaMask")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<string>("TemplateNameMask")
|
b.Property<string>("TemplateNameMask")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ namespace PARR.DAL.Models.Job
|
|||||||
/// </summary
|
/// </summary
|
||||||
public required string WorkGroupMask { get; set; }
|
public required string WorkGroupMask { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Зона ответственности
|
||||||
|
/// </summary>
|
||||||
|
public required string ResponseAreaMask { get; set; }
|
||||||
|
|
||||||
public Guid TnkId { get; set; }
|
public Guid TnkId { get; set; }
|
||||||
|
|
||||||
public Guid GroupId { get; set; }
|
public Guid GroupId { get; set; }
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ namespace PARR.DAL.Services.Implementations
|
|||||||
.ThenInclude(s => s!.Subprocess)
|
.ThenInclude(s => s!.Subprocess)
|
||||||
.ThenInclude(p => p!.Process)
|
.ThenInclude(p => p!.Process)
|
||||||
.Include(t => t.Job)
|
.Include(t => t.Job)
|
||||||
.ThenInclude(t => t!.Group);
|
.ThenInclude(t => t!.Group)
|
||||||
|
.ThenInclude(t=>t.GroupType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> CreateAsync(Template obj)
|
public override Task<bool> CreateAsync(Template obj)
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace PARR.EsppScheduleSync
|
|||||||
|
|
||||||
private async Task SyncScheduleAsync(string str)
|
private async Task SyncScheduleAsync(string str)
|
||||||
{
|
{
|
||||||
await syncService.SyncEsppObjectAsync(str, ParseStrToEsppObject, ConvertDbObjToEsppObj);
|
await syncService.SyncEsppObjectAsync(str, ParseStrToEsppObject, ConvertDbObjToEsppObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ namespace PARR.EsppSync
|
|||||||
//.AsNoTracking() <- не надо так, а то потом не сохранится
|
//.AsNoTracking() <- не надо так, а то потом не сохранится
|
||||||
.Include(h => h.Unit)
|
.Include(h => h.Unit)
|
||||||
.ThenInclude(t => t!.UnitValues)
|
.ThenInclude(t => t!.UnitValues)
|
||||||
.ThenInclude(t => t.Value)
|
.ThenInclude(t => t.Value)
|
||||||
.Include(h => h.Unit)
|
.Include(h => h.Unit)
|
||||||
.ThenInclude(t => t!.UnitValues)
|
.ThenInclude(t => t!.UnitValues)
|
||||||
.ThenInclude(t => t.Field)
|
.ThenInclude(t => t.Field)
|
||||||
.Include(t => t.RobotConfigurations)
|
.Include(t => t.RobotConfigurations)
|
||||||
.Include(t => t.Job)
|
.Include(t => t.Job)
|
||||||
.ThenInclude(j => j.Group)
|
.ThenInclude(j => j.Group)
|
||||||
@@ -129,7 +129,7 @@ namespace PARR.EsppSync
|
|||||||
{
|
{
|
||||||
var value = property.GetValue(dbObjectInEsppObject)?.ToString();
|
var value = property.GetValue(dbObjectInEsppObject)?.ToString();
|
||||||
|
|
||||||
if (value != null && shortcodesService.IsAnyShortcodes(value))
|
if (value != null)
|
||||||
{
|
{
|
||||||
var processedValue = await shortcodesService.ApplyShortcodesAsync(value, templateForShortcodes);
|
var processedValue = await shortcodesService.ApplyShortcodesAsync(value, templateForShortcodes);
|
||||||
property.SetValue(dbObjectInEsppObject, processedValue);
|
property.SetValue(dbObjectInEsppObject, processedValue);
|
||||||
|
|||||||
@@ -89,10 +89,11 @@ namespace PARR.EsppTemplateSync
|
|||||||
//ShortDescription = Normalize(template.Job.Group.ShortDescription.ApplyShortcode(Constants.Shortcodes.ShortcodeEnum.EK,template.Unit.Name)),
|
//ShortDescription = Normalize(template.Job.Group.ShortDescription.ApplyShortcode(Constants.Shortcodes.ShortcodeEnum.EK,template.Unit.Name)),
|
||||||
ShortDescription = template.Job!.Group!.ShortDescription,//TODO Вынести в переменную
|
ShortDescription = template.Job!.Group!.ShortDescription,//TODO Вынести в переменную
|
||||||
//ResponseArea = template.Host!.ResponseArea!.Name,
|
//ResponseArea = template.Host!.ResponseArea!.Name,
|
||||||
//ЗО берем РГ а не хоста
|
////ЗО берем РГ а не хоста
|
||||||
ResponseArea = template.Unit!.BaseFields!.ResponseArea!,
|
//ResponseArea = template.Unit!.BaseFields!.ResponseArea!,
|
||||||
|
ResponseArea = template.Job.ResponseAreaMask,
|
||||||
Duration = template.Job.Group.TemplateDuration,
|
Duration = template.Job.Group.TemplateDuration,
|
||||||
EK = template.Unit.Name,
|
EK = template.Unit!.Name,
|
||||||
FullDescription = template.Job.Group.FullDescription,
|
FullDescription = template.Job.Group.FullDescription,
|
||||||
Solution = template.Job.Group.Solution,
|
Solution = template.Job.Group.Solution,
|
||||||
Process = template.Job.Tnk!.Subprocess!.Process!.Name,
|
Process = template.Job.Tnk!.Subprocess!.Process!.Name,
|
||||||
|
|||||||
Reference in New Issue
Block a user