feat: Из dal перенесены все модели в Domain. Из dal переименованы service в repository, вынесены в Core.

This commit is contained in:
Mikhail Trubnikov
2026-04-30 10:35:31 +10:00
parent f1ea69da1f
commit eb78dfd6a8
356 changed files with 1817 additions and 1985 deletions

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities;
namespace PARR.Core.Repositories.Interfaces
{
public interface IAgentHistoryRepository : IBaseRepository<AgentHistory>
{
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities;
namespace PARR.Core.Repositories.Interfaces
{
public interface IDistributionPeriodRepository : IBaseRepository<DistributionPeriod>
{
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities;
namespace PARR.Core.Repositories.Interfaces
{
public interface IOrderRepository : IBaseRepository<Order>
{
}
}

View File

@@ -0,0 +1,11 @@
using PARR.Domain.Entities;
using PARR.Domain.Enums;
namespace PARR.Core.Repositories.Interfaces
{
public interface IOrderStatusRepository
{
IQueryable<OrderStatus> Get();
OrderStatusEnum GetOrderStatusByName(string statusName);
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Domain.Entities;
namespace PARR.Core.Repositories.Interfaces
{
public interface IParrComponentRepository
{
IQueryable<ParrComponent> Get();
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities;
namespace PARR.Core.Repositories.Interfaces
{
public interface IProcessRepository : IBaseRepository<Process>
{
}
}

View File

@@ -0,0 +1,46 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities;
using PARR.Domain.Enums;
namespace PARR.Core.Repositories.Interfaces
{
public interface IRobotConfigurationRepository : IBaseRepository<RobotConfiguration>
{
/// <summary>
/// Обновить статус работы робота
/// </summary>
/// <param name="robotStatus"></param>
/// <param name="configuration"></param>
void ChangeRobotStatus(RobotStatusEnum robotStatus, RobotConfiguration configuration);
/// <summary>
/// Обновить статус задания (автоматически обновляется статус робота при необходимости)
/// </summary>
/// <param name="taskStatus"></param>
/// <param name="configuration"></param>
void ChangeTaskStatus(TaskStatusEnum taskStatus, RobotConfiguration configuration);
/// <summary>
/// Поиск невыполненных заданий и установка им статуса ошибки робота
/// </summary>
/// <param name="robotAttemptsNumber"></param>
/// <param name="robotWaitTime"></param>
/// <returns></returns>
Task FindUnfulfilledTaskAndSetRobotErrorStatusAsync(int robotAttemptsNumber, TimeSpan robotWaitTime);
/// <summary>
/// Получить конфигурацию из шаблона по RobotCode. У шаблона обязательно должен быть Include таблицы RobotConfiguration
/// </summary>
/// <param name="robotsEnum"></param>
/// <param name="template"></param>
/// <returns></returns>
RobotConfiguration GetFromTemplateByRobotCode(RobotsEnum robotsEnum, Template template);
/// <summary>
/// Установить статус задания "Обновить", если разрешено
/// </summary>
/// <param name="configuration"></param>
/// <returns>true - если изменил статус, false - нельзя изменить статус</returns>
bool SetUpdateTaskStatusIfAllow(RobotConfiguration configuration);
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Domain.Entities;
namespace PARR.Core.Repositories.Interfaces
{
public interface IRobotHistoryLevelRepository
{
IQueryable<RobotHistoryLevel> Get();
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities;
namespace PARR.Core.Repositories.Interfaces
{
public interface IRobotHistoryRepository : IBaseRepository<RobotHistory>
{
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Domain.Entities;
namespace PARR.Core.Repositories.Interfaces
{
public interface IRobotRepository
{
IQueryable<Robot> Get();
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Domain.Entities;
namespace PARR.Core.Repositories.Interfaces
{
public interface IRobotStatusRepository
{
IQueryable<RobotStatus> Get();
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities;
namespace PARR.Core.Repositories.Interfaces
{
public interface IRoleRepository : IBaseRepository<Role>
{
}
}

View File

@@ -0,0 +1,7 @@
namespace PARR.Core.Repositories.Interfaces
{
public interface IStatusTemplateRepository
{
IQueryable<Domain.Entities.TaskStatus> Get();
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities;
namespace PARR.Core.Repositories.Interfaces
{
public interface ISubprocessRepository : IBaseRepository<Subprocess>
{
}
}

View File

@@ -0,0 +1,7 @@
namespace PARR.Core.Repositories.Interfaces
{
public interface ITaskStatusRepository
{
IQueryable<Domain.Entities.TaskStatus> Get();
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities;
namespace PARR.Core.Repositories.Interfaces
{
public interface ITemplateHistoryRepository : IBaseRepository<TemplateHistory>
{
}
}

View File

@@ -0,0 +1,26 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities;
using PARR.Domain.Entities.Base.History;
namespace PARR.Core.Repositories.Interfaces
{
public interface ITemplateRepository : IBaseRepository<Template>
{
Task<Template?> GetTemplateByNameAsync(string name);
/// <summary>
/// Резервирует неиспользуемый шаблон: устанавливает статус <see cref="TemplateStatusTypeEnum.Updating"/>
/// и фиксирует данные инициатора.
/// </summary>
/// <param name="newUnitId">Идентификатор подразделения (используется для фильтрации и логирования).</param>
/// <param name="initiator">Данные инициатора операции.</param>
/// <returns>
/// Идентификатор зарезервированного шаблона или <see langword="null"/>,
/// если подходящий шаблон не найден.
/// </returns>
Task<Guid?> ReserveUnusedTemplateAsync(Guid newUnitId, HistoryInitiator initiator);
IQueryable<Template> GetWithIncludes();
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Domain.Entities;
namespace PARR.Core.Repositories.Interfaces
{
public interface ITemplateStatusTypeRepository
{
IQueryable<TemplateStatusType> Get();
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities;
namespace PARR.Core.Repositories.Interfaces
{
public interface ITnkRepository : IBaseRepository<Tnk>
{
}
}

View File

@@ -0,0 +1,10 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities;
namespace PARR.Core.Repositories.Interfaces
{
public interface IUserRepository: IBaseRepository<User>
{
Task<User?> GetByIpWithRolesAsync(string ipAddress);
}
}

View File

@@ -0,0 +1,18 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities;
namespace PARR.Core.Repositories.Interfaces
{
public interface IWeekendDayRepository : IBaseRepository<WeekendDay>
{
IQueryable<DateOnly> GetWeekends(DateOnly start, DateOnly end);
/// <summary>
/// Проверка, это рабочий день?
/// </summary>
/// <param name="date"></param>
/// <param name="useCache">разрешить использовать кэш? По умолчанию false</param>
/// <returns></returns>
Task<bool> IsWorkDayAsync(DateOnly date, bool useCache = false);
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities.Job;
namespace PARR.Core.Repositories.Interfaces.Job
{
public interface IFieldFilterRepository : IBaseRepository<JobFieldFilter>
{
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Domain.Entities.Job;
namespace PARR.Core.Repositories.Interfaces.Job
{
public interface IJobAutoControlRepository
{
IQueryable<JobAutoControl> Get();
}
}

View File

@@ -0,0 +1,14 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities.Job;
namespace PARR.Core.Repositories.Interfaces.Job
{
public interface IJobGroupRepository : IBaseRepository<JobGroup>
{
/// <summary>
/// Удалить настройки автораспределения
/// </summary>
/// <param name="distributionConfig"></param>
void DeleteDistributionConfig(JobGroupDistributionConfig distributionConfig);
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities.Job;
namespace PARR.Core.Repositories.Interfaces.Job
{
public interface IJobGroupTypeRepository : IBaseRepository<JobGroupType>
{
}
}

View File

@@ -0,0 +1,8 @@
using PARR.Core.Repositories.Base;
namespace PARR.Core.Repositories.Interfaces.Job
{
public interface IJobRepository : IBaseRepository<Domain.Entities.Job.Job>
{
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities.Job;
namespace PARR.Core.Repositories.Interfaces.Job
{
public interface IJobUnitFilterRepository : IBaseRepository<JobUnitFilter>
{
}
}

View File

@@ -0,0 +1,48 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities.Schedule;
namespace PARR.Core.Repositories.Interfaces.Schedule
{
public interface IEsppSchTypeConfigRepository : IBaseRepository<EsppSchTypeConfig>
{
/// <summary>
/// Формирует расписание в нормальном понятном виде из БД синхронно
/// </summary>
/// <param name="jobGroupId"></param>
/// <returns></returns>
EsppScheduleDto? GetEsppScheduleDto(Guid jobGroupId);
/// <summary>
/// Формирует расписание в нормальном понятном виде из БД асинхронно
/// </summary>
/// <param name="jobGroupId"></param>
/// <returns></returns>
Task<EsppScheduleDto?> GetEsppScheduleDtoAsync(Guid jobGroupId);
IQueryable<EsppSchTypeConfig> GetWithSchIncludes();
}
//todo: эти методы GetEsppScheduleDto, GetEsppScheduleDtoAsync должны быть в сервисе а не в репозитории. И модели тогда переедут в Domain или в Core
/// <summary>
/// Расписание ЕСПП в нормальном виде
/// </summary>
public class EsppScheduleDto
{
public required EsppSchTypeSchedule TypeSchedule { get; set; }
public required List<EsppScheduleValDto> Values { get; set; }
}
public class EsppScheduleValDto
{
public int Order { get; set; }
public required EsppSchType Type { get; set; }
public required EsppSchTypeValue Value { get; set; }
}
}

View File

@@ -0,0 +1,10 @@
using PARR.Domain.Entities.Schedule;
namespace PARR.Core.Repositories.Interfaces.Schedule
{
public interface IEsppSchTypeScheduleRepository
{
IQueryable<EsppSchTypeSchedule> Get();
Task<EsppSchTypeSchedule?> GetAsync(int id);
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities.Schedule;
namespace PARR.Core.Repositories.Interfaces.Schedule
{
public interface IEsppSchTypeValueRepository : IBaseRepository<EsppSchTypeValue>
{
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities.Schedule;
namespace PARR.Core.Repositories.Interfaces.Schedule
{
public interface IScheduleExcludeTypeCalendarRepository: IBaseRepository<ScheduleExcludeTypeCalendar>
{
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities.Schedule;
namespace PARR.Core.Repositories.Interfaces.Schedule
{
public interface IScheduleExcludeTypeRepository : IBaseRepository<ScheduleExcludeType>
{
}
}

View File

@@ -0,0 +1,24 @@
using PARR.Domain.Entities.Schedule;
namespace PARR.Core.Repositories.Interfaces.Schedule
{
public interface IScheduleResponseAreaTimeOffsetRepository
{
/// <summary>
/// Список всех значений
/// </summary>
IReadOnlyDictionary<string, ScheduleResponseAreaTimeOffset> GetAll { get; }
/// <summary>
/// Значение по умолчанию
/// </summary>
ScheduleResponseAreaTimeOffset GetDefault { get; }
/// <summary>
/// Получить значение по ЗО, если не найдет, то значение по умолчанию
/// </summary>
/// <param name="responseArea"></param>
/// <returns></returns>
ScheduleResponseAreaTimeOffset GetByResponseAreaOrDefault(string responseArea);
}
}

View File

@@ -0,0 +1,10 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities.Unit;
namespace PARR.Core.Repositories.Interfaces.Unit
{
public interface IUnitFieldRepository : IBaseRepository<UnitField>
{
Task<UnitField?> GetByAihitNameAsync(string name);
}
}

View File

@@ -0,0 +1,10 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities.Unit;
namespace PARR.Core.Repositories.Interfaces.Unit
{
public interface IUnitFieldValueRepository: IBaseRepository<UnitFieldValue>
{
Task<UnitFieldValue?> GetByValueNameAsync(string? value);
}
}

View File

@@ -0,0 +1,23 @@
using PARR.Domain.Entities.Unit;
namespace PARR.Core.Repositories.Interfaces.Unit
{
public interface IUnitInUnitRepository
{
Task<List<UnitInUnit>> GetByParentIdAsync(Guid parentId);
Task<List<UnitInUnit>> GetByChildIdAsync(Guid childId);
/// <summary>
/// Получает связи, где ChildUnitId unitIds (для IsParent=True).
/// </summary>
Task<List<UnitInUnit>> GetParentLinksByChildIdsAsync(IEnumerable<Guid> childUnitIds);
/// <summary>
/// Получает связи, где ParentUnitId unitIds (для IsParent=False).
/// </summary>
Task<List<UnitInUnit>> GetChildLinksByParentIdsAsync(IEnumerable<Guid> parentUnitIds);
IQueryable<UnitInUnit> Get();
}
}

View File

@@ -0,0 +1,28 @@
using PARR.Domain.Entities.Unit;
namespace PARR.Core.Repositories.Interfaces.Unit
{
public interface IUnitInValueRepository
{
Task<List<UnitInValue>> GetByUnitIdsAsync(IEnumerable<Guid> unitIds);
Task<List<UnitInValue>> GetByUnitIdAsync(Guid unitId);
Task<List<(string FieldName, string? Value)>> GetFieldValuesAsync(Guid unitId, IReadOnlyCollection<string> aihitNames);
/// <summary>
/// Получает UnitInValue (с Value) для заданных UnitId и FieldId.
/// </summary>
Task<List<UnitInValue>> GetByUnitIdsAndFieldIdsAsync(IEnumerable<Guid> unitIds, IEnumerable<Guid> fieldIds);
/// <summary>
/// Находит наиболее часто встречающееся непустое значение указанного поля среди переданных юнитов.
/// </summary>
/// <param name="unitIds">Список Id юнитов для анализа.</param>
/// <param name="fieldName">Имя поля (AihitName) для поиска значения.</param>
/// <returns>Наиболее частое значение поля или null, если не найдено.</returns>
Task<string?> GetMostFrequentValueForFieldAsync(List<Guid> unitIds, string fieldName);
IQueryable<UnitInValue> Get();
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Domain.Entities.Unit;
namespace PARR.Core.Repositories.Interfaces.Unit
{
public interface IUnitKiiUnitRepository
{
IQueryable<UnitKiiUnit> Get();
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Domain.Entities.Unit;
namespace PARR.Core.Repositories.Interfaces.Unit
{
public interface IUnitRegionalEkPtkGroupRepository
{
IQueryable<UnitRegionalEkPtkGroup> Get();
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
namespace PARR.Core.Repositories.Interfaces.Unit
{
public interface IUnitRepository : IBaseRepository<Domain.Entities.Unit.Unit>
{
IQueryable<Domain.Entities.Unit.Unit> GetWithIncludes();
}
}