2024-07-02 11:43:59 +10:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
using PARR.DAL.Models;
|
|
|
|
|
|
using PARR.DAL.Services.Interfaces;
|
|
|
|
|
|
|
|
|
|
|
|
namespace PARR.TemplateDistributor
|
|
|
|
|
|
{
|
|
|
|
|
|
internal class TemplateDistributor : ITemplateDistributor
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IApplicationsInWorkService applicationsInWorkService;
|
|
|
|
|
|
|
|
|
|
|
|
public TemplateDistributor(IApplicationsInWorkService applicationsInWorkService)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.applicationsInWorkService = applicationsInWorkService;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-02 15:04:23 +10:00
|
|
|
|
public async Task UpdateScheduleAsync(Guid applicationInWorkId)
|
|
|
|
|
|
{
|
|
|
|
|
|
// все шаблоны по applicationInWorkId
|
|
|
|
|
|
// группирует по РР
|
|
|
|
|
|
// -> DistributeTemplateForPeriodAsync
|
|
|
|
|
|
// сохранить в БД
|
|
|
|
|
|
}
|
2024-07-02 11:43:59 +10:00
|
|
|
|
|
|
|
|
|
|
|
2024-07-02 15:04:23 +10:00
|
|
|
|
|
|
|
|
|
|
public async Task<List<Template>> DistributeTemplateAsync(List<Template> templates, Guid applicationInWorkId)
|
2024-07-02 11:43:59 +10:00
|
|
|
|
{
|
|
|
|
|
|
//TODO: ЗАГУЛШКА переделать!
|
|
|
|
|
|
|
2024-07-02 15:04:23 +10:00
|
|
|
|
// распределить?
|
|
|
|
|
|
// не распределить, NextRun = appInWork.ReferenceDate
|
|
|
|
|
|
|
2024-07-02 11:43:59 +10:00
|
|
|
|
var appInWork = await applicationsInWorkService.Get().FirstOrDefaultAsync(t => t.Id == applicationInWorkId);
|
|
|
|
|
|
if (appInWork == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception("ERROROORORO!!!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates.ForEach(t => t.NextRun = appInWork.ReferenceDate);
|
|
|
|
|
|
|
|
|
|
|
|
return templates;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|