Контроллеры РТК

1. Добавлен сервис
2. Изменён метод получения списка РТК по скважине
3. Небольшой рефакторинг
This commit is contained in:
Степанов Дмитрий 2023-12-04 17:12:28 +05:00
parent a9c8fa98ab
commit 456f5d44d4
3 changed files with 33 additions and 19 deletions

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Data;
@ -8,6 +9,7 @@ using AsbCloudApp.Exceptions;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using AsbCloudApp.Services.ProcessMaps;
using AsbCloudWebApi.SignalR;
using AsbCloudWebApi.SignalR.Clients;
using Microsoft.AspNetCore.Authorization;
@ -32,13 +34,15 @@ public abstract class ProcessMapBaseController<T> : ControllerBase
private readonly IUserRepository userRepository;
private readonly ICrudRepository<WellSectionTypeDto> wellSectionRepository;
private readonly IProcessMapPlanRepository<T> repository;
private readonly IProcessMapPlanService<T> service;
protected ProcessMapBaseController(IWellService wellService,
IProcessMapPlanRepository<T> repository,
IUserRepository userRepository,
ICrudRepository<WellSectionTypeDto> wellSectionRepository,
IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext,
ITelemetryService telemetryService)
ITelemetryService telemetryService,
IProcessMapPlanService<T> service)
{
this.wellService = wellService;
this.repository = repository;
@ -46,9 +50,10 @@ public abstract class ProcessMapBaseController<T> : ControllerBase
this.wellSectionRepository = wellSectionRepository;
this.telemetryHubContext = telemetryHubContext;
this.telemetryService = telemetryService;
this.service = service;
}
public abstract string SignalRMethod { get; }
protected abstract string SignalRGroup { get; }
protected int IdUser
{
@ -147,9 +152,15 @@ public abstract class ProcessMapBaseController<T> : ControllerBase
/// <param name="cancellationToken"></param>
/// <returns></returns>
[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);
}
@ -204,7 +215,7 @@ public abstract class ProcessMapBaseController<T> : ControllerBase
var dtos = await repository.GetByIdWellAsync(idWell, cancellationToken);
await telemetryHubContext.Clients
.Group($"{SignalRMethod}_{idWell}")
.Group($"{SignalRGroup}_{idWell}")
.UpdateProcessMap(dtos, cancellationToken);
}

View File

@ -26,7 +26,7 @@ public class ProcessMapWellDrillingController : ProcessMapBaseController<Process
private readonly IProcessMapReportWellDrillingExportService processMapReportWellDrillingExportService;
private readonly IProcessMapPlanImportService processMapPlanImportService;
public override string SignalRMethod => "ProcessMapWellDrilling";
protected override string SignalRGroup => "ProcessMapWellDrilling";
public ProcessMapWellDrillingController(IWellService wellService,
IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> repository,
@ -36,8 +36,9 @@ public class ProcessMapWellDrillingController : ProcessMapBaseController<Process
IProcessMapReportWellDrillingService processMapReportWellDrillingService,
ICrudRepository<WellSectionTypeDto> wellSectionRepository,
IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext,
ITelemetryService telemetryService)
: base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService)
ITelemetryService telemetryService,
IProcessMapPlanService<ProcessMapPlanWellDrillingDto> service)
: base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService, service)
{
this.processMapReportWellDrillingExportService = processMapReportWellDrillingExportService;
this.processMapPlanImportService = processMapPlanImportService;

View File

@ -2,6 +2,7 @@
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Services;
using AsbCloudApp.Services.ProcessMaps;
using AsbCloudWebApi.SignalR;
using AsbCloudWebApi.SignalR.Clients;
using Microsoft.AspNetCore.SignalR;
@ -18,10 +19,11 @@ public class ProcessMapWellReamController : ProcessMapBaseController<ProcessMapP
IUserRepository userRepository,
ICrudRepository<WellSectionTypeDto> wellSectionRepository,
IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext,
ITelemetryService telemetryService)
: base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService)
ITelemetryService telemetryService,
IProcessMapPlanService<ProcessMapPlanWellReamDto> service)
: base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService, service)
{
}
public override string SignalRMethod => "ProccessMapWellReam";
protected override string SignalRGroup => "ProcessMapWellReam";
}