feat(dal,api,nextRun,templateGenerator,templateActivator): IsUnused вынесена в TemplateStatusType
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
using PARR.Constants;
|
||||||
|
|
||||||
|
namespace PARR.API.Contracts.V1.Requests
|
||||||
|
{
|
||||||
|
public class MatchTemplatesForJobRequest
|
||||||
|
{
|
||||||
|
public TemplateMatcherActionEnum Action { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using PARR.API.Contracts.V1;
|
using PARR.API.Contracts.V1;
|
||||||
|
using PARR.API.Contracts.V1.Requests;
|
||||||
using PARR.API.Contracts.V1.Responses.Base;
|
using PARR.API.Contracts.V1.Responses.Base;
|
||||||
using PARR.API.Controllers.V1.Base;
|
using PARR.API.Controllers.V1.Base;
|
||||||
using PARR.API.Services.Implementations;
|
using PARR.API.Services.Implementations;
|
||||||
@@ -7,6 +8,8 @@ using PARR.API.Services.Interfaces;
|
|||||||
using PARR.API.Settings;
|
using PARR.API.Settings;
|
||||||
using PARR.BLL.Domain.Mq;
|
using PARR.BLL.Domain.Mq;
|
||||||
using PARR.BLL.Services.Interfaces;
|
using PARR.BLL.Services.Interfaces;
|
||||||
|
using PARR.Common.Domain;
|
||||||
|
using PARR.Constants;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace PARR.API.Controllers.V1
|
namespace PARR.API.Controllers.V1
|
||||||
@@ -17,18 +20,21 @@ namespace PARR.API.Controllers.V1
|
|||||||
private readonly IMqService mqService;
|
private readonly IMqService mqService;
|
||||||
private readonly IUriService uriService;
|
private readonly IUriService uriService;
|
||||||
private readonly MqSettings mqSettings;
|
private readonly MqSettings mqSettings;
|
||||||
|
private readonly IClientService clientService;
|
||||||
|
|
||||||
public SyncTaskController(
|
public SyncTaskController(
|
||||||
ILogger<SyncTaskController> logger,
|
ILogger<SyncTaskController> logger,
|
||||||
IMqService mqService,
|
IMqService mqService,
|
||||||
IUriService uriService,
|
IUriService uriService,
|
||||||
MqSettings mqSettings
|
MqSettings mqSettings,
|
||||||
|
IClientService clientService
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.mqService = mqService;
|
this.mqService = mqService;
|
||||||
this.uriService = uriService;
|
this.uriService = uriService;
|
||||||
this.mqSettings = mqSettings;
|
this.mqSettings = mqSettings;
|
||||||
|
this.clientService = clientService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -36,13 +42,20 @@ namespace PARR.API.Controllers.V1
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">ИД шаблона</param>
|
/// <param name="id">ИД шаблона</param>
|
||||||
[HttpPost(ApiRoutes.SyncTask.MatchTemplatesForJob)]
|
[HttpPost(ApiRoutes.SyncTask.MatchTemplatesForJob)]
|
||||||
public async Task<IActionResult> MatchTemplatesForJob([FromRoute] Guid jobId)
|
public async Task<IActionResult> MatchTemplatesForJob([FromRoute] Guid jobId, [FromBody] MatchTemplatesForJobRequest request)
|
||||||
{
|
{
|
||||||
//24b3529a-dd43-444a-b10e-ac54fefd046a
|
//24b3529a-dd43-444a-b10e-ac54fefd046a
|
||||||
var matchTemplateTask = new TemplateMatcherMq
|
var matchTemplateTask = new TemplateMatcherMq
|
||||||
{
|
{
|
||||||
Id = jobId,
|
Id = jobId,
|
||||||
EntityType = Constants.SyncTaskEntityTypeEnum.Job
|
EntityType = Constants.SyncTaskEntityTypeEnum.Job,
|
||||||
|
Action = request.Action,
|
||||||
|
Initiator = new HistoryInitiator
|
||||||
|
{
|
||||||
|
InitiatorIp = clientService.GetClientIp()?.ToString(),
|
||||||
|
InitiatorParrComponentId = ParrComponentsEnum.Api,
|
||||||
|
InitiatorComment = $"Отправлен запрос из GUI, action: {request.Action.ToString()}"
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var msg = JsonSerializer.Serialize(matchTemplateTask);
|
var msg = JsonSerializer.Serialize(matchTemplateTask);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using PARR.Constants;
|
using PARR.Common.Domain;
|
||||||
|
using PARR.Constants;
|
||||||
|
|
||||||
namespace PARR.BLL.Domain.Mq
|
namespace PARR.BLL.Domain.Mq
|
||||||
{
|
{
|
||||||
@@ -6,5 +7,8 @@ namespace PARR.BLL.Domain.Mq
|
|||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public SyncTaskEntityTypeEnum EntityType { get; set; }
|
public SyncTaskEntityTypeEnum EntityType { get; set; }
|
||||||
|
public TemplateMatcherActionEnum Action { get; set; }
|
||||||
|
|
||||||
|
public required IHistoryInitiator Initiator { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
30
PARR.BLL/Domain/Mq/TemplateUpdaterMq.cs
Normal file
30
PARR.BLL/Domain/Mq/TemplateUpdaterMq.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using PARR.Common.Domain;
|
||||||
|
using PARR.Constants;
|
||||||
|
|
||||||
|
namespace PARR.BLL.Domain.Mq
|
||||||
|
{
|
||||||
|
public class TemplateUpdaterMq
|
||||||
|
{
|
||||||
|
public Guid TemplateId { get; set; }
|
||||||
|
|
||||||
|
public Guid JobId { get; set; }
|
||||||
|
|
||||||
|
public required string Name { get; set; }
|
||||||
|
|
||||||
|
public bool IsActiveTemplate { get; set; }
|
||||||
|
|
||||||
|
public bool IsActiveSchedule { get; set; }
|
||||||
|
|
||||||
|
public DateTimeOffset? LastRun { get; set; }
|
||||||
|
|
||||||
|
public DateTimeOffset NextRun { get; set; }
|
||||||
|
|
||||||
|
public Guid UnitId { get; set; }
|
||||||
|
|
||||||
|
public int? Index { get; set; }
|
||||||
|
|
||||||
|
public TemplateStatusTypeEnum StatusTypeId { get; set; }
|
||||||
|
|
||||||
|
public required IHistoryInitiator Initiator { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
17
PARR.Constants/TemplateMatcherActionEnum.cs
Normal file
17
PARR.Constants/TemplateMatcherActionEnum.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace PARR.Constants
|
||||||
|
{
|
||||||
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||||
|
public enum TemplateMatcherActionEnum
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Только сгенерировать недостающие шаблоны(можно использовать IsUnused)
|
||||||
|
/// </summary>
|
||||||
|
Create,
|
||||||
|
/// <summary>
|
||||||
|
/// Обновить существующие шаблоны без сохдания новых(имя шаблона, новая Job и т.д.)
|
||||||
|
/// </summary>
|
||||||
|
Update
|
||||||
|
}
|
||||||
|
}
|
||||||
9
PARR.Constants/TemplateStatusTypeEnum.cs
Normal file
9
PARR.Constants/TemplateStatusTypeEnum.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace PARR.Constants
|
||||||
|
{
|
||||||
|
public enum TemplateStatusTypeEnum
|
||||||
|
{
|
||||||
|
Used = 0,
|
||||||
|
Unused = 1,
|
||||||
|
Updating =2
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ namespace PARR.DAL.Context
|
|||||||
|
|
||||||
public DbSet<Template> Templates { get; set; }
|
public DbSet<Template> Templates { get; set; }
|
||||||
public DbSet<TemplateHistory> TemplateHistories { get; set; }
|
public DbSet<TemplateHistory> TemplateHistories { get; set; }
|
||||||
|
public DbSet<TemplateStatusType> TemplateStatusTypes { get; set; }
|
||||||
public DbSet<Models.TaskStatus> TaskStatuses { get; set; }
|
public DbSet<Models.TaskStatus> TaskStatuses { get; set; }
|
||||||
public DbSet<RobotStatus> RobotStatuses { get; set; }
|
public DbSet<RobotStatus> RobotStatuses { get; set; }
|
||||||
|
|
||||||
@@ -489,6 +490,19 @@ namespace PARR.DAL.Context
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region TemplateStatusType
|
||||||
|
|
||||||
|
modelBuilder.Entity<TemplateStatusType>(f =>
|
||||||
|
{
|
||||||
|
f.HasData(
|
||||||
|
new() { Id = TemplateStatusTypeEnum.Used, Name = TemplateStatusTypeEnum.Used.ToString(), Description = "В работе" },
|
||||||
|
new() { Id = TemplateStatusTypeEnum.Unused, Name = TemplateStatusTypeEnum.Unused.ToString(), Description = "Не используется" },
|
||||||
|
new() { Id = TemplateStatusTypeEnum.Updating, Name = TemplateStatusTypeEnum.Updating.ToString(), Description = "Обновляется" }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
//protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
|||||||
12
PARR.DAL/DomainModels/HistoryInitiator.cs
Normal file
12
PARR.DAL/DomainModels/HistoryInitiator.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using PARR.Common.Domain;
|
||||||
|
using PARR.Constants;
|
||||||
|
|
||||||
|
namespace PARR.DAL.DomainModels
|
||||||
|
{
|
||||||
|
public class HistoryInitiator : IHistoryInitiator
|
||||||
|
{
|
||||||
|
string? IHistoryInitiator.InitiatorIp { get; set; }
|
||||||
|
ParrComponentsEnum? IHistoryInitiator.InitiatorParrComponentId { get; set; }
|
||||||
|
string? IHistoryInitiator.InitiatorComment { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
4026
PARR.DAL/Migrations/20251201045923_tblTemplateStatusType.Designer.cs
generated
Normal file
4026
PARR.DAL/Migrations/20251201045923_tblTemplateStatusType.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
101
PARR.DAL/Migrations/20251201045923_tblTemplateStatusType.cs
Normal file
101
PARR.DAL/Migrations/20251201045923_tblTemplateStatusType.cs
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
||||||
|
|
||||||
|
namespace PARR.DAL.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class tblTemplateStatusType : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "IsUnused",
|
||||||
|
table: "Templates");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "StatusTypeId",
|
||||||
|
table: "Templates",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "StatusTypeId",
|
||||||
|
table: "TemplateHistories",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "TemplateStatusTypes",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Description = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_TemplateStatusTypes", x => x.Id);
|
||||||
|
},
|
||||||
|
comment: "Таблица описания критериев выборки аттрибутов ЭК");
|
||||||
|
|
||||||
|
migrationBuilder.InsertData(
|
||||||
|
table: "TemplateStatusTypes",
|
||||||
|
columns: new[] { "Id", "Description", "Name" },
|
||||||
|
values: new object[,]
|
||||||
|
{
|
||||||
|
{ 0, "В работе", "Used" },
|
||||||
|
{ 1, "Не используется", "Unused" },
|
||||||
|
{ 2, "Обновляется", "Updating" }
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Templates_StatusTypeId",
|
||||||
|
table: "Templates",
|
||||||
|
column: "StatusTypeId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Templates_TemplateStatusTypes_StatusTypeId",
|
||||||
|
table: "Templates",
|
||||||
|
column: "StatusTypeId",
|
||||||
|
principalTable: "TemplateStatusTypes",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Templates_TemplateStatusTypes_StatusTypeId",
|
||||||
|
table: "Templates");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "TemplateStatusTypes");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Templates_StatusTypeId",
|
||||||
|
table: "Templates");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "StatusTypeId",
|
||||||
|
table: "Templates");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "StatusTypeId",
|
||||||
|
table: "TemplateHistories");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "IsUnused",
|
||||||
|
table: "Templates",
|
||||||
|
type: "boolean",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2693,9 +2693,6 @@ namespace PARR.DAL.Migrations
|
|||||||
b.Property<bool>("IsActiveTemplate")
|
b.Property<bool>("IsActiveTemplate")
|
||||||
.HasColumnType("boolean");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<bool>("IsUnused")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<Guid>("JobId")
|
b.Property<Guid>("JobId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
@@ -2712,6 +2709,9 @@ namespace PARR.DAL.Migrations
|
|||||||
b.Property<string>("ScheduleEsppId")
|
b.Property<string>("ScheduleEsppId")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("StatusTypeId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<Guid>("UnitId")
|
b.Property<Guid>("UnitId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
@@ -2719,6 +2719,8 @@ namespace PARR.DAL.Migrations
|
|||||||
|
|
||||||
b.HasIndex("JobId");
|
b.HasIndex("JobId");
|
||||||
|
|
||||||
|
b.HasIndex("StatusTypeId");
|
||||||
|
|
||||||
b.HasIndex("UnitId");
|
b.HasIndex("UnitId");
|
||||||
|
|
||||||
b.HasIndex("Name", "Index")
|
b.HasIndex("Name", "Index")
|
||||||
@@ -2767,6 +2769,9 @@ namespace PARR.DAL.Migrations
|
|||||||
b.Property<Guid>("ParentId")
|
b.Property<Guid>("ParentId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("StatusTypeId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("ParentId");
|
b.HasIndex("ParentId");
|
||||||
@@ -2774,6 +2779,47 @@ namespace PARR.DAL.Migrations
|
|||||||
b.ToTable("TemplateHistories");
|
b.ToTable("TemplateHistories");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PARR.DAL.Models.TemplateStatusType", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("TemplateStatusTypes", t =>
|
||||||
|
{
|
||||||
|
t.HasComment("Таблица описания критериев выборки аттрибутов ЭК");
|
||||||
|
});
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 0,
|
||||||
|
Description = "В работе",
|
||||||
|
Name = "Used"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
Description = "Не используется",
|
||||||
|
Name = "Unused"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
Description = "Обновляется",
|
||||||
|
Name = "Updating"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PARR.DAL.Models.Tnk", b =>
|
modelBuilder.Entity("PARR.DAL.Models.Tnk", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
@@ -3552,6 +3598,12 @@ namespace PARR.DAL.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("PARR.DAL.Models.TemplateStatusType", "StatusType")
|
||||||
|
.WithMany("Templates")
|
||||||
|
.HasForeignKey("StatusTypeId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("PARR.DAL.Models.Unit.Unit", "Unit")
|
b.HasOne("PARR.DAL.Models.Unit.Unit", "Unit")
|
||||||
.WithMany("Templates")
|
.WithMany("Templates")
|
||||||
.HasForeignKey("UnitId")
|
.HasForeignKey("UnitId")
|
||||||
@@ -3560,6 +3612,8 @@ namespace PARR.DAL.Migrations
|
|||||||
|
|
||||||
b.Navigation("Job");
|
b.Navigation("Job");
|
||||||
|
|
||||||
|
b.Navigation("StatusType");
|
||||||
|
|
||||||
b.Navigation("Unit");
|
b.Navigation("Unit");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -3904,6 +3958,11 @@ namespace PARR.DAL.Migrations
|
|||||||
b.Navigation("UnitsInTemplate");
|
b.Navigation("UnitsInTemplate");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PARR.DAL.Models.TemplateStatusType", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Templates");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PARR.DAL.Models.Tnk", b =>
|
modelBuilder.Entity("PARR.DAL.Models.Tnk", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Works");
|
b.Navigation("Works");
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using PARR.Constants;
|
|||||||
using PARR.DAL.Models.Base;
|
using PARR.DAL.Models.Base;
|
||||||
using PARR.DAL.Models.Base.History;
|
using PARR.DAL.Models.Base.History;
|
||||||
using PARR.DAL.Models.Base.History.Base;
|
using PARR.DAL.Models.Base.History.Base;
|
||||||
using PARR.DAL.Models.Job;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
@@ -32,11 +31,6 @@ namespace PARR.DAL.Models
|
|||||||
|
|
||||||
public bool IsActiveSchedule { get; set; }
|
public bool IsActiveSchedule { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Шаблон не используется : перестал подходить условиям Job'а. true - не используется
|
|
||||||
/// </summary>
|
|
||||||
public bool IsUnused { get; set; } = false;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Номер расписания еспп
|
/// Номер расписания еспп
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -64,6 +58,8 @@ namespace PARR.DAL.Models
|
|||||||
|
|
||||||
public Guid UnitId { get; set; }
|
public Guid UnitId { get; set; }
|
||||||
|
|
||||||
|
public TemplateStatusTypeEnum StatusTypeId { get; set; } = TemplateStatusTypeEnum.Used;
|
||||||
|
|
||||||
//public Guid HostId { get; set; }
|
//public Guid HostId { get; set; }
|
||||||
|
|
||||||
#region Initiator
|
#region Initiator
|
||||||
@@ -96,5 +92,7 @@ namespace PARR.DAL.Models
|
|||||||
public ICollection<TemplateHistory> TemplateHistories { get; set; } = new HashSet<TemplateHistory>();
|
public ICollection<TemplateHistory> TemplateHistories { get; set; } = new HashSet<TemplateHistory>();
|
||||||
|
|
||||||
public ICollection<UnitsInTemplate> UnitsInTemplate { get; set; } = new HashSet<UnitsInTemplate>();
|
public ICollection<UnitsInTemplate> UnitsInTemplate { get; set; } = new HashSet<UnitsInTemplate>();
|
||||||
|
|
||||||
|
public TemplateStatusType? StatusType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ namespace PARR.DAL.Models
|
|||||||
|
|
||||||
public DateTimeOffset NextRun { get; set; }
|
public DateTimeOffset NextRun { get; set; }
|
||||||
|
|
||||||
|
public TemplateStatusTypeEnum StatusTypeId { get; set; } = TemplateStatusTypeEnum.Used;
|
||||||
|
|
||||||
|
|
||||||
[ForeignKey(nameof(ParentId))]
|
[ForeignKey(nameof(ParentId))]
|
||||||
public Template? Template { get; set; }
|
public Template? Template { get; set; }
|
||||||
|
|||||||
21
PARR.DAL/Models/TemplateStatusType.cs
Normal file
21
PARR.DAL/Models/TemplateStatusType.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PARR.Constants;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace PARR.DAL.Models
|
||||||
|
{
|
||||||
|
[Table("TemplateStatusTypes")]
|
||||||
|
[Comment("Таблица описания критериев выборки аттрибутов ЭК")]
|
||||||
|
public class TemplateStatusType
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public TemplateStatusTypeEnum Id { get; set; }
|
||||||
|
|
||||||
|
public required string Name { get; set; }
|
||||||
|
|
||||||
|
public required string Description { get; set; }
|
||||||
|
|
||||||
|
public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.BLL.Services.Interfaces;
|
using PARR.BLL.Services.Interfaces;
|
||||||
using PARR.Common.Domain;
|
using PARR.Common.Domain;
|
||||||
|
using PARR.Constants;
|
||||||
using PARR.DAL.Models;
|
using PARR.DAL.Models;
|
||||||
using PARR.DAL.Services.Interfaces;
|
using PARR.DAL.Services.Interfaces;
|
||||||
using PARR.DAL.Services.Interfaces.Job;
|
using PARR.DAL.Services.Interfaces.Job;
|
||||||
@@ -81,7 +82,7 @@ namespace PARR.NextRun
|
|||||||
|
|
||||||
// Загружаем только шаблоны текущей группы где nextRun в БД не равен расчетному
|
// Загружаем только шаблоны текущей группы где nextRun в БД не равен расчетному
|
||||||
var templatesToUpdate = await templateService.Get()
|
var templatesToUpdate = await templateService.Get()
|
||||||
.Where(t => t.IsUnused == false && t.Job!.GroupId == group.Id && t.NextRun != nextRun)
|
.Where(t => t.StatusTypeId == TemplateStatusTypeEnum.Used && t.Job!.GroupId == group.Id && t.NextRun != nextRun)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
if (!templatesToUpdate.Any())
|
if (!templatesToUpdate.Any())
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ internal class TemplateActivator : ITemplateActivator
|
|||||||
if (query.AllowUnused == false)
|
if (query.AllowUnused == false)
|
||||||
// учитываем только шаблоны которые не помеченные как IsUnused = true (неиспользуемые)
|
// учитываем только шаблоны которые не помеченные как IsUnused = true (неиспользуемые)
|
||||||
// т е берем только используемые шаблоны
|
// т е берем только используемые шаблоны
|
||||||
templatesQuery = templatesQuery.Where(t => t.IsUnused == false);
|
templatesQuery = templatesQuery.Where(t => t.StatusTypeId == TemplateStatusTypeEnum.Used);
|
||||||
|
|
||||||
return await templatesQuery.Include(t => t.RobotConfigurations).ToListAsync();
|
return await templatesQuery.Include(t => t.RobotConfigurations).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,8 @@ namespace PARR.TemplateGeneratorWorker
|
|||||||
IsActiveTemplate = query.IsActiveTemplate ?? false,
|
IsActiveTemplate = query.IsActiveTemplate ?? false,
|
||||||
IsActiveSchedule = query.IsActiveSchedule ?? false,
|
IsActiveSchedule = query.IsActiveSchedule ?? false,
|
||||||
NextRun = nextRun,
|
NextRun = nextRun,
|
||||||
IsUnused = false,
|
//IsUnused = false,
|
||||||
|
StatusTypeId = TemplateStatusTypeEnum.Used,
|
||||||
InitiatorComment = query.HistoryInitiator?.InitiatorComment,
|
InitiatorComment = query.HistoryInitiator?.InitiatorComment,
|
||||||
InitiatorParrComponentId = query.HistoryInitiator?.InitiatorParrComponentId
|
InitiatorParrComponentId = query.HistoryInitiator?.InitiatorParrComponentId
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user