feat(dal,api): Удалены старые таблицы AppInWorks
This commit is contained in:
@@ -1,102 +0,0 @@
|
||||
namespace PARR.API.Contracts.V1.Responses
|
||||
{
|
||||
public class ApplicationInWorkBaseResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public required string TemplateDuration { get; set; }
|
||||
|
||||
public required string ShortDescription { get; set; }
|
||||
|
||||
public required string FullDescription { get; set; }
|
||||
|
||||
public required string Solution { get; set; }
|
||||
|
||||
public DateTimeOffset ReferenceDate { get; set; }
|
||||
|
||||
public bool IsAutoDistributionEnabled { get; set; }
|
||||
|
||||
public bool IsAgent { get; set; }
|
||||
|
||||
public ApplicationResponse? Application { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class ApplicationInWorkResponse : ApplicationInWorkBaseResponse
|
||||
{
|
||||
public string? AgentName { get; set; }
|
||||
|
||||
public int? AgentTimeOutSec { get; set; }
|
||||
|
||||
public string? AgentScript { get; set; }
|
||||
|
||||
//public WorkResponse? Work { get; set; }
|
||||
|
||||
public int TemplatesCount { get; set; }
|
||||
|
||||
|
||||
#region Статистика
|
||||
|
||||
public TemplateStats? TemplateStatistics { get; set; }
|
||||
|
||||
public ScheduleStats? ScheduleStatistics { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public ApplicationInWorkScheduleResponse? Schedule { get; set; }
|
||||
|
||||
public List<WorkGroupResponse>? WorkGroups { get; set; }
|
||||
|
||||
//public JobAutoControlBaseResponse? AutoControl { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class ApplicationInWorkScheduleResponse
|
||||
{
|
||||
public string Timezone { get; set; } = string.Empty;
|
||||
|
||||
public EsppScheduleTypeScheduleResponse? TypeSchedule { get; set; }
|
||||
|
||||
public List<EsppScheduleValResponse>? Values { get; set; }
|
||||
}
|
||||
|
||||
|
||||
//public class TemplateStats
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Активированных шаблонов
|
||||
// /// </summary>
|
||||
// public int Activated { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// Синхронизировано шаблонов (TaskStatus = 30/Ok)
|
||||
// /// </summary>
|
||||
// public int Synchronized { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// Ошибок синхронизации (RobotStatus = 33/Error)
|
||||
// /// </summary>
|
||||
// public int Errors { get; set; }
|
||||
//}
|
||||
|
||||
|
||||
//public class ScheduleStats
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Активированных шаблонов
|
||||
// /// </summary>
|
||||
// public int Activated { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// Синхронизировано шаблонов (TaskStatus = 30/Ok)
|
||||
// /// </summary>
|
||||
// public int Synchronized { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// Ошибок синхронизации (RobotStatus = 33/Error)
|
||||
// /// </summary>
|
||||
// public int Errors { get; set; }
|
||||
//}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace PARR.API.Contracts.V1.Responses
|
||||
{
|
||||
public class ApplicationResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public required string Name { get; set; }
|
||||
|
||||
public ApplicationTypeResponse? Type { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace PARR.API.Contracts.V1.Responses
|
||||
{
|
||||
public class ApplicationTypeResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public required string Name { get; set; }
|
||||
|
||||
public required string Description { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace PARR.API.Contracts.V1.Responses
|
||||
{
|
||||
public class EkStatusResponse
|
||||
{
|
||||
public int Code { get; set; }
|
||||
public required string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
namespace PARR.API.Contracts.V1.Responses
|
||||
{
|
||||
public class HostBaseResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Ek { get; set; } = string.Empty;
|
||||
|
||||
public required string IP { get; set; }
|
||||
|
||||
//TODO: Удалить поле Status, использовать EkStatus
|
||||
public string? Status { get; set; }
|
||||
|
||||
public EkStatusResponse? EkStatus { get; set; }
|
||||
|
||||
public string? WorkGroupName { get; set; }
|
||||
|
||||
public WorkGroupResponse? WorkGroup { get; set; }
|
||||
|
||||
//TODO: Удалить поле ResponseArea, использовать EkResponseArea
|
||||
public string? ResponseArea { get; set; }
|
||||
|
||||
public ResponseAreaResponse? EkResponseArea { get; set; }
|
||||
|
||||
public DateTimeOffset? LastLogon { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Респонс Хоста для Шаблона
|
||||
/// </summary>
|
||||
public class HostTemplateResponse : HostBaseResponse
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Респонс Хоста с приложениями (компнентном составе)
|
||||
/// </summary>
|
||||
public class HostWithApplicationsResponse : HostBaseResponse
|
||||
{
|
||||
public List<ApplicationResponse>? Applications { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace PARR.API.Contracts.V1.Responses
|
||||
{
|
||||
public class ResponseAreaResponse
|
||||
{
|
||||
public int Code { get; set; }
|
||||
|
||||
public required string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,6 @@
|
||||
{
|
||||
public class StatResponseAreaWorkLoadResponse : StatWorkLoadDataBaseResponse
|
||||
{
|
||||
public required ResponseAreaResponse ResponseArea { get; set; }
|
||||
//public required ResponseAreaResponse ResponseArea { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
{
|
||||
public class StatWorkGroupWorkLoadResponse : StatWorkLoadDataBaseResponse
|
||||
{
|
||||
public required WorkGroupResponse WorkGroup { get; set; }
|
||||
//public required WorkGroupResponse WorkGroup { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
{
|
||||
public class StatWorkWorkLoadResponse : StatWorkLoadDataBaseResponse
|
||||
{
|
||||
public required ApplicationInWorkBaseResponse Job { get; set; }
|
||||
//public required ApplicationInWorkBaseResponse Job { get; set; }
|
||||
|
||||
public required WorkGroupResponse WorkGroup { get; set; }
|
||||
//public required WorkGroupResponse WorkGroup { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace PARR.API.Contracts.V1.Responses
|
||||
{
|
||||
public class WorkGroupResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public required string Name { get; set; }
|
||||
|
||||
public ResponseAreaResponse? ResponseArea { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Requests.Queries;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Управление приложениями
|
||||
/// </summary>
|
||||
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class ApplicationController : BaseApiController
|
||||
{
|
||||
private readonly IMapper mapper;
|
||||
private readonly IApplicationService applicationService;
|
||||
|
||||
public ApplicationController(
|
||||
IMapper mapper,
|
||||
IApplicationService applicationService
|
||||
)
|
||||
{
|
||||
this.mapper = mapper;
|
||||
this.applicationService = applicationService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Список приложений постранично
|
||||
/// </summary>
|
||||
/// <param name="paginationQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.Application.GetAll)]
|
||||
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] ApplicationQuery filter)
|
||||
{
|
||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||
|
||||
IQueryable<Application> query = applicationService.Get()
|
||||
.Include(t => t.ApplicationType)
|
||||
.OrderBy(t => t.Name);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(filter.Name))
|
||||
query = query.Where(t => t.Name.ToLower().Contains(filter.Name.ToLower()));
|
||||
|
||||
if (filter.TypeId.HasValue)
|
||||
query = query.Where(t => t.ApplicationTypeId == filter.TypeId);
|
||||
|
||||
if (filter.Id.HasValue)
|
||||
query = query.Where(t => t.Id == filter.Id);
|
||||
|
||||
|
||||
var apps = await applicationService.GetPage(query, paginationFilter).ToListAsync();
|
||||
|
||||
if (!apps.Any())
|
||||
return NoContent();
|
||||
|
||||
var appsResponse = mapper.Map<List<ApplicationResponse>>(apps);
|
||||
var paginationResponse = new PagedResponse<ApplicationResponse>(appsResponse, true).GetPaginatedProps(paginationFilter, query);
|
||||
|
||||
return Ok(paginationResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Управление типами приложений
|
||||
/// </summary>
|
||||
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class ApplicationTypeController : BaseApiController
|
||||
{
|
||||
private readonly IMapper mapper;
|
||||
private readonly IApplicationTypeService applicationTypeService;
|
||||
|
||||
public ApplicationTypeController(
|
||||
IMapper mapper,
|
||||
IApplicationTypeService applicationTypeService
|
||||
)
|
||||
{
|
||||
this.mapper = mapper;
|
||||
this.applicationTypeService = applicationTypeService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Список типов приложений
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.ApplicationType.GetAll)]
|
||||
public async Task<IActionResult> GetAll()
|
||||
{
|
||||
var appTypes = await applicationTypeService.Get().OrderBy(t => t.Description)
|
||||
.ToListAsync();
|
||||
|
||||
if (!appTypes.Any())
|
||||
return NoContent();
|
||||
|
||||
var response = mapper.Map<List<ApplicationTypeResponse>>(appTypes);
|
||||
|
||||
return Ok(new Response<List<ApplicationTypeResponse>>(response, true));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Статусы ЭК
|
||||
/// </summary>
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class EkStatusController : BaseApiController
|
||||
{
|
||||
private readonly IEkStatusService ekStatusService;
|
||||
private readonly IMapper mapper;
|
||||
|
||||
public EkStatusController(
|
||||
IEkStatusService ekStatusService,
|
||||
IMapper mapper
|
||||
)
|
||||
{
|
||||
this.ekStatusService = ekStatusService;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить список статусов ЭК
|
||||
/// </summary>
|
||||
/// <returns></returns>млни
|
||||
[HttpGet(ApiRoutes.EkStatus.GetAll)]
|
||||
public async Task<IActionResult> GetAll()
|
||||
{
|
||||
var statuses = await ekStatusService.Get().OrderBy(t => t.Name).ToListAsync();
|
||||
|
||||
if (!statuses.Any())
|
||||
return NoContent();
|
||||
|
||||
var response = mapper.Map<List<EkStatusResponse>>(statuses);
|
||||
|
||||
return Ok(new Response<List<EkStatusResponse>>(response, true));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Зоны ответственности
|
||||
/// </summary>
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class ResponseAreaController : BaseApiController
|
||||
{
|
||||
private readonly IMapper mapper;
|
||||
private readonly IResponseAreaService responseAreaService;
|
||||
|
||||
public ResponseAreaController(
|
||||
IMapper mapper,
|
||||
IResponseAreaService responseAreaService
|
||||
)
|
||||
{
|
||||
this.mapper = mapper;
|
||||
this.responseAreaService = responseAreaService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Список зон ответственности
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.ResponseArea.GetAll)]
|
||||
public async Task<IActionResult> GetAll()
|
||||
{
|
||||
var query = responseAreaService.Get().OrderBy(t => t.Name);
|
||||
|
||||
var responseAreas = await query.ToListAsync();
|
||||
|
||||
if (!responseAreas.Any())
|
||||
return NoContent();
|
||||
|
||||
var response = mapper.Map<List<ResponseAreaResponse>>(responseAreas);
|
||||
|
||||
return Ok(new Response<List<ResponseAreaResponse>>(response, true));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить зону ответственности по коду
|
||||
/// </summary>
|
||||
/// <param name="responseAreaCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.ResponseArea.Get)]
|
||||
public async Task<IActionResult> Get([FromRoute] int responseAreaCode)
|
||||
{
|
||||
var responseArea = await responseAreaService.Get().FirstOrDefaultAsync(t => t.Code == responseAreaCode);
|
||||
|
||||
if (responseArea == null)
|
||||
return NotFound();
|
||||
|
||||
var response = mapper.Map<ResponseAreaResponse>(responseArea);
|
||||
|
||||
return Ok(new Response<ResponseAreaResponse>(response, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,19 +22,19 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
public class StatResponseAreaWorkLoadController : BaseApiController
|
||||
{
|
||||
private readonly ITemplateService templateService;
|
||||
private readonly IResponseAreaService responseAreaService;
|
||||
//private readonly IResponseAreaService responseAreaService;
|
||||
private readonly IMapper mapper;
|
||||
private readonly IWorkLoadService workLoadService;
|
||||
|
||||
public StatResponseAreaWorkLoadController(
|
||||
ITemplateService templateService,
|
||||
IResponseAreaService responseAreaService,
|
||||
//IResponseAreaService responseAreaService,
|
||||
IMapper mapper,
|
||||
IWorkLoadService workLoadService
|
||||
)
|
||||
{
|
||||
this.templateService = templateService;
|
||||
this.responseAreaService = responseAreaService;
|
||||
//this.responseAreaService = responseAreaService;
|
||||
this.mapper = mapper;
|
||||
this.workLoadService = workLoadService;
|
||||
}
|
||||
|
||||
@@ -19,20 +19,20 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class StatUnitFieldValuesController : BaseApiController
|
||||
{
|
||||
private readonly IApplicationService applicationService;
|
||||
//private readonly IApplicationService applicationService;
|
||||
private readonly IUnitFieldValueService unitFieldValueService;
|
||||
private readonly INextRunService nextRunService;
|
||||
|
||||
//private readonly ICalendarService calendarService;
|
||||
|
||||
public StatUnitFieldValuesController(
|
||||
IApplicationService applicationService,
|
||||
//IApplicationService applicationService,
|
||||
IUnitFieldValueService unitFieldValueService,
|
||||
//ICalendarService calendarService
|
||||
INextRunService nextRunService
|
||||
)
|
||||
{
|
||||
this.applicationService = applicationService;
|
||||
//this.applicationService = applicationService;
|
||||
this.unitFieldValueService = unitFieldValueService;
|
||||
this.nextRunService = nextRunService;
|
||||
//this.calendarService = calendarService;
|
||||
|
||||
@@ -20,21 +20,21 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
{
|
||||
private readonly ITemplateService templateService;
|
||||
private readonly IWorkLoadService workLoadService;
|
||||
private readonly IWorkGroupService workGroupService;
|
||||
//private readonly IWorkGroupService workGroupService;
|
||||
private readonly IMapper mapper;
|
||||
private readonly ILogger<StatWorkGroupWorkLoadController> logger;
|
||||
|
||||
public StatWorkGroupWorkLoadController(
|
||||
ITemplateService templateService,
|
||||
IWorkLoadService workLoadService,
|
||||
IWorkGroupService workGroupService,
|
||||
//IWorkGroupService workGroupService,
|
||||
IMapper mapper,
|
||||
ILogger<StatWorkGroupWorkLoadController> logger
|
||||
)
|
||||
{
|
||||
this.templateService = templateService;
|
||||
this.workLoadService = workLoadService;
|
||||
this.workGroupService = workGroupService;
|
||||
//this.workGroupService = workGroupService;
|
||||
this.mapper = mapper;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@@ -23,21 +23,21 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
private readonly IWorkLoadService workLoadService;
|
||||
private readonly IMapper mapper;
|
||||
private readonly ILogger<StatWorkWorkLoadController> logger;
|
||||
private readonly IWorkGroupService workGroupService;
|
||||
//private readonly IWorkGroupService workGroupService;
|
||||
|
||||
public StatWorkWorkLoadController(
|
||||
ITemplateService templateService,
|
||||
IWorkLoadService workLoadService,
|
||||
IMapper mapper,
|
||||
ILogger<StatWorkWorkLoadController> logger,
|
||||
IWorkGroupService workGroupService
|
||||
ILogger<StatWorkWorkLoadController> logger
|
||||
//IWorkGroupService workGroupService
|
||||
)
|
||||
{
|
||||
this.templateService = templateService;
|
||||
this.workLoadService = workLoadService;
|
||||
this.mapper = mapper;
|
||||
this.logger = logger;
|
||||
this.workGroupService = workGroupService;
|
||||
//this.workGroupService = workGroupService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Requests.Queries;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Рабочие группы
|
||||
/// </summary>
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class WorkGroupController : BaseApiController
|
||||
{
|
||||
private readonly IMapper mapper;
|
||||
private readonly IWorkGroupService workGroupService;
|
||||
|
||||
public WorkGroupController(
|
||||
IMapper mapper,
|
||||
IWorkGroupService workGroupService
|
||||
)
|
||||
{
|
||||
this.mapper = mapper;
|
||||
this.workGroupService = workGroupService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Список рабочих групп постранично
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.WorkGroup.GetAll)]
|
||||
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] WorkGroupQuery filter)
|
||||
{
|
||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||
|
||||
IQueryable<WorkGroup> query = workGroupService.Get()
|
||||
.Include(t => t.ResponseArea)
|
||||
.OrderBy(t => t.Name);
|
||||
|
||||
if (!string.IsNullOrEmpty(filter.Name))
|
||||
query = query.Where(t => t.Name.ToLower().Contains(filter.Name.ToLower()));
|
||||
|
||||
if (filter.ResponseAreaCode.HasValue)
|
||||
{
|
||||
//todo: validate ResponseAreaEnum
|
||||
if (!Enum.IsDefined(typeof(ResponseAreaEnum), filter.ResponseAreaCode.Value))
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { FieldName = nameof(filter.ResponseAreaCode), Message = "Неверное значение" } }));
|
||||
|
||||
query = query.Where(t => t.ResponseAreaCode == filter.ResponseAreaCode.Value);
|
||||
}
|
||||
|
||||
var workGroups = await workGroupService.GetPage(query, paginationFilter).ToListAsync();
|
||||
|
||||
if (!workGroups.Any())
|
||||
return NoContent();
|
||||
|
||||
var workGroupResponse = mapper.Map<List<WorkGroupResponse>>(workGroups);
|
||||
var paginationResponse = new PagedResponse<WorkGroupResponse>(workGroupResponse, true).GetPaginatedProps(paginationFilter, query);
|
||||
|
||||
return Ok(paginationResponse);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить рабочую группу по id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.WorkGroup.Get)]
|
||||
public async Task<IActionResult> Get([FromRoute] Guid id)
|
||||
{
|
||||
var workGroup = await workGroupService.Get().Include(t => t.ResponseArea).FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
if (workGroup == null)
|
||||
return NotFound();
|
||||
|
||||
var response = mapper.Map<WorkGroupResponse>(workGroup);
|
||||
|
||||
return Ok(new Response<WorkGroupResponse>(response, true));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -106,31 +106,6 @@ namespace PARR.API.MappingProfiles
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
CreateMap<Application, ApplicationResponse>()
|
||||
.ForMember(t => t.Type, o => o.MapFrom(s => s.ApplicationType));
|
||||
|
||||
CreateMap<ApplicationType, ApplicationTypeResponse>();
|
||||
|
||||
#region Host
|
||||
|
||||
CreateMap<DAL.Models.Host, HostBaseResponse>()
|
||||
.Include<DAL.Models.Host, HostTemplateResponse>()
|
||||
.Include<DAL.Models.Host, HostWithApplicationsResponse>()
|
||||
.ForMember(d => d.Status, o => o.MapFrom(s => s.EkStatus!.Name))
|
||||
.ForMember(d => d.EkStatus, o => o.MapFrom(s => s.EkStatus))
|
||||
.ForMember(d => d.ResponseArea, o => o.MapFrom(s => s.ResponseArea!.Name))
|
||||
.ForMember(d => d.WorkGroupName, o => o.MapFrom(s => s.WorkGroup!.Name))
|
||||
.ForMember(d => d.WorkGroup, o => o.MapFrom(s => s.WorkGroup))
|
||||
.ForMember(d => d.EkResponseArea, o => o.MapFrom(s => s.ResponseArea));
|
||||
|
||||
CreateMap<DAL.Models.Host, HostTemplateResponse>();
|
||||
|
||||
CreateMap<DAL.Models.Host, HostWithApplicationsResponse>()
|
||||
.ForMember(d => d.Applications, o => o.MapFrom(s => s.ApplicationsInHosts.Select(t => t.Application).OrderBy(t => t.Name)));
|
||||
|
||||
#endregion
|
||||
|
||||
#region Unit
|
||||
|
||||
CreateMap<Unit, UnitBaseResponse>();
|
||||
@@ -181,12 +156,6 @@ namespace PARR.API.MappingProfiles
|
||||
//));
|
||||
#endregion
|
||||
|
||||
#region WorkGroup
|
||||
|
||||
CreateMap<WorkGroup, WorkGroupResponse>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Robot
|
||||
|
||||
CreateMap<RobotStatus, RobotStatusResponse>();
|
||||
@@ -423,29 +392,6 @@ namespace PARR.API.MappingProfiles
|
||||
|
||||
#endregion
|
||||
|
||||
//#region JobAutoControl
|
||||
|
||||
//CreateMap<JobAutoControl, JobAutoControlBaseResponse>()
|
||||
// .Include<JobAutoControl, JobAutoControlResponse>();
|
||||
|
||||
//CreateMap<JobAutoControl, JobAutoControlResponse>()
|
||||
// .ForMember(d => d.EkMasks, o => o.MapFrom(s => s.JobEkMasks.OrderBy(t => t.Name)))
|
||||
// .ForMember(d => d.EnabledEkStatuses, o => o.MapFrom(s => s.JobAutoControlInEkStatuses.Select(t => t.EkStatus).OrderBy(t => t.Name)))
|
||||
// .ForMember(d => d.WorkGroups, o => o.MapFrom(s => s.ApplicationsInWork!.WorkGroups.Select(t => t.WorkGroup).OrderBy(t => t.Name)));
|
||||
|
||||
|
||||
//#endregion
|
||||
|
||||
#region ResponseArea
|
||||
CreateMap<ResponseArea, ResponseAreaResponse>();
|
||||
#endregion
|
||||
|
||||
//CreateMap<JobEkMask, JobEkMaskResponse>();
|
||||
|
||||
|
||||
CreateMap<EkStatus, EkStatusResponse>();
|
||||
|
||||
|
||||
CreateMap<WeekendDay, WeekendResponse>();
|
||||
|
||||
#region TemplateHistory
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
using AutoMapper;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Schedule;
|
||||
|
||||
namespace PARR.API.MappingProfiles.Resolvers
|
||||
{
|
||||
public class ApplicationInWorkScheduleResolver : IValueResolver<ApplicationsInWork, ApplicationInWorkResponse, ApplicationInWorkScheduleResponse?>
|
||||
{
|
||||
private readonly IEsppSchTypeConfigService esppConfigService;
|
||||
private readonly ILogger<ApplicationInWorkScheduleResolver> logger;
|
||||
private readonly IMapper mapper;
|
||||
private readonly SettingsFromDb settingsFromDb;
|
||||
private readonly IScheduleResponseAreaTimeOffsetService scheduleResponseAreaTimeOffsetService;
|
||||
|
||||
public ApplicationInWorkScheduleResolver(
|
||||
IEsppSchTypeConfigService esppConfigService,
|
||||
ILogger<ApplicationInWorkScheduleResolver> logger,
|
||||
IMapper mapper,
|
||||
SettingsFromDb settingsFromDb,
|
||||
IScheduleResponseAreaTimeOffsetService scheduleResponseAreaTimeOffsetService
|
||||
)
|
||||
{
|
||||
this.esppConfigService = esppConfigService;
|
||||
this.logger = logger;
|
||||
this.mapper = mapper;
|
||||
this.settingsFromDb = settingsFromDb;
|
||||
this.scheduleResponseAreaTimeOffsetService = scheduleResponseAreaTimeOffsetService;
|
||||
}
|
||||
|
||||
public ApplicationInWorkScheduleResponse? Resolve(ApplicationsInWork source, ApplicationInWorkResponse destination, ApplicationInWorkScheduleResponse? destMember, ResolutionContext context)
|
||||
{
|
||||
var schedule = esppConfigService.GetEsppScheduleDto(source.Id);
|
||||
|
||||
if (schedule == null)
|
||||
{
|
||||
logger.LogError($"ApplicationInWorkScheduleResolver: Не смог замапить расписание, так как оно null. appInWorksId: {source.Id}");
|
||||
return null;
|
||||
}
|
||||
|
||||
var response = new ApplicationInWorkScheduleResponse
|
||||
{
|
||||
//Timezone = settingsFromDb.ScheduleTimezone,
|
||||
Timezone = scheduleResponseAreaTimeOffsetService.GetDefault.EsppValue,
|
||||
TypeSchedule = mapper.Map<EsppScheduleTypeScheduleResponse>(schedule.TypeSchedule),
|
||||
Values = mapper.Map<List<EsppScheduleValResponse>>(schedule.Values).OrderBy(t => t.Order).ToList()
|
||||
};
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,230 +0,0 @@
|
||||
using FluentValidation;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PARR.API.Contracts.V1.Requests;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.API.Validators
|
||||
{
|
||||
public class ApplicationInWorkValidator : AbstractValidator<ApplicationInWorkRequest>
|
||||
{
|
||||
private readonly IApplicationsInWorkService applicationsInWorkService;
|
||||
private readonly IEsppSchTypeConfigService esppSchTypeConfigService;
|
||||
private readonly IWorkGroupService workGroupService;
|
||||
private readonly IEsppSchTypeValueService esppSchTypeValueService;
|
||||
|
||||
public ApplicationInWorkValidator(
|
||||
IApplicationsInWorkService applicationsInWorkService,
|
||||
IEsppSchTypeConfigService esppSchTypeConfigService,
|
||||
IWorkGroupService workGroupService,
|
||||
IEsppSchTypeValueService esppSchTypeValueService
|
||||
)
|
||||
{
|
||||
this.applicationsInWorkService = applicationsInWorkService;
|
||||
this.esppSchTypeConfigService = esppSchTypeConfigService;
|
||||
this.workGroupService = workGroupService;
|
||||
this.esppSchTypeValueService = esppSchTypeValueService;
|
||||
|
||||
RuleFor(t => t.TemplateDuration)
|
||||
.NotNull().NotEmpty()//.WithMessage("Длительность данного задания на выполнение работ не может быть пустым")
|
||||
.Matches("^\\d{1,2}\\s\\d{1,2}[:]\\d{1,2}[:]\\d{1,2}$")
|
||||
//.WithMessage("Длительность данного задания на выполнение работ должна соответствовать шаблону dd hh:mm:ss(7 00:00:00)");
|
||||
.WithMessage("Значение не соответствует шаблону dd hh:mm:ss(7 00:00:00)");
|
||||
|
||||
RuleFor(t => t.ShortDescription)
|
||||
.NotNull().NotEmpty();//.WithMessage("Краткое описание данного задания на выполнение работ не может быть пустым");
|
||||
|
||||
RuleFor(t => t.FullDescription)
|
||||
.NotNull().NotEmpty();//.WithMessage("Подробное описание данного задания на выполнение работ не может быть пустым");
|
||||
|
||||
RuleFor(t => t.Solution)
|
||||
.NotNull().NotEmpty();//.WithMessage("Решение данного задания на выполнение работ не может быть пустым");
|
||||
|
||||
RuleFor(t => t.WorkId)
|
||||
.MustAsync(async (entity, value, c) => await IsWorkExist(entity))
|
||||
.WithMessage("Указан несуществующий Id работы");
|
||||
//.WithMessage("У данного задания на выполнение работ указан несуществующий Id работы");
|
||||
|
||||
RuleFor(t => t.ApplicationId)
|
||||
.MustAsync(async (entity, value, c) => await IsApplicationExist(entity))
|
||||
.WithMessage("Указан несуществующий Id программного обеспечения");
|
||||
//.MustAsync(async (entity, value, c) => await AppInWorkIsUnique(entity))
|
||||
// .WithMessage("Задание на выполнение работ с такими ПО и работой уже существует");
|
||||
//.WithMessage("У данного задания на выполнение работ указан несуществующий Id программного обеспечения");
|
||||
|
||||
|
||||
|
||||
#region old schedule
|
||||
//Проверяем настройки планировщика
|
||||
//RuleFor(t => t.Schedule).NotNull().NotEmpty()
|
||||
// .WithMessage("Настройки планировщика задания на выполнение работ не могут быть пустыми");
|
||||
|
||||
//RuleFor(t => t.Schedule.EsppSchValues)
|
||||
// .NotNull().NotEmpty()
|
||||
// .When(t => t.Schedule != null)
|
||||
// .WithMessage("Настройки планировщика задания на выполнение работ не могут быть пустыми")
|
||||
// .Must((entity, value, c) => IsEsppSchValuesExist(entity))
|
||||
// .WithMessage("Не удалось найти подходящую конфигруцию планировщика задания на выполнение работ");
|
||||
#endregion
|
||||
|
||||
//RuleFor(t => t.Schedule)
|
||||
// .NotNull().NotEmpty()
|
||||
// .When(t => t.Schedule.Count() > 0)
|
||||
// .WithMessage("Настройки планировщика не могут быть пустыми")
|
||||
// .Must((entity, value, c) => IsEsppSchValuesExist(entity.Schedule))
|
||||
// .WithMessage("Не удалось найти подходящую конфигруцию планировщика задания");
|
||||
|
||||
#region comment
|
||||
|
||||
//RuleFor(t => t.Schedule.Values)
|
||||
// .NotNull().NotEmpty().WithMessage($"Настройки значений планировщика задания на выполнение работ не могут быть пустыми")
|
||||
// .Must((entity, value, c) => IsScheduleTypeValueIdExist(entity))
|
||||
// .When(t => t.Schedule != null).WithMessage("Не удалось найти подходящую конфигруцию планировщика задания на выполнение работ");
|
||||
|
||||
//RuleFor(t => t.Schedule.TypeScheduleId)
|
||||
// .NotNull().NotEmpty().WithMessage($"Тип планировщика задания на выполнение работ не может быть пустым")
|
||||
// .Must((entity, value, c) => IsTypeScheduleIdExist(entity))
|
||||
// .When(t => t.Schedule != null).WithMessage($"Не удалось найти указанный тип планировщика задания на выполнение работ");
|
||||
|
||||
//RuleFor(t => t.Schedule.Values)
|
||||
// .NotNull().NotEmpty().WithMessage($"Настройки значений планировщика задания на выполнение работ не могут быть пустыми")
|
||||
// .Must((entity, value, c) => IsScheduleTypeValueIdExist(entity))
|
||||
// .When(t => t.Schedule != null).WithMessage("Не удалось найти подходящую конфигруцию планировщика задания на выполнение работ");
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
RuleFor(t => t.WorkGroups)
|
||||
.MustAsync(async (entity, value, c) => await IsWorkGroupsExistAsync(entity))
|
||||
.WithMessage("Указаные несуществующие Id рабочих групп");
|
||||
|
||||
|
||||
//Автораспределение может быть включено, только если у EsppSchTypeValues не пустое поле DistributionPeriodId
|
||||
RuleFor(t => t.IsAutoDistributionEnabled)
|
||||
.MustAsync(async (entity, value, c) => await IsAllowAutoDistributionEnabledAsync(entity, value))
|
||||
.WithMessage("Нельзя включить автораспределение для этого типа расписания");
|
||||
}
|
||||
|
||||
|
||||
private async Task<bool> IsAllowAutoDistributionEnabledAsync(ApplicationInWorkRequest entity, bool value)//TODO JobGroupRequest
|
||||
{
|
||||
//Автораспределение может быть включено, только если у EsppSchTypeValues не пустое поле DistributionPeriodId
|
||||
|
||||
if (value == false)
|
||||
return true;
|
||||
|
||||
//Распределение включено, смотрим, разрешено ли оно в расписании
|
||||
//по идее, это расписание только с одним значением в EsppSchValues, но мы проверим у всех, но такого быть не может по хорошему
|
||||
//foreach (var item in entity.Schedule)
|
||||
//{
|
||||
// var schVal = await esppSchTypeValueService.GetAsync(item.TypeValueId);
|
||||
// if (schVal != null)
|
||||
// if (schVal.DistributionPeriodId == null)
|
||||
// return false;
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private async Task<bool> IsWorkGroupsExistAsync(ApplicationInWorkRequest entity)
|
||||
{
|
||||
var result = await workGroupService.Get().Where(t => entity.WorkGroups.Contains(t.Id)).ToListAsync();
|
||||
|
||||
return entity.WorkGroups.Count() == result.Count();
|
||||
}
|
||||
|
||||
//private bool IsEsppSchValuesExist(ApplicationInWorkRequest request)
|
||||
private bool IsEsppSchValuesExist(List<EsppSchValueRequest> listSchedule)
|
||||
{
|
||||
var configs = esppSchTypeConfigService.GetWithSchIncludes().ToList();
|
||||
|
||||
//Проверяем полученные Id конфигураций и Id конфигураций в базе
|
||||
var typeConfigIdList = listSchedule.Select(t => t.TypeConfigId);
|
||||
var foundTypeConfigIdList = configs.Where(t => typeConfigIdList.Contains(t.Id)).Distinct();
|
||||
|
||||
if (foundTypeConfigIdList.Count() == 0 //Не найдено совпадений с базой
|
||||
|| foundTypeConfigIdList.Select(t => t.TypeScheduleId).Distinct().Count() > 1) //или имеют разный тип планировщика
|
||||
return false;
|
||||
|
||||
var typeScheduleId = foundTypeConfigIdList.Select(t => t.TypeScheduleId).FirstOrDefault();
|
||||
|
||||
if (foundTypeConfigIdList.Count() != configs.Where(t => t.TypeScheduleId == typeScheduleId).Count()) //не все typeConfig найдены в базе
|
||||
return false;
|
||||
|
||||
//Теперь проверяем значения
|
||||
foreach (var item in listSchedule)
|
||||
{
|
||||
var curTypeConfig = configs.Where(t => t.Id == item.TypeConfigId).Single();
|
||||
|
||||
var isCurValueExist = curTypeConfig!.EsppSchType!.EsppSchTypeValues.Where(t => t.Id == item.TypeValueId).Any();
|
||||
|
||||
if (!isCurValueExist)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//private async Task<bool> AppInWorkIsUnique(ApplicationInWorkRequest request)
|
||||
//{
|
||||
// //уникальная запись по полям ApplicationId, WorkId
|
||||
|
||||
// var existSameAiW = await applicationsInWorkService.GetAsync(request.ApplicationId, request.WorkId);
|
||||
|
||||
// //TODO: тут спорно, нужна ли эта проверка? Мы же можем создать несколько РР на одно и тоже ПО но с разным расписанием?
|
||||
// //к тому же, в методе update, такой проверки нет!
|
||||
// //if (existSameAiW != null)
|
||||
// // return BadRequest(new Response(false, new List<ErrorModel> {
|
||||
// // new ErrorModel { Message = $"Уже существует задание на выполнение работ для программного обеспечения id({request.ApplicationId}) и работой id({request.WorkId})." } }
|
||||
// // ));
|
||||
|
||||
// return existSameAiW == null;
|
||||
//}
|
||||
|
||||
private async Task<bool> IsWorkExist(ApplicationInWorkRequest request)
|
||||
{
|
||||
//return await workService.GetAsync(request.WorkId) != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private async Task<bool> IsApplicationExist(ApplicationInWorkRequest request)
|
||||
{
|
||||
//return await workService.GetAsync(request.WorkId) != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//private bool IsTypeScheduleIdExist(ApplicationInWorkRequest request)
|
||||
//{
|
||||
// var configs = esppSchTypeConfigService.GetWithSchIncludes().ToList();
|
||||
//var result = configs.Where(t => t.TypeId == request.Schedule.TypeScheduleId).FirstOrDefault() != null;
|
||||
//return result;
|
||||
// return false;
|
||||
//}
|
||||
|
||||
|
||||
//private bool IsScheduleTypeValueIdExist(ApplicationInWorkRequest request)
|
||||
//{
|
||||
// var configs = esppSchTypeConfigService.GetWithSchIncludes().ToList();
|
||||
|
||||
// var mustValues = configs.Where(t => t.TypeScheduleId == request.Schedule.TypeScheduleId).ToList();
|
||||
// var values = request.Schedule.Values;
|
||||
|
||||
// foreach (var mustValue in mustValues)
|
||||
// {
|
||||
// var mlValues = mustValue?.EsppSchType?.EsppSchTypeValues.Select(t => t.Id);
|
||||
|
||||
// if (mlValues == null)
|
||||
// return false;
|
||||
|
||||
// if (!mlValues.Intersect(values).Any())
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// return true;
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user