forked from ddrilling/AsbCloudServer
Контроллеры РТК
1. Добавлен сервис 2. Изменён метод получения списка РТК по скважине 3. Небольшой рефакторинг
This commit is contained in:
parent
a9c8fa98ab
commit
456f5d44d4
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
@ -8,6 +9,7 @@ using AsbCloudApp.Exceptions;
|
|||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
using AsbCloudApp.Requests;
|
using AsbCloudApp.Requests;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
|
using AsbCloudApp.Services.ProcessMaps;
|
||||||
using AsbCloudWebApi.SignalR;
|
using AsbCloudWebApi.SignalR;
|
||||||
using AsbCloudWebApi.SignalR.Clients;
|
using AsbCloudWebApi.SignalR.Clients;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
@ -32,13 +34,15 @@ public abstract class ProcessMapBaseController<T> : ControllerBase
|
|||||||
private readonly IUserRepository userRepository;
|
private readonly IUserRepository userRepository;
|
||||||
private readonly ICrudRepository<WellSectionTypeDto> wellSectionRepository;
|
private readonly ICrudRepository<WellSectionTypeDto> wellSectionRepository;
|
||||||
private readonly IProcessMapPlanRepository<T> repository;
|
private readonly IProcessMapPlanRepository<T> repository;
|
||||||
|
private readonly IProcessMapPlanService<T> service;
|
||||||
|
|
||||||
protected ProcessMapBaseController(IWellService wellService,
|
protected ProcessMapBaseController(IWellService wellService,
|
||||||
IProcessMapPlanRepository<T> repository,
|
IProcessMapPlanRepository<T> repository,
|
||||||
IUserRepository userRepository,
|
IUserRepository userRepository,
|
||||||
ICrudRepository<WellSectionTypeDto> wellSectionRepository,
|
ICrudRepository<WellSectionTypeDto> wellSectionRepository,
|
||||||
IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext,
|
IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext,
|
||||||
ITelemetryService telemetryService)
|
ITelemetryService telemetryService,
|
||||||
|
IProcessMapPlanService<T> service)
|
||||||
{
|
{
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
@ -46,9 +50,10 @@ public abstract class ProcessMapBaseController<T> : ControllerBase
|
|||||||
this.wellSectionRepository = wellSectionRepository;
|
this.wellSectionRepository = wellSectionRepository;
|
||||||
this.telemetryHubContext = telemetryHubContext;
|
this.telemetryHubContext = telemetryHubContext;
|
||||||
this.telemetryService = telemetryService;
|
this.telemetryService = telemetryService;
|
||||||
|
this.service = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract string SignalRMethod { get; }
|
protected abstract string SignalRGroup { get; }
|
||||||
|
|
||||||
protected int IdUser
|
protected int IdUser
|
||||||
{
|
{
|
||||||
@ -147,10 +152,16 @@ public abstract class ProcessMapBaseController<T> : ControllerBase
|
|||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult<IEnumerable<T>>> GetAsync(int idWell, CancellationToken cancellationToken)
|
[ProducesResponseType(typeof(ValidationResultDto<>), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||||
|
public async Task<ActionResult<ValidationResultDto<T>>> GetAsync(int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var processMaps = await repository.GetByIdWellAsync(idWell, cancellationToken);
|
var processMaps = await service.GetAsync(idWell, cancellationToken);
|
||||||
|
|
||||||
|
if (!processMaps.Any())
|
||||||
|
return NoContent();
|
||||||
|
|
||||||
return Ok(processMaps);
|
return Ok(processMaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +215,7 @@ public abstract class ProcessMapBaseController<T> : ControllerBase
|
|||||||
var dtos = await repository.GetByIdWellAsync(idWell, cancellationToken);
|
var dtos = await repository.GetByIdWellAsync(idWell, cancellationToken);
|
||||||
|
|
||||||
await telemetryHubContext.Clients
|
await telemetryHubContext.Clients
|
||||||
.Group($"{SignalRMethod}_{idWell}")
|
.Group($"{SignalRGroup}_{idWell}")
|
||||||
.UpdateProcessMap(dtos, cancellationToken);
|
.UpdateProcessMap(dtos, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ public class ProcessMapWellDrillingController : ProcessMapBaseController<Process
|
|||||||
private readonly IProcessMapReportWellDrillingExportService processMapReportWellDrillingExportService;
|
private readonly IProcessMapReportWellDrillingExportService processMapReportWellDrillingExportService;
|
||||||
private readonly IProcessMapPlanImportService processMapPlanImportService;
|
private readonly IProcessMapPlanImportService processMapPlanImportService;
|
||||||
|
|
||||||
public override string SignalRMethod => "ProcessMapWellDrilling";
|
protected override string SignalRGroup => "ProcessMapWellDrilling";
|
||||||
|
|
||||||
public ProcessMapWellDrillingController(IWellService wellService,
|
public ProcessMapWellDrillingController(IWellService wellService,
|
||||||
IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> repository,
|
IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> repository,
|
||||||
@ -36,8 +36,9 @@ public class ProcessMapWellDrillingController : ProcessMapBaseController<Process
|
|||||||
IProcessMapReportWellDrillingService processMapReportWellDrillingService,
|
IProcessMapReportWellDrillingService processMapReportWellDrillingService,
|
||||||
ICrudRepository<WellSectionTypeDto> wellSectionRepository,
|
ICrudRepository<WellSectionTypeDto> wellSectionRepository,
|
||||||
IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext,
|
IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext,
|
||||||
ITelemetryService telemetryService)
|
ITelemetryService telemetryService,
|
||||||
: base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService)
|
IProcessMapPlanService<ProcessMapPlanWellDrillingDto> service)
|
||||||
|
: base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService, service)
|
||||||
{
|
{
|
||||||
this.processMapReportWellDrillingExportService = processMapReportWellDrillingExportService;
|
this.processMapReportWellDrillingExportService = processMapReportWellDrillingExportService;
|
||||||
this.processMapPlanImportService = processMapPlanImportService;
|
this.processMapPlanImportService = processMapPlanImportService;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using AsbCloudApp.Data.ProcessMaps;
|
using AsbCloudApp.Data.ProcessMaps;
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
|
using AsbCloudApp.Services.ProcessMaps;
|
||||||
using AsbCloudWebApi.SignalR;
|
using AsbCloudWebApi.SignalR;
|
||||||
using AsbCloudWebApi.SignalR.Clients;
|
using AsbCloudWebApi.SignalR.Clients;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
@ -13,15 +14,16 @@ namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProcessMapWellReamController : ProcessMapBaseController<ProcessMapPlanWellReamDto>
|
public class ProcessMapWellReamController : ProcessMapBaseController<ProcessMapPlanWellReamDto>
|
||||||
{
|
{
|
||||||
public ProcessMapWellReamController(IWellService wellService,
|
public ProcessMapWellReamController(IWellService wellService,
|
||||||
IProcessMapPlanRepository<ProcessMapPlanWellReamDto> repository,
|
IProcessMapPlanRepository<ProcessMapPlanWellReamDto> repository,
|
||||||
IUserRepository userRepository,
|
IUserRepository userRepository,
|
||||||
ICrudRepository<WellSectionTypeDto> wellSectionRepository,
|
ICrudRepository<WellSectionTypeDto> wellSectionRepository,
|
||||||
IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext,
|
IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext,
|
||||||
ITelemetryService telemetryService)
|
ITelemetryService telemetryService,
|
||||||
: base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService)
|
IProcessMapPlanService<ProcessMapPlanWellReamDto> service)
|
||||||
{
|
: base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService, service)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public override string SignalRMethod => "ProccessMapWellReam";
|
protected override string SignalRGroup => "ProcessMapWellReam";
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user