Compare commits
23 Commits
fe4461ee4e
...
9c27f81fe8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c27f81fe8 | ||
|
|
36e866f637 | ||
|
|
1affa34b07 | ||
|
|
3c9e03adbb | ||
|
|
143ae10190 | ||
|
|
f8e16e9496 | ||
|
|
55ac424f1a | ||
|
|
cb3c98ed8c | ||
|
|
16f97904eb | ||
|
|
52bd0d8ce1 | ||
|
|
65ef0dec92 | ||
|
|
7574cd31c2 | ||
|
|
8a44f43a34 | ||
|
|
16ba4f21a2 | ||
|
|
c1ff4d0258 | ||
|
|
5c2d1c31b5 | ||
|
|
806633aaf7 | ||
|
|
0d7969da44 | ||
|
|
4f2b2c204e | ||
|
|
df6ed47bd9 | ||
|
|
8dfb2587b2 | ||
|
|
4a8a67247d | ||
|
|
8151ea89b9 |
21
.gitlab/issue_templates/Bug.md
Normal file
21
.gitlab/issue_templates/Bug.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
### 📋 Описание бага
|
||||||
|
Кратко и понятно опишите, что идет не так.
|
||||||
|
|
||||||
|
### 🔄 Шаги для воспроизведения
|
||||||
|
1. Перейти на страницу...
|
||||||
|
2. Нажать кнопку...
|
||||||
|
3. Ввести в поле поиска...
|
||||||
|
|
||||||
|
### ❌ Фактический результат
|
||||||
|
Что произошло на самом деле? (Например: Приложение завершилось с ошибкой 500).
|
||||||
|
|
||||||
|
### ✅ Ожидаемый результат
|
||||||
|
Что должно было произойти? (Например: Появился список найденных товаров).
|
||||||
|
|
||||||
|
### 🖥️ Окружение
|
||||||
|
* **ОС:** Windows 11 / macOS Sequoia
|
||||||
|
* **Браузер / Версия:** Chrome 124 / iOS App v2.1
|
||||||
|
* **Стенд:** Staging / Production
|
||||||
|
|
||||||
|
### 📎 Вложения
|
||||||
|
Скриншоты, гифки или логи, которые помогают понять проблему.
|
||||||
23
NuGet.config
23
NuGet.config
@@ -1,13 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
<packageSources>
|
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
<add key="Nexus-SVRW" value="http://nexus.svrw.oao.rzd/repository/nuget-group/" allowInsecureConnections="true"/>
|
||||||
<add key="Nexus" value="http://10.99.253.167:8081/repository/nuget-group/" allowInsecureConnections="true"/>
|
<add key="Nexus-DVGD" value="http://10.99.253.167:8081/repository/nuget-group/index.json" protocolVersion="3" allowInsecureConnections="true"/>
|
||||||
<add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
|
<add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
|
||||||
</packageSources>
|
</packageSources>
|
||||||
<disabledPackageSources>
|
<disabledPackageSources>
|
||||||
<add key="Microsoft Visual Studio Offline Packages" value="true" />
|
<add key="Microsoft Visual Studio Offline Packages" value="true" />
|
||||||
<add key="nuget.org" value="true" />
|
<add key="nuget.org" value="true" />
|
||||||
</disabledPackageSources>
|
<add key="Nexus-SVRW" value="true" />
|
||||||
</configuration>
|
</disabledPackageSources>
|
||||||
|
</configuration>
|
||||||
@@ -27,7 +27,14 @@ FROM base AS final
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=publish /app/publish .
|
COPY --from=publish /app/publish .
|
||||||
|
|
||||||
# Fixes an old version TLS (AIH IT GVC)
|
# 1. Принудительно настраиваем OpenSSL 3 на игнорирование непредвиденных EOF (UnsafeLegacyRenegotiation и IgnoreUnexpectedEOF)
|
||||||
RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf
|
RUN sed -i 's/providers = provider_sect/providers = provider_sect\nssl_conf = ssl_sect/' /etc/ssl/openssl.cnf \
|
||||||
|
&& printf "\n[ssl_sect]\nsystem_default = system_default_sect\n" >> /etc/ssl/openssl.cnf \
|
||||||
|
&& printf "\n[system_default_sect]\nOptions = UnsafeLegacyRenegotiation,IgnoreUnexpectedEOF\nMinProtocol = TLSv1\nCipherString = DEFAULT@SECLEVEL=0\n" >> /etc/ssl/openssl.cnf
|
||||||
|
|
||||||
|
# 2. Оставляем глобальные переменные совместимости для самого рантайма .NET 9
|
||||||
|
ENV DOTNET_AppContext_Switch_System_Net_Security_UseUnsafeOldTlsRuntimeBehavior=true
|
||||||
|
ENV DOTNET_AppContext_Switch_Microsoft_Data_SqlClient_UseOldTlsValue=true
|
||||||
|
ENV DOTNET_SYSTEM_NET_SECURITY_ALLOWUNSECUREDEFAULTS=true
|
||||||
|
|
||||||
ENTRYPOINT ["dotnet", "PARR.AIHITLoaderWorker.dll"]
|
ENTRYPOINT ["dotnet", "PARR.AIHITLoaderWorker.dll"]
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"AihitConnection": "Data Source=10.248.19.97; Initial Catalog=mao2;User ID=awhit-ipp-parr;pwd=ET3h$9y1LH#D;TrustServerCertificate=true;"
|
"AihitConnection": "Data Source=10.248.19.97; Initial Catalog=mao2;User ID=awhit-ipp-parr;pwd=ET3h$9y1LH#D;Encrypt=Optional;TrustServerCertificate=true;MultiSubnetFailover=True;"
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.20" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.17" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ namespace PARR.AIHITMainSyncer.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async Task SyncValuesAsync(List<string?> values)
|
private async Task SyncValuesAsync(List<string?> values)
|
||||||
{
|
{
|
||||||
bool hasNull = values.Any(v => v is null);
|
bool hasNull = values.Any(v => v is null);
|
||||||
var normalizedNoneNullValues = values
|
var normalizedNoneNullValues = values
|
||||||
@@ -288,6 +288,7 @@ private async Task SyncValuesAsync(List<string?> values)
|
|||||||
if (hasNull && !existingValuesInDb.Contains(null))
|
if (hasNull && !existingValuesInDb.Contains(null))
|
||||||
newValuesToInsert.Add(null);
|
newValuesToInsert.Add(null);
|
||||||
|
|
||||||
|
// Если нет новых значений, выходим БЕЗ вызова CommitAsync
|
||||||
if (newValuesToInsert.Count == 0)
|
if (newValuesToInsert.Count == 0)
|
||||||
{
|
{
|
||||||
logger.LogDebug("Нет новых значений для добавления в базу данных");
|
logger.LogDebug("Нет новых значений для добавления в базу данных");
|
||||||
@@ -302,15 +303,19 @@ private async Task SyncValuesAsync(List<string?> values)
|
|||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
// Только добавляем в контекст, НЕ коммитим
|
|
||||||
if (!await unitFieldValueRepository.AddRangeAsync(newFieldValues))
|
if (!await unitFieldValueRepository.AddRangeAsync(newFieldValues))
|
||||||
{
|
{
|
||||||
logger.LogError("Не удалось добавить {Count} новых значений FieldValues в контекст", newValuesToInsert.Count);
|
logger.LogError("Не удалось добавить {Count} новых значений FieldValues в контекст", newValuesToInsert.Count);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
// Коммит выполняется ТОЛЬКО если были добавлены новые сущности
|
||||||
|
if (!await unitFieldValueRepository.CommitAsync())
|
||||||
{
|
{
|
||||||
logger.LogDebug("Подготовлено {Count} новых значений FieldValues для сохранения", newValuesToInsert.Count);
|
logger.LogError("Не удалось сохранить {Count} новых значений FieldValues в базу данных", newValuesToInsert.Count);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.LogDebug("Успешно сохранено {Count} новых значений FieldValues", newValuesToInsert.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -318,6 +323,7 @@ private async Task SyncValuesAsync(List<string?> values)
|
|||||||
{
|
{
|
||||||
var newFields = fieldsFromAihit.Where(t => !fieldsFromDB.Any(f => IsStringEqual(f.AihitName, t))).ToList();
|
var newFields = fieldsFromAihit.Where(t => !fieldsFromDB.Any(f => IsStringEqual(f.AihitName, t))).ToList();
|
||||||
|
|
||||||
|
// Если нет новых полей, выходим БЕЗ вызова CommitAsync
|
||||||
if (!newFields.Any())
|
if (!newFields.Any())
|
||||||
{
|
{
|
||||||
logger.LogDebug("Нет новых полей для добавления в базу данных");
|
logger.LogDebug("Нет новых полей для добавления в базу данных");
|
||||||
@@ -335,19 +341,24 @@ private async Task SyncValuesAsync(List<string?> values)
|
|||||||
EsppName = null,
|
EsppName = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Только добавляем в контекст, НЕ коммитим
|
|
||||||
if (!await unitFieldRepository.CreateAsync(field))
|
if (!await unitFieldRepository.CreateAsync(field))
|
||||||
{
|
{
|
||||||
logger.LogError("Не удалось добавить поле в контекст: {FieldName}", item);
|
logger.LogError("Не удалось добавить поле в контекст: {FieldName}", item);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Коммит выполняется ТОЛЬКО после успешного добавления конкретного поля
|
||||||
|
if (!await unitFieldRepository.CommitAsync())
|
||||||
|
{
|
||||||
|
logger.LogError("Не удалось сохранить поле в базу данных: {FieldName}", item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.LogDebug("Подготовлено поле для сохранения: {FieldName}", item);
|
logger.LogDebug("Успешно сохранено поле: {FieldName}", item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private bool IsStringEqual(string? value1, string? value2)
|
private bool IsStringEqual(string? value1, string? value2)
|
||||||
{
|
{
|
||||||
return string.Equals(
|
return string.Equals(
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.20" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.17" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
FROM 10.99.253.167:8090/dotnet/runtime:9.0 AS base
|
FROM 10.99.253.167:8090/dotnet/runtime:9.0 AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
||||||
# This stage is used to build the service project
|
# This stage is used to build the service project
|
||||||
FROM 10.99.253.167:8090/dotnet/sdk:9.0 AS build
|
FROM 10.99.253.167:8090/dotnet/sdk:9.0 AS build
|
||||||
ARG BUILD_CONFIGURATION=Release
|
ARG BUILD_CONFIGURATION=Release
|
||||||
@@ -32,8 +31,15 @@ RUN dotnet publish "./PARR.AIHITRelationshipsSyncerWorker.csproj" -c $BUILD_CONF
|
|||||||
FROM base AS final
|
FROM base AS final
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=publish /app/publish .
|
COPY --from=publish /app/publish .
|
||||||
|
|
||||||
|
# 1. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> OpenSSL 3 <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> EOF (UnsafeLegacyRenegotiation <20> IgnoreUnexpectedEOF)
|
||||||
|
RUN sed -i 's/providers = provider_sect/providers = provider_sect\nssl_conf = ssl_sect/' /etc/ssl/openssl.cnf \
|
||||||
|
&& printf "\n[ssl_sect]\nsystem_default = system_default_sect\n" >> /etc/ssl/openssl.cnf \
|
||||||
|
&& printf "\n[system_default_sect]\nOptions = UnsafeLegacyRenegotiation,IgnoreUnexpectedEOF\nMinProtocol = TLSv1\nCipherString = DEFAULT@SECLEVEL=0\n" >> /etc/ssl/openssl.cnf
|
||||||
|
|
||||||
# Fixes an old version TLS (AIH IT GVC)
|
# 2. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> .NET 9
|
||||||
RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf
|
ENV DOTNET_AppContext_Switch_System_Net_Security_UseUnsafeOldTlsRuntimeBehavior=true
|
||||||
|
ENV DOTNET_AppContext_Switch_Microsoft_Data_SqlClient_UseOldTlsValue=true
|
||||||
|
ENV DOTNET_SYSTEM_NET_SECURITY_ALLOWUNSECUREDEFAULTS=true
|
||||||
|
|
||||||
ENTRYPOINT ["dotnet", "PARR.AIHITRelationshipsSyncerWorker.dll"]
|
ENTRYPOINT ["dotnet", "PARR.AIHITRelationshipsSyncerWorker.dll"]
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"AihitConnection": "Data Source=10.248.19.97; Initial Catalog=mao2;User ID=awhit-ipp-parr;pwd=ET3h$9y1LH#D;TrustServerCertificate=true;",
|
"AihitConnection": "Data Source=10.248.19.97; Initial Catalog=mao2;User ID=awhit-ipp-parr;pwd=ET3h$9y1LH#D;Encrypt=Optional;TrustServerCertificate=true;MultiSubnetFailover=True;",
|
||||||
"DefaultConnection": "Server=10.99.253.184;Database=parr;User Id=app_parr; Password=PosdfkhT&)%sdfligL&%5546;"
|
"DefaultConnection": "Server=10.99.253.184;Database=parr;User Id=app_parr; Password=PosdfkhT&)%sdfligL&%5546;"
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
|
|||||||
@@ -1,31 +1,27 @@
|
|||||||
{
|
{
|
||||||
"Logging": {
|
"ConnectionStrings": {
|
||||||
"LogLevel": {
|
"RedisConnection": "10.99.253.216:6379,password=ParrP@ssPtk202MMdevDvs"
|
||||||
"Default": "Debug",
|
|
||||||
"Microsoft.EntityFrameworkCore": "Debug",
|
|
||||||
"Microsoft.EntityFrameworkCore.Database.Command": "Warning",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Serilog": {
|
|
||||||
"MinimumLevel": {
|
|
||||||
"Default": "Debug",
|
|
||||||
"Override": {
|
|
||||||
//"Microsoft": "Information",
|
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"WriteTo": [
|
"Serilog": {
|
||||||
{
|
"MinimumLevel": {
|
||||||
"Name": "File",
|
"Default": "Debug",
|
||||||
"Args": {
|
"Override": {
|
||||||
"path": "log/log-.txt",
|
"Microsoft": "Warning",
|
||||||
"rollingInterval": "Day"
|
"Microsoft.Hosting.Lifetime": "Debug",
|
||||||
}
|
"PARR.DAL": "Information"
|
||||||
}
|
}
|
||||||
]
|
},
|
||||||
},
|
"WriteTo": [
|
||||||
"MqSettings": {
|
{
|
||||||
"HostName": "10.99.253.216"
|
"Name": "File",
|
||||||
}
|
"Args": {
|
||||||
|
"path": "log/log-.txt",
|
||||||
|
"rollingInterval": "Day"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"MqSettings": {
|
||||||
|
"HostName": "10.99.253.216"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"DefaultConnection": "Server=10.99.253.184;Database=parr;User Id=app_parr; Password=PosdfkhT&)%sdfligL&%5546;"
|
"DefaultConnection": "Server=10.99.253.184;Database=parr;User Id=app_parr; Password=PosdfkhT&)%sdfligL&%5546;",
|
||||||
|
"RedisConnection": "parr-redis:6379,password=ParrP@ssPtk202MMdevDvs"
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
|
|||||||
@@ -1,52 +1,14 @@
|
|||||||
using PARR.Domain.Enums;
|
namespace PARR.API.Contracts.V1.Requests
|
||||||
|
|
||||||
namespace PARR.API.Contracts.V1.Requests
|
|
||||||
{
|
{
|
||||||
public class JobAutoControlRequest
|
/// <summary>
|
||||||
|
/// Часть реквеста по управлению авто контролем для Job, JobGroup
|
||||||
|
/// </summary>
|
||||||
|
public record JobAutoControlRequest
|
||||||
{
|
{
|
||||||
/// <summary>
|
public bool IsEnable { get; init; }
|
||||||
/// Создавать новые РР (из настроке РР)
|
|
||||||
/// </summary>
|
|
||||||
public bool CreateNew { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
public bool InitUsedTemplateState { get; init; }
|
||||||
/// Деактивировать не актуальные согласно ЭК (обратные статусы ЭК)
|
|
||||||
/// </summary>
|
|
||||||
public bool Deactivate { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
public bool InitUsedScheduleState { get; init; }
|
||||||
/// Активировать РР после смены ЭК (согласно настройкам статусов ЭК)
|
|
||||||
/// </summary>
|
|
||||||
public bool Activate { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Состояние для активированных РР, шаблоны
|
|
||||||
/// </summary>
|
|
||||||
public bool OnTemplateIsActive { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Состояние для активированных РР, расписания
|
|
||||||
/// </summary>
|
|
||||||
public bool OnScheduleIsActive { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Состояние для деактивированных РР, шаблоны
|
|
||||||
/// </summary>
|
|
||||||
public bool OffTemplateIsActive { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Состояние для деактивированных РР, расписания
|
|
||||||
/// </summary>
|
|
||||||
public bool OffScheduleIsActive { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Маски ЭК
|
|
||||||
/// </summary>
|
|
||||||
public required List<string> EkMasks { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Статусы ЭК для которых включена генерация РР и активация
|
|
||||||
/// </summary>
|
|
||||||
public required List<EkStatusEnum> EnabledEkStatuses { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,47 +1,47 @@
|
|||||||
namespace PARR.API.Contracts.V1.Requests
|
namespace PARR.API.Contracts.V1.Requests
|
||||||
{
|
{
|
||||||
public class JobGroupRequest
|
public record JobGroupRequest
|
||||||
{
|
{
|
||||||
public required string Name { get; set; }
|
public required string Name { get; init; }
|
||||||
|
|
||||||
//public bool? IsUmbrella { get; set; }
|
//public bool? IsUmbrella { get; set; }
|
||||||
|
|
||||||
public Guid GroupTypeId { get; set; }
|
public Guid GroupTypeId { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Поле по которому групиируем, если тип - ГРУППА
|
/// Поле по которому групиируем, если тип - ГРУППА
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Guid? GroupingUnitFieldId { get; set; }
|
public Guid? GroupingUnitFieldId { get; init; }
|
||||||
|
|
||||||
public bool? IsGroupByResponsible { get; set; }
|
public bool? IsGroupByResponsible { get; init; }
|
||||||
|
|
||||||
public required string ShortDescription { get; set; }
|
public required string ShortDescription { get; init; }
|
||||||
|
|
||||||
public required string FullDescription { get; set; }
|
public required string FullDescription { get; init; }
|
||||||
|
|
||||||
public required string Solution { get; set; }
|
public required string Solution { get; init; }
|
||||||
|
|
||||||
public required string TemplateDuration { get; set; }
|
public required string TemplateDuration { get; init; }
|
||||||
|
|
||||||
public DateTimeOffset ReferenceDate { get; set; }
|
public DateTimeOffset ReferenceDate { get; init; }
|
||||||
|
|
||||||
public int? UserTimeZoneOffsetMinutes { get; set; }
|
public int? UserTimeZoneOffsetMinutes { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Использовать таймзону рабочей группы ответственного за ЭК шаблона
|
/// Использовать таймзону рабочей группы ответственного за ЭК шаблона
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsWorkGroupTimezone { get; set; }
|
public bool IsWorkGroupTimezone { get; init; }
|
||||||
|
|
||||||
public Guid ScheduleExcludeTypeId { get; set; }
|
public Guid ScheduleExcludeTypeId { get; init; }
|
||||||
|
|
||||||
public Guid? ScheduleExcludeTypeCalendarId { get; set; }
|
public Guid? ScheduleExcludeTypeCalendarId { get; init; }
|
||||||
|
|
||||||
public bool IsAutoDistributionEnabled { get; set; }
|
public bool IsAutoDistributionEnabled { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Настройки автораспределения
|
/// Настройки автораспределения
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DistributionConfigRequest? DistributionConfig { get; set; }
|
public DistributionConfigRequest? DistributionConfig { get; init; }
|
||||||
|
|
||||||
//public bool IsAgent { get; set; }
|
//public bool IsAgent { get; set; }
|
||||||
|
|
||||||
@@ -51,28 +51,35 @@
|
|||||||
|
|
||||||
//public string? AgentScript { get; set; }
|
//public string? AgentScript { get; set; }
|
||||||
|
|
||||||
public List<EsppSchValueRequest> Schedule { get; set; } = new List<EsppSchValueRequest>();
|
public List<EsppSchValueRequest> Schedule { get; init; } = new List<EsppSchValueRequest>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Настройки автоконтроля (возможны только в случае, если JobGroupType.IsJobGroupAutocontrol==true)
|
||||||
|
/// </summary>
|
||||||
|
public JobAutoControlRequest? AutoControl { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EsppSchValueRequest
|
public record EsppSchValueRequest
|
||||||
{
|
{
|
||||||
public Guid TypeValueId { get; set; }
|
public Guid TypeValueId { get; init; }
|
||||||
|
|
||||||
public Guid TypeConfigId { get; set; }
|
public Guid TypeConfigId { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DistributionConfigRequest
|
public record DistributionConfigRequest
|
||||||
{
|
{
|
||||||
public Guid DistributionPeriodId { get; set; }
|
public Guid DistributionPeriodId { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Исключать выходные и праздники
|
/// Исключать выходные и праздники
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsExcludeWeekends { get; set; }
|
public bool IsExcludeWeekends { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Группировать по рабочей группе
|
/// Группировать по рабочей группе
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsGroupingByWorkGroup { get; set; }
|
public bool IsGroupingByWorkGroup { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,79 +1,91 @@
|
|||||||
namespace PARR.API.Contracts.V1.Requests
|
namespace PARR.API.Contracts.V1.Requests
|
||||||
{
|
{
|
||||||
public class JobRequest
|
public record JobRequest
|
||||||
{
|
{
|
||||||
|
|
||||||
public required Guid TnkId { get; set; }
|
public required Guid TnkId { get; init; }
|
||||||
|
|
||||||
public required Guid GroupId { get; set; }
|
public required Guid GroupId { get; init; }
|
||||||
|
|
||||||
public required string Name { get; set; }
|
public required string Name { get; init; }
|
||||||
|
|
||||||
public int? MinValueRelationships { get; set; }
|
//public int? MinValueRelationships { get; init; }
|
||||||
|
|
||||||
public int? MaxValueRelationships { get; set; }
|
//public int? MaxValueRelationships { get; init; }
|
||||||
|
|
||||||
public bool? IsParentRelationships { get; set; }
|
//public bool? IsParentRelationships { get; init; }
|
||||||
|
|
||||||
public required string TemplateNameMask { get; set; }
|
public JobRelationships? Relationships { get; init; }
|
||||||
|
|
||||||
public required string WorkGroupMask { get; set; }
|
public required string TemplateNameMask { get; init; }
|
||||||
|
|
||||||
public required string WorkName { get; set; }
|
public required string WorkGroupMask { get; init; }
|
||||||
|
|
||||||
public required string ResponseAreaMask { get; set; }
|
public required string WorkName { get; init; }
|
||||||
|
|
||||||
#region AutoControl
|
public required string ResponseAreaMask { get; init; }
|
||||||
|
|
||||||
public bool IsEnableAutoControl { get; set; }
|
//#region AutoControl
|
||||||
|
|
||||||
public bool InitUsedTemplateState { get; set; }
|
//public bool IsEnableAutoControl { get; set; }
|
||||||
|
|
||||||
public bool InitUsedScheduleState { get; set; }
|
//public bool InitUsedTemplateState { get; set; }
|
||||||
|
|
||||||
#endregion
|
//public bool InitUsedScheduleState { get; set; }
|
||||||
|
|
||||||
public required List<UnitFilterRequest> UnitFilters { get; set; }
|
//#endregion
|
||||||
|
|
||||||
|
public JobAutoControlRequest? AutoControl { get; init; }
|
||||||
|
|
||||||
|
public required List<UnitFilterRequest> UnitFilters { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public record JobRelationships
|
||||||
|
{
|
||||||
|
public int MinValueRelationships { get; init; }
|
||||||
|
|
||||||
public class UnitFilterRequest
|
public int MaxValueRelationships { get; init; }
|
||||||
|
|
||||||
|
public bool IsParentRelationships { get; init; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public record UnitFilterRequest
|
||||||
{
|
{
|
||||||
///// <summary>
|
///// <summary>
|
||||||
///// Id = null в методе Create, в Update обязателен
|
///// Id = null в методе Create, в Update обязателен
|
||||||
///// </summary>
|
///// </summary>
|
||||||
//public Guid? Id { get; set; }
|
//public Guid? Id { get; set; }
|
||||||
|
|
||||||
public required string UnitFilterMask { get; set; }
|
public required string UnitFilterMask { get; init; }
|
||||||
|
|
||||||
public List<FieldFilterRequest>? FieldFilters { get; set; }
|
public List<FieldFilterRequest>? FieldFilters { get; init; }
|
||||||
|
|
||||||
public List<RelationshipFilterRequest>? RelationshipFilters { get; set; }
|
public List<RelationshipFilterRequest>? RelationshipFilters { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class FieldFilterRequest
|
public record FieldFilterRequest
|
||||||
{
|
{
|
||||||
|
|
||||||
public Guid FieldId { get; set; }
|
public Guid FieldId { get; init; }
|
||||||
|
|
||||||
public string? ValueMask { get; set; }
|
public string? ValueMask { get; init; }
|
||||||
|
|
||||||
public bool IsInverse { get; set; } = false;
|
public bool IsInverse { get; init; } = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class RelationshipFilterRequest
|
public record RelationshipFilterRequest
|
||||||
{
|
{
|
||||||
public Guid FieldId { get; set; }
|
public Guid FieldId { get; init; }
|
||||||
|
|
||||||
public bool? IsParent { get; set; }
|
public bool? IsParent { get; init; }
|
||||||
|
|
||||||
public string? ValueMask { get; set; }
|
public string? ValueMask { get; init; }
|
||||||
|
|
||||||
public bool? IsFullMatch { get; set; }
|
public bool? IsFullMatch { get; init; }
|
||||||
|
|
||||||
public bool? IsInverse { get; set; }
|
public bool? IsInverse { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,8 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsAutoDistributionEnabled { get; set; }
|
public bool IsAutoDistributionEnabled { get; set; }
|
||||||
|
|
||||||
|
public JobGroupAutoControlResponse? AutoControl { get; set; }
|
||||||
|
|
||||||
// public bool IsAgent { get; set; }
|
// public bool IsAgent { get; set; }
|
||||||
|
|
||||||
// public string? AgentName { get; set; }
|
// public string? AgentName { get; set; }
|
||||||
@@ -74,6 +76,15 @@
|
|||||||
//public JobGroupDistributionConfigResponse? DistributionConfig { get; set; }
|
//public JobGroupDistributionConfigResponse? DistributionConfig { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class JobGroupAutoControlResponse
|
||||||
|
{
|
||||||
|
public bool IsEnable { get; set; }
|
||||||
|
|
||||||
|
public bool InitUsedTemplateState { get; set; }
|
||||||
|
|
||||||
|
public bool InitUsedScheduleState { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class JobGroupScheduleResponse
|
public class JobGroupScheduleResponse
|
||||||
{
|
{
|
||||||
public string Timezone { get; set; } = string.Empty;
|
public string Timezone { get; set; } = string.Empty;
|
||||||
|
|||||||
@@ -2,14 +2,20 @@
|
|||||||
|
|
||||||
namespace PARR.API.Contracts.V1.Responses
|
namespace PARR.API.Contracts.V1.Responses
|
||||||
{
|
{
|
||||||
public class JobGroupTypeResponse
|
public record JobGroupTypeResponse
|
||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; init; }
|
||||||
|
|
||||||
public required JobGroupTypesEnum Code { get; set; }
|
public required JobGroupTypesEnum Code { get; init; }
|
||||||
|
|
||||||
public required string Name { get; set; }
|
public required string Name { get; init; }
|
||||||
|
|
||||||
public required string Description { get; set; }
|
public required string Description { get; init; }
|
||||||
|
|
||||||
|
public bool IsAllowJobUnitFilter { get; init; }
|
||||||
|
|
||||||
|
public bool IsJobGroupAutoControl { get; init; }
|
||||||
|
|
||||||
|
public bool IsRelationshipsAllowed { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class TemplateResponse : TemplateBaseResponse
|
public class TemplateResponse : TemplateBaseResponse
|
||||||
{
|
{
|
||||||
public required string Category { get; set; }
|
public required string Category { get; set; }
|
||||||
@@ -72,6 +71,42 @@
|
|||||||
|
|
||||||
public required string TemplateDuration { get; set; }
|
public required string TemplateDuration { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
#region Поля с примененнымм шорткодами
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Работа в ЕСПП (с примененными шорткодами)
|
||||||
|
/// </summary>
|
||||||
|
public string? WorkNameRendered { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Рабочая группа (с примененными шорткодами)
|
||||||
|
/// </summary>
|
||||||
|
public string? WorkGroupRendered { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ЗО (с примененными шорткодами)
|
||||||
|
/// </summary>
|
||||||
|
public string? ResponseAreaRendered { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Краткое описание (с примененными шорткодами)
|
||||||
|
/// </summary>
|
||||||
|
public string? ShortDescriptionRendered { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Подробное описание (с примененными шорткодами)
|
||||||
|
/// </summary>
|
||||||
|
public string? FullDescriptionRendered { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Решение (с примененными шорткодами)
|
||||||
|
/// </summary>
|
||||||
|
public string? SolutionRendered { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
public JobResponse? Job { get; set; }
|
public JobResponse? Job { get; set; }
|
||||||
|
|
||||||
public ProcessResponse? Process { get; set; }
|
public ProcessResponse? Process { get; set; }
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ using PARR.Core.Common.Helpers;
|
|||||||
using PARR.Core.Common.Interfaces.RabbitServices;
|
using PARR.Core.Common.Interfaces.RabbitServices;
|
||||||
using PARR.Core.Extensions;
|
using PARR.Core.Extensions;
|
||||||
using PARR.Core.Repositories.Interfaces;
|
using PARR.Core.Repositories.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.Core.Repositories.Interfaces.Unit;
|
using PARR.Core.Repositories.Interfaces.Unit;
|
||||||
using PARR.Core.Services.MatchingStatusService;
|
using PARR.Core.Services.MatchingStatusService;
|
||||||
using PARR.Core.Services.UnitFilterService;
|
using PARR.Core.Services.UnitFilterService;
|
||||||
@@ -24,7 +25,7 @@ using PARR.Domain.Common.Pagination;
|
|||||||
using PARR.Domain.Common.Rabbit.Messages;
|
using PARR.Domain.Common.Rabbit.Messages;
|
||||||
using PARR.Domain.Common.Roles;
|
using PARR.Domain.Common.Roles;
|
||||||
using PARR.Domain.Entities.Base.History;
|
using PARR.Domain.Entities.Base.History;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
|
|
||||||
namespace PARR.API.Controllers.V1
|
namespace PARR.API.Controllers.V1
|
||||||
@@ -35,46 +36,40 @@ namespace PARR.API.Controllers.V1
|
|||||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||||
public class JobController : BaseApiController
|
public class JobController : BaseApiController
|
||||||
{
|
{
|
||||||
private readonly ILogger<JobController> logger;
|
private readonly ILogger<JobController> _logger;
|
||||||
private readonly IMapper mapper;
|
private readonly IMapper _mapper;
|
||||||
private readonly IUriService uriService;
|
private readonly IUriService _uriService;
|
||||||
private readonly IJobRepository jobService;
|
private readonly IJobRepository _jobRepository;
|
||||||
private readonly ITemplateRepository templateService;
|
private readonly ITemplateRepository _templateRepository;
|
||||||
//private readonly IValidator<JobRequest> jobValidator;
|
private readonly IRabbitService _mqService;
|
||||||
private readonly IRabbitService mqService;
|
private readonly MqSettings _mqSettings;
|
||||||
private readonly MqSettings mqSettings;
|
private readonly IClientService _clientService;
|
||||||
private readonly IClientService clientService;
|
private readonly IMatchingStatusService _matchingStatusService;
|
||||||
private readonly IJobAutoControlRepository jobAutoControlService;
|
|
||||||
private readonly IMatchingStatusService matchingStatusService;
|
|
||||||
|
|
||||||
public JobController(
|
public JobController(
|
||||||
ILogger<JobController> logger,
|
ILogger<JobController> logger,
|
||||||
IMapper mapper,
|
IMapper mapper,
|
||||||
IUriService uriService,
|
IUriService uriService,
|
||||||
IJobRepository jobService,
|
IJobRepository jobRepository,
|
||||||
ITemplateRepository templateService,
|
ITemplateRepository templateRepository,
|
||||||
IJobGroupRepository jobGroupService,
|
IJobGroupRepository jobGroupRepository,
|
||||||
//IValidator<JobRequest> jobValidator,
|
IUnitFilterService unitFilterRepository,
|
||||||
IUnitFilterService unitFilterService,
|
IUnitRepository unitRepository,
|
||||||
IUnitRepository unitService,
|
|
||||||
IRabbitService mqService,
|
IRabbitService mqService,
|
||||||
MqSettings mqSettings,
|
MqSettings mqSettings,
|
||||||
IClientService clientService,
|
IClientService clientService,
|
||||||
IJobAutoControlRepository jobAutoControlService,
|
|
||||||
IMatchingStatusService matchingStatusService
|
IMatchingStatusService matchingStatusService
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
_logger = logger;
|
||||||
this.mapper = mapper;
|
_mapper = mapper;
|
||||||
this.uriService = uriService;
|
_uriService = uriService;
|
||||||
this.jobService = jobService;
|
_jobRepository = jobRepository;
|
||||||
this.templateService = templateService;
|
_templateRepository = templateRepository;
|
||||||
//this.jobValidator = jobValidator;
|
_mqService = mqService;
|
||||||
this.mqService = mqService;
|
_mqSettings = mqSettings;
|
||||||
this.mqSettings = mqSettings;
|
_clientService = clientService;
|
||||||
this.clientService = clientService;
|
_matchingStatusService = matchingStatusService;
|
||||||
this.jobAutoControlService = jobAutoControlService;
|
|
||||||
this.matchingStatusService = matchingStatusService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -84,18 +79,20 @@ namespace PARR.API.Controllers.V1
|
|||||||
[HttpGet(ApiRoutes.Job.GetAll)]
|
[HttpGet(ApiRoutes.Job.GetAll)]
|
||||||
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] JobQuery filter)
|
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] JobQuery filter)
|
||||||
{
|
{
|
||||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
var paginationFilter = _mapper.Map<PaginationFilter>(paginationQuery);
|
||||||
|
|
||||||
|
IQueryable<Job> query = _jobRepository.Get()
|
||||||
|
.Include(t => t.AutoControl);
|
||||||
|
|
||||||
IQueryable<Job> query = jobService.Get().Include(t => t.AutoControl);
|
|
||||||
|
|
||||||
query = query.OrderBy(t => t.Name);
|
query = query.OrderBy(t => t.Name);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(filter.Name))
|
if (!string.IsNullOrEmpty(filter.Name))
|
||||||
{
|
{
|
||||||
//query = query.Where(t => t.Name.ToLower().Contains(filter.Name.ToLower()));
|
//query = query.Where(t => t.Name.ToLower().Contains(filter.Name.ToLower()));
|
||||||
query = query.Where(t=>EF.Functions.Like(t.Name.ToLower(), SqlHelpers.RegexToLike(filter.Name)));
|
query = query.Where(t => EF.Functions.Like(t.Name.ToLower(), SqlHelpers.RegexToLike(filter.Name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (filter.GroupId.HasValue)
|
if (filter.GroupId.HasValue)
|
||||||
query = query.Where(t => t.GroupId == filter.GroupId.Value);
|
query = query.Where(t => t.GroupId == filter.GroupId.Value);
|
||||||
@@ -107,9 +104,10 @@ namespace PARR.API.Controllers.V1
|
|||||||
if (filter.IsFull)
|
if (filter.IsFull)
|
||||||
{
|
{
|
||||||
query = query
|
query = query
|
||||||
.Include(t => t.Tnk)
|
.Include(t => t.Tnk)
|
||||||
.Include(t => t.Group).ThenInclude(t => t.GroupType)
|
.Include(t => t.Group).ThenInclude(t => t.GroupType)
|
||||||
.Include(t => t.Group).ThenInclude(t => t.GroupingUnitField);
|
.Include(t => t.Group).ThenInclude(t => t.GroupingUnitField)
|
||||||
|
.Include(t => t.Group).ThenInclude(t => t.AutoControl);
|
||||||
|
|
||||||
query = query
|
query = query
|
||||||
.Include(t => t.UnitFilters)
|
.Include(t => t.UnitFilters)
|
||||||
@@ -120,12 +118,12 @@ namespace PARR.API.Controllers.V1
|
|||||||
.ThenInclude(t => t.UnitField);
|
.ThenInclude(t => t.UnitField);
|
||||||
}
|
}
|
||||||
|
|
||||||
var jobs = await jobService.GetPage(query, paginationFilter).ToListAsync();
|
var jobs = await _jobRepository.GetPage(query, paginationFilter).ToListAsync();
|
||||||
|
|
||||||
if (!jobs.Any())
|
if (!jobs.Any())
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
var response = mapper.Map<List<JobResponse>>(jobs);//TODO Migration to job
|
var response = _mapper.Map<List<JobResponse>>(jobs);//TODO Migration to job
|
||||||
|
|
||||||
foreach (var jobResponse in response)
|
foreach (var jobResponse in response)
|
||||||
{
|
{
|
||||||
@@ -152,9 +150,10 @@ namespace PARR.API.Controllers.V1
|
|||||||
[HttpGet(ApiRoutes.Job.Get)]
|
[HttpGet(ApiRoutes.Job.Get)]
|
||||||
public async Task<IActionResult> GetById([FromRoute] Guid id)
|
public async Task<IActionResult> GetById([FromRoute] Guid id)
|
||||||
{
|
{
|
||||||
var job = await jobService.Get()
|
var job = await _jobRepository.Get()
|
||||||
.Include(t => t.Tnk)
|
.Include(t => t.Tnk)
|
||||||
.Include(t => t.Group).ThenInclude(t => t.GroupType)
|
.Include(t => t.Group).ThenInclude(t => t.GroupType)
|
||||||
|
.Include(t => t.Group).ThenInclude(t => t.AutoControl)
|
||||||
.Include(t => t.Group).ThenInclude(t => t.GroupingUnitField)
|
.Include(t => t.Group).ThenInclude(t => t.GroupingUnitField)
|
||||||
.Include(t => t.UnitFilters)
|
.Include(t => t.UnitFilters)
|
||||||
.ThenInclude(t => t.FieldFilters)
|
.ThenInclude(t => t.FieldFilters)
|
||||||
@@ -168,7 +167,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
if (job == null)
|
if (job == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
var response = mapper.Map<JobResponse>(job);
|
var response = _mapper.Map<JobResponse>(job);
|
||||||
|
|
||||||
response.TemplatesCount = await GetCountTemplatesAsync(id); //await templateService.Get().CountAsync(t => t.JobId == id);
|
response.TemplatesCount = await GetCountTemplatesAsync(id); //await templateService.Get().CountAsync(t => t.JobId == id);
|
||||||
response.MatchingStatus = await GetMatchingStatusAsync(id);
|
response.MatchingStatus = await GetMatchingStatusAsync(id);
|
||||||
@@ -188,51 +187,56 @@ namespace PARR.API.Controllers.V1
|
|||||||
[HttpPost(ApiRoutes.Job.Create)]
|
[HttpPost(ApiRoutes.Job.Create)]
|
||||||
public async Task<IActionResult> Create([FromBody] JobRequest request)
|
public async Task<IActionResult> Create([FromBody] JobRequest request)
|
||||||
{
|
{
|
||||||
//#region Валидация
|
#region Проверка существования работы с такими же настройками связей параметрами
|
||||||
//var jobValidateResult = await jobValidator.ValidateAsync(request);//Валидация параметров самого задания
|
|
||||||
|
|
||||||
//if (!jobValidateResult.IsValid)
|
if (request.Relationships != null)
|
||||||
// return BadRequest(new Response(jobValidateResult.Errors));
|
{
|
||||||
//#endregion
|
//todo: не сильно правильный запрос, в нем проверяем полное совпадение, но не проверяем пересечения
|
||||||
|
var isExistTheSameLinks = await _jobRepository.Get()
|
||||||
|
//.Include(t => t.Group).ThenInclude(t => t.GroupType)
|
||||||
|
.AsNoTracking()
|
||||||
|
.CountAsync(t =>
|
||||||
|
//t.Group!.GroupType!.Code == JobGroupTypesEnum.Umbrella
|
||||||
|
//(t.Group!.GroupType!.Code == JobGroupTypesEnum.Umbrella || t.Group!.GroupType!.Code == JobGroupTypesEnum.Group) &&
|
||||||
|
t.Group!.GroupType!.IsRelationshipsAllowed &&
|
||||||
|
t.GroupId == request.GroupId &&
|
||||||
|
(t.MinValueRelationships == request.Relationships.MinValueRelationships ||
|
||||||
|
t.MaxValueRelationships == request.Relationships.MaxValueRelationships)
|
||||||
|
);
|
||||||
|
|
||||||
//TODO: !!!!!!! проверить, если тип ЗОНТИК или ГРУППИРОВКА, то обязательно должны быть заполнены поля min max
|
if (isExistTheSameLinks > 0)
|
||||||
|
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel {
|
||||||
#region Проверка существования работы с такими же параметрами
|
FieldName = nameof(request.Name),
|
||||||
|
Message = $"Работа с указанным диапазоном связей пересекается с уже имеющейся в базе данных({request.Relationships.MinValueRelationships}-{request.Relationships.MaxValueRelationships})"
|
||||||
var isExistTheSameLinks = await jobService.Get()
|
} }));
|
||||||
.Include(t => t.Group).ThenInclude(t => t.GroupType)
|
}
|
||||||
.CountAsync(t =>
|
|
||||||
//t.Group!.GroupType!.Code == JobGroupTypesEnum.Umbrella
|
|
||||||
(t.Group!.GroupType!.Code == JobGroupTypesEnum.Umbrella || t.Group!.GroupType!.Code == JobGroupTypesEnum.Group) &&
|
|
||||||
t.GroupId == request.GroupId &&
|
|
||||||
(t.MinValueRelationships == request.MinValueRelationships ||
|
|
||||||
t.MaxValueRelationships == request.MaxValueRelationships)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isExistTheSameLinks > 0)
|
|
||||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { FieldName = nameof(request.Name), Message = $"Работа с указанным диапазоном связей пересекается с уже имеющейся в базе данных({request.MinValueRelationships}-{request.MaxValueRelationships})" } }));
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
var job = mapper.Map<Job>(request);
|
var job = _mapper.Map<Job>(request);
|
||||||
|
|
||||||
job.AutoControl = new JobAutoControl
|
if (request.AutoControl != null)
|
||||||
{
|
{
|
||||||
JobId = job.Id,
|
// разрешен автоконтроль или нет, проверил в валидаторе
|
||||||
IsEnable = request.IsEnableAutoControl,
|
job.AutoControl = new JobAutoControl
|
||||||
InitUsedScheduleState = request.InitUsedScheduleState,
|
{
|
||||||
InitUsedTemplateState = request.InitUsedTemplateState
|
JobId = job.Id,
|
||||||
};
|
IsEnable = request.AutoControl.IsEnable,
|
||||||
|
InitUsedScheduleState = request.AutoControl.InitUsedScheduleState,
|
||||||
|
InitUsedTemplateState = request.AutoControl.InitUsedTemplateState
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (!await jobService.CreateAsync(job) || !await jobService.CommitAsync())
|
if (!await _jobRepository.CreateAsync(job) || !await _jobRepository.CommitAsync())
|
||||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при созании задания на выполнение работ" } }));
|
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при созании задания на выполнение работ" } }));
|
||||||
|
|
||||||
logger.LogInformation($"Пользователь {User.Identity?.Name} добавил задание на выполнение работ: {job.Id}, {job.Name}, {job.WorkName}");
|
_logger.LogInformation($"Пользователь {User.Identity?.Name} добавил задание на выполнение работ: {job.Id}, {job.Name}, {job.WorkName}");
|
||||||
|
|
||||||
var createdJob = await jobService.Get()
|
var createdJob = await _jobRepository.Get()
|
||||||
.Include(t => t.Tnk)
|
.Include(t => t.Tnk)
|
||||||
.Include(t => t.Group).ThenInclude(t => t.GroupType)
|
.Include(t => t.Group).ThenInclude(t => t.GroupType)
|
||||||
|
.Include(t => t.Group).ThenInclude(t => t.AutoControl)
|
||||||
.Include(t => t.Group).ThenInclude(t => t.GroupingUnitField)
|
.Include(t => t.Group).ThenInclude(t => t.GroupingUnitField)
|
||||||
.Include(t => t.UnitFilters)
|
.Include(t => t.UnitFilters)
|
||||||
.ThenInclude(t => t.FieldFilters)
|
.ThenInclude(t => t.FieldFilters)
|
||||||
@@ -242,9 +246,9 @@ namespace PARR.API.Controllers.V1
|
|||||||
.Include(t => t.AutoControl)
|
.Include(t => t.AutoControl)
|
||||||
.FirstOrDefaultAsync(t => t.Id == job.Id);
|
.FirstOrDefaultAsync(t => t.Id == job.Id);
|
||||||
|
|
||||||
var locationUri = uriService.GetUri(ApiRoutes.Job.Get, ApiRoutes.Job.getParam, createdJob!.Id);
|
var locationUri = _uriService.GetUri(ApiRoutes.Job.Get, ApiRoutes.Job.getParam, createdJob!.Id);
|
||||||
|
|
||||||
var response = mapper.Map<JobResponse>(createdJob);
|
var response = _mapper.Map<JobResponse>(createdJob);
|
||||||
// так как мы только что создали Job, то у него нет шаблонов, смело ставим = 0 (ускоряем запрос)
|
// так как мы только что создали Job, то у него нет шаблонов, смело ставим = 0 (ускоряем запрос)
|
||||||
response.TemplatesCount = 0;
|
response.TemplatesCount = 0;
|
||||||
response.MatchingStatus = await GetMatchingStatusAsync(response.Id);
|
response.MatchingStatus = await GetMatchingStatusAsync(response.Id);
|
||||||
@@ -262,11 +266,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
[HttpPut(ApiRoutes.Job.Update)]
|
[HttpPut(ApiRoutes.Job.Update)]
|
||||||
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] JobRequest request)
|
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] JobRequest request)
|
||||||
{
|
{
|
||||||
//var resultValidate = await jobValidator.ValidateAsync(request);
|
var orig = await _jobRepository.Get()
|
||||||
//if (!resultValidate.IsValid)
|
|
||||||
// return BadRequest(new Response(resultValidate.Errors));
|
|
||||||
|
|
||||||
var orig = await jobService.Get()
|
|
||||||
.Include(t => t.Tnk)
|
.Include(t => t.Tnk)
|
||||||
.Include(t => t.Group).ThenInclude(t => t.GroupType)
|
.Include(t => t.Group).ThenInclude(t => t.GroupType)
|
||||||
.Include(t => t.Group).ThenInclude(t => t.GroupingUnitField)
|
.Include(t => t.Group).ThenInclude(t => t.GroupingUnitField)
|
||||||
@@ -287,77 +287,77 @@ namespace PARR.API.Controllers.V1
|
|||||||
|
|
||||||
//TODO: ВОТ ЭТО ВООБЩЕ МЫ БУДЕМ ПРОВЕРЯТЬ, АААА???? - Проверка существования работы с такими же параметрами
|
//TODO: ВОТ ЭТО ВООБЩЕ МЫ БУДЕМ ПРОВЕРЯТЬ, АААА???? - Проверка существования работы с такими же параметрами
|
||||||
|
|
||||||
//TODO: !!!!!!! проверить, если тип ЗОНТИК или ГРУППИРОВКА, то обязательно должны быть заполнены поля min max
|
|
||||||
|
|
||||||
#region обновление полей задания на работу
|
#region обновление полей задания на работу
|
||||||
|
|
||||||
orig.Name = request.Name.Trim();
|
orig.Name = request.Name.Trim();
|
||||||
orig.WorkName = request.WorkName.Trim();
|
orig.WorkName = request.WorkName.Trim();
|
||||||
orig.MinValueRelationships = request.MinValueRelationships;
|
orig.MinValueRelationships = request.Relationships?.MinValueRelationships;
|
||||||
orig.MaxValueRelationships = request.MaxValueRelationships;
|
orig.MaxValueRelationships = request.Relationships?.MaxValueRelationships;
|
||||||
orig.IsParentRelationships = request.IsParentRelationships;
|
orig.IsParentRelationships = request.Relationships?.IsParentRelationships;
|
||||||
orig.TemplateNameMask = request.TemplateNameMask.Trim();
|
orig.TemplateNameMask = request.TemplateNameMask.Trim();
|
||||||
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.Trim();
|
orig.ResponseAreaMask = request.ResponseAreaMask.Trim();
|
||||||
|
|
||||||
if (orig.AutoControl != null)
|
#region Настройки автоконтроля
|
||||||
|
|
||||||
|
// валидатор проверяет корректность
|
||||||
|
if (request.AutoControl != null)
|
||||||
{
|
{
|
||||||
orig.AutoControl.IsEnable = request.IsEnableAutoControl;
|
// Создаем новую запись или обновляем существующую
|
||||||
orig.AutoControl.InitUsedScheduleState = request.InitUsedScheduleState;
|
if (orig.AutoControl != null)
|
||||||
orig.AutoControl.InitUsedTemplateState = request.InitUsedTemplateState;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// автоконтрол не загружен, проверяем есть ли он в бд, если нет, то создадим
|
|
||||||
var existAutoControl = await jobAutoControlService.Get().FirstOrDefaultAsync(t => t.JobId == id);
|
|
||||||
if (existAutoControl != null)
|
|
||||||
{
|
{
|
||||||
logger.LogError($"При обновлении job {id}, не загрузась связь с JobAutoControl, но она есть. Не стал обновлять Job, вернул ошибку.");
|
orig.AutoControl.IsEnable = request.AutoControl.IsEnable;
|
||||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Ошибка при изменении задания на выполнение работ." } }));
|
orig.AutoControl.InitUsedScheduleState = request.AutoControl.InitUsedScheduleState;
|
||||||
|
orig.AutoControl.InitUsedTemplateState = request.AutoControl.InitUsedTemplateState;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var autoControl = new JobAutoControl
|
orig.AutoControl = new JobAutoControl
|
||||||
{
|
{
|
||||||
JobId = id,
|
JobId = id,
|
||||||
InitUsedScheduleState = request.InitUsedScheduleState,
|
InitUsedScheduleState = request.AutoControl.InitUsedScheduleState,
|
||||||
InitUsedTemplateState = request.InitUsedTemplateState,
|
InitUsedTemplateState = request.AutoControl.InitUsedTemplateState,
|
||||||
IsEnable = request.IsEnableAutoControl
|
IsEnable = request.AutoControl.IsEnable
|
||||||
};
|
};
|
||||||
orig.AutoControl = autoControl;
|
|
||||||
logger.LogWarning($"При обновлении job {id}, отсутствовала запись в таблице JobAutoControl, создал ее. {autoControl.ToJson()}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Удаляем настройки, скорей всего автоконтролем управляет группа работ
|
||||||
|
orig.AutoControl = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
orig.DateModified = DateTimeOffset.UtcNow;
|
orig.DateModified = DateTimeOffset.UtcNow;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
var job = mapper.Map<Job>(request);
|
var job = _mapper.Map<Job>(request);
|
||||||
job.Id = id;//На всякий. Пусть будет для чистоты
|
job.Id = id;//На всякий. Пусть будет для чистоты
|
||||||
|
|
||||||
UpdateUnitFilters(orig, job);//Обновление вложенных дочерних элементов-фильтров
|
UpdateUnitFilters(orig, job);//Обновление вложенных дочерних элементов-фильтров
|
||||||
|
|
||||||
if (!await jobService.CommitAsync())
|
if (!await _jobRepository.CommitAsync())
|
||||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при изменении задания на выполнение работ." } }));
|
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при изменении задания на выполнение работ." } }));
|
||||||
|
|
||||||
// если изменили маску, отправим задание на переименование связанных шаблонов
|
// если изменили маску, отправим задание на переименование связанных шаблонов
|
||||||
if (isChangedTemplateNameMask)
|
if (isChangedTemplateNameMask)
|
||||||
{
|
{
|
||||||
var mqResult = await SendRequestToUpdateTemplates(id);
|
var mqResult = await SendRequestToUpdateTemplates(orig);
|
||||||
//todo: если ошибка. пользователя не предупреждаем... возможно ему это и не нужно знать...ну не переименуются шаблоны, может они переименуются позже...
|
//todo: если ошибка. пользователя не предупреждаем... возможно ему это и не нужно знать...ну не переименуются шаблоны, может они переименуются позже...
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.LogInformation($"Пользователь {User.Identity?.Name} обновил задание на выполнение работ: {orig.Id}," +
|
_logger.LogInformation($"Пользователь {User.Identity?.Name} обновил задание на выполнение работ: {orig.Id}," +
|
||||||
$" {orig.Name}, {orig.WorkName}, {orig.MinValueRelationships}, {orig.MaxValueRelationships}," +
|
$" {orig.Name}, {orig.WorkName}, {orig.MinValueRelationships}, {orig.MaxValueRelationships}," +
|
||||||
$" {orig.TemplateNameMask}, {orig.TnkId}, {nameof(orig.GroupId)}");
|
$" {orig.TemplateNameMask}, {orig.TnkId}, {nameof(orig.GroupId)}");
|
||||||
|
|
||||||
|
|
||||||
var updatedJob = await jobService.Get()
|
var updatedJob = await _jobRepository.Get()
|
||||||
.Include(t => t.Tnk)
|
.Include(t => t.Tnk)
|
||||||
.Include(t => t.Group).ThenInclude(t => t.GroupType)
|
.Include(t => t.Group).ThenInclude(t => t.GroupType)
|
||||||
|
.Include(t => t.Group).ThenInclude(t => t.AutoControl)
|
||||||
.Include(t => t.Group).ThenInclude(t => t.GroupingUnitField)
|
.Include(t => t.Group).ThenInclude(t => t.GroupingUnitField)
|
||||||
.Include(t => t.UnitFilters)
|
.Include(t => t.UnitFilters)
|
||||||
.ThenInclude(t => t.FieldFilters)
|
.ThenInclude(t => t.FieldFilters)
|
||||||
@@ -367,7 +367,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
.Include(t => t.AutoControl)
|
.Include(t => t.AutoControl)
|
||||||
.FirstAsync(t => t.Id == orig.Id);
|
.FirstAsync(t => t.Id == orig.Id);
|
||||||
|
|
||||||
var response = mapper.Map<JobResponse>(updatedJob);
|
var response = _mapper.Map<JobResponse>(updatedJob);
|
||||||
response.TemplatesCount = await GetCountTemplatesAsync(id); //await templateService.Get().CountAsync(t => t.JobId == id);
|
response.TemplatesCount = await GetCountTemplatesAsync(id); //await templateService.Get().CountAsync(t => t.JobId == id);
|
||||||
response.MatchingStatus = await GetMatchingStatusAsync(id);
|
response.MatchingStatus = await GetMatchingStatusAsync(id);
|
||||||
|
|
||||||
@@ -564,7 +564,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
[HttpDelete(ApiRoutes.Job.Delete)]
|
[HttpDelete(ApiRoutes.Job.Delete)]
|
||||||
public async Task<IActionResult> Delete([FromRoute] Guid id)
|
public async Task<IActionResult> Delete([FromRoute] Guid id)
|
||||||
{
|
{
|
||||||
var job = await jobService.Get().Include(t => t.Tnk)
|
var job = await _jobRepository.Get().Include(t => t.Tnk)
|
||||||
.FirstOrDefaultAsync(t => t.Id == id);
|
.FirstOrDefaultAsync(t => t.Id == id);
|
||||||
|
|
||||||
if (job == null)
|
if (job == null)
|
||||||
@@ -572,19 +572,19 @@ namespace PARR.API.Controllers.V1
|
|||||||
Message = $"Ошибка при удалении задания на выполнение работ. Не найдено задание на выполнение работ Id: {id}"
|
Message = $"Ошибка при удалении задания на выполнение работ. Не найдено задание на выполнение работ Id: {id}"
|
||||||
} }));
|
} }));
|
||||||
|
|
||||||
var templateCount = await templateService.Get().CountAsync(t => t.JobId == id);
|
var templateCount = await _templateRepository.Get().CountAsync(t => t.JobId == id);
|
||||||
|
|
||||||
if (templateCount > 0)
|
if (templateCount > 0)
|
||||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel {
|
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel {
|
||||||
Message = $"Ошибка при удалении задания на выполнение работ. С данным заданием связаны шаблоны: {templateCount} шт."
|
Message = $"Ошибка при удалении задания на выполнение работ. С данным заданием связаны шаблоны: {templateCount} шт."
|
||||||
} }));
|
} }));
|
||||||
|
|
||||||
if (!jobService.Delete(job) || !await jobService.CommitAsync())
|
if (!_jobRepository.Delete(job) || !await _jobRepository.CommitAsync())
|
||||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel {
|
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel {
|
||||||
Message = $"Ошибка при удалении задания на выполнение работ"
|
Message = $"Ошибка при удалении задания на выполнение работ"
|
||||||
} }));
|
} }));
|
||||||
|
|
||||||
logger.LogInformation($"Пользователь {User.Identity?.Name} удалил задание на выполнение работ: {job.Id},{job.Name}," +
|
_logger.LogInformation($"Пользователь {User.Identity?.Name} удалил задание на выполнение работ: {job.Id},{job.Name}," +
|
||||||
$" {job.WorkName}, {job.MinValueRelationships}, {job.MaxValueRelationships}," +
|
$" {job.WorkName}, {job.MinValueRelationships}, {job.MaxValueRelationships}," +
|
||||||
$" {job.TemplateNameMask}, {job.TnkId}, {job.GroupId}");
|
$" {job.TemplateNameMask}, {job.TnkId}, {job.GroupId}");
|
||||||
|
|
||||||
@@ -599,7 +599,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task<JobStatModel> GetStatisticsAsync(Guid jobId)
|
private async Task<JobStatModel> GetStatisticsAsync(Guid jobId)
|
||||||
{
|
{
|
||||||
var statResult = await jobService.Get()
|
var statResult = await _jobRepository.Get()
|
||||||
.Include(t => t.Templates)
|
.Include(t => t.Templates)
|
||||||
.ThenInclude(t => t.RobotConfigurations)
|
.ThenInclude(t => t.RobotConfigurations)
|
||||||
.Where(x => x.Id == jobId)
|
.Where(x => x.Id == jobId)
|
||||||
@@ -629,35 +629,53 @@ namespace PARR.API.Controllers.V1
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async Task<bool> SendRequestToUpdateTemplates(Guid jobId)
|
private async Task<bool> SendRequestToUpdateTemplates(Job job)
|
||||||
{
|
{
|
||||||
|
if (job.Group?.GroupType == null)
|
||||||
|
throw new ArgumentException("Не хватает include для job.Group.GroupType", nameof(job.Group.GroupType));
|
||||||
|
|
||||||
|
Guid Id = default;
|
||||||
|
SyncTaskEntityTypeEnum EntityType = default;
|
||||||
|
|
||||||
|
// Смотрим кто управляет автоконтролем, и какой объект можно синхронизировать
|
||||||
|
if (job.Group.GroupType.IsJobGroupAutoControl)
|
||||||
|
{
|
||||||
|
// Управляет JobGroup
|
||||||
|
Id = job.GroupId;
|
||||||
|
EntityType = SyncTaskEntityTypeEnum.JobGroup;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Управляет Job
|
||||||
|
Id = job.Id;
|
||||||
|
EntityType = SyncTaskEntityTypeEnum.Job;
|
||||||
|
}
|
||||||
|
|
||||||
var request = new TemplateMatcherMq
|
var request = new TemplateMatcherMq
|
||||||
{
|
{
|
||||||
Id = jobId,
|
Id = Id,
|
||||||
EntityType = SyncTaskEntityTypeEnum.Job,
|
EntityType = EntityType,
|
||||||
Action = TemplateMatcherActionEnum.Update,
|
Action = TemplateMatcherActionEnum.Update,
|
||||||
Initiator = new HistoryInitiator
|
Initiator = new HistoryInitiator
|
||||||
{
|
{
|
||||||
InitiatorIp = clientService.GetClientIp()?.ToString(),
|
InitiatorIp = _clientService.GetClientIp()?.ToString(),
|
||||||
InitiatorParrComponentId = ParrComponentsEnum.Api,
|
InitiatorParrComponentId = ParrComponentsEnum.Api,
|
||||||
InitiatorComment = $"В GUI изменено имя шаблона, при сохранении Job отправлен запрос на обновление связанных шаблонов"
|
InitiatorComment = $"В GUI изменено имя шаблона, при сохранении Job отправлен запрос на обновление связанных шаблонов"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//var msg = JsonSerializer.Serialize(request);
|
var result = await _mqService.SendAsync(_mqSettings.TemplatesMatcher, new List<object> { request });
|
||||||
|
|
||||||
//var result = await mqService.SendAsync(mqSettings.TemplatesMatcher, new[] { msg });
|
_logger.LogDebug("Получен код отпрвки: {IsSuccess}", result.IsSuccess);
|
||||||
var result = await mqService.SendAsync(mqSettings.TemplatesMatcher, new List<object> { request });
|
|
||||||
|
|
||||||
logger.LogDebug("Получен код отпрвки: {IsSuccess}", result.IsSuccess);
|
|
||||||
|
|
||||||
if (!result.IsSuccess)
|
if (!result.IsSuccess)
|
||||||
{
|
{
|
||||||
logger.LogError($"Ошибка при отправке запроса в очередь на обновление связанных шаблонов, после обновления маски шаблона. {request.ToJson()}");
|
_logger.LogError($"Ошибка при отправке запроса в очередь на обновление связанных шаблонов, после обновления маски шаблона. {request.ToJson()}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.LogInformation($"После изменения маски шаблона в jobId: {jobId}, отправлен запрос в очередь на переименование связанных шаблонов: {request.ToJson()}");
|
_logger.LogInformation($"После изменения маски шаблона в jobId: {job.Id}, отправлен запрос в очередь на переименование связанных шаблонов: {request.ToJson()}");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -671,7 +689,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
private async Task<int> GetCountTemplatesAsync(Guid jobId)
|
private async Task<int> GetCountTemplatesAsync(Guid jobId)
|
||||||
{
|
{
|
||||||
// Получаем только шаблоны в статусе used
|
// Получаем только шаблоны в статусе used
|
||||||
return await templateService.Get().CountAsync(t => t.JobId == jobId && t.StatusTypeId == TemplateStatusTypeEnum.Used);
|
return await _templateRepository.Get().CountAsync(t => t.JobId == jobId && t.StatusTypeId == TemplateStatusTypeEnum.Used);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -681,9 +699,9 @@ namespace PARR.API.Controllers.V1
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task<MatchingStatusResponse?> GetMatchingStatusAsync(Guid jobId)
|
private async Task<MatchingStatusResponse?> GetMatchingStatusAsync(Guid jobId)
|
||||||
{
|
{
|
||||||
var statusMatching = await matchingStatusService.GetStatusAsync(jobId, SyncTaskEntityTypeEnum.Job);
|
var statusMatching = await _matchingStatusService.GetStatusAsync(jobId, SyncTaskEntityTypeEnum.Job);
|
||||||
|
|
||||||
return mapper.Map<MatchingStatusResponse>(statusMatching);
|
return _mapper.Map<MatchingStatusResponse>(statusMatching);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ using PARR.API.Services.Interfaces;
|
|||||||
using PARR.API.Settings;
|
using PARR.API.Settings;
|
||||||
using PARR.Core.Common.Helpers;
|
using PARR.Core.Common.Helpers;
|
||||||
using PARR.Core.Common.Interfaces.RabbitServices;
|
using PARR.Core.Common.Interfaces.RabbitServices;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.Core.Repositories.Interfaces.Schedule;
|
using PARR.Core.Repositories.Interfaces.Schedule;
|
||||||
using PARR.Core.Services.MatchingStatusService;
|
using PARR.Core.Services.MatchingStatusService;
|
||||||
using PARR.Domain.Common.Pagination;
|
using PARR.Domain.Common.Pagination;
|
||||||
@@ -33,63 +34,64 @@ namespace PARR.API.Controllers.V1
|
|||||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||||
public class JobGroupController : BaseApiController
|
public class JobGroupController : BaseApiController
|
||||||
{
|
{
|
||||||
private readonly ILogger<JobController> logger;
|
private readonly ILogger<JobController> _logger;
|
||||||
private readonly IMapper mapper;
|
private readonly IMapper _mapper;
|
||||||
private readonly IUriService uriService;
|
private readonly IUriService _uriService;
|
||||||
private readonly IJobGroupRepository groupService;
|
private readonly IJobGroupRepository _groupRepository;
|
||||||
private readonly IJobRepository jobService;
|
private readonly IJobRepository _jobRepository;
|
||||||
private readonly IEsppSchTypeConfigRepository esppConfigService;
|
private readonly IEsppSchTypeConfigRepository _esppConfigRepository;
|
||||||
//private readonly IValidator<JobGroupRequest> validator;
|
private readonly IJobGroupTypeRepository _jobGroupTypeRepository;
|
||||||
private readonly IJobGroupTypeRepository jobGroupTypeService;
|
private readonly IMatchingStatusService _matchingStatusRepository;
|
||||||
private readonly IMatchingStatusService matchingStatusService;
|
private readonly IScheduleResponseAreaTimeOffsetRepository _scheduleResponseAreaTimeOffsetRepository;
|
||||||
private readonly IScheduleResponseAreaTimeOffsetRepository scheduleResponseAreaTimeOffsetService;
|
private readonly IJobAutoControlRepository _jobAutoControlRepository;
|
||||||
private readonly IRabbitService mqService;
|
private readonly IRabbitService _mqService;
|
||||||
private readonly MqSettings mqSettings;
|
private readonly MqSettings _mqSettings;
|
||||||
|
|
||||||
public JobGroupController(
|
public JobGroupController(
|
||||||
ILogger<JobController> logger,
|
ILogger<JobController> logger,
|
||||||
IMapper mapper,
|
IMapper mapper,
|
||||||
IUriService uriService,
|
IUriService uriService,
|
||||||
IJobGroupRepository groupService,
|
IJobGroupRepository groupRepository,
|
||||||
IJobRepository jobService,
|
IJobRepository jobRepository,
|
||||||
IEsppSchTypeConfigRepository esppConfigService,
|
IEsppSchTypeConfigRepository esppConfigRepository,
|
||||||
//IValidator<JobGroupRequest> validator,
|
IJobGroupTypeRepository jobGroupTypeRepository,
|
||||||
IJobGroupTypeRepository jobGroupTypeService,
|
IMatchingStatusService matchingStatusRepository,
|
||||||
IMatchingStatusService matchingStatusService,
|
IScheduleResponseAreaTimeOffsetRepository scheduleResponseAreaTimeOffsetRepository,
|
||||||
IScheduleResponseAreaTimeOffsetRepository scheduleResponseAreaTimeOffsetService,
|
IJobAutoControlRepository jobAutoControlRepository,
|
||||||
IRabbitService mqService,
|
IRabbitService mqService,
|
||||||
MqSettings mqSettings
|
MqSettings mqSettings
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this._logger = logger;
|
||||||
this.mapper = mapper;
|
this._mapper = mapper;
|
||||||
this.uriService = uriService;
|
this._uriService = uriService;
|
||||||
this.groupService = groupService;
|
_groupRepository = groupRepository;
|
||||||
this.jobService = jobService;
|
_jobRepository = jobRepository;
|
||||||
this.esppConfigService = esppConfigService;
|
_esppConfigRepository = esppConfigRepository;
|
||||||
//this.validator = validator;
|
_jobGroupTypeRepository = jobGroupTypeRepository;
|
||||||
this.jobGroupTypeService = jobGroupTypeService;
|
_matchingStatusRepository = matchingStatusRepository;
|
||||||
this.matchingStatusService = matchingStatusService;
|
_scheduleResponseAreaTimeOffsetRepository = scheduleResponseAreaTimeOffsetRepository;
|
||||||
this.scheduleResponseAreaTimeOffsetService = scheduleResponseAreaTimeOffsetService;
|
_jobAutoControlRepository = jobAutoControlRepository;
|
||||||
this.mqService = mqService;
|
this._mqService = mqService;
|
||||||
this.mqSettings = mqSettings;
|
this._mqSettings = mqSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить список групп заданий на выполнение работ постранично
|
/// Получить список групп работ постранично
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet(ApiRoutes.JobGroup.GetAll)]
|
[HttpGet(ApiRoutes.JobGroup.GetAll)]
|
||||||
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] JobGroupQuery filter)
|
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] JobGroupQuery filter)
|
||||||
{
|
{
|
||||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
var paginationFilter = _mapper.Map<PaginationFilter>(paginationQuery);
|
||||||
|
|
||||||
IQueryable<JobGroup> query = groupService.Get()
|
IQueryable<JobGroup> query = _groupRepository.Get()
|
||||||
.Include(t => t.GroupType)
|
.Include(t => t.GroupType)
|
||||||
.Include(t => t.GroupingUnitField)
|
.Include(t => t.GroupingUnitField)
|
||||||
.Include(t => t.ScheduleExcludeType)
|
.Include(t => t.ScheduleExcludeType)
|
||||||
.Include(t => t.ScheduleExcludeTypeCalendar);
|
.Include(t => t.ScheduleExcludeTypeCalendar)
|
||||||
|
.Include(t => t.AutoControl);
|
||||||
|
|
||||||
query = query.OrderBy(t => t.GroupName);
|
query = query.OrderBy(t => t.GroupName);
|
||||||
|
|
||||||
@@ -104,12 +106,12 @@ namespace PARR.API.Controllers.V1
|
|||||||
.Include(t => t.Jobs).ThenInclude(t => t.Tnk)
|
.Include(t => t.Jobs).ThenInclude(t => t.Tnk)
|
||||||
.Include(t => t.DistributionConfig).ThenInclude(t => t.DistributionPeriod);
|
.Include(t => t.DistributionConfig).ThenInclude(t => t.DistributionPeriod);
|
||||||
|
|
||||||
var jobGroups = await groupService.GetPage(query, paginationFilter).ToListAsync();
|
var jobGroups = await _groupRepository.GetPage(query, paginationFilter).ToListAsync();
|
||||||
|
|
||||||
if (!jobGroups.Any())
|
if (!jobGroups.Any())
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
var response = mapper.Map<List<JobGroupResponse>>(jobGroups);
|
var response = _mapper.Map<List<JobGroupResponse>>(jobGroups);
|
||||||
|
|
||||||
if (filter.IsFull)
|
if (filter.IsFull)
|
||||||
foreach (var jobGroupResponse in response)
|
foreach (var jobGroupResponse in response)
|
||||||
@@ -122,26 +124,27 @@ namespace PARR.API.Controllers.V1
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить группу заданий на выполнение работ по id
|
/// Получить группу работ по id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet(ApiRoutes.JobGroup.Get)]
|
[HttpGet(ApiRoutes.JobGroup.Get)]
|
||||||
public async Task<IActionResult> GetById([FromRoute] Guid id)
|
public async Task<IActionResult> GetById([FromRoute] Guid id)
|
||||||
{
|
{
|
||||||
var jobGroup = await groupService.Get()
|
var jobGroup = await _groupRepository.Get()
|
||||||
.Include(t => t.Jobs).ThenInclude(t => t.Tnk)
|
.Include(t => t.Jobs).ThenInclude(t => t.Tnk)
|
||||||
.Include(t => t.GroupType)
|
.Include(t => t.GroupType)
|
||||||
.Include(t => t.GroupingUnitField)
|
.Include(t => t.GroupingUnitField)
|
||||||
.Include(t => t.ScheduleExcludeType)
|
.Include(t => t.ScheduleExcludeType)
|
||||||
.Include(t => t.ScheduleExcludeTypeCalendar)
|
.Include(t => t.ScheduleExcludeTypeCalendar)
|
||||||
.Include(t => t.DistributionConfig).ThenInclude(t => t.DistributionPeriod)
|
.Include(t => t.DistributionConfig).ThenInclude(t => t.DistributionPeriod)
|
||||||
|
.Include(t => t.AutoControl)
|
||||||
.FirstOrDefaultAsync(t => t.Id == id);
|
.FirstOrDefaultAsync(t => t.Id == id);
|
||||||
|
|
||||||
if (jobGroup == null)
|
if (jobGroup == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
var response = mapper.Map<JobGroupResponse>(jobGroup);
|
var response = _mapper.Map<JobGroupResponse>(jobGroup);
|
||||||
await AppendMissingDataAsync(response);
|
await AppendMissingDataAsync(response);
|
||||||
|
|
||||||
return Ok(new Response<JobGroupResponse>(response, true));
|
return Ok(new Response<JobGroupResponse>(response, true));
|
||||||
@@ -149,18 +152,13 @@ namespace PARR.API.Controllers.V1
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Создать группу заданий на выполнение работ (JobGroup)
|
/// Создать группу работ (JobGroup)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost(ApiRoutes.JobGroup.Create)]
|
[HttpPost(ApiRoutes.JobGroup.Create)]
|
||||||
public async Task<IActionResult> Create([FromBody] JobGroupRequest request)
|
public async Task<IActionResult> Create([FromBody] JobGroupRequest request)
|
||||||
{
|
{
|
||||||
//var resultValidate = await validator.ValidateAsync(request);
|
|
||||||
|
|
||||||
//if (!resultValidate.IsValid)
|
|
||||||
// return BadRequest(new Response(resultValidate.Errors));
|
|
||||||
|
|
||||||
var jobGroup = new JobGroup
|
var jobGroup = new JobGroup
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
@@ -191,7 +189,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
// на всякий проверим, но вообще это проверяется в валидаторе
|
// на всякий проверим, но вообще это проверяется в валидаторе
|
||||||
if (request.DistributionConfig == null)
|
if (request.DistributionConfig == null)
|
||||||
{
|
{
|
||||||
logger.LogError("Ошибка при создании группы работ '{name}', отсутствуют настройки автораспределения", request.Name);
|
_logger.LogError("Ошибка при создании группы работ '{name}', отсутствуют настройки автораспределения", request.Name);
|
||||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при создании группы заданий на выполнение работ" } }));
|
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при создании группы заданий на выполнение работ" } }));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,6 +197,22 @@ namespace PARR.API.Controllers.V1
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Настройки автоконтроля
|
||||||
|
|
||||||
|
// Корректность проверяется в валидаторе
|
||||||
|
if (request.AutoControl != null)
|
||||||
|
{
|
||||||
|
jobGroup.AutoControl = new JobGroupAutoControl
|
||||||
|
{
|
||||||
|
InitUsedScheduleState = request.AutoControl.InitUsedScheduleState,
|
||||||
|
InitUsedTemplateState = request.AutoControl.InitUsedTemplateState,
|
||||||
|
IsEnable = request.AutoControl.IsEnable,
|
||||||
|
JobGroupId = jobGroup.Id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
//Добавляем настройки планировщика
|
//Добавляем настройки планировщика
|
||||||
request.Schedule.ForEach(item =>
|
request.Schedule.ForEach(item =>
|
||||||
{
|
{
|
||||||
@@ -210,23 +224,24 @@ namespace PARR.API.Controllers.V1
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!await groupService.CreateAsync(jobGroup) || !await groupService.CommitAsync())
|
if (!await _groupRepository.CreateAsync(jobGroup) || !await _groupRepository.CommitAsync())
|
||||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при создании группы заданий на выполнение работ" } }));
|
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при создании группы заданий на выполнение работ" } }));
|
||||||
|
|
||||||
logger.LogInformation($"Пользователь {User.Identity?.Name} добавил группу заданий на выполнение работ: {jobGroup.Id}, {jobGroup.GroupName}, {jobGroup.ShortDescription}");
|
_logger.LogInformation($"Пользователь {User.Identity?.Name} добавил группу заданий на выполнение работ: {jobGroup.Id}, {jobGroup.GroupName}, {jobGroup.ShortDescription}");
|
||||||
|
|
||||||
|
|
||||||
var createdJobGroup = await groupService.Get().Include(t => t.Jobs).ThenInclude(t => t.Tnk)
|
var createdJobGroup = await _groupRepository.Get().Include(t => t.Jobs).ThenInclude(t => t.Tnk)
|
||||||
.Include(t => t.GroupType)
|
.Include(t => t.GroupType)
|
||||||
.Include(t => t.GroupingUnitField)
|
.Include(t => t.GroupingUnitField)
|
||||||
.Include(t => t.ScheduleExcludeType)
|
.Include(t => t.ScheduleExcludeType)
|
||||||
.Include(t => t.ScheduleExcludeTypeCalendar)
|
.Include(t => t.ScheduleExcludeTypeCalendar)
|
||||||
.Include(t => t.DistributionConfig).ThenInclude(t => t.DistributionPeriod)
|
.Include(t => t.DistributionConfig).ThenInclude(t => t.DistributionPeriod)
|
||||||
|
.Include(t => t.AutoControl)
|
||||||
.FirstAsync(t => t.Id == jobGroup.Id);
|
.FirstAsync(t => t.Id == jobGroup.Id);
|
||||||
|
|
||||||
var locationUri = uriService.GetUri(ApiRoutes.JobGroup.Get, ApiRoutes.JobGroup.getParam, createdJobGroup.Id);
|
var locationUri = _uriService.GetUri(ApiRoutes.JobGroup.Get, ApiRoutes.JobGroup.getParam, createdJobGroup.Id);
|
||||||
|
|
||||||
var response = mapper.Map<JobGroupResponse>(createdJobGroup);
|
var response = _mapper.Map<JobGroupResponse>(createdJobGroup);
|
||||||
await AppendMissingDataAsync(response);
|
await AppendMissingDataAsync(response);
|
||||||
|
|
||||||
return Created(locationUri, new Response<JobGroupResponse>(response, true));
|
return Created(locationUri, new Response<JobGroupResponse>(response, true));
|
||||||
@@ -234,7 +249,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обновить группу заданий на выполнение работ (JobGroup)
|
/// Обновить группу работ (JobGroup)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
@@ -242,15 +257,11 @@ namespace PARR.API.Controllers.V1
|
|||||||
[HttpPut(ApiRoutes.JobGroup.Update)]
|
[HttpPut(ApiRoutes.JobGroup.Update)]
|
||||||
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] JobGroupRequest request)
|
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] JobGroupRequest request)
|
||||||
{
|
{
|
||||||
//var resultValidate = await validator.ValidateAsync(request);
|
var orig = await _groupRepository.Get()
|
||||||
|
|
||||||
//if (!resultValidate.IsValid)
|
|
||||||
// return BadRequest(new Response(resultValidate.Errors));
|
|
||||||
|
|
||||||
var orig = await groupService.Get()
|
|
||||||
.Include(t => t.Jobs)
|
.Include(t => t.Jobs)
|
||||||
.ThenInclude(t => t.Tnk)
|
.ThenInclude(t => t.Tnk)
|
||||||
.Include(t => t.EsppSchValues)
|
.Include(t => t.EsppSchValues)
|
||||||
|
.Include(t => t.AutoControl)
|
||||||
.Include(t => t.DistributionConfig).ThenInclude(t => t.DistributionPeriod)
|
.Include(t => t.DistributionConfig).ThenInclude(t => t.DistributionPeriod)
|
||||||
.FirstOrDefaultAsync(t => t.Id == id);
|
.FirstOrDefaultAsync(t => t.Id == id);
|
||||||
|
|
||||||
@@ -287,7 +298,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
{
|
{
|
||||||
if (request.DistributionConfig == null)
|
if (request.DistributionConfig == null)
|
||||||
{
|
{
|
||||||
logger.LogError("Ошибка при изменении группы работ '{name}', отсутствуют настройки автораспределения", request.Name);
|
_logger.LogError("Ошибка при изменении группы работ '{name}', отсутствуют настройки автораспределения", request.Name);
|
||||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при изменении группы заданий на выполнение работ" } }));
|
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при изменении группы заданий на выполнение работ" } }));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,12 +320,50 @@ namespace PARR.API.Controllers.V1
|
|||||||
// удаляем настройки распределения если они были
|
// удаляем настройки распределения если они были
|
||||||
if (orig.DistributionConfig != null)
|
if (orig.DistributionConfig != null)
|
||||||
{
|
{
|
||||||
groupService.DeleteDistributionConfig(orig.DistributionConfig);
|
_groupRepository.DeleteDistributionConfig(orig.DistributionConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Настройки автоконтроля
|
||||||
|
|
||||||
|
// валидатор проверяет корректность
|
||||||
|
if (request.AutoControl != null)
|
||||||
|
{
|
||||||
|
// автоконтролем управляет JobGroup
|
||||||
|
if (orig.AutoControl != null)
|
||||||
|
{
|
||||||
|
// обновляем
|
||||||
|
orig.AutoControl.IsEnable = request.AutoControl.IsEnable;
|
||||||
|
orig.AutoControl.InitUsedScheduleState = request.AutoControl.InitUsedScheduleState;
|
||||||
|
orig.AutoControl.InitUsedTemplateState = request.AutoControl.InitUsedTemplateState;
|
||||||
|
// удалить настройки автоконтроля для job
|
||||||
|
await RemoveJobAutoControlSettingsAsync(orig.Id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// создаем новую запись
|
||||||
|
orig.AutoControl = new JobGroupAutoControl
|
||||||
|
{
|
||||||
|
InitUsedScheduleState = request.AutoControl.InitUsedScheduleState,
|
||||||
|
InitUsedTemplateState = request.AutoControl.InitUsedTemplateState,
|
||||||
|
IsEnable = request.AutoControl.IsEnable,
|
||||||
|
JobGroupId = orig.Id
|
||||||
|
};
|
||||||
|
// удалить настройки автоконтроля для job
|
||||||
|
await RemoveJobAutoControlSettingsAsync(orig.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// автоконтролем управляет каждый job отдельно
|
||||||
|
// удаляем настройки, если они были
|
||||||
|
orig.AutoControl = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
//обновляем планировщик
|
//обновляем планировщик
|
||||||
orig.EsppSchValues.Clear();
|
orig.EsppSchValues.Clear();
|
||||||
request.Schedule.ForEach(item =>
|
request.Schedule.ForEach(item =>
|
||||||
@@ -327,10 +376,10 @@ namespace PARR.API.Controllers.V1
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!await groupService.CommitAsync())
|
if (!await _groupRepository.CommitAsync())
|
||||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при изменении группы заданий на выполнение работ." } }));
|
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при изменении группы заданий на выполнение работ." } }));
|
||||||
|
|
||||||
logger.LogInformation($"Пользователь {User.Identity?.Name} обновил группу заданий на выполнение работ: {orig.Id}," +
|
_logger.LogInformation($"Пользователь {User.Identity?.Name} обновил группу заданий на выполнение работ: {orig.Id}," +
|
||||||
$" {orig.GroupName}, {orig.ShortDescription}, {orig.FullDescription}," +
|
$" {orig.GroupName}, {orig.ShortDescription}, {orig.FullDescription}," +
|
||||||
$" {orig.Solution}, {orig.TemplateDuration}, {orig.ReferenceDate}, {orig.IsAutoDistributionEnabled}" +
|
$" {orig.Solution}, {orig.TemplateDuration}, {orig.ReferenceDate}, {orig.IsAutoDistributionEnabled}" +
|
||||||
$", {orig.IsAgent}, {orig.AgentName}, {orig.AgentTimeOutSec}, {orig.AgentScript}");
|
$", {orig.IsAgent}, {orig.AgentName}, {orig.AgentTimeOutSec}, {orig.AgentScript}");
|
||||||
@@ -345,17 +394,17 @@ namespace PARR.API.Controllers.V1
|
|||||||
JobGroupId = id,
|
JobGroupId = id,
|
||||||
Initiator = new HistoryInitiator { InitiatorComment = "Изменилось расписание группы работ в ГУИ, отправлен запрос на перерасчет nextRun", InitiatorParrComponentId = ParrComponentsEnum.Api }
|
Initiator = new HistoryInitiator { InitiatorComment = "Изменилось расписание группы работ в ГУИ, отправлен запрос на перерасчет nextRun", InitiatorParrComponentId = ParrComponentsEnum.Api }
|
||||||
};
|
};
|
||||||
var sendResult = await mqService.SendAsync(mqSettings.NextRun, new List<object> { requestToMq });
|
var sendResult = await _mqService.SendAsync(_mqSettings.NextRun, new List<object> { requestToMq });
|
||||||
|
|
||||||
if (sendResult.IsSuccess)
|
if (sendResult.IsSuccess)
|
||||||
logger.LogInformation("Задание на перерасчет NextRun успешно отправлено в очередь MQ {queueName}", mqSettings.NextRun.QueueName);
|
_logger.LogInformation("Задание на перерасчет NextRun успешно отправлено в очередь MQ {queueName}", _mqSettings.NextRun.QueueName);
|
||||||
else
|
else
|
||||||
logger.LogError("Ошибка при отправке задания на перерасчет NextRun в очередь MQ {queueName}", mqSettings.NextRun.QueueName);
|
_logger.LogError("Ошибка при отправке задания на перерасчет NextRun в очередь MQ {queueName}", _mqSettings.NextRun.QueueName);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
var updatedJobGroup = await groupService.Get()
|
var updatedJobGroup = await _groupRepository.Get()
|
||||||
.Include(t => t.Jobs)
|
.Include(t => t.Jobs)
|
||||||
.ThenInclude(t => t.Tnk)
|
.ThenInclude(t => t.Tnk)
|
||||||
.Include(t => t.GroupType)
|
.Include(t => t.GroupType)
|
||||||
@@ -363,9 +412,10 @@ namespace PARR.API.Controllers.V1
|
|||||||
.Include(t => t.ScheduleExcludeType)
|
.Include(t => t.ScheduleExcludeType)
|
||||||
.Include(t => t.ScheduleExcludeTypeCalendar)
|
.Include(t => t.ScheduleExcludeTypeCalendar)
|
||||||
.Include(t => t.DistributionConfig).ThenInclude(t => t.DistributionPeriod)
|
.Include(t => t.DistributionConfig).ThenInclude(t => t.DistributionPeriod)
|
||||||
|
.Include(t => t.AutoControl)
|
||||||
.FirstAsync(t => t.Id == orig.Id);
|
.FirstAsync(t => t.Id == orig.Id);
|
||||||
|
|
||||||
var response = mapper.Map<JobGroupResponse>(updatedJobGroup);
|
var response = _mapper.Map<JobGroupResponse>(updatedJobGroup);
|
||||||
await AppendMissingDataAsync(response);
|
await AppendMissingDataAsync(response);
|
||||||
|
|
||||||
return Ok(new Response<JobGroupResponse>(response, true));
|
return Ok(new Response<JobGroupResponse>(response, true));
|
||||||
@@ -373,14 +423,14 @@ namespace PARR.API.Controllers.V1
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удалить группу заданий на выполнение работ (только если нет связанных заданий)
|
/// Удалить группу работ (только если нет связанных работ)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpDelete(ApiRoutes.JobGroup.Delete)]
|
[HttpDelete(ApiRoutes.JobGroup.Delete)]
|
||||||
public async Task<IActionResult> Delete([FromRoute] Guid id)
|
public async Task<IActionResult> Delete([FromRoute] Guid id)
|
||||||
{
|
{
|
||||||
var jobGroup = await groupService.Get()
|
var jobGroup = await _groupRepository.Get()
|
||||||
.FirstOrDefaultAsync(t => t.Id == id);
|
.FirstOrDefaultAsync(t => t.Id == id);
|
||||||
|
|
||||||
if (jobGroup == null)
|
if (jobGroup == null)
|
||||||
@@ -388,18 +438,18 @@ namespace PARR.API.Controllers.V1
|
|||||||
Message = $"Ошибка при удалении группы заданий на выполнение работ. Не найдена группа заданий на выполнение работ Id: {id}"
|
Message = $"Ошибка при удалении группы заданий на выполнение работ. Не найдена группа заданий на выполнение работ Id: {id}"
|
||||||
} }));
|
} }));
|
||||||
|
|
||||||
var jobCount = await jobService.Get().CountAsync(t => t.GroupId == id);
|
var jobCount = await _jobRepository.Get().CountAsync(t => t.GroupId == id);
|
||||||
if (jobCount > 0)
|
if (jobCount > 0)
|
||||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel {
|
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel {
|
||||||
Message = $"Ошибка при удалении группы заданий на выполнение работ. С данным группой связаны задания: {jobCount} шт."
|
Message = $"Ошибка при удалении группы заданий на выполнение работ. С данным группой связаны задания: {jobCount} шт."
|
||||||
} }));
|
} }));
|
||||||
|
|
||||||
if (!groupService.Delete(jobGroup) || !await groupService.CommitAsync())
|
if (!_groupRepository.Delete(jobGroup) || !await _groupRepository.CommitAsync())
|
||||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel {
|
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel {
|
||||||
Message = $"Ошибка при удалении группы заданий на выполнение работ"
|
Message = $"Ошибка при удалении группы заданий на выполнение работ"
|
||||||
} }));
|
} }));
|
||||||
|
|
||||||
logger.LogInformation($"Пользователь {User.Identity?.Name} удалил группу заданий на выполнение работ: {jobGroup.Id},{jobGroup.GroupName}," +
|
_logger.LogInformation($"Пользователь {User.Identity?.Name} удалил группу заданий на выполнение работ: {jobGroup.Id},{jobGroup.GroupName}," +
|
||||||
$" {jobGroup.ShortDescription}, {jobGroup.FullDescription}," +
|
$" {jobGroup.ShortDescription}, {jobGroup.FullDescription}," +
|
||||||
$" {jobGroup.Solution}, {jobGroup.TemplateDuration}, {jobGroup.ReferenceDate}," +
|
$" {jobGroup.Solution}, {jobGroup.TemplateDuration}, {jobGroup.ReferenceDate}," +
|
||||||
$" {jobGroup.IsAutoDistributionEnabled}, {jobGroup.IsAgent}, {jobGroup.AgentName}," +
|
$" {jobGroup.IsAutoDistributionEnabled}, {jobGroup.IsAgent}, {jobGroup.AgentName}," +
|
||||||
@@ -408,6 +458,24 @@ namespace PARR.API.Controllers.V1
|
|||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Удалить настройки автоконтроля для связанных Job
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="jobGroupId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task RemoveJobAutoControlSettingsAsync(Guid jobGroupId)
|
||||||
|
{
|
||||||
|
var jobAutoControlsToRemove = await _jobAutoControlRepository.Get()
|
||||||
|
.Where(t => t.Job!.GroupId == jobGroupId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
if (!jobAutoControlsToRemove.Any())
|
||||||
|
return;
|
||||||
|
|
||||||
|
_logger.LogInformation("У группы работ {JobGroupId}, у связанных работ {JobsCount} шт. удалены настройки автоконтроля, так как автоконтролем управляем группа работ.", jobGroupId, jobAutoControlsToRemove.Count);
|
||||||
|
|
||||||
|
_jobAutoControlRepository.RemoveRange(jobAutoControlsToRemove);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Проверка, были ли изменения в расписании
|
/// Проверка, были ли изменения в расписании
|
||||||
@@ -471,25 +539,25 @@ namespace PARR.API.Controllers.V1
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task AppendMissingDataAsync(JobGroupResponse jobGroupResponse)
|
private async Task AppendMissingDataAsync(JobGroupResponse jobGroupResponse)
|
||||||
{
|
{
|
||||||
var schedule = await esppConfigService.GetEsppScheduleDtoAsync(jobGroupResponse.Id);
|
var schedule = await _esppConfigRepository.GetEsppScheduleDtoAsync(jobGroupResponse.Id);
|
||||||
|
|
||||||
if (schedule == null)
|
if (schedule == null)
|
||||||
{
|
{
|
||||||
logger.LogError($"Не смог замапить расписание, так как оно null. JobGroupId: {jobGroupResponse.Id}");
|
_logger.LogError($"Не смог замапить расписание, так как оно null. JobGroupId: {jobGroupResponse.Id}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var scheduleResponse = new JobGroupScheduleResponse
|
var scheduleResponse = new JobGroupScheduleResponse
|
||||||
{
|
{
|
||||||
//Timezone = settingsFromDb.ScheduleTimezone,
|
//Timezone = settingsFromDb.ScheduleTimezone,
|
||||||
Timezone = scheduleResponseAreaTimeOffsetService.GetDefault.EsppValue,
|
Timezone = _scheduleResponseAreaTimeOffsetRepository.GetDefault.EsppValue,
|
||||||
TypeSchedule = mapper.Map<EsppScheduleTypeScheduleResponse>(schedule.TypeSchedule),
|
TypeSchedule = _mapper.Map<EsppScheduleTypeScheduleResponse>(schedule.TypeSchedule),
|
||||||
Values = mapper.Map<List<EsppScheduleValResponse>>(schedule.Values).OrderBy(t => t.Order).ToList()
|
Values = _mapper.Map<List<EsppScheduleValResponse>>(schedule.Values).OrderBy(t => t.Order).ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
jobGroupResponse.Schedule = scheduleResponse;
|
jobGroupResponse.Schedule = scheduleResponse;
|
||||||
|
|
||||||
jobGroupResponse.JobsCount = await jobService.Get().CountAsync(t => t.GroupId == jobGroupResponse.Id);
|
jobGroupResponse.JobsCount = await _jobRepository.Get().CountAsync(t => t.GroupId == jobGroupResponse.Id);
|
||||||
|
|
||||||
jobGroupResponse.MatchingStatus = await GetMatchingStatusAsync(jobGroupResponse.Id);
|
jobGroupResponse.MatchingStatus = await GetMatchingStatusAsync(jobGroupResponse.Id);
|
||||||
}
|
}
|
||||||
@@ -506,7 +574,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Если есть значение, смотрим, групповой ли тип работ, и если нет, то вернем null
|
// Если есть значение, смотрим, групповой ли тип работ, и если нет, то вернем null
|
||||||
var groupingType = await jobGroupTypeService.Get().FirstAsync(t => t.Code == JobGroupTypesEnum.Group);
|
var groupingType = await _jobGroupTypeRepository.Get().FirstAsync(t => t.Code == JobGroupTypesEnum.Group);
|
||||||
if (request.GroupTypeId == groupingType.Id)
|
if (request.GroupTypeId == groupingType.Id)
|
||||||
{
|
{
|
||||||
// это групповой тип работ, все ок
|
// это групповой тип работ, все ок
|
||||||
@@ -515,7 +583,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Это не сгруппированный тип, обнуляем IsGroupByResponsible
|
// Это не сгруппированный тип, обнуляем IsGroupByResponsible
|
||||||
logger.LogInformation("При сохраненни JobGroup, был передан IsGroupByResponsible: {IsGroupByResponsible}, но при этом, тип группы не сгруппированный, а GroupTypeId: {GroupTypeId}, обнулил IsGroupByResponsible",
|
_logger.LogInformation("При сохраненни JobGroup, был передан IsGroupByResponsible: {IsGroupByResponsible}, но при этом, тип группы не сгруппированный, а GroupTypeId: {GroupTypeId}, обнулил IsGroupByResponsible",
|
||||||
request.IsGroupByResponsible, request.GroupTypeId);
|
request.IsGroupByResponsible, request.GroupTypeId);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -534,7 +602,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
return request.GroupingUnitFieldId;
|
return request.GroupingUnitFieldId;
|
||||||
|
|
||||||
|
|
||||||
var groupingType = await jobGroupTypeService.Get().FirstAsync(t => t.Code == JobGroupTypesEnum.Group);
|
var groupingType = await _jobGroupTypeRepository.Get().FirstAsync(t => t.Code == JobGroupTypesEnum.Group);
|
||||||
|
|
||||||
if (request.GroupTypeId == groupingType.Id)
|
if (request.GroupTypeId == groupingType.Id)
|
||||||
{
|
{
|
||||||
@@ -544,7 +612,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Это не сгруппированный тип, обнуляем GroupingUnitFieldId
|
// Это не сгруппированный тип, обнуляем GroupingUnitFieldId
|
||||||
logger.LogInformation("При сохраненни JobGroup, был передан GroupingUnitFieldId: {GroupingUnitFieldId}, но при этом, тип группы не сгруппированный, а GroupTypeId: {GroupTypeId}, обнулил GroupingUnitFieldId",
|
_logger.LogInformation("При сохраненни JobGroup, был передан GroupingUnitFieldId: {GroupingUnitFieldId}, но при этом, тип группы не сгруппированный, а GroupTypeId: {GroupTypeId}, обнулил GroupingUnitFieldId",
|
||||||
request.GroupingUnitFieldId, request.GroupTypeId);
|
request.GroupingUnitFieldId, request.GroupTypeId);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -558,9 +626,9 @@ namespace PARR.API.Controllers.V1
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task<MatchingStatusResponse?> GetMatchingStatusAsync(Guid jobGroupId)
|
private async Task<MatchingStatusResponse?> GetMatchingStatusAsync(Guid jobGroupId)
|
||||||
{
|
{
|
||||||
var statusMatching = await matchingStatusService.GetStatusAsync(jobGroupId, SyncTaskEntityTypeEnum.JobGroup);
|
var statusMatching = await _matchingStatusRepository.GetStatusAsync(jobGroupId, SyncTaskEntityTypeEnum.JobGroup);
|
||||||
|
|
||||||
return mapper.Map<MatchingStatusResponse>(statusMatching);
|
return _mapper.Map<MatchingStatusResponse>(statusMatching);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using PARR.API.Contracts.V1;
|
|||||||
using PARR.API.Contracts.V1.Responses;
|
using PARR.API.Contracts.V1.Responses;
|
||||||
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.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
using PARR.Domain.Common.Roles;
|
using PARR.Domain.Common.Roles;
|
||||||
|
|
||||||
namespace PARR.API.Controllers.V1
|
namespace PARR.API.Controllers.V1
|
||||||
@@ -17,23 +17,29 @@ namespace PARR.API.Controllers.V1
|
|||||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||||
public class JobGroupTypeController : BaseApiController
|
public class JobGroupTypeController : BaseApiController
|
||||||
{
|
{
|
||||||
private readonly IJobGroupTypeRepository jobGroupTypeService;
|
private readonly IJobGroupTypeRepository jobGroupTypeRepository;
|
||||||
private readonly IMapper mapper;
|
private readonly IMapper mapper;
|
||||||
|
|
||||||
public JobGroupTypeController(
|
public JobGroupTypeController(
|
||||||
IJobGroupTypeRepository jobGroupTypeService,
|
IJobGroupTypeRepository jobGroupTypeRepository,
|
||||||
IMapper mapper
|
IMapper mapper
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.jobGroupTypeService = jobGroupTypeService;
|
this.jobGroupTypeRepository = jobGroupTypeRepository;
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить список типов групп работ
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpGet(ApiRoutes.JobGroupType.GetAll)]
|
[HttpGet(ApiRoutes.JobGroupType.GetAll)]
|
||||||
public async Task<IActionResult> GetAll()
|
public async Task<IActionResult> GetAll()
|
||||||
{
|
{
|
||||||
var query = jobGroupTypeService.Get().OrderBy(t => t.Description);
|
var query = jobGroupTypeRepository.Get()
|
||||||
|
.AsNoTracking()
|
||||||
|
.OrderBy(t => t.Description);
|
||||||
|
|
||||||
var types = await query.ToListAsync();
|
var types = await query.ToListAsync();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using PARR.API.Contracts.V1.Responses.Base;
|
|||||||
using PARR.API.Controllers.V1.Base;
|
using PARR.API.Controllers.V1.Base;
|
||||||
using PARR.API.Settings;
|
using PARR.API.Settings;
|
||||||
using PARR.Core.Common.Interfaces.RabbitServices;
|
using PARR.Core.Common.Interfaces.RabbitServices;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
using PARR.Domain.Common.Rabbit.Messages;
|
using PARR.Domain.Common.Rabbit.Messages;
|
||||||
using PARR.Domain.Common.Roles;
|
using PARR.Domain.Common.Roles;
|
||||||
using PARR.Domain.Entities.Base.History;
|
using PARR.Domain.Entities.Base.History;
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ using PARR.API.Contracts.V1.Requests;
|
|||||||
using PARR.API.Contracts.V1.Responses;
|
using PARR.API.Contracts.V1.Responses;
|
||||||
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.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
using PARR.Core.Repositories.Interfaces.Unit;
|
using PARR.Core.Repositories.Interfaces.Unit;
|
||||||
using PARR.Core.Services.UnitFilterService;
|
using PARR.Core.Services.UnitFilterService;
|
||||||
using PARR.Domain.Common.Roles;
|
using PARR.Domain.Common.Roles;
|
||||||
using Job = PARR.Domain.Entities.Job.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
namespace PARR.API.Controllers.V1
|
namespace PARR.API.Controllers.V1
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить список всех переменных составляющих
|
/// Применить шорткод
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost(ApiRoutes.ShortcodeApply.Apply)]
|
[HttpPost(ApiRoutes.ShortcodeApply.Apply)]
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить список всех переменных составляющих
|
/// Получить список всех переменных составляющих (список шорткодов)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet(ApiRoutes.Shortcode.GetAll)]
|
[HttpGet(ApiRoutes.Shortcode.GetAll)]
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ using PARR.API.Contracts.V1.Responses.Base;
|
|||||||
using PARR.API.Contracts.V1.Responses.Statistics;
|
using PARR.API.Contracts.V1.Responses.Statistics;
|
||||||
using PARR.API.Controllers.V1.Base;
|
using PARR.API.Controllers.V1.Base;
|
||||||
using PARR.Core.Repositories.Interfaces;
|
using PARR.Core.Repositories.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
using PARR.Core.Repositories.Interfaces.Schedule;
|
using PARR.Core.Repositories.Interfaces.Schedule;
|
||||||
using PARR.Core.Services.NextRunServices;
|
using PARR.Core.Services.NextRunServices;
|
||||||
using PARR.Core.Services.Shortcodes;
|
using PARR.Core.Services.Shortcodes;
|
||||||
|
|||||||
@@ -48,9 +48,6 @@ namespace PARR.API.Controllers.V1
|
|||||||
[HttpPost(ApiRoutes.SyncTask.MatchTemplates)]
|
[HttpPost(ApiRoutes.SyncTask.MatchTemplates)]
|
||||||
public async Task<IActionResult> MatchTemplatesForJob([FromBody] MatchTemplatesRequest request)
|
public async Task<IActionResult> MatchTemplatesForJob([FromBody] MatchTemplatesRequest request)
|
||||||
{
|
{
|
||||||
//todo: Валидатор! Валидатор то забыли!!!
|
|
||||||
|
|
||||||
|
|
||||||
// проверяем, если уже идет синхронизация по этому объекту, то ахтунг, ошибка
|
// проверяем, если уже идет синхронизация по этому объекту, то ахтунг, ошибка
|
||||||
var matchingStatus = await matchingStatusService.GetStatusAsync(request.ObjectId, request.EntityType);
|
var matchingStatus = await matchingStatusService.GetStatusAsync(request.ObjectId, request.EntityType);
|
||||||
if (matchingStatus.IsMatchingObject)
|
if (matchingStatus.IsMatchingObject)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using FluentValidation;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
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.Requests;
|
||||||
@@ -8,7 +7,7 @@ using PARR.API.Controllers.V1.Base;
|
|||||||
using PARR.API.Services.Interfaces;
|
using PARR.API.Services.Interfaces;
|
||||||
using PARR.API.Settings;
|
using PARR.API.Settings;
|
||||||
using PARR.Core.Common.Interfaces.RabbitServices;
|
using PARR.Core.Common.Interfaces.RabbitServices;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.Domain.Common.Rabbit.Messages;
|
using PARR.Domain.Common.Rabbit.Messages;
|
||||||
using PARR.Domain.Common.Roles;
|
using PARR.Domain.Common.Roles;
|
||||||
using PARR.Domain.Entities.Base.History;
|
using PARR.Domain.Entities.Base.History;
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ using PARR.API.Contracts.V1.Responses.Base;
|
|||||||
using PARR.API.Controllers.V1.Base;
|
using PARR.API.Controllers.V1.Base;
|
||||||
using PARR.API.Extensions;
|
using PARR.API.Extensions;
|
||||||
using PARR.API.Services.Interfaces;
|
using PARR.API.Services.Interfaces;
|
||||||
using PARR.BLL.Helpers;
|
|
||||||
using PARR.Core.Common.Helpers;
|
using PARR.Core.Common.Helpers;
|
||||||
using PARR.Core.Repositories.Interfaces;
|
using PARR.Core.Repositories.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces.Schedule;
|
using PARR.Core.Repositories.Interfaces.Schedule;
|
||||||
@@ -30,37 +29,34 @@ namespace PARR.API.Controllers.V1
|
|||||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||||
public class TemplateController : BaseApiController
|
public class TemplateController : BaseApiController
|
||||||
{
|
{
|
||||||
private readonly IMapper mapper;
|
private readonly IMapper _mapper;
|
||||||
private readonly ITemplateRepository templateService;
|
private readonly ITemplateRepository _templateRepository;
|
||||||
private readonly IRobotConfigurationRepository robotConfigurationService;
|
private readonly IRobotConfigurationRepository _robotConfigurationRepository;
|
||||||
private readonly IClientService clientService;
|
private readonly IClientService _clientService;
|
||||||
private readonly ILogger<TemplateController> logger;
|
private readonly ILogger<TemplateController> _logger;
|
||||||
private readonly IShortcodesService shortcodesService;
|
private readonly IShortcodesService _shortcodesService;
|
||||||
private readonly IOrderRepository orderService;
|
private readonly IOrderRepository _orderRepository;
|
||||||
private readonly SettingsFromDb settingsFromDb;
|
private readonly SettingsFromDb _settingsFromDb;
|
||||||
private readonly IScheduleResponseAreaTimeOffsetRepository scheduleResponseAreaTimeOffsetService;
|
|
||||||
|
|
||||||
public TemplateController(
|
public TemplateController(
|
||||||
IMapper mapper,
|
IMapper mapper,
|
||||||
ITemplateRepository templateService,
|
ITemplateRepository templateRepository,
|
||||||
IRobotConfigurationRepository robotConfigurationService,
|
IRobotConfigurationRepository robotConfigurationRepository,
|
||||||
IClientService clientService,
|
IClientService clientService,
|
||||||
ILogger<TemplateController> logger,
|
ILogger<TemplateController> logger,
|
||||||
IShortcodesService shortcodesService,
|
IShortcodesService shortcodesService,
|
||||||
IOrderRepository orderService,
|
IOrderRepository orderRepository,
|
||||||
SettingsFromDb settingsFromDb,
|
SettingsFromDb settingsFromDb
|
||||||
IScheduleResponseAreaTimeOffsetRepository scheduleResponseAreaTimeOffsetService
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.mapper = mapper;
|
_mapper = mapper;
|
||||||
this.templateService = templateService;
|
_templateRepository = templateRepository;
|
||||||
this.robotConfigurationService = robotConfigurationService;
|
_robotConfigurationRepository = robotConfigurationRepository;
|
||||||
this.clientService = clientService;
|
_clientService = clientService;
|
||||||
this.logger = logger;
|
_logger = logger;
|
||||||
this.shortcodesService = shortcodesService;
|
_shortcodesService = shortcodesService;
|
||||||
this.orderService = orderService;
|
_orderRepository = orderRepository;
|
||||||
this.settingsFromDb = settingsFromDb;
|
_settingsFromDb = settingsFromDb;
|
||||||
this.scheduleResponseAreaTimeOffsetService = scheduleResponseAreaTimeOffsetService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -72,9 +68,10 @@ namespace PARR.API.Controllers.V1
|
|||||||
[HttpGet(ApiRoutes.Template.GetAll)]
|
[HttpGet(ApiRoutes.Template.GetAll)]
|
||||||
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] TemplateQuery filter)
|
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] TemplateQuery filter)
|
||||||
{
|
{
|
||||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
var paginationFilter = _mapper.Map<PaginationFilter>(paginationQuery);
|
||||||
|
|
||||||
IQueryable<Template> query = templateService.Get()
|
IQueryable<Template> query = _templateRepository.Get()
|
||||||
|
.AsNoTracking()
|
||||||
.Include(t => t.Unit).ThenInclude(t => t!.UnitValues).ThenInclude(t => t.Field)
|
.Include(t => t.Unit).ThenInclude(t => t!.UnitValues).ThenInclude(t => t.Field)
|
||||||
.Include(t => t.Unit).ThenInclude(t => t!.UnitValues).ThenInclude(t => t.Value)
|
.Include(t => t.Unit).ThenInclude(t => t!.UnitValues).ThenInclude(t => t.Value)
|
||||||
.Include(t => t.StatusType)
|
.Include(t => t.StatusType)
|
||||||
@@ -82,8 +79,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.Robot)
|
.Include(t => t.RobotConfigurations).ThenInclude(t => t.Robot)
|
||||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.TaskStatus)
|
.Include(t => t.RobotConfigurations).ThenInclude(t => t.TaskStatus)
|
||||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
|
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
|
||||||
.OrderBy(t => t.Name)
|
.OrderBy(t => t.Name);
|
||||||
.AsNoTracking();
|
|
||||||
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(filter.Mask))
|
if (!string.IsNullOrEmpty(filter.Mask))
|
||||||
@@ -114,7 +110,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
var templates = await templateService.GetPage(query, paginationFilter).ToListAsync();
|
var templates = await _templateRepository.GetPage(query, paginationFilter).ToListAsync();
|
||||||
|
|
||||||
//logger.LogDebug("Загрузка шаблонов из БД: {ElapsedMs} мс", sw.ElapsedMilliseconds);
|
//logger.LogDebug("Загрузка шаблонов из БД: {ElapsedMs} мс", sw.ElapsedMilliseconds);
|
||||||
|
|
||||||
@@ -122,7 +118,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
if (!templates.Any())
|
if (!templates.Any())
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
var templateResponse = mapper.Map<List<TemplateListResponse>>(templates);
|
var templateResponse = _mapper.Map<List<TemplateListResponse>>(templates);
|
||||||
|
|
||||||
// словари для быстрого поиска
|
// словари для быстрого поиска
|
||||||
var templatesDict = templates.ToDictionary(t => t.Id);
|
var templatesDict = templates.ToDictionary(t => t.Id);
|
||||||
@@ -135,7 +131,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
foreach (var responseItem in templateResponse)
|
foreach (var responseItem in templateResponse)
|
||||||
{
|
{
|
||||||
//await ApplyTemplateShortcodesAsync(responseItem, templates.First(t => t.Id == responseItem.Id));
|
//await ApplyTemplateShortcodesAsync(responseItem, templates.First(t => t.Id == responseItem.Id));
|
||||||
await ApplyTemplateShortcodesAsync(responseItem, templatesDict[responseItem.Id]);
|
await ApplyBaseTemplateShortcodesAsync(responseItem, templatesDict[responseItem.Id]);
|
||||||
//FillResponseAreaOffset(responseItem);
|
//FillResponseAreaOffset(responseItem);
|
||||||
}
|
}
|
||||||
//logger.LogDebug("Получение шорткодов: {ElapsedMs} мс", sw.ElapsedMilliseconds);
|
//logger.LogDebug("Получение шорткодов: {ElapsedMs} мс", sw.ElapsedMilliseconds);
|
||||||
@@ -165,7 +161,8 @@ namespace PARR.API.Controllers.V1
|
|||||||
[HttpGet(ApiRoutes.Template.Get)]
|
[HttpGet(ApiRoutes.Template.Get)]
|
||||||
public async Task<IActionResult> GetById([FromRoute] Guid id)
|
public async Task<IActionResult> GetById([FromRoute] Guid id)
|
||||||
{
|
{
|
||||||
var template = await templateService.GetWithIncludes().AsNoTracking()
|
var template = await _templateRepository.GetWithIncludes()
|
||||||
|
.AsNoTracking()
|
||||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.Robot)
|
.Include(t => t.RobotConfigurations).ThenInclude(t => t.Robot)
|
||||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.TaskStatus)
|
.Include(t => t.RobotConfigurations).ThenInclude(t => t.TaskStatus)
|
||||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
|
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
|
||||||
@@ -179,9 +176,9 @@ namespace PARR.API.Controllers.V1
|
|||||||
if (template == null)
|
if (template == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
var response = mapper.Map<TemplateResponse>(template);
|
var response = _mapper.Map<TemplateResponse>(template);
|
||||||
|
await ApplyBaseTemplateShortcodesAsync(response, template);
|
||||||
await ApplyTemplateShortcodesAsync(response, template);
|
await ApplyTemplateShortcodesAsync(response, template);
|
||||||
//FillResponseAreaOffset(response);
|
|
||||||
|
|
||||||
var ordersCountResult = await GetOrdersCountAsync(new List<Guid> { response.Id });
|
var ordersCountResult = await GetOrdersCountAsync(new List<Guid> { response.Id });
|
||||||
response.OrderCount = ordersCountResult.Count > 0 ? ordersCountResult.First().Value : 0;
|
response.OrderCount = ordersCountResult.Count > 0 ? ordersCountResult.First().Value : 0;
|
||||||
@@ -215,7 +212,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
// .FirstOrDefaultAsync(t => t.Id == id);
|
// .FirstOrDefaultAsync(t => t.Id == id);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
var template = await templateService.Get()
|
var template = await _templateRepository.Get()
|
||||||
.Include(t => t.RobotConfigurations)
|
.Include(t => t.RobotConfigurations)
|
||||||
.FirstOrDefaultAsync(t => t.Id == id);
|
.FirstOrDefaultAsync(t => t.Id == id);
|
||||||
|
|
||||||
@@ -226,21 +223,21 @@ namespace PARR.API.Controllers.V1
|
|||||||
{
|
{
|
||||||
template.IsActiveTemplate = request.IsActiveTemplate;
|
template.IsActiveTemplate = request.IsActiveTemplate;
|
||||||
//необходимо обновить шаблон
|
//необходимо обновить шаблон
|
||||||
var config = robotConfigurationService.GetFromTemplateByRobotCode(RobotsEnum.TemplateOrder, template);
|
var config = _robotConfigurationRepository.GetFromTemplateByRobotCode(RobotsEnum.TemplateOrder, template);
|
||||||
//robotConfigurationService.ChangeTaskStatus(TaskStatusEnum.Updating, config);
|
//robotConfigurationService.ChangeTaskStatus(TaskStatusEnum.Updating, config);
|
||||||
robotConfigurationService.SetUpdateTaskStatusIfAllow(config);
|
_robotConfigurationRepository.SetUpdateTaskStatusIfAllow(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (template.IsActiveSchedule != request.IsActiveSchedule)
|
if (template.IsActiveSchedule != request.IsActiveSchedule)
|
||||||
{
|
{
|
||||||
template.IsActiveSchedule = request.IsActiveSchedule;
|
template.IsActiveSchedule = request.IsActiveSchedule;
|
||||||
//необходимо обновить расписание
|
//необходимо обновить расписание
|
||||||
var config = robotConfigurationService.GetFromTemplateByRobotCode(RobotsEnum.ScheduleOrder, template);
|
var config = _robotConfigurationRepository.GetFromTemplateByRobotCode(RobotsEnum.ScheduleOrder, template);
|
||||||
//robotConfigurationService.ChangeTaskStatus(TaskStatusEnum.Updating, config);
|
//robotConfigurationService.ChangeTaskStatus(TaskStatusEnum.Updating, config);
|
||||||
robotConfigurationService.SetUpdateTaskStatusIfAllow(config);
|
_robotConfigurationRepository.SetUpdateTaskStatusIfAllow(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!await templateService.CommitAsync(new HistoryInitiator { InitiatorComment = "Изменён статус шаблона/расписания", InitiatorIp = clientService.GetClientIp()?.ToString(), InitiatorParrComponentId = ParrComponentsEnum.Api }))
|
if (!await _templateRepository.CommitAsync(new HistoryInitiator { InitiatorComment = "Изменён статус шаблона/расписания", InitiatorIp = _clientService.GetClientIp()?.ToString(), InitiatorParrComponentId = ParrComponentsEnum.Api }))
|
||||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при изменении шаблона." } }));
|
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при изменении шаблона." } }));
|
||||||
|
|
||||||
#region old
|
#region old
|
||||||
@@ -263,7 +260,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
//return Ok(new Response<TemplateResponse>(response, true));
|
//return Ok(new Response<TemplateResponse>(response, true));
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
var templateToResponse = await templateService.Get()
|
var templateToResponse = await _templateRepository.Get()
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Include(t => t.Unit).ThenInclude(t => t!.UnitValues).ThenInclude(t => t.Field)
|
.Include(t => t.Unit).ThenInclude(t => t!.UnitValues).ThenInclude(t => t.Field)
|
||||||
.Include(t => t.Unit).ThenInclude(t => t!.UnitValues).ThenInclude(t => t.Value)
|
.Include(t => t.Unit).ThenInclude(t => t!.UnitValues).ThenInclude(t => t.Value)
|
||||||
@@ -274,10 +271,9 @@ namespace PARR.API.Controllers.V1
|
|||||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
|
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
|
||||||
.FirstAsync(t => t.Id == id);
|
.FirstAsync(t => t.Id == id);
|
||||||
|
|
||||||
var response = mapper.Map<TemplateListResponse>(templateToResponse);
|
var response = _mapper.Map<TemplateListResponse>(templateToResponse);
|
||||||
|
|
||||||
await ApplyTemplateShortcodesAsync(response, templateToResponse);
|
await ApplyBaseTemplateShortcodesAsync(response, templateToResponse);
|
||||||
//FillResponseAreaOffset(response);
|
|
||||||
|
|
||||||
var ordersCountResult = await GetOrdersCountAsync(new List<Guid> { response.Id });
|
var ordersCountResult = await GetOrdersCountAsync(new List<Guid> { response.Id });
|
||||||
response.OrderCount = ordersCountResult.Count > 0 ? ordersCountResult.First().Value : 0;
|
response.OrderCount = ordersCountResult.Count > 0 ? ordersCountResult.First().Value : 0;
|
||||||
@@ -287,18 +283,34 @@ namespace PARR.API.Controllers.V1
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Применить шорткоды
|
/// Применить шорткоды. Для респонса TemplateBaseResponse
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="response"></param>
|
/// <param name="response"></param>
|
||||||
/// <param name="template"></param>
|
/// <param name="template"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task ApplyTemplateShortcodesAsync(TemplateBaseResponse response, Template template)
|
private async Task ApplyBaseTemplateShortcodesAsync(TemplateBaseResponse response, Template template)
|
||||||
{
|
{
|
||||||
response.WorkGroup = await shortcodesService.ApplyShortcodesAsync(template.Job.WorkGroupMask, template);
|
response.WorkGroup = await _shortcodesService.ApplyShortcodesAsync(template.Job!.WorkGroupMask, template);
|
||||||
response.ResponseArea = await shortcodesService.ApplyShortcodesAsync(template.Job.ResponseAreaMask, template);
|
response.ResponseArea = await _shortcodesService.ApplyShortcodesAsync(template.Job!.ResponseAreaMask, template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Применить шорткоды. Для респонса TemplateResponse (добавлены дополнительные поля Rendered)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="response"></param>
|
||||||
|
/// <param name="template"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task ApplyTemplateShortcodesAsync(TemplateResponse response, Template template)
|
||||||
|
{
|
||||||
|
response.WorkNameRendered = await _shortcodesService.ApplyShortcodesAsync(template.Job!.WorkName, template);
|
||||||
|
response.WorkGroupRendered = await _shortcodesService.ApplyShortcodesAsync(template.Job!.WorkGroupMask, template);
|
||||||
|
response.ResponseAreaRendered = await _shortcodesService.ApplyShortcodesAsync(template.Job!.ResponseAreaMask, template);
|
||||||
|
response.ShortDescriptionRendered = await _shortcodesService.ApplyShortcodesAsync(template.Job.Group!.ShortDescription, template);
|
||||||
|
response.FullDescriptionRendered = await _shortcodesService.ApplyShortcodesAsync(template.Job.Group!.FullDescription, template);
|
||||||
|
response.SolutionRendered = await _shortcodesService.ApplyShortcodesAsync(template.Job.Group!.Solution, template);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить кол-во нарядов для шаблонов
|
/// Получить кол-во нарядов для шаблонов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -309,7 +321,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
if (!templateIdList.Any())
|
if (!templateIdList.Any())
|
||||||
return new Dictionary<Guid, int>();
|
return new Dictionary<Guid, int>();
|
||||||
|
|
||||||
var templateWithOrders = await orderService.Get()
|
var templateWithOrders = await _orderRepository.Get()
|
||||||
.Where(t => t.TemplateId.HasValue && templateIdList.Contains(t.TemplateId.Value))
|
.Where(t => t.TemplateId.HasValue && templateIdList.Contains(t.TemplateId.Value))
|
||||||
.GroupBy(t => t.TemplateId)
|
.GroupBy(t => t.TemplateId)
|
||||||
.Select(t => new { TemplateId = t.Key, OrderCount = t.Count() })
|
.Select(t => new { TemplateId = t.Key, OrderCount = t.Count() })
|
||||||
@@ -323,36 +335,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Заполнить ResponseAreaOffset
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="response"></param>
|
|
||||||
//private void FillResponseAreaOffset(TemplateBaseResponse response)
|
|
||||||
//{
|
|
||||||
// // если стоит галка IsResponseAreaTimezone и есть ЗО, то возвращаем оффсет
|
|
||||||
// if (response.IsResponseAreaTimezone && !string.IsNullOrEmpty(response.ResponseArea))
|
|
||||||
// {
|
|
||||||
// var responseArea = response.ResponseArea;
|
|
||||||
// response.ResponseAreaOffset = mapper.Map<ScheduleResponseAreaTimeOffsetResponse>(scheduleResponseAreaTimeOffsetService.GetByResponseAreaOrDefault(responseArea));
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// response.ResponseAreaOffset = null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //var responseArea = response.IsResponseAreaTimezone && !string.IsNullOrEmpty(response.ResponseArea)
|
|
||||||
// // ? response.ResponseArea
|
|
||||||
// // : settingsFromDb.DefaultResponseAreaToTimeOffset;
|
|
||||||
|
|
||||||
// //response.NextRunResponseAreaInLocal = response.IsResponseAreaTimezone && !string.IsNullOrEmpty(response.ResponseArea)
|
|
||||||
// // ? nextRunService.GetNextRunWithResponseAreaOffset(response.NextRun, response.ResponseArea)
|
|
||||||
// // // возвращаем в дефолтной зоне
|
|
||||||
// // : nextRunService.GetNextRunWithResponseAreaOffset(response.NextRun, settingsFromDb.DefaultResponseAreaToTimeOffset);
|
|
||||||
|
|
||||||
// //response.NextRunResponseAreaInLocal = nextRunService.GetNextRunWithResponseAreaOffset(response.NextRun, responseArea);
|
|
||||||
|
|
||||||
// //response.ResponseAreaOffset = mapper.Map<ScheduleResponseAreaTimeOffsetResponse>(scheduleResponseAreaTimeOffsetService.GetByResponseAreaOrDefault(responseArea));
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ using PARR.Domain.DTOs.User;
|
|||||||
using PARR.Domain.DTOs.Workload;
|
using PARR.Domain.DTOs.Workload;
|
||||||
using PARR.Domain.Entities;
|
using PARR.Domain.Entities;
|
||||||
using PARR.Domain.Entities.Base.History;
|
using PARR.Domain.Entities.Base.History;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Entities.JobGroupEntities;
|
using PARR.Domain.Entities.JobGroupEntities;
|
||||||
using PARR.Domain.Entities.Schedule;
|
using PARR.Domain.Entities.Schedule;
|
||||||
using PARR.Domain.Entities.Unit;
|
using PARR.Domain.Entities.Unit;
|
||||||
@@ -368,7 +368,8 @@ namespace PARR.API.MappingProfiles
|
|||||||
.Include<JobGroup, JobGroupWithDistributionConfigResponse>()
|
.Include<JobGroup, JobGroupWithDistributionConfigResponse>()
|
||||||
.ForMember(d => d.GroupType, o => o.MapFrom(s => s.GroupType))
|
.ForMember(d => d.GroupType, o => o.MapFrom(s => s.GroupType))
|
||||||
.ForMember(d => d.GroupingUnitField, o => o.MapFrom(s => s.GroupingUnitField))
|
.ForMember(d => d.GroupingUnitField, o => o.MapFrom(s => s.GroupingUnitField))
|
||||||
.ForMember(d => d.IsWorkGroupTimezone, o => o.MapFrom(s => s.IsResponseAreaTimezone));
|
.ForMember(d => d.IsWorkGroupTimezone, o => o.MapFrom(s => s.IsResponseAreaTimezone))
|
||||||
|
.ForMember(d => d.AutoControl, o => o.MapFrom(s => s.AutoControl));
|
||||||
|
|
||||||
CreateMap<JobGroup, JobGroupBaseResponse>()
|
CreateMap<JobGroup, JobGroupBaseResponse>()
|
||||||
.ForMember(d => d.Name, o => o.MapFrom(s => s.GroupName))
|
.ForMember(d => d.Name, o => o.MapFrom(s => s.GroupName))
|
||||||
@@ -382,6 +383,7 @@ namespace PARR.API.MappingProfiles
|
|||||||
.ForMember(d => d.ScheduleExcludeTypeCalendar, o => o.MapFrom(s => s.ScheduleExcludeTypeCalendar));
|
.ForMember(d => d.ScheduleExcludeTypeCalendar, o => o.MapFrom(s => s.ScheduleExcludeTypeCalendar));
|
||||||
//.ForMember(d => d.DistributionConfig, o => o.MapFrom(s => s.DistributionConfig));
|
//.ForMember(d => d.DistributionConfig, o => o.MapFrom(s => s.DistributionConfig));
|
||||||
|
|
||||||
|
CreateMap<JobGroupAutoControl, JobGroupAutoControlResponse>();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using PARR.API.Contracts.V1.Requests;
|
|||||||
using PARR.API.Contracts.V1.Requests.Queries;
|
using PARR.API.Contracts.V1.Requests.Queries;
|
||||||
using PARR.Domain.Common.Pagination;
|
using PARR.Domain.Common.Pagination;
|
||||||
using PARR.Domain.DTOs.RobotSnapshotDTO;
|
using PARR.Domain.DTOs.RobotSnapshotDTO;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
namespace PARR.API.MappingProfiles
|
namespace PARR.API.MappingProfiles
|
||||||
{
|
{
|
||||||
@@ -17,7 +17,11 @@ namespace PARR.API.MappingProfiles
|
|||||||
|
|
||||||
CreateMap<JobRequest, Job>()
|
CreateMap<JobRequest, Job>()
|
||||||
.ForMember(d => d.Id, o => o.MapFrom(s => Guid.NewGuid()))
|
.ForMember(d => d.Id, o => o.MapFrom(s => Guid.NewGuid()))
|
||||||
|
.ForMember(d => d.IsParentRelationships, o => o.MapFrom(s => s.Relationships != null ? s.Relationships.IsParentRelationships : (bool?)null))
|
||||||
|
.ForMember(d => d.MaxValueRelationships, o => o.MapFrom(s => s.Relationships != null ? s.Relationships.MaxValueRelationships : (int?)null))
|
||||||
|
.ForMember(d => d.MinValueRelationships, o => o.MapFrom(s => s.Relationships != null ? s.Relationships.MinValueRelationships : (int?)null))
|
||||||
.ForMember(d => d.DateCreated, o => o.MapFrom(s => DateTimeOffset.UtcNow))
|
.ForMember(d => d.DateCreated, o => o.MapFrom(s => DateTimeOffset.UtcNow))
|
||||||
|
.ForMember(d => d.AutoControl, o => o.Ignore())
|
||||||
.AfterMap((s, d) =>
|
.AfterMap((s, d) =>
|
||||||
{
|
{
|
||||||
if (d.UnitFilters != null)
|
if (d.UnitFilters != null)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PARR.API.Contracts.V1.Requests;
|
using PARR.API.Contracts.V1.Requests;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
|
|
||||||
namespace PARR.API.Validators
|
namespace PARR.API.Validators
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
using FluentValidation;
|
|
||||||
using PARR.API.Contracts.V1.Requests;
|
|
||||||
using PARR.Domain.Enums;
|
|
||||||
|
|
||||||
namespace PARR.API.Validators
|
|
||||||
{
|
|
||||||
public class JobAutoControlRequestValidator : AbstractValidator<JobAutoControlRequest>
|
|
||||||
{
|
|
||||||
public JobAutoControlRequestValidator()
|
|
||||||
{
|
|
||||||
RuleFor(t => t.EkMasks).Must(items =>
|
|
||||||
items.Count(t => t.Trim().Length > 0) > 0
|
|
||||||
).WithMessage("Должна быть указана хотя бы одна маска ЭК");
|
|
||||||
|
|
||||||
RuleFor(t => t.EnabledEkStatuses).Must(
|
|
||||||
items => items.Distinct().Count() == items.Count()
|
|
||||||
).WithMessage("Статусы ЭК не должны повторяться");
|
|
||||||
|
|
||||||
RuleFor(t => t.EnabledEkStatuses).Must(items =>
|
|
||||||
{
|
|
||||||
return !items.Any(item => !Enum.IsDefined(typeof(EkStatusEnum), item)) && !items.Any(t => t == 0);
|
|
||||||
})
|
|
||||||
.WithMessage($"Допустимые значения: {(int)EkStatusEnum.New} ({EkStatusEnum.New}), " +
|
|
||||||
$"{(int)EkStatusEnum.Preapre} ({EkStatusEnum.Preapre}), " +
|
|
||||||
$"{(int)EkStatusEnum.Exploitation} ({EkStatusEnum.Exploitation}), " +
|
|
||||||
$"{(int)EkStatusEnum.Repair} ({EkStatusEnum.Repair}), " +
|
|
||||||
$"{(int)EkStatusEnum.Reserve} ({EkStatusEnum.Reserve}), " +
|
|
||||||
$"{(int)EkStatusEnum.OutOfService} ({EkStatusEnum.OutOfService}), " +
|
|
||||||
$"{(int)EkStatusEnum.Test} ({EkStatusEnum.Test}), " +
|
|
||||||
$"{(int)EkStatusEnum.Development} ({EkStatusEnum.Development})");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PARR.API.Contracts.V1.Requests;
|
using PARR.API.Contracts.V1.Requests;
|
||||||
using PARR.Core.Repositories.Interfaces;
|
using PARR.Core.Repositories.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
using PARR.Core.Repositories.Interfaces.Schedule;
|
using PARR.Core.Repositories.Interfaces.Schedule;
|
||||||
using PARR.Core.Repositories.Interfaces.Unit;
|
using PARR.Core.Repositories.Interfaces.Unit;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
@@ -12,11 +12,11 @@ namespace PARR.API.Validators
|
|||||||
public class JobGroupValidator : AbstractValidator<JobGroupRequest>
|
public class JobGroupValidator : AbstractValidator<JobGroupRequest>
|
||||||
{
|
{
|
||||||
public JobGroupValidator(
|
public JobGroupValidator(
|
||||||
IJobGroupTypeRepository jobGroupTypeService,
|
IJobGroupTypeRepository jobGroupTypeRepository,
|
||||||
IUnitFieldRepository unitFieldService,
|
IUnitFieldRepository unitFieldRepository,
|
||||||
IScheduleExcludeTypeRepository scheduleExcludeTypeService,
|
IScheduleExcludeTypeRepository scheduleExcludeTypeRepository,
|
||||||
IScheduleExcludeTypeCalendarRepository scheduleExcludeTypeCalendarService,
|
IScheduleExcludeTypeCalendarRepository scheduleExcludeTypeCalendarRepository,
|
||||||
IDistributionPeriodRepository distributionPeriodService
|
IDistributionPeriodRepository distributionPeriodRepository
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
RuleFor(t => t.Name)
|
RuleFor(t => t.Name)
|
||||||
@@ -35,7 +35,7 @@ namespace PARR.API.Validators
|
|||||||
.NotNull().NotEmpty();
|
.NotNull().NotEmpty();
|
||||||
|
|
||||||
RuleFor(t => t.GroupTypeId)
|
RuleFor(t => t.GroupTypeId)
|
||||||
.MustAsync(async (entity, value, c) => await jobGroupTypeService.GetAsync(value) != null)
|
.MustAsync(async (entity, value, c) => await jobGroupTypeRepository.GetAsync(value) != null)
|
||||||
.WithMessage("Указан несуществующий Id типа");
|
.WithMessage("Указан несуществующий Id типа");
|
||||||
|
|
||||||
//Проверяем существует ли такой GroupingUnitFieldId в unitField
|
//Проверяем существует ли такой GroupingUnitFieldId в unitField
|
||||||
@@ -47,7 +47,7 @@ namespace PARR.API.Validators
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await unitFieldService.GetAsync(value.Value) != null;
|
return await unitFieldRepository.GetAsync(value.Value) != null;
|
||||||
})
|
})
|
||||||
.WithMessage("Указано несуществующий Id поля");
|
.WithMessage("Указано несуществующий Id поля");
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ namespace PARR.API.Validators
|
|||||||
RuleFor(t => t.GroupingUnitFieldId)
|
RuleFor(t => t.GroupingUnitFieldId)
|
||||||
.MustAsync(async (entity, value, c) =>
|
.MustAsync(async (entity, value, c) =>
|
||||||
{
|
{
|
||||||
var groupingJobType = await jobGroupTypeService.Get().FirstAsync(t => t.Code == JobGroupTypesEnum.Group);
|
var groupingJobType = await jobGroupTypeRepository.Get().FirstAsync(t => t.Code == JobGroupTypesEnum.Group);
|
||||||
|
|
||||||
// Если это сгруппированный тип, то у него обязательно должно быть заполнено поле GroupingUnitFieldId
|
// Если это сгруппированный тип, то у него обязательно должно быть заполнено поле GroupingUnitFieldId
|
||||||
if (entity.GroupTypeId == groupingJobType.Id)
|
if (entity.GroupTypeId == groupingJobType.Id)
|
||||||
@@ -68,14 +68,14 @@ namespace PARR.API.Validators
|
|||||||
RuleFor(t => t.ScheduleExcludeTypeId)
|
RuleFor(t => t.ScheduleExcludeTypeId)
|
||||||
.NotNull()
|
.NotNull()
|
||||||
.NotEmpty()
|
.NotEmpty()
|
||||||
.MustAsync(async (entity, value, c) => await scheduleExcludeTypeService.GetAsync(value) != null)
|
.MustAsync(async (entity, value, c) => await scheduleExcludeTypeRepository.GetAsync(value) != null)
|
||||||
.WithMessage("Некорректное значение");
|
.WithMessage("Некорректное значение");
|
||||||
|
|
||||||
RuleFor(t => t.ScheduleExcludeTypeCalendarId)
|
RuleFor(t => t.ScheduleExcludeTypeCalendarId)
|
||||||
.MustAsync(async (entity, value, c) =>
|
.MustAsync(async (entity, value, c) =>
|
||||||
{
|
{
|
||||||
// Если выбрано "Нет исключений", то это поле должно быть пустое, иначе, должно быть валидное значение
|
// Если выбрано "Нет исключений", то это поле должно быть пустое, иначе, должно быть валидное значение
|
||||||
var type = await scheduleExcludeTypeService.GetAsync(entity.ScheduleExcludeTypeId);
|
var type = await scheduleExcludeTypeRepository.GetAsync(entity.ScheduleExcludeTypeId);
|
||||||
if (type == null)
|
if (type == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ namespace PARR.API.Validators
|
|||||||
if (!value.HasValue)
|
if (!value.HasValue)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return await scheduleExcludeTypeCalendarService.GetAsync(value.Value) != null;
|
return await scheduleExcludeTypeCalendarRepository.GetAsync(value.Value) != null;
|
||||||
})
|
})
|
||||||
.WithMessage("Некорректное значение");
|
.WithMessage("Некорректное значение");
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ namespace PARR.API.Validators
|
|||||||
|
|
||||||
if (periodId.HasValue)
|
if (periodId.HasValue)
|
||||||
{
|
{
|
||||||
var exist = await distributionPeriodService.GetAsync(periodId.Value);
|
var exist = await distributionPeriodRepository.GetAsync(periodId.Value);
|
||||||
|
|
||||||
return exist != null;
|
return exist != null;
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,26 @@ namespace PARR.API.Validators
|
|||||||
// если IsResponseAreaTimezone == true, то поле UserTimeZoneOffsetMinutes обязательно.
|
// если IsResponseAreaTimezone == true, то поле UserTimeZoneOffsetMinutes обязательно.
|
||||||
// если IsResponseAreaTimezone == false, то UserTimeZoneOffsetMinutes должно быть null
|
// если IsResponseAreaTimezone == false, то UserTimeZoneOffsetMinutes должно быть null
|
||||||
return (entity.IsWorkGroupTimezone && value != null) || (!entity.IsWorkGroupTimezone && value == null);
|
return (entity.IsWorkGroupTimezone && value != null) || (!entity.IsWorkGroupTimezone && value == null);
|
||||||
}).WithMessage("Некорректное значение."); ;
|
}).WithMessage("Некорректное значение.");
|
||||||
|
|
||||||
|
RuleFor(t => t.AutoControl)
|
||||||
|
.MustAsync(async (entity, value, c) =>
|
||||||
|
{
|
||||||
|
// Автоконтроль разрешен только типам работ у которых включен IsJobGroupAutoControl
|
||||||
|
var isAllowedAutocontrol = await jobGroupTypeRepository.Get()
|
||||||
|
.AnyAsync(t => t.Id == entity.GroupTypeId && t.IsJobGroupAutoControl == true);
|
||||||
|
|
||||||
|
// Разрешен автоконтроль и есть значение
|
||||||
|
if (isAllowedAutocontrol && value != null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Запрещен автоконтроль и нет значения
|
||||||
|
if (!isAllowedAutocontrol && value == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
.WithMessage("Некорректные параметры автоконтроля");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,28 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PARR.API.Contracts.V1.Requests;
|
using PARR.API.Contracts.V1.Requests;
|
||||||
using PARR.Core.Repositories.Interfaces;
|
using PARR.Core.Repositories.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
using PARR.Core.Repositories.Interfaces.Unit;
|
using PARR.Core.Repositories.Interfaces.Unit;
|
||||||
using PARR.Domain.Entities.JobGroupEntities;
|
|
||||||
|
|
||||||
namespace PARR.API.Validators
|
namespace PARR.API.Validators
|
||||||
{
|
{
|
||||||
public class JobRequestValidator : AbstractValidator<JobRequest>
|
public class JobRequestValidator : AbstractValidator<JobRequest>
|
||||||
{
|
{
|
||||||
private readonly ITnkRepository tnkService;
|
private readonly ITnkRepository _tnkRepository;
|
||||||
private readonly IJobGroupRepository jobGroupService;
|
private readonly IJobGroupRepository _jobGroupRepository;
|
||||||
private readonly IJobRepository jobRepository;
|
private readonly IUnitFieldRepository _unitFieldRepository;
|
||||||
private readonly IUnitFieldRepository unitFieldService;
|
//private JobGroup? jobGroup;
|
||||||
private JobGroup? jobGroup;
|
|
||||||
|
|
||||||
public JobRequestValidator(
|
public JobRequestValidator(
|
||||||
ITnkRepository tnkService,
|
ITnkRepository tnkRepository,
|
||||||
IJobGroupRepository jobGroupService,
|
IJobGroupRepository jobGroupRepository,
|
||||||
IJobRepository jobService,
|
IUnitFieldRepository unitFieldRepository
|
||||||
IUnitFieldRepository unitFieldService
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.tnkService = tnkService;
|
_tnkRepository = tnkRepository;
|
||||||
this.jobGroupService = jobGroupService;
|
_jobGroupRepository = jobGroupRepository;
|
||||||
this.jobRepository = jobService;
|
_unitFieldRepository = unitFieldRepository;
|
||||||
this.unitFieldService = unitFieldService;
|
|
||||||
|
|
||||||
RuleFor(t => t.Name)
|
RuleFor(t => t.Name)
|
||||||
.NotNull().NotEmpty();
|
.NotNull().NotEmpty();
|
||||||
@@ -48,14 +45,54 @@ namespace PARR.API.Validators
|
|||||||
.MustAsync(async (entity, value, c) => await IsUnitFiltersCorrect(entity))
|
.MustAsync(async (entity, value, c) => await IsUnitFiltersCorrect(entity))
|
||||||
.WithMessage("Неверно заданы параметры фильтров. Внимательнее, пожалуйста!");
|
.WithMessage("Неверно заданы параметры фильтров. Внимательнее, пожалуйста!");
|
||||||
|
|
||||||
RuleFor(t => t.MinValueRelationships)
|
RuleFor(t => t.Relationships)
|
||||||
.GreaterThanOrEqualTo(0);
|
.MustAsync(async (entity, value, c) =>
|
||||||
|
{
|
||||||
|
// Relationships должны быть обязательно заполнены если в типе работ IsRelationshipsAllowed==true
|
||||||
|
var relationshipsIsRequired = await jobGroupRepository.Get()
|
||||||
|
.AnyAsync(t => t.Id == entity.GroupId && t.GroupType!.IsRelationshipsAllowed, c);
|
||||||
|
|
||||||
|
if (relationshipsIsRequired && value != null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!relationshipsIsRequired && value == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
.WithMessage("Некорректные настройки кол-ва связей");
|
||||||
|
|
||||||
|
When(t => t.Relationships != null, () =>
|
||||||
|
{
|
||||||
|
RuleFor(t => t.Relationships!.MinValueRelationships)
|
||||||
|
.GreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
RuleFor(t => t.Relationships!.MaxValueRelationships)
|
||||||
|
.GreaterThanOrEqualTo(t => t.Relationships!.MinValueRelationships);
|
||||||
|
});
|
||||||
|
|
||||||
RuleFor(t => t.MaxValueRelationships)
|
|
||||||
.GreaterThanOrEqualTo(t => t.MinValueRelationships);
|
|
||||||
|
|
||||||
RuleFor(t => t.ResponseAreaMask)
|
RuleFor(t => t.ResponseAreaMask)
|
||||||
.NotNull().NotEmpty();
|
.NotNull().NotEmpty();
|
||||||
|
|
||||||
|
RuleFor(t => t.AutoControl)
|
||||||
|
.MustAsync(async (entity, value, c) =>
|
||||||
|
{
|
||||||
|
// Автоконтроль разрешен только типам работ, у которых выключен IsJobGroupAutoControl
|
||||||
|
var isAllowedJobAutocontrol = await jobGroupRepository.Get()
|
||||||
|
.AnyAsync(t => t.Id == entity.GroupId && t.GroupType!.IsJobGroupAutoControl == false, c);
|
||||||
|
|
||||||
|
// Разрешен автоконтроль и есть значение
|
||||||
|
if (isAllowedJobAutocontrol && value != null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Запрещен автоконтроль и нет значения
|
||||||
|
if (!isAllowedJobAutocontrol && value == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
.WithMessage("Некорректные параметры автоконтроля");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> IsUnitFiltersCorrect(JobRequest entity)
|
private async Task<bool> IsUnitFiltersCorrect(JobRequest entity)
|
||||||
@@ -72,7 +109,7 @@ namespace PARR.API.Validators
|
|||||||
foreach (var fieldFilter in unitFilter.FieldFilters)
|
foreach (var fieldFilter in unitFilter.FieldFilters)
|
||||||
{
|
{
|
||||||
var fieldId = fieldFilter.FieldId;
|
var fieldId = fieldFilter.FieldId;
|
||||||
if (await unitFieldService.GetAsync(fieldId) == null)
|
if (await _unitFieldRepository.GetAsync(fieldId) == null)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +117,7 @@ namespace PARR.API.Validators
|
|||||||
foreach (var relationshipFilter in unitFilter.RelationshipFilters!)
|
foreach (var relationshipFilter in unitFilter.RelationshipFilters!)
|
||||||
{
|
{
|
||||||
var fieldId = relationshipFilter.FieldId;
|
var fieldId = relationshipFilter.FieldId;
|
||||||
if (await unitFieldService.GetAsync(fieldId) == null)
|
if (await _unitFieldRepository.GetAsync(fieldId) == null)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +127,7 @@ namespace PARR.API.Validators
|
|||||||
|
|
||||||
private async Task<bool> IsGroupExist(JobRequest entity)
|
private async Task<bool> IsGroupExist(JobRequest entity)
|
||||||
{
|
{
|
||||||
jobGroup = await jobGroupService.GetAsync(entity.GroupId);
|
var jobGroup = await _jobGroupRepository.GetAsync(entity.GroupId);
|
||||||
|
|
||||||
return jobGroup != null;
|
return jobGroup != null;
|
||||||
}
|
}
|
||||||
@@ -98,7 +135,7 @@ namespace PARR.API.Validators
|
|||||||
|
|
||||||
private async Task<bool> IsTnkExist(JobRequest entity)
|
private async Task<bool> IsTnkExist(JobRequest entity)
|
||||||
{
|
{
|
||||||
return await tnkService.GetAsync(entity.TnkId) != null;
|
return await _tnkRepository.GetAsync(entity.TnkId) != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
51
PARR.API/Validators/MatchTemplatesRequestValidator.cs
Normal file
51
PARR.API/Validators/MatchTemplatesRequestValidator.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PARR.API.Contracts.V1.Requests;
|
||||||
|
using PARR.Core.Repositories.Interfaces;
|
||||||
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
|
using PARR.Domain.Enums;
|
||||||
|
|
||||||
|
namespace PARR.API.Validators
|
||||||
|
{
|
||||||
|
public class MatchTemplatesRequestValidator : AbstractValidator<MatchTemplatesRequest>
|
||||||
|
{
|
||||||
|
public MatchTemplatesRequestValidator(
|
||||||
|
IJobGroupRepository jobGroupRepository,
|
||||||
|
IJobRepository jobRepository,
|
||||||
|
ITemplateRepository templateRepository
|
||||||
|
)
|
||||||
|
{
|
||||||
|
RuleFor(t => t.ObjectId)
|
||||||
|
.NotNull()
|
||||||
|
.NotEmpty()
|
||||||
|
.WithMessage("Идентификатор объекта не может быть пустым.");
|
||||||
|
|
||||||
|
RuleFor(t => t)
|
||||||
|
.MustAsync(async (request, cancellation) =>
|
||||||
|
{
|
||||||
|
return request.EntityType switch
|
||||||
|
{
|
||||||
|
SyncTaskEntityTypeEnum.JobGroup =>
|
||||||
|
await jobGroupRepository.Get().AsNoTracking().AnyAsync(t => t.Id == request.ObjectId, cancellation),
|
||||||
|
|
||||||
|
SyncTaskEntityTypeEnum.Job =>
|
||||||
|
await jobRepository.Get().AsNoTracking().AnyAsync(t => t.Id == request.ObjectId && t.Group!.GroupType!.IsJobGroupAutoControl == false, cancellation),
|
||||||
|
|
||||||
|
SyncTaskEntityTypeEnum.Template =>
|
||||||
|
false, // TODO: Синхронизировать шаблоны нельзя
|
||||||
|
|
||||||
|
_ => false
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.WithMessage(request => request.EntityType switch
|
||||||
|
{
|
||||||
|
SyncTaskEntityTypeEnum.Template => "Синхронизация шаблонов пока не поддерживается.",
|
||||||
|
SyncTaskEntityTypeEnum.Job => "Объект не найден или данные работы нельзя отправить на синхронизацию.",
|
||||||
|
_ => "Не найден объект с переданным ИД."
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using PARR.API.Contracts.V1.Requests;
|
using PARR.API.Contracts.V1.Requests;
|
||||||
using PARR.Core.Repositories.Interfaces;
|
using PARR.Core.Repositories.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
|
|
||||||
namespace PARR.API.Validators
|
namespace PARR.API.Validators
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
using PARR.Domain.Entities.Base.History;
|
using PARR.Domain.Entities.Base.History;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Entities.JobGroupEntities;
|
using PARR.Domain.Entities.JobGroupEntities;
|
||||||
using PARR.Domain.Entities.Schedule;
|
using PARR.Domain.Entities.Schedule;
|
||||||
|
|
||||||
@@ -15,16 +15,13 @@ namespace PARR.Core.Common.Helpers;
|
|||||||
public class JobGroupCloneHelper
|
public class JobGroupCloneHelper
|
||||||
{
|
{
|
||||||
private readonly IJobGroupRepository groupRepository;
|
private readonly IJobGroupRepository groupRepository;
|
||||||
private readonly IJobRepository jobRepository;
|
|
||||||
private readonly ILogger<JobGroupCloneHelper> logger;
|
private readonly ILogger<JobGroupCloneHelper> logger;
|
||||||
|
|
||||||
public JobGroupCloneHelper(
|
public JobGroupCloneHelper(
|
||||||
IJobGroupRepository groupRepository,
|
IJobGroupRepository groupRepository,
|
||||||
IJobRepository jobRepository,
|
|
||||||
ILogger<JobGroupCloneHelper> logger)
|
ILogger<JobGroupCloneHelper> logger)
|
||||||
{
|
{
|
||||||
this.groupRepository = groupRepository;
|
this.groupRepository = groupRepository;
|
||||||
this.jobRepository = jobRepository;
|
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.Domain.Entities.Base.History;
|
using PARR.Domain.Entities.Base.History;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PARR.Core.Common.Helpers;
|
namespace PARR.Core.Common.Helpers;
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,6 @@ namespace PARR.Core.Common.Interfaces.RabbitServices
|
|||||||
/// <param name="mqSettings"></param>
|
/// <param name="mqSettings"></param>
|
||||||
/// <param name="msgObjectList"></param>
|
/// <param name="msgObjectList"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<RabbitSendResult> SendAsync(IMqSettings mqSettings, List<object> msgObjectList);
|
Task<RabbitSendResult> SendAsync(IMqSettings mqSettings, IEnumerable<object> msgObjectList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
using PARR.Domain.Entities.Job;
|
|
||||||
|
|
||||||
namespace PARR.Core.Repositories.Interfaces.Job
|
|
||||||
{
|
|
||||||
public interface IJobAutoControlRepository
|
|
||||||
{
|
|
||||||
IQueryable<JobAutoControl> Get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
using PARR.Core.Repositories.Base;
|
|
||||||
|
|
||||||
namespace PARR.Core.Repositories.Interfaces.Job
|
|
||||||
{
|
|
||||||
public interface IJobRepository : IBaseRepository<Domain.Entities.Job.Job>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using PARR.Core.Repositories.Base;
|
using PARR.Core.Repositories.Base;
|
||||||
using PARR.Domain.Entities.JobGroupEntities;
|
using PARR.Domain.Entities.JobGroupEntities;
|
||||||
|
|
||||||
namespace PARR.Core.Repositories.Interfaces.Job
|
namespace PARR.Core.Repositories.Interfaces.JobGroupRepositories
|
||||||
{
|
{
|
||||||
public interface IJobGroupRepository : IBaseRepository<JobGroup>
|
public interface IJobGroupRepository : IBaseRepository<JobGroup>
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using PARR.Core.Repositories.Base;
|
using PARR.Core.Repositories.Base;
|
||||||
using PARR.Domain.Entities.JobGroupEntities;
|
using PARR.Domain.Entities.JobGroupEntities;
|
||||||
|
|
||||||
namespace PARR.Core.Repositories.Interfaces.Job
|
namespace PARR.Core.Repositories.Interfaces.JobGroupRepositories
|
||||||
{
|
{
|
||||||
public interface IJobGroupTypeRepository : IBaseRepository<JobGroupType>
|
public interface IJobGroupTypeRepository : IBaseRepository<JobGroupType>
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using PARR.Core.Repositories.Base;
|
using PARR.Core.Repositories.Base;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
namespace PARR.Core.Repositories.Interfaces.Job
|
namespace PARR.Core.Repositories.Interfaces.JobRepositories
|
||||||
{
|
{
|
||||||
public interface IFieldFilterRepository : IBaseRepository<JobFieldFilter>
|
public interface IFieldFilterRepository : IBaseRepository<JobFieldFilter>
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
|
namespace PARR.Core.Repositories.Interfaces.JobRepositories
|
||||||
|
{
|
||||||
|
public interface IJobAutoControlRepository
|
||||||
|
{
|
||||||
|
IQueryable<JobAutoControl> Get();
|
||||||
|
void RemoveRange(List<JobAutoControl> autoControlList);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using PARR.Core.Repositories.Base;
|
||||||
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
|
namespace PARR.Core.Repositories.Interfaces.JobRepositories
|
||||||
|
{
|
||||||
|
public interface IJobRepository : IBaseRepository<Job>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using PARR.Core.Repositories.Base;
|
using PARR.Core.Repositories.Base;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
namespace PARR.Core.Repositories.Interfaces.Job
|
namespace PARR.Core.Repositories.Interfaces.JobRepositories
|
||||||
{
|
{
|
||||||
public interface IJobUnitFilterRepository : IBaseRepository<JobUnitFilter>
|
public interface IJobUnitFilterRepository : IBaseRepository<JobUnitFilter>
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PARR.Core.Common.Interfaces;
|
using PARR.Core.Common.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.Domain.Cache.Models;
|
using PARR.Domain.Cache.Models;
|
||||||
using PARR.Domain.DTOs.Matching;
|
using PARR.Domain.DTOs.Matching;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Repositories.Interfaces;
|
using PARR.Core.Repositories.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
using PARR.Core.Repositories.Interfaces.Schedule;
|
using PARR.Core.Repositories.Interfaces.Schedule;
|
||||||
using PARR.Core.Services.NextRunServices.Models;
|
using PARR.Core.Services.NextRunServices.Models;
|
||||||
using PARR.Core.Services.NextRunServices.Subservices;
|
using PARR.Core.Services.NextRunServices.Subservices;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Common.Interfaces;
|
using PARR.Core.Common.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces;
|
using PARR.Core.Repositories.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.Core.Repositories.Interfaces.Unit;
|
using PARR.Core.Repositories.Interfaces.Unit;
|
||||||
using PARR.Core.Services.Shortcodes.Enums;
|
using PARR.Core.Services.Shortcodes.Enums;
|
||||||
using PARR.Core.Services.Shortcodes.Handlers;
|
using PARR.Core.Services.Shortcodes.Handlers;
|
||||||
@@ -10,7 +10,7 @@ using PARR.Core.Services.Shortcodes.Models;
|
|||||||
using PARR.Domain.Cache.Models;
|
using PARR.Domain.Cache.Models;
|
||||||
using PARR.Domain.DTOs.Shortcode;
|
using PARR.Domain.DTOs.Shortcode;
|
||||||
using PARR.Domain.Entities;
|
using PARR.Domain.Entities;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
using PARR.Domain.Settings;
|
using PARR.Domain.Settings;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
@@ -79,8 +79,8 @@ internal class ShortcodesService : IShortcodesService
|
|||||||
Index: template.Index,
|
Index: template.Index,
|
||||||
JobId: template.JobId,
|
JobId: template.JobId,
|
||||||
UnitId: template.UnitId,
|
UnitId: template.UnitId,
|
||||||
UnitName: initialUnitName ?? string.Empty,
|
UnitName: initialUnitName ?? string.Empty,
|
||||||
Job: initialJob,
|
Job: initialJob,
|
||||||
UnitsInTemplate: initialUnitsInTemplate,
|
UnitsInTemplate: initialUnitsInTemplate,
|
||||||
UnitTags: new List<string>(),
|
UnitTags: new List<string>(),
|
||||||
RelatedUnitTags: new Dictionary<Guid, List<string>>()
|
RelatedUnitTags: new Dictionary<Guid, List<string>>()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using PARR.Core.Services.UnitFilterService.Models;
|
using PARR.Core.Services.UnitFilterService.Models;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
namespace PARR.Core.Services.UnitFilterService
|
namespace PARR.Core.Services.UnitFilterService
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Services.UnitFilterService.Matchers.Interfaces;
|
using PARR.Core.Services.UnitFilterService.Matchers.Interfaces;
|
||||||
using PARR.Core.Services.UnitFilterService.Models;
|
using PARR.Core.Services.UnitFilterService.Models;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
|
|
||||||
namespace PARR.Core.Services.UnitFilterService.Matchers;
|
namespace PARR.Core.Services.UnitFilterService.Matchers;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Repositories.Interfaces.Unit;
|
using PARR.Core.Repositories.Interfaces.Unit;
|
||||||
using PARR.Core.Services.UnitFilterService.Matchers.Interfaces;
|
using PARR.Core.Services.UnitFilterService.Matchers.Interfaces;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
namespace PARR.Core.Services.UnitFilterService.Matchers;
|
namespace PARR.Core.Services.UnitFilterService.Matchers;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
using PARR.Core.Repositories.Interfaces.Unit;
|
using PARR.Core.Repositories.Interfaces.Unit;
|
||||||
using PARR.Core.Services.UnitFilterService.Matchers.Interfaces;
|
using PARR.Core.Services.UnitFilterService.Matchers.Interfaces;
|
||||||
using PARR.Core.Services.UnitFilterService.Models;
|
using PARR.Core.Services.UnitFilterService.Models;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
namespace PARR.Core.Services.UnitFilterService.Matchers;
|
namespace PARR.Core.Services.UnitFilterService.Matchers;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using PARR.Core.Services.UnitFilterService.Models;
|
using PARR.Core.Services.UnitFilterService.Models;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
namespace PARR.Core.Services.UnitFilterService.Matchers.Interfaces
|
namespace PARR.Core.Services.UnitFilterService.Matchers.Interfaces
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
namespace PARR.Core.Services.UnitFilterService.Matchers.Interfaces
|
namespace PARR.Core.Services.UnitFilterService.Matchers.Interfaces
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using PARR.Core.Services.UnitFilterService.Models;
|
using PARR.Core.Services.UnitFilterService.Models;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
namespace PARR.Core.Services.UnitFilterService.Matchers.Interfaces
|
namespace PARR.Core.Services.UnitFilterService.Matchers.Interfaces
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Common.Interfaces;
|
using PARR.Core.Common.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.Core.Repositories.Interfaces.Unit;
|
using PARR.Core.Repositories.Interfaces.Unit;
|
||||||
using PARR.Core.Services.UnitFilterService.Matchers.Interfaces;
|
using PARR.Core.Services.UnitFilterService.Matchers.Interfaces;
|
||||||
using PARR.Core.Services.UnitFilterService.Models;
|
using PARR.Core.Services.UnitFilterService.Models;
|
||||||
using PARR.Core.Services.UnitService.Interfaces;
|
using PARR.Core.Services.UnitService.Interfaces;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Entities.Unit;
|
using PARR.Domain.Entities.Unit;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Repositories.Interfaces;
|
using PARR.Core.Repositories.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.Core.Repositories.Interfaces.TaskRepositories;
|
using PARR.Core.Repositories.Interfaces.TaskRepositories;
|
||||||
using PARR.Core.Services.NextRunServices;
|
using PARR.Core.Services.NextRunServices;
|
||||||
using PARR.Core.Services.TaskServices.Helpers;
|
using PARR.Core.Services.TaskServices.Helpers;
|
||||||
@@ -10,7 +10,6 @@ using PARR.Core.Services.Workload.Interfaces;
|
|||||||
using PARR.Core.Services.Workload.Models;
|
using PARR.Core.Services.Workload.Models;
|
||||||
using PARR.Domain.Cache.Models;
|
using PARR.Domain.Cache.Models;
|
||||||
using PARR.Domain.DTOs.Workload;
|
using PARR.Domain.DTOs.Workload;
|
||||||
using PARR.Domain.Entities;
|
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
using PARR.Domain.Enums.Workload;
|
using PARR.Domain.Enums.Workload;
|
||||||
|
|
||||||
|
|||||||
@@ -3,15 +3,14 @@ using Microsoft.Extensions.Logging;
|
|||||||
using Microsoft.Extensions.Logging.Abstractions;
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
using Moq;
|
using Moq;
|
||||||
using PARR.Core.Common.Interfaces;
|
using PARR.Core.Common.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.Core.Repositories.Interfaces.Unit;
|
using PARR.Core.Repositories.Interfaces.Unit;
|
||||||
using PARR.Core.Services.UnitFilterService;
|
|
||||||
using PARR.Core.Services.UnitFilterService.Matchers.Interfaces;
|
using PARR.Core.Services.UnitFilterService.Matchers.Interfaces;
|
||||||
using PARR.Core.Services.UnitFilterService.Models;
|
using PARR.Core.Services.UnitFilterService.Models;
|
||||||
using PARR.Core.Services.UnitService.Interfaces;
|
using PARR.Core.Services.UnitService.Interfaces;
|
||||||
using PARR.DAL.Context;
|
using PARR.DAL.Context;
|
||||||
using PARR.Domain.Cache.Models;
|
using PARR.Domain.Cache.Models;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Entities.JobGroupEntities;
|
using PARR.Domain.Entities.JobGroupEntities;
|
||||||
using PARR.Domain.Entities.Unit;
|
using PARR.Domain.Entities.Unit;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using PARR.Core.Extensions;
|
|||||||
using PARR.Domain.Common.Roles;
|
using PARR.Domain.Common.Roles;
|
||||||
using PARR.Domain.Common.Template;
|
using PARR.Domain.Common.Template;
|
||||||
using PARR.Domain.Entities;
|
using PARR.Domain.Entities;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Entities.JobGroupEntities;
|
using PARR.Domain.Entities.JobGroupEntities;
|
||||||
using PARR.Domain.Entities.RobotEntities;
|
using PARR.Domain.Entities.RobotEntities;
|
||||||
using PARR.Domain.Entities.Schedule;
|
using PARR.Domain.Entities.Schedule;
|
||||||
@@ -179,9 +179,9 @@ namespace PARR.DAL.Context
|
|||||||
modelBuilder.Entity<JobGroupType>(f =>
|
modelBuilder.Entity<JobGroupType>(f =>
|
||||||
{
|
{
|
||||||
f.HasData(
|
f.HasData(
|
||||||
new() { Id = new Guid("4FA62E79-86BB-47C2-BE1A-72A716A170FA"), DateCreated = dateCreated, DateModified = null, Name = JobGroupTypesEnum.Simple.ToString(), Code = JobGroupTypesEnum.Simple, Description = "Обычный", IsAllowJobUnitFilter = true, IsJobGroupAutoControl = false },
|
new() { Id = new Guid("4FA62E79-86BB-47C2-BE1A-72A716A170FA"), DateCreated = dateCreated, DateModified = null, Name = JobGroupTypesEnum.Simple.ToString(), Code = JobGroupTypesEnum.Simple, Description = "Обычный", IsAllowJobUnitFilter = true, IsJobGroupAutoControl = false, IsRelationshipsAllowed = false },
|
||||||
new() { Id = new Guid("6EC58B1A-5C40-47B9-B036-4FA490E8D503"), DateCreated = dateCreated, DateModified = null, Name = JobGroupTypesEnum.Umbrella.ToString(), Code = JobGroupTypesEnum.Umbrella, Description = "Зонтик", IsAllowJobUnitFilter = false, IsJobGroupAutoControl = true },
|
new() { Id = new Guid("6EC58B1A-5C40-47B9-B036-4FA490E8D503"), DateCreated = dateCreated, DateModified = null, Name = JobGroupTypesEnum.Umbrella.ToString(), Code = JobGroupTypesEnum.Umbrella, Description = "Зонтик", IsAllowJobUnitFilter = false, IsJobGroupAutoControl = true, IsRelationshipsAllowed = true },
|
||||||
new() { Id = new Guid("318625E5-F833-436A-99DF-2A382A1E71C7"), DateCreated = dateCreated, DateModified = null, Name = JobGroupTypesEnum.Group.ToString(), Code = JobGroupTypesEnum.Group, Description = "Сгруппированный", IsAllowJobUnitFilter = false, IsJobGroupAutoControl = true }
|
new() { Id = new Guid("318625E5-F833-436A-99DF-2A382A1E71C7"), DateCreated = dateCreated, DateModified = null, Name = JobGroupTypesEnum.Group.ToString(), Code = JobGroupTypesEnum.Group, Description = "Сгруппированный", IsAllowJobUnitFilter = false, IsJobGroupAutoControl = true, IsRelationshipsAllowed = true }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ using Microsoft.Extensions.Configuration;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Repositories.Interfaces;
|
using PARR.Core.Repositories.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
|
||||||
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.Core.Repositories.Interfaces.RobotRepositories;
|
using PARR.Core.Repositories.Interfaces.RobotRepositories;
|
||||||
using PARR.Core.Repositories.Interfaces.Schedule;
|
using PARR.Core.Repositories.Interfaces.Schedule;
|
||||||
using PARR.Core.Repositories.Interfaces.TaskRepositories;
|
using PARR.Core.Repositories.Interfaces.TaskRepositories;
|
||||||
@@ -14,6 +14,7 @@ using PARR.DAL.Context;
|
|||||||
using PARR.DAL.Repositories;
|
using PARR.DAL.Repositories;
|
||||||
using PARR.DAL.Repositories.Job;
|
using PARR.DAL.Repositories.Job;
|
||||||
using PARR.DAL.Repositories.JobGroupRepositories;
|
using PARR.DAL.Repositories.JobGroupRepositories;
|
||||||
|
using PARR.DAL.Repositories.JobRepositories;
|
||||||
using PARR.DAL.Repositories.RobotRepositories;
|
using PARR.DAL.Repositories.RobotRepositories;
|
||||||
using PARR.DAL.Repositories.Schedule;
|
using PARR.DAL.Repositories.Schedule;
|
||||||
using PARR.DAL.Repositories.TaskRepositories;
|
using PARR.DAL.Repositories.TaskRepositories;
|
||||||
|
|||||||
4021
PARR.DAL/Migrations/20260615235401_tblGroupTypesAddRelationshipsSettings.Designer.cs
generated
Normal file
4021
PARR.DAL/Migrations/20260615235401_tblGroupTypesAddRelationshipsSettings.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace PARR.DAL.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class tblGroupTypesAddRelationshipsSettings : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "IsRelationshipsAllowed",
|
||||||
|
schema: "jobGroup",
|
||||||
|
table: "GroupTypes",
|
||||||
|
type: "boolean",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false,
|
||||||
|
comment: "Разрешена настройка кол-ва связей");
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
schema: "jobGroup",
|
||||||
|
table: "GroupTypes",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: new Guid("318625e5-f833-436a-99df-2a382a1e71c7"),
|
||||||
|
column: "IsRelationshipsAllowed",
|
||||||
|
value: true);
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
schema: "jobGroup",
|
||||||
|
table: "GroupTypes",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: new Guid("4fa62e79-86bb-47c2-be1a-72a716a170fa"),
|
||||||
|
column: "IsRelationshipsAllowed",
|
||||||
|
value: false);
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
schema: "jobGroup",
|
||||||
|
table: "GroupTypes",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: new Guid("6ec58b1a-5c40-47b9-b036-4fa490e8d503"),
|
||||||
|
column: "IsRelationshipsAllowed",
|
||||||
|
value: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "IsRelationshipsAllowed",
|
||||||
|
schema: "jobGroup",
|
||||||
|
table: "GroupTypes");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -599,6 +599,10 @@ namespace PARR.DAL.Migrations
|
|||||||
.HasColumnType("boolean")
|
.HasColumnType("boolean")
|
||||||
.HasComment("Автоконтролем управляет JobGroup? true - да JobGroup, false - Job. Влияет на интерфейс и на логику работы автоконтроля.");
|
.HasComment("Автоконтролем управляет JobGroup? true - да JobGroup, false - Job. Влияет на интерфейс и на логику работы автоконтроля.");
|
||||||
|
|
||||||
|
b.Property<bool>("IsRelationshipsAllowed")
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasComment("Разрешена настройка кол-ва связей");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@@ -619,6 +623,7 @@ namespace PARR.DAL.Migrations
|
|||||||
Description = "Обычный",
|
Description = "Обычный",
|
||||||
IsAllowJobUnitFilter = true,
|
IsAllowJobUnitFilter = true,
|
||||||
IsJobGroupAutoControl = false,
|
IsJobGroupAutoControl = false,
|
||||||
|
IsRelationshipsAllowed = false,
|
||||||
Name = "Simple"
|
Name = "Simple"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
@@ -629,6 +634,7 @@ namespace PARR.DAL.Migrations
|
|||||||
Description = "Зонтик",
|
Description = "Зонтик",
|
||||||
IsAllowJobUnitFilter = false,
|
IsAllowJobUnitFilter = false,
|
||||||
IsJobGroupAutoControl = true,
|
IsJobGroupAutoControl = true,
|
||||||
|
IsRelationshipsAllowed = true,
|
||||||
Name = "Umbrella"
|
Name = "Umbrella"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
@@ -639,6 +645,7 @@ namespace PARR.DAL.Migrations
|
|||||||
Description = "Сгруппированный",
|
Description = "Сгруппированный",
|
||||||
IsAllowJobUnitFilter = false,
|
IsAllowJobUnitFilter = false,
|
||||||
IsJobGroupAutoControl = true,
|
IsJobGroupAutoControl = true,
|
||||||
|
IsRelationshipsAllowed = true,
|
||||||
Name = "Group"
|
Name = "Group"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
using PARR.DAL.Context;
|
using PARR.DAL.Context;
|
||||||
using PARR.DAL.Repositories.Base;
|
using PARR.DAL.Repositories.Base;
|
||||||
using PARR.Domain.Entities.JobGroupEntities;
|
using PARR.Domain.Entities.JobGroupEntities;
|
||||||
|
|
||||||
namespace PARR.DAL.Repositories.Job
|
namespace PARR.DAL.Repositories.JobGroupRepositories
|
||||||
{
|
{
|
||||||
internal class JobGroupRepository : BaseRepository<JobGroup>, IJobGroupRepository
|
internal class JobGroupRepository : BaseRepository<JobGroup>, IJobGroupRepository
|
||||||
{
|
{
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
using PARR.DAL.Context;
|
using PARR.DAL.Context;
|
||||||
using PARR.DAL.Repositories.Base;
|
using PARR.DAL.Repositories.Base;
|
||||||
using PARR.Domain.Entities.JobGroupEntities;
|
using PARR.Domain.Entities.JobGroupEntities;
|
||||||
|
|
||||||
namespace PARR.DAL.Repositories.Job
|
namespace PARR.DAL.Repositories.JobGroupRepositories
|
||||||
{
|
{
|
||||||
internal class JobGroupTypeRepository : BaseRepository<JobGroupType>, IJobGroupTypeRepository
|
internal class JobGroupTypeRepository : BaseRepository<JobGroupType>, IJobGroupTypeRepository
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.DAL.Context;
|
using PARR.DAL.Context;
|
||||||
using PARR.DAL.Repositories.Base;
|
using PARR.DAL.Repositories.Base;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
namespace PARR.DAL.Repositories.Job
|
namespace PARR.DAL.Repositories.Job
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.DAL.Context;
|
using PARR.DAL.Context;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
namespace PARR.DAL.Repositories.Job
|
namespace PARR.DAL.Repositories.Job
|
||||||
{
|
{
|
||||||
@@ -17,5 +17,10 @@ namespace PARR.DAL.Repositories.Job
|
|||||||
{
|
{
|
||||||
return dataContext.JobAutoControls;
|
return dataContext.JobAutoControls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RemoveRange(List<JobAutoControl> autoControlList)
|
||||||
|
{
|
||||||
|
dataContext.JobAutoControls.RemoveRange(autoControlList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.DAL.Context;
|
using PARR.DAL.Context;
|
||||||
using PARR.DAL.Repositories.Base;
|
using PARR.DAL.Repositories.Base;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
namespace PARR.DAL.Repositories.Job
|
namespace PARR.DAL.Repositories.JobRepositories
|
||||||
{
|
{
|
||||||
internal class JobRepository : BaseRepository<Domain.Entities.Job.Job>, IJobRepository
|
internal class JobRepository : BaseRepository<Domain.Entities.JobEntities.Job>, IJobRepository
|
||||||
{
|
{
|
||||||
public JobRepository(DataContext dataContext, ILogger<JobRepository> logger) : base(logger, dataContext) { }
|
public JobRepository(DataContext dataContext, ILogger<JobRepository> logger) : base(logger, dataContext) { }
|
||||||
|
|
||||||
public override Task<bool> CreateAsync(Domain.Entities.Job.Job obj)
|
public override Task<bool> CreateAsync(Domain.Entities.JobEntities.Job obj)
|
||||||
{
|
{
|
||||||
if (obj.AutoControl == null)
|
if (obj.AutoControl == null)
|
||||||
obj.AutoControl = new JobAutoControl
|
obj.AutoControl = new JobAutoControl
|
||||||
@@ -22,7 +22,7 @@ namespace PARR.DAL.Repositories.Job
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override Task<bool> AddRangeAsync(List<Domain.Entities.Job.Job> objs)
|
public override Task<bool> AddRangeAsync(List<Domain.Entities.JobEntities.Job> objs)
|
||||||
{
|
{
|
||||||
objs.ForEach(job =>
|
objs.ForEach(job =>
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.DAL.Context;
|
using PARR.DAL.Context;
|
||||||
using PARR.DAL.Repositories.Base;
|
using PARR.DAL.Repositories.Base;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
namespace PARR.DAL.Repositories.Job
|
namespace PARR.DAL.Repositories.Job
|
||||||
{
|
{
|
||||||
@@ -5,7 +5,7 @@ using PARR.Domain.Entities.JobGroupEntities;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace PARR.Domain.Entities.Job
|
namespace PARR.Domain.Entities.JobEntities
|
||||||
{
|
{
|
||||||
[Table("Jobs", Schema = DatabaseSchemas.Job)]
|
[Table("Jobs", Schema = DatabaseSchemas.Job)]
|
||||||
[Comment("Таблица видов работ")]
|
[Comment("Таблица видов работ")]
|
||||||
@@ -3,7 +3,7 @@ using PARR.Domain.Constants;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace PARR.Domain.Entities.Job
|
namespace PARR.Domain.Entities.JobEntities
|
||||||
{
|
{
|
||||||
[Table("AutoControls", Schema = DatabaseSchemas.Job)]
|
[Table("AutoControls", Schema = DatabaseSchemas.Job)]
|
||||||
[Comment("Таблица управления автоконтролем для работ")]
|
[Comment("Таблица управления автоконтролем для работ")]
|
||||||
@@ -5,7 +5,7 @@ using PARR.Domain.Entities.Unit;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace PARR.Domain.Entities.Job
|
namespace PARR.Domain.Entities.JobEntities
|
||||||
{
|
{
|
||||||
[Table("FieldFilters", Schema = DatabaseSchemas.Job)]
|
[Table("FieldFilters", Schema = DatabaseSchemas.Job)]
|
||||||
[Comment("Таблица описания критериев выборки аттрибутов ЭК")]
|
[Comment("Таблица описания критериев выборки аттрибутов ЭК")]
|
||||||
@@ -3,7 +3,7 @@ using PARR.Domain.Constants;
|
|||||||
using PARR.Domain.Entities.Unit;
|
using PARR.Domain.Entities.Unit;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace PARR.Domain.Entities.Job
|
namespace PARR.Domain.Entities.JobEntities
|
||||||
{
|
{
|
||||||
[Table("RelationshipFilters", Schema = DatabaseSchemas.Job)]
|
[Table("RelationshipFilters", Schema = DatabaseSchemas.Job)]
|
||||||
[Comment("Таблица фильтров связей ЭК")]
|
[Comment("Таблица фильтров связей ЭК")]
|
||||||
@@ -4,7 +4,7 @@ using PARR.Domain.Entities.Base;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace PARR.Domain.Entities.Job
|
namespace PARR.Domain.Entities.JobEntities
|
||||||
{
|
{
|
||||||
[Table("UnitFilters", Schema = DatabaseSchemas.Job)]
|
[Table("UnitFilters", Schema = DatabaseSchemas.Job)]
|
||||||
[Comment("Таблица описания критериев выборки ЭК, описание полей в АСУ ЕСПП")]
|
[Comment("Таблица описания критериев выборки ЭК, описание полей в АСУ ЕСПП")]
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
using PARR.Domain.Constants;
|
using PARR.Domain.Constants;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace PARR.Domain.Entities.Job
|
namespace PARR.Domain.Entities.JobEntities
|
||||||
{
|
{
|
||||||
[Table("UnitsInTemplates", Schema = DatabaseSchemas.Job)]
|
[Table("UnitsInTemplates", Schema = DatabaseSchemas.Job)]
|
||||||
[Comment("Таблица связи ЭК в шаблонах")]
|
[Comment("Таблица связи ЭК в шаблонах")]
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PARR.Domain.Constants;
|
using PARR.Domain.Constants;
|
||||||
using PARR.Domain.Entities.Base;
|
using PARR.Domain.Entities.Base;
|
||||||
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Entities.Schedule;
|
using PARR.Domain.Entities.Schedule;
|
||||||
using PARR.Domain.Entities.Unit;
|
using PARR.Domain.Entities.Unit;
|
||||||
using PARR.Domain.Settings;
|
using PARR.Domain.Settings;
|
||||||
@@ -180,7 +181,7 @@ namespace PARR.Domain.Entities.JobGroupEntities
|
|||||||
[ForeignKey(nameof(GroupTypeId))]
|
[ForeignKey(nameof(GroupTypeId))]
|
||||||
public JobGroupType? GroupType { get; set; }
|
public JobGroupType? GroupType { get; set; }
|
||||||
|
|
||||||
public ICollection<Job.Job> Jobs { get; set; } = new HashSet<Job.Job>();
|
public ICollection<Job> Jobs { get; set; } = new HashSet<Job>();
|
||||||
|
|
||||||
public ICollection<EsppSchValue> EsppSchValues { get; set; } = new HashSet<EsppSchValue>();
|
public ICollection<EsppSchValue> EsppSchValues { get; set; } = new HashSet<EsppSchValue>();
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PARR.Domain.Cache.Models;
|
|
||||||
using PARR.Domain.Constants;
|
using PARR.Domain.Constants;
|
||||||
using PARR.Domain.Entities.Job;
|
|
||||||
using PARR.Domain.Entities.Unit;
|
using PARR.Domain.Entities.Unit;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PARR.Domain.Entities.JobGroupEntities
|
namespace PARR.Domain.Entities.JobGroupEntities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,10 +35,17 @@ namespace PARR.Domain.Entities.JobGroupEntities
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Автоконтролем управляет JobGroup? true - да JobGroup, false - Job.
|
/// Автоконтролем управляет JobGroup? true - да JobGroup, false - Job.
|
||||||
/// Влияет на интерфейс и на логику работы автоконтроля.
|
/// Влияет на интерфейс и на логику работы автоконтроля.
|
||||||
|
/// Если true - то в GUI, кнопку синхронизировать можно нажать только в группах.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Comment("Автоконтролем управляет JobGroup? true - да JobGroup, false - Job. Влияет на интерфейс и на логику работы автоконтроля.")]
|
[Comment("Автоконтролем управляет JobGroup? true - да JobGroup, false - Job. Влияет на интерфейс и на логику работы автоконтроля.")]
|
||||||
public bool IsJobGroupAutoControl { get; set; } = false;
|
public bool IsJobGroupAutoControl { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Разрешена настройка кол-ва связей
|
||||||
|
/// </summary>
|
||||||
|
[Comment("Разрешена настройка кол-ва связей")]
|
||||||
|
public bool IsRelationshipsAllowed { get; set; } = false;
|
||||||
|
|
||||||
public ICollection<JobGroup> JobGroups { get; set; } = new HashSet<JobGroup>();
|
public ICollection<JobGroup> JobGroups { get; set; } = new HashSet<JobGroup>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
using PARR.Domain.Entities.Base;
|
using PARR.Domain.Entities.Base;
|
||||||
using PARR.Domain.Entities.Base.History;
|
using PARR.Domain.Entities.Base.History;
|
||||||
using PARR.Domain.Entities.Base.History.Base;
|
using PARR.Domain.Entities.Base.History.Base;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
@@ -77,7 +77,7 @@ namespace PARR.Domain.Entities
|
|||||||
//public Host? Host { get; set; }
|
//public Host? Host { get; set; }
|
||||||
|
|
||||||
[ForeignKey(nameof(JobId))]
|
[ForeignKey(nameof(JobId))]
|
||||||
public Job.Job? Job { get; set; }
|
public JobEntities.Job? Job { get; set; }
|
||||||
|
|
||||||
[ForeignKey(nameof(UnitId))]
|
[ForeignKey(nameof(UnitId))]
|
||||||
public Unit.Unit? Unit { get; set; }
|
public Unit.Unit? Unit { get; set; }
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using PARR.Domain.Entities.Base;
|
using PARR.Domain.Entities.Base;
|
||||||
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
@@ -30,6 +31,6 @@ namespace PARR.Domain.Entities
|
|||||||
public Subprocess? Subprocess { get; set; }
|
public Subprocess? Subprocess { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public ICollection<Job.Job> Jobs { get; set; } = new HashSet<Job.Job>();
|
public ICollection<Job> Jobs { get; set; } = new HashSet<Job>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PARR.Domain.Constants;
|
using PARR.Domain.Constants;
|
||||||
using PARR.Domain.Entities.Base;
|
using PARR.Domain.Entities.Base;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PARR.Domain.Constants;
|
using PARR.Domain.Constants;
|
||||||
using PARR.Domain.Entities.Base;
|
using PARR.Domain.Entities.Base;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Entities.JobGroupEntities;
|
using PARR.Domain.Entities.JobGroupEntities;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PARR.Domain.Constants;
|
using PARR.Domain.Constants;
|
||||||
using PARR.Domain.Entities.Base;
|
using PARR.Domain.Entities.Base;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ namespace PARR.Infrastructure.Rabbit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RabbitSendResult> SendAsync(IMqSettings mqSettings, List<object> msgObjectList)
|
public async Task<RabbitSendResult> SendAsync(IMqSettings mqSettings, IEnumerable<object> msgObjectList)
|
||||||
{
|
{
|
||||||
var msgStringList = msgObjectList.Select(t => JsonSerializer.Serialize(t, jsonOptions)).ToArray();
|
var msgStringList = msgObjectList.Select(t => JsonSerializer.Serialize(t, jsonOptions)).ToArray();
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Common.Interfaces;
|
using PARR.Core.Common.Interfaces;
|
||||||
using PARR.Core.Common.Interfaces.RabbitServices;
|
using PARR.Core.Common.Interfaces.RabbitServices;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.Domain.Common.Rabbit.Messages;
|
using PARR.Domain.Common.Rabbit.Messages;
|
||||||
using PARR.Domain.Entities.Base.History;
|
using PARR.Domain.Entities.Base.History;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
@@ -13,11 +14,11 @@ namespace PARR.JobAutoControl
|
|||||||
{
|
{
|
||||||
internal class JobAutoControlManager : IJobAutoControlManager
|
internal class JobAutoControlManager : IJobAutoControlManager
|
||||||
{
|
{
|
||||||
private readonly WorkerSettings workerSettings;
|
private readonly WorkerSettings _workerSettings;
|
||||||
private readonly ILogger<JobAutoControlManager> logger;
|
private readonly ILogger<JobAutoControlManager> _logger;
|
||||||
private readonly IIntervalService intervalService;
|
private readonly IIntervalService _intervalService;
|
||||||
private readonly IServiceProvider serviceProvider;
|
private readonly IServiceProvider _serviceProvider;
|
||||||
private readonly MqSettings mqSettings;
|
private readonly MqSettings _mqSettings;
|
||||||
|
|
||||||
public JobAutoControlManager(
|
public JobAutoControlManager(
|
||||||
WorkerSettings workerSettings,
|
WorkerSettings workerSettings,
|
||||||
@@ -27,68 +28,87 @@ namespace PARR.JobAutoControl
|
|||||||
MqSettings mqSettings
|
MqSettings mqSettings
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.workerSettings = workerSettings;
|
_workerSettings = workerSettings;
|
||||||
this.logger = logger;
|
_logger = logger;
|
||||||
this.intervalService = intervalService;
|
_intervalService = intervalService;
|
||||||
this.serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
this.mqSettings = mqSettings;
|
_mqSettings = mqSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StartAsync()
|
public async Task StartAsync()
|
||||||
{
|
{
|
||||||
logger.LogInformation("Запуск сервиса управления авто-контролем РР (JobAutoControl)");
|
_logger.LogInformation("Запуск сервиса управления авто-контролем РР (JobAutoControl)");
|
||||||
|
|
||||||
await intervalService.IntervalInitAsync(async () =>
|
await _intervalService.IntervalInitAsync(async () =>
|
||||||
{
|
{
|
||||||
await using (var scope = serviceProvider.CreateAsyncScope())
|
await using (var scope = _serviceProvider.CreateAsyncScope())
|
||||||
//using (var scope = serviceProvider.CreateScope())
|
|
||||||
{
|
{
|
||||||
var jobAutoControlService = scope.ServiceProvider.GetService<IJobAutoControlRepository>();
|
var jobAutoControlRepository = scope.ServiceProvider.GetRequiredService<IJobAutoControlRepository>();
|
||||||
var mqService = scope.ServiceProvider.GetService<IRabbitService>();
|
var jobGroupAutoControlRepository = scope.ServiceProvider.GetRequiredService<IJobGroupAutoControlRepository>();
|
||||||
|
var mqService = scope.ServiceProvider.GetRequiredService<IRabbitService>();
|
||||||
|
|
||||||
if (jobAutoControlService == null || mqService == null)
|
await HandlerAsync(jobAutoControlRepository, jobGroupAutoControlRepository, mqService);
|
||||||
throw new Exception($"Не смог получить серивс {nameof(IJobAutoControlRepository)} или {nameof(IRabbitService)}");
|
|
||||||
|
|
||||||
await HandlerAsync(jobAutoControlService, mqService);
|
|
||||||
}
|
}
|
||||||
}, workerSettings.RepeatEvery);
|
}, _workerSettings.RepeatEvery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async Task HandlerAsync(IJobAutoControlRepository jobAutoControlService, IRabbitService mqService)
|
private async Task HandlerAsync(IJobAutoControlRepository jobAutoControlRepository, IJobGroupAutoControlRepository jobGroupAutoControlRepository, IRabbitService mqService)
|
||||||
{
|
{
|
||||||
var jobsWithAutoControl = await jobAutoControlService.Get().Where(t => t.IsEnable).ToListAsync();
|
// Список JobGroup с включенным автоконтролем
|
||||||
|
var jobGroupsIds = await jobGroupAutoControlRepository.Get()
|
||||||
|
.AsNoTracking()
|
||||||
|
.Where(t => t.IsEnable)
|
||||||
|
.Select(t => t.JobGroupId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
logger.LogInformation($"Работ с включенным авто-контролем: {jobsWithAutoControl.Count} шт.");
|
// Список Job с включенным автоконтролем, но у которых в JobGroupType.IsJobGroupAutocOntrol==false
|
||||||
|
var jobIds = await jobAutoControlRepository.Get()
|
||||||
|
.AsNoTracking()
|
||||||
|
.Where(t => t.IsEnable && t.Job!.Group!.GroupType!.IsJobGroupAutoControl == false)
|
||||||
|
.Select(t => t.JobId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
if (jobsWithAutoControl.Count == 0)
|
_logger.LogInformation("Найдено объектов с включенным автоконтролем, групп: {JobGroupCount} шт., работ: {JobCount} шт.", jobGroupsIds.Count, jobIds.Count);
|
||||||
|
|
||||||
|
if (jobGroupsIds.Count == 0 && jobIds.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
// формируем сообщения
|
// формируем сообщения
|
||||||
var msgList = jobsWithAutoControl.Select(t => new TemplateMatcherMq
|
var msgList = new List<TemplateMatcherMq>(jobGroupsIds.Count + jobIds.Count);
|
||||||
|
|
||||||
|
var initiator = new HistoryInitiator
|
||||||
|
{
|
||||||
|
InitiatorComment = $"Инициатор авто-контроль, периодичность: {_workerSettings.RepeatEvery}",
|
||||||
|
InitiatorIp = null,
|
||||||
|
InitiatorParrComponentId = ParrComponentsEnum.JobAutoControl
|
||||||
|
};
|
||||||
|
|
||||||
|
// группы
|
||||||
|
msgList.AddRange(jobGroupsIds.Select(id => new TemplateMatcherMq
|
||||||
|
{
|
||||||
|
Action = TemplateMatcherActionEnum.Sync,
|
||||||
|
EntityType = SyncTaskEntityTypeEnum.JobGroup,
|
||||||
|
Id = id,
|
||||||
|
Initiator = initiator
|
||||||
|
}));
|
||||||
|
|
||||||
|
// работы
|
||||||
|
msgList.AddRange(jobIds.Select(id => new TemplateMatcherMq
|
||||||
{
|
{
|
||||||
Action = TemplateMatcherActionEnum.Sync,
|
Action = TemplateMatcherActionEnum.Sync,
|
||||||
EntityType = SyncTaskEntityTypeEnum.Job,
|
EntityType = SyncTaskEntityTypeEnum.Job,
|
||||||
Id = t.JobId,
|
Id = id,
|
||||||
Initiator = new HistoryInitiator
|
Initiator = initiator
|
||||||
{
|
}));
|
||||||
InitiatorComment = $"Инициатор авто-контроль, периодичность: {workerSettings.RepeatEvery}",
|
|
||||||
InitiatorIp = null,
|
|
||||||
InitiatorParrComponentId = ParrComponentsEnum.JobAutoControl
|
|
||||||
}
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
//var msgStrList = msgList.Select(t => JsonSerializer.Serialize(t));
|
|
||||||
|
|
||||||
// отправляем задания в очередь template matcher`a
|
// отправляем задания в очередь template matcher`a
|
||||||
//var sendResult = await mqService.SendAsync(mqSettings.TemplateMatcher, msgStrList.ToArray());
|
var sendResult = await mqService.SendAsync(_mqSettings.TemplateMatcher, msgList);
|
||||||
var sendResult = await mqService.SendAsync(mqSettings.TemplateMatcher, msgList.ToList<object>());
|
|
||||||
|
|
||||||
if (!sendResult.IsSuccess)
|
if (!sendResult.IsSuccess)
|
||||||
logger.LogError($"Ошибка при отправке сообщений ({msgList.Count()} шт.) в очередь.");
|
_logger.LogError("Ошибка при отправке сообщений ({Count} шт.) в очередь.", msgList.Count);
|
||||||
else
|
else
|
||||||
logger.LogInformation($"Выполнена отправка сообщений в очередь, {msgList.Count()} шт.");
|
_logger.LogInformation("Выполнена отправка сообщений в очередь, {Count} шт.", msgList.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Common.Interfaces;
|
using PARR.Core.Common.Interfaces;
|
||||||
using PARR.Core.Common.Interfaces.RabbitServices;
|
using PARR.Core.Common.Interfaces.RabbitServices;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
using PARR.Domain.Common.Rabbit.Messages;
|
using PARR.Domain.Common.Rabbit.Messages;
|
||||||
using PARR.NextRun.Services;
|
using PARR.NextRun.Services;
|
||||||
using PARR.NextRun.Settings;
|
using PARR.NextRun.Settings;
|
||||||
|
|||||||
@@ -2,10 +2,11 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Repositories.Base;
|
using PARR.Core.Repositories.Base;
|
||||||
using PARR.Core.Repositories.Interfaces;
|
using PARR.Core.Repositories.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.Domain.Entities;
|
using PARR.Domain.Entities;
|
||||||
using PARR.Domain.Entities.Base;
|
using PARR.Domain.Entities.Base;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Entities.JobGroupEntities;
|
using PARR.Domain.Entities.JobGroupEntities;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
using PARR.Domain.Entities.JobGroupEntities;
|
using PARR.Domain.Entities.JobGroupEntities;
|
||||||
|
|
||||||
namespace PARR.TemplateDistributor.Services
|
namespace PARR.TemplateDistributor.Services
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PARR.Core.Repositories.Interfaces;
|
using PARR.Core.Repositories.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.Core.Repositories.Interfaces.Unit;
|
using PARR.Core.Repositories.Interfaces.Unit;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PARR.Core.Common.Interfaces;
|
using PARR.Core.Common.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces;
|
using PARR.Core.Repositories.Interfaces;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||||
using PARR.Core.Services.NextRunServices;
|
using PARR.Core.Services.NextRunServices;
|
||||||
using PARR.Core.Services.Shortcodes;
|
using PARR.Core.Services.Shortcodes;
|
||||||
using PARR.Domain.Common.Rabbit.Messages.TemplateMatching;
|
using PARR.Domain.Common.Rabbit.Messages.TemplateMatching;
|
||||||
using PARR.Domain.Entities;
|
using PARR.Domain.Entities;
|
||||||
using PARR.Domain.Entities.Base.History;
|
using PARR.Domain.Entities.Base.History;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
using PARR.TemplateGeneratorWorker.Services;
|
using PARR.TemplateGeneratorWorker.Services;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using PARR.Domain.Common.Rabbit.Messages.TemplateMatching;
|
using PARR.Domain.Common.Rabbit.Messages.TemplateMatching;
|
||||||
using PARR.Domain.Entities.Base.History;
|
using PARR.Domain.Entities.Base.History;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Entities.Unit;
|
using PARR.Domain.Entities.Unit;
|
||||||
|
|
||||||
namespace PARR.TemplateMatcher.Models
|
namespace PARR.TemplateMatcher.Models
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using PARR.Core.Services.UnitFilterService.Models;
|
using PARR.Core.Services.UnitFilterService.Models;
|
||||||
using PARR.Domain.Entities.Base.History;
|
using PARR.Domain.Entities.Base.History;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Entities.JobGroupEntities;
|
using PARR.Domain.Entities.JobGroupEntities;
|
||||||
using PARR.TemplateMatcher.Models;
|
using PARR.TemplateMatcher.Models;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using PARR.Core.Repositories.Interfaces.Unit;
|
|||||||
using PARR.Core.Services.Shortcodes;
|
using PARR.Core.Services.Shortcodes;
|
||||||
using PARR.Domain.Constants;
|
using PARR.Domain.Constants;
|
||||||
using PARR.Domain.Entities;
|
using PARR.Domain.Entities;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Entities.JobGroupEntities;
|
using PARR.Domain.Entities.JobGroupEntities;
|
||||||
using PARR.TemplateMatcher.Models;
|
using PARR.TemplateMatcher.Models;
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ using PARR.Core.Repositories.Interfaces.Unit;
|
|||||||
using PARR.Domain.Common.Rabbit.Messages.TemplateMatching;
|
using PARR.Domain.Common.Rabbit.Messages.TemplateMatching;
|
||||||
using PARR.Domain.Entities;
|
using PARR.Domain.Entities;
|
||||||
using PARR.Domain.Entities.Base.History;
|
using PARR.Domain.Entities.Base.History;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
using PARR.TemplateMatcher.Models;
|
using PARR.TemplateMatcher.Models;
|
||||||
|
using PARR.TemplateMatcher.Services.Implementations;
|
||||||
using PARR.TemplateMatcher.Services.Interfaces;
|
using PARR.TemplateMatcher.Services.Interfaces;
|
||||||
using PARR.TemplateMatcher.Settings;
|
using PARR.TemplateMatcher.Settings;
|
||||||
|
|
||||||
@@ -173,11 +174,9 @@ internal class GroupedTemplateProcessor : IGroupedTemplateProcessor
|
|||||||
HistoryInitiator initiator,
|
HistoryInitiator initiator,
|
||||||
CancellationToken ct)
|
CancellationToken ct)
|
||||||
{
|
{
|
||||||
// Вычисляем флаги активности
|
var (isActiveTemplate, isActiveSchedule) = AutoControlResolver.ResolveInitStates(
|
||||||
var isActiveTemplate = targetJob.AutoControl?.InitUsedTemplateState ?? false;
|
targetJob, targetJob.Group);
|
||||||
var isActiveSchedule = targetJob.AutoControl?.InitUsedScheduleState ?? false;
|
|
||||||
|
|
||||||
// Маппим кортежи в сообщения
|
|
||||||
var unitsInTemplateMsg = unitsInTemplateSubGroup
|
var unitsInTemplateMsg = unitsInTemplateSubGroup
|
||||||
.Select(e => new UnitInTemplateMessage
|
.Select(e => new UnitInTemplateMessage
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.Domain.Entities.JobGroupEntities;
|
using PARR.Domain.Entities.JobGroupEntities;
|
||||||
using PARR.TemplateMatcher.Models;
|
using PARR.TemplateMatcher.Models;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using PARR.Domain.Entities.Base.History;
|
using PARR.Domain.Entities.Base.History;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
using PARR.TemplateMatcher.Models;
|
using PARR.TemplateMatcher.Models;
|
||||||
|
|
||||||
namespace PARR.TemplateMatcher.Services.GroupedSync;
|
namespace PARR.TemplateMatcher.Services.GroupedSync;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using PARR.Core.Services.UnitFilterService.Models;
|
using PARR.Core.Services.UnitFilterService.Models;
|
||||||
using PARR.Domain.Entities.Job;
|
using PARR.Domain.Entities.JobEntities;
|
||||||
|
|
||||||
namespace PARR.TemplateMatcher.Services.GroupedSync
|
namespace PARR.TemplateMatcher.Services.GroupedSync
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Repositories.Interfaces.Job;
|
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||||
using PARR.TemplateMatcher.Services.GroupedSync;
|
using PARR.TemplateMatcher.Services.GroupedSync;
|
||||||
|
|
||||||
namespace PARR.TemplateMatcher.Services.Implementations.GroupedSync;
|
namespace PARR.TemplateMatcher.Services.Implementations.GroupedSync;
|
||||||
@@ -24,6 +24,7 @@ internal class LoadJobGroupStage : IGroupedSyncStage
|
|||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.AsSingleQuery()
|
.AsSingleQuery()
|
||||||
.Include(jg => jg.GroupType)
|
.Include(jg => jg.GroupType)
|
||||||
|
.Include(jg => jg.AutoControl)
|
||||||
.Include(jg => jg.Jobs).ThenInclude(j => j.AutoControl)
|
.Include(jg => jg.Jobs).ThenInclude(j => j.AutoControl)
|
||||||
.Include(jg => jg.Jobs).ThenInclude(j => j.UnitFilters)
|
.Include(jg => jg.Jobs).ThenInclude(j => j.UnitFilters)
|
||||||
.ThenInclude(uf => uf.RelationshipFilters).ThenInclude(rf => rf.UnitField)
|
.ThenInclude(uf => uf.RelationshipFilters).ThenInclude(rf => rf.UnitField)
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user