feat(api,dal): tbl TemplateStatusType - добавлен новый тип Error. В API добавлен метод просмотра статистики распределения StatTemplateDistributionController
This commit is contained in:
@@ -512,7 +512,8 @@ namespace PARR.DAL.Context
|
||||
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 = "Обновляется" }
|
||||
new() { Id = TemplateStatusTypeEnum.Updating, Name = TemplateStatusTypeEnum.Updating.ToString(), Description = "Обновляется" },
|
||||
new() { Id = TemplateStatusTypeEnum.Error, Name = TemplateStatusTypeEnum.Error.ToString(), Description = "Ошибка" }
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
4117
PARR.DAL/Migrations/20260126042226_tblTemplateStatusTypeAddStatusError.Designer.cs
generated
Normal file
4117
PARR.DAL/Migrations/20260126042226_tblTemplateStatusTypeAddStatusError.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PARR.DAL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class tblTemplateStatusTypeAddStatusError : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.InsertData(
|
||||
table: "TemplateStatusTypes",
|
||||
columns: new[] { "Id", "Description", "Name" },
|
||||
values: new object[] { 3, "Ошибка", "Error" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DeleteData(
|
||||
table: "TemplateStatusTypes",
|
||||
keyColumn: "Id",
|
||||
keyValue: 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2900,6 +2900,12 @@ namespace PARR.DAL.Migrations
|
||||
Id = 2,
|
||||
Description = "Обновляется",
|
||||
Name = "Updating"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 3,
|
||||
Description = "Ошибка",
|
||||
Name = "Error"
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
using PARR.DAL.NextRunServices.Models;
|
||||
using PARR.DAL.Models.Job;
|
||||
using PARR.DAL.NextRunServices.Models;
|
||||
|
||||
namespace PARR.DAL.NextRunServices
|
||||
{
|
||||
public interface INextRunService
|
||||
{
|
||||
/// <summary>
|
||||
/// Получить продолжительность распределения в днях
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
int GetDurationDays(JobGroupDistributionConfig config);
|
||||
|
||||
/// <summary>
|
||||
/// Получить список TemplateId, NextRun по jobGroupId с автораспределением (распределить шаблоны в группе работ)
|
||||
/// </summary>
|
||||
@@ -36,5 +44,14 @@ namespace PARR.DAL.NextRunServices
|
||||
/// <returns></returns>
|
||||
Task<DateTimeOffset> GetNextRunForTemplateAsync(Guid templateId, bool isNew);
|
||||
|
||||
/// <summary>
|
||||
/// Получить список рабочих дней
|
||||
/// </summary>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="excludeWeekends"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<DateOnly>> GetWorkDaysAsync(DateOnly start, DateOnly end, bool excludeWeekends);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,18 +70,19 @@ namespace PARR.DAL.NextRunServices
|
||||
var duration = GetDurationDays(jobGroup.DistributionConfig);
|
||||
var dateStart = GetDateStart(jobGroup.ReferenceDate);
|
||||
|
||||
//получаем шаблоны только в статусе Used
|
||||
var allTemplates = await templateService.Get()
|
||||
.Include(t => t.Job)
|
||||
.Where(t => t.Job!.GroupId == jobGroupId)
|
||||
.Where(t => t.Job!.GroupId == jobGroupId && t.StatusTypeId == TemplateStatusTypeEnum.Used)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
if (!allTemplates.Any())
|
||||
{
|
||||
logger.LogInformation("В группе c ИД {jobGroupId} отсутствуют шаблоны", jobGroupId);
|
||||
logger.LogInformation("В группе c ИД {jobGroupId} отсутствуют шаблоны в статусе Used", jobGroupId);
|
||||
return null;
|
||||
}
|
||||
|
||||
logger.LogDebug("Всего шаблонов для распределения: {count} шт.", allTemplates.Count);
|
||||
logger.LogDebug("Всего шаблонов для распределения в статусе Used: {count} шт.", allTemplates.Count);
|
||||
|
||||
var result = new List<TemplateNextRunResultDto>();
|
||||
|
||||
@@ -258,7 +259,7 @@ namespace PARR.DAL.NextRunServices
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
private int GetDurationDays(JobGroupDistributionConfig config)
|
||||
public int GetDurationDays(JobGroupDistributionConfig config)
|
||||
{
|
||||
var period = config.DistributionPeriod;
|
||||
var periodType = period!.Type;
|
||||
@@ -303,5 +304,11 @@ namespace PARR.DAL.NextRunServices
|
||||
else
|
||||
return DateOnly.FromDateTime(today.Date);
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<DateOnly>> GetWorkDaysAsync(DateOnly start, DateOnly end, bool excludeWeekends)
|
||||
{
|
||||
return await templateDistributor.GetWorkDaysAsync(start, end, excludeWeekends);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,16 @@ namespace PARR.DAL.NextRunServices.Subservices
|
||||
/// <param name="isNew">Новый шаблон</param>
|
||||
/// <returns></returns>
|
||||
Task<TemplateNextRunResultDto> GetValidNextRunForTemplateAsync(DateOnly startDate, int duration, DateTimeOffset referenceDate, TemplateNextRunDto targetTemplate, List<TemplateNextRunDto> allTemplates, bool excludeWeekends, bool isNew);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить список рабочих дней
|
||||
/// </summary>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="excludeWeekends"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<DateOnly>> GetWorkDaysAsync(DateOnly start, DateOnly end, bool excludeWeekends);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -465,6 +465,8 @@ namespace PARR.DAL.NextRunServices.Subservices
|
||||
{
|
||||
var interval = (double)totalDays / totalWorks;
|
||||
|
||||
logger.LogDebug("Интевал между шаблонами: {interval}", interval);
|
||||
|
||||
return interval;
|
||||
}
|
||||
|
||||
@@ -562,7 +564,7 @@ namespace PARR.DAL.NextRunServices.Subservices
|
||||
/// <param name="end"></param>
|
||||
/// <param name="excludeWeekends">Исключить выходные и праздники</param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<DateOnly>> GetWorkDaysAsync(DateOnly start, DateOnly end, bool excludeWeekends)
|
||||
public async Task<List<DateOnly>> GetWorkDaysAsync(DateOnly start, DateOnly end, bool excludeWeekends)
|
||||
{
|
||||
// Получаем список выходных/праздничных дней
|
||||
var weekends = new HashSet<DateOnly>();
|
||||
|
||||
Reference in New Issue
Block a user