forked from ddrilling/AsbCloudServer
Рефакторинг контроллеров
This commit is contained in:
parent
6556a03bb5
commit
53e1e07ca0
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Data.ProcessMaps;
|
using AsbCloudApp.Data.ProcessMaps;
|
||||||
using AsbCloudApp.Exceptions;
|
using AsbCloudApp.Exceptions;
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
@ -17,8 +18,8 @@ namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/well/{idWell}/[controller]")]
|
[Route("api/well/{idWell}/[controller]")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public abstract class ProcessMapBaseController<TProcessMap> : ControllerBase
|
public abstract class ProcessMapBaseController<T> : ControllerBase
|
||||||
where TProcessMap : ProcessMapBaseDto
|
where T : ProcessMapPlanBaseDto
|
||||||
{
|
{
|
||||||
protected int IdUser
|
protected int IdUser
|
||||||
{
|
{
|
||||||
@ -33,17 +34,21 @@ public abstract class ProcessMapBaseController<TProcessMap> : ControllerBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
protected readonly IRepositoryWellRelated<TProcessMap> repository;
|
private readonly IUserRepository userRepository;
|
||||||
protected readonly IUserRepository userRepository;
|
private readonly ICrudRepository<WellSectionTypeDto> wellSectionRepository;
|
||||||
|
|
||||||
|
protected readonly IRepositoryWellRelated<T> repository;
|
||||||
|
|
||||||
protected ProcessMapBaseController(IWellService wellService,
|
protected ProcessMapBaseController(IWellService wellService,
|
||||||
IRepositoryWellRelated<TProcessMap> repository,
|
IProcessMapPlanRepository<T> repository,
|
||||||
IUserRepository userRepository)
|
IUserRepository userRepository,
|
||||||
|
ICrudRepository<WellSectionTypeDto> wellSectionRepository)
|
||||||
{
|
{
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
this.userRepository = userRepository;
|
this.userRepository = userRepository;
|
||||||
|
this.wellSectionRepository = wellSectionRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -56,12 +61,14 @@ public abstract class ProcessMapBaseController<TProcessMap> : ControllerBase
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
public virtual async Task<IActionResult> InsertAsync(TProcessMap processMap, int idWell, CancellationToken cancellationToken)
|
public virtual async Task<IActionResult> InsertAsync(T processMap, int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
processMap.IdWell = idWell;
|
processMap.IdWell = idWell;
|
||||||
processMap.IdUser = IdUser;
|
processMap.IdUser = IdUser;
|
||||||
processMap.LastUpdate = DateTime.UtcNow;
|
processMap.LastUpdate = DateTime.UtcNow;
|
||||||
|
|
||||||
|
await CheckIsExistsWellSectionTypeAsync(processMap.IdWellSectionType, cancellationToken);
|
||||||
|
|
||||||
await AssertUserHasAccessToEditProcessMapAsync(processMap.IdWell, cancellationToken);
|
await AssertUserHasAccessToEditProcessMapAsync(processMap.IdWell, cancellationToken);
|
||||||
|
|
||||||
var result = await repository.InsertAsync(processMap, cancellationToken);
|
var result = await repository.InsertAsync(processMap, cancellationToken);
|
||||||
@ -79,17 +86,19 @@ public abstract class ProcessMapBaseController<TProcessMap> : ControllerBase
|
|||||||
[HttpPut]
|
[HttpPut]
|
||||||
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
public virtual async Task<IActionResult> UpdateAsync(TProcessMap processMap, int idWell, CancellationToken cancellationToken)
|
public virtual async Task<IActionResult> UpdateAsync(T processMap, int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
processMap.IdWell = idWell;
|
processMap.IdWell = idWell;
|
||||||
processMap.IdUser = IdUser;
|
processMap.IdUser = IdUser;
|
||||||
processMap.LastUpdate = DateTime.UtcNow;
|
processMap.LastUpdate = DateTime.UtcNow;
|
||||||
|
|
||||||
|
await CheckIsExistsWellSectionTypeAsync(processMap.IdWellSectionType, cancellationToken);
|
||||||
|
|
||||||
await AssertUserHasAccessToEditProcessMapAsync(idWell, cancellationToken);
|
await AssertUserHasAccessToEditProcessMapAsync(idWell, cancellationToken);
|
||||||
|
|
||||||
var result = await repository.UpdateAsync(processMap, cancellationToken);
|
var result = await repository.UpdateAsync(processMap, cancellationToken);
|
||||||
|
|
||||||
if (result == ICrudRepository<TProcessMap>.ErrorIdNotFound)
|
if (result == ICrudRepository<T>.ErrorIdNotFound)
|
||||||
return this.ValidationBadRequest(nameof(processMap.Id), $"РТК с Id: {processMap.Id} не существует");
|
return this.ValidationBadRequest(nameof(processMap.Id), $"РТК с Id: {processMap.Id} не существует");
|
||||||
|
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
@ -98,17 +107,18 @@ public abstract class ProcessMapBaseController<TProcessMap> : ControllerBase
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление РТК
|
/// Удаление РТК
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="id">Id удаляемой РТК</param>
|
||||||
/// <param name="idWell">Id скважины</param>
|
/// <param name="idWell">Id скважины</param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
public virtual async Task<IActionResult> DeleteAsync(int idWell, CancellationToken cancellationToken)
|
public virtual async Task<IActionResult> DeleteAsync(int id, int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await AssertUserHasAccessToEditProcessMapAsync(idWell, cancellationToken);
|
await AssertUserHasAccessToEditProcessMapAsync(idWell, cancellationToken);
|
||||||
|
|
||||||
var result = await repository.DeleteAsync(idWell, cancellationToken);
|
var result = await repository.DeleteAsync(id, cancellationToken);
|
||||||
|
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
@ -128,8 +138,7 @@ public abstract class ProcessMapBaseController<TProcessMap> : ControllerBase
|
|||||||
return Ok(processMaps);
|
return Ok(processMaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual async Task AssertUserHasAccessToEditProcessMapAsync(int idWell,
|
protected async Task AssertUserHasAccessToEditProcessMapAsync(int idWell, CancellationToken cancellationToken)
|
||||||
CancellationToken cancellationToken)
|
|
||||||
{
|
{
|
||||||
var well = await wellService.GetOrDefaultAsync(idWell, cancellationToken)
|
var well = await wellService.GetOrDefaultAsync(idWell, cancellationToken)
|
||||||
?? throw new ArgumentInvalidException(nameof(idWell),$"Скважины с {idWell} не существует");
|
?? throw new ArgumentInvalidException(nameof(idWell),$"Скважины с {idWell} не существует");
|
||||||
@ -140,7 +149,15 @@ public abstract class ProcessMapBaseController<TProcessMap> : ControllerBase
|
|||||||
!await wellService.IsCompanyInvolvedInWellAsync(idCompany.Value, idWell, cancellationToken))
|
!await wellService.IsCompanyInvolvedInWellAsync(idCompany.Value, idWell, cancellationToken))
|
||||||
throw new ForbidException("Нет доступа к скважине");
|
throw new ForbidException("Нет доступа к скважине");
|
||||||
|
|
||||||
if (well.IdState == 2 && !userRepository.HasPermission(IdUser, "WellDrillingProcessMap.editCompletedWell"))
|
if (well.IdState == 2 && !userRepository.HasPermission(IdUser, "ProcessMap.editCompletedWell"))
|
||||||
throw new ForbidException("Недостаточно прав для редактирования РТК завершенной скважины");
|
throw new ForbidException("Недостаточно прав для редактирования РТК завершенной скважины");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task CheckIsExistsWellSectionTypeAsync(int idWellSectionType, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var wellSection = await wellSectionRepository.GetOrDefaultAsync(idWellSectionType, cancellationToken);
|
||||||
|
|
||||||
|
if (wellSection is null)
|
||||||
|
throw new ArgumentInvalidException(nameof(ProcessMapPlanWellDrillingDto.IdWellSectionType), $"Тип секции с Id: {idWellSectionType} не найден");
|
||||||
|
}
|
||||||
}
|
}
|
@ -16,30 +16,28 @@ using Microsoft.AspNetCore.SignalR;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
||||||
|
|
||||||
public class WellDrillingProcessMapController : ProcessMapBaseController<WellDrillingProcessMapDto>
|
public class ProcessMapWellDrillingController : ProcessMapBaseController<ProcessMapPlanWellDrillingDto>
|
||||||
{
|
{
|
||||||
private readonly IHubContext<TelemetryHub> telemetryHubContext;
|
private readonly IHubContext<TelemetryHub> telemetryHubContext;
|
||||||
|
|
||||||
private readonly IWellDrillingProcessMapReportService wellDrillingProcessMapReportService;
|
private readonly IProcessMapReportWellDrillingService wellDrillingProcessMapReportService;
|
||||||
private readonly IProcessMapReportExportService wellDrillingProcessMapReportExportService;
|
private readonly IProcessMapReportExportService wellDrillingProcessMapReportExportService;
|
||||||
private readonly IProcessMapImportService wellDrillingProcessMapImportService;
|
private readonly IProcessMapImportService wellDrillingProcessMapImportService;
|
||||||
private readonly ICrudRepository<WellSectionTypeDto> wellSectionRepository;
|
|
||||||
|
|
||||||
public WellDrillingProcessMapController(IWellService wellService,
|
public ProcessMapWellDrillingController(IWellService wellService,
|
||||||
IWellDrillingProcessMapRepository repository,
|
IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> repository,
|
||||||
IUserRepository userRepository,
|
IUserRepository userRepository,
|
||||||
IHubContext<TelemetryHub> telemetryHubContext,
|
IHubContext<TelemetryHub> telemetryHubContext,
|
||||||
IProcessMapReportExportService wellDrillingProcessMapReportExportService,
|
IProcessMapReportExportService wellDrillingProcessMapReportExportService,
|
||||||
IProcessMapImportService wellDrillingProcessMapImportService,
|
IProcessMapImportService wellDrillingProcessMapImportService,
|
||||||
IWellDrillingProcessMapReportService wellDrillingProcessMapReportService,
|
IProcessMapReportWellDrillingService wellDrillingProcessMapReportService,
|
||||||
ICrudRepository<WellSectionTypeDto> wellSectionRepository)
|
ICrudRepository<WellSectionTypeDto> wellSectionRepository)
|
||||||
: base(wellService, repository, userRepository)
|
: base(wellService, repository, userRepository, wellSectionRepository)
|
||||||
{
|
{
|
||||||
this.telemetryHubContext = telemetryHubContext;
|
this.telemetryHubContext = telemetryHubContext;
|
||||||
this.wellDrillingProcessMapReportExportService = wellDrillingProcessMapReportExportService;
|
this.wellDrillingProcessMapReportExportService = wellDrillingProcessMapReportExportService;
|
||||||
this.wellDrillingProcessMapImportService = wellDrillingProcessMapImportService;
|
this.wellDrillingProcessMapImportService = wellDrillingProcessMapImportService;
|
||||||
this.wellDrillingProcessMapReportService = wellDrillingProcessMapReportService;
|
this.wellDrillingProcessMapReportService = wellDrillingProcessMapReportService;
|
||||||
this.wellSectionRepository = wellSectionRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -49,11 +47,8 @@ public class WellDrillingProcessMapController : ProcessMapBaseController<WellDri
|
|||||||
/// <param name="idWell">Id скважины</param>
|
/// <param name="idWell">Id скважины</param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override async Task<IActionResult> InsertAsync(WellDrillingProcessMapDto processMap, int idWell,
|
public override async Task<IActionResult> InsertAsync(ProcessMapPlanWellDrillingDto processMap, int idWell, CancellationToken cancellationToken)
|
||||||
CancellationToken cancellationToken)
|
|
||||||
{
|
{
|
||||||
await CheckIsExistsWellSectionTypeAsync(processMap.IdWellSectionType, cancellationToken);
|
|
||||||
|
|
||||||
var result = await base.InsertAsync(processMap, idWell, cancellationToken);
|
var result = await base.InsertAsync(processMap, idWell, cancellationToken);
|
||||||
|
|
||||||
await NotifyUsersBySignalR(idWell, cancellationToken);
|
await NotifyUsersBySignalR(idWell, cancellationToken);
|
||||||
@ -68,11 +63,8 @@ public class WellDrillingProcessMapController : ProcessMapBaseController<WellDri
|
|||||||
/// <param name="idWell">Id скважины</param>
|
/// <param name="idWell">Id скважины</param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override async Task<IActionResult> UpdateAsync(WellDrillingProcessMapDto processMap, int idWell,
|
public override async Task<IActionResult> UpdateAsync(ProcessMapPlanWellDrillingDto processMap, int idWell, CancellationToken cancellationToken)
|
||||||
CancellationToken cancellationToken)
|
|
||||||
{
|
{
|
||||||
await CheckIsExistsWellSectionTypeAsync(processMap.IdWellSectionType, cancellationToken);
|
|
||||||
|
|
||||||
var result = await base.UpdateAsync(processMap, idWell, cancellationToken);
|
var result = await base.UpdateAsync(processMap, idWell, cancellationToken);
|
||||||
|
|
||||||
await NotifyUsersBySignalR(idWell, cancellationToken);
|
await NotifyUsersBySignalR(idWell, cancellationToken);
|
||||||
@ -83,12 +75,13 @@ public class WellDrillingProcessMapController : ProcessMapBaseController<WellDri
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление РТК
|
/// Удаление РТК
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="id">Id удаляемой РТК</param>
|
||||||
/// <param name="idWell">Id скважины</param>
|
/// <param name="idWell">Id скважины</param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override async Task<IActionResult> DeleteAsync(int idWell, CancellationToken cancellationToken)
|
public override async Task<IActionResult> DeleteAsync(int id, int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var result = await base.DeleteAsync(idWell, cancellationToken);
|
var result = await base.DeleteAsync(id, idWell, cancellationToken);
|
||||||
|
|
||||||
await NotifyUsersBySignalR(idWell, cancellationToken);
|
await NotifyUsersBySignalR(idWell, cancellationToken);
|
||||||
|
|
||||||
@ -102,7 +95,7 @@ public class WellDrillingProcessMapController : ProcessMapBaseController<WellDri
|
|||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("report")]
|
[HttpGet("report")]
|
||||||
[ProducesResponseType(typeof(WellDrillingProcessMapDto), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(ProcessMapPlanWellDrillingDto), StatusCodes.Status200OK)]
|
||||||
public async Task<IActionResult> GetReportAsync(int idWell, CancellationToken cancellationToken)
|
public async Task<IActionResult> GetReportAsync(int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var report = await wellDrillingProcessMapReportService.GetAsync(idWell, cancellationToken);
|
var report = await wellDrillingProcessMapReportService.GetAsync(idWell, cancellationToken);
|
||||||
@ -158,6 +151,8 @@ public class WellDrillingProcessMapController : ProcessMapBaseController<WellDri
|
|||||||
(options & 1) > 0,
|
(options & 1) > 0,
|
||||||
stream,
|
stream,
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
|
|
||||||
|
await NotifyUsersBySignalR(idWell, cancellationToken);
|
||||||
}
|
}
|
||||||
catch (FileFormatException ex)
|
catch (FileFormatException ex)
|
||||||
{
|
{
|
||||||
@ -195,14 +190,6 @@ public class WellDrillingProcessMapController : ProcessMapBaseController<WellDri
|
|||||||
return File(template.File, "application/octet-stream", template.Name);
|
return File(template.File, "application/octet-stream", template.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CheckIsExistsWellSectionTypeAsync(int idWellSectionType, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var wellSection = await wellSectionRepository.GetOrDefaultAsync(idWellSectionType, cancellationToken);
|
|
||||||
|
|
||||||
if (wellSection is null)
|
|
||||||
throw new ArgumentInvalidException(nameof(WellDrillingProcessMapDto.IdWellSectionType), $"Тип секции с Id: {idWellSectionType} не найден");
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task NotifyUsersBySignalR(int idWell, CancellationToken cancellationToken)
|
private async Task NotifyUsersBySignalR(int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var wellDrillingProcessMaps = await repository.GetByIdWellAsync(idWell, cancellationToken);
|
var wellDrillingProcessMaps = await repository.GetByIdWellAsync(idWell, cancellationToken);
|
@ -0,0 +1,17 @@
|
|||||||
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Data.ProcessMaps;
|
||||||
|
using AsbCloudApp.Repositories;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
|
||||||
|
namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
||||||
|
|
||||||
|
public class ProcessMapWellReamController : ProcessMapBaseController<ProcessMapPlanWellReamDto>
|
||||||
|
{
|
||||||
|
public ProcessMapWellReamController(IWellService wellService,
|
||||||
|
IProcessMapPlanRepository<ProcessMapPlanWellReamDto> repository,
|
||||||
|
IUserRepository userRepository,
|
||||||
|
ICrudRepository<WellSectionTypeDto> wellSectionRepository)
|
||||||
|
: base(wellService, repository, userRepository, wellSectionRepository)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +0,0 @@
|
|||||||
using AsbCloudApp.Data.ProcessMaps;
|
|
||||||
using AsbCloudApp.Repositories;
|
|
||||||
using AsbCloudApp.Services;
|
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
|
||||||
|
|
||||||
public class WellReamProcessMapController : ProcessMapBaseController<WellReamProcessMapDto>
|
|
||||||
{
|
|
||||||
public WellReamProcessMapController(IWellService wellService,
|
|
||||||
IWellReamProcessMapRepository repository,
|
|
||||||
IUserRepository userRepository)
|
|
||||||
: base(wellService, repository, userRepository)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using AsbCloudApp.Data.ProcessMaps;
|
using AsbCloudApp.Data.ProcessMaps;
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
using AsbCloudApp.Requests;
|
using AsbCloudApp.Requests;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers.SAUB;
|
namespace AsbCloudWebApi.Controllers.SAUB;
|
||||||
|
|
||||||
@ -18,20 +18,17 @@ namespace AsbCloudWebApi.Controllers.SAUB;
|
|||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
public class TelemetryProcessMapController : ControllerBase
|
public class TelemetryProcessMapController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IWellService wellService;
|
|
||||||
private readonly ITelemetryService telemetryService;
|
private readonly ITelemetryService telemetryService;
|
||||||
private readonly IWellDrillingProcessMapRepository wellDrillingProcessMapRepository;
|
private readonly IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> processMapPlanWellDrillingRepository;
|
||||||
private readonly IWellReamProcessMapRepository wellReamProcessMapRepository;
|
private readonly IProcessMapPlanRepository<ProcessMapPlanWellReamDto> processMapPlanWellReamRepository;
|
||||||
|
|
||||||
public TelemetryProcessMapController(IWellService wellService,
|
public TelemetryProcessMapController(ITelemetryService telemetryService,
|
||||||
ITelemetryService telemetryService,
|
IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> processMapPlanWellDrillingRepository,
|
||||||
IWellDrillingProcessMapRepository wellDrillingProcessMapRepository,
|
IProcessMapPlanRepository<ProcessMapPlanWellReamDto> processMapPlanWellReamRepository)
|
||||||
IWellReamProcessMapRepository wellReamProcessMapRepository)
|
|
||||||
{
|
{
|
||||||
this.wellService = wellService;
|
|
||||||
this.telemetryService = telemetryService;
|
this.telemetryService = telemetryService;
|
||||||
this.wellDrillingProcessMapRepository = wellDrillingProcessMapRepository;
|
this.processMapPlanWellDrillingRepository = processMapPlanWellDrillingRepository;
|
||||||
this.wellReamProcessMapRepository = wellReamProcessMapRepository;
|
this.processMapPlanWellReamRepository = processMapPlanWellReamRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -42,7 +39,7 @@ public class TelemetryProcessMapController : ControllerBase
|
|||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("wellDrillingProcessMap")]
|
[HttpGet("wellDrillingProcessMap")]
|
||||||
[ProducesResponseType(typeof(IEnumerable<WellDrillingProcessMapDto>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(IEnumerable<ProcessMapPlanWellDrillingDto>), StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
public async Task<IActionResult> GetWellDrillingProcessMapByUidAsync(string uid, DateTime updateFrom, CancellationToken cancellationToken)
|
public async Task<IActionResult> GetWellDrillingProcessMapByUidAsync(string uid, DateTime updateFrom, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
@ -51,11 +48,11 @@ public class TelemetryProcessMapController : ControllerBase
|
|||||||
if (!idWell.HasValue)
|
if (!idWell.HasValue)
|
||||||
return this.ValidationBadRequest(nameof(uid), $"Wrong uid {uid}");
|
return this.ValidationBadRequest(nameof(uid), $"Wrong uid {uid}");
|
||||||
|
|
||||||
var wellDrillingProcessMaps = await wellDrillingProcessMapRepository.GetAsync(new WellDrillingProcessMapRequest
|
var wellDrillingProcessMaps = await processMapPlanWellDrillingRepository.GetAsync(new[] { new ProcessMapPlanRequest
|
||||||
{
|
{
|
||||||
IdWell = idWell.Value,
|
IdWell = idWell.Value,
|
||||||
UpdateFrom = updateFrom
|
UpdateFrom = updateFrom
|
||||||
}, cancellationToken);
|
}}, cancellationToken);
|
||||||
|
|
||||||
return Ok(wellDrillingProcessMaps);
|
return Ok(wellDrillingProcessMaps);
|
||||||
}
|
}
|
||||||
@ -68,7 +65,7 @@ public class TelemetryProcessMapController : ControllerBase
|
|||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("wellReamProcessMap")]
|
[HttpGet("wellReamProcessMap")]
|
||||||
[ProducesResponseType(typeof(IEnumerable<WellReamProcessMapDto>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(IEnumerable<ProcessMapPlanWellReamDto>), StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
public async Task<IActionResult> GetWellReamProcessMapByUidAsync(string uid, DateTime updateFrom,
|
public async Task<IActionResult> GetWellReamProcessMapByUidAsync(string uid, DateTime updateFrom,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
@ -78,11 +75,11 @@ public class TelemetryProcessMapController : ControllerBase
|
|||||||
if (!idWell.HasValue)
|
if (!idWell.HasValue)
|
||||||
return this.ValidationBadRequest(nameof(uid), $"Wrong uid {uid}");
|
return this.ValidationBadRequest(nameof(uid), $"Wrong uid {uid}");
|
||||||
|
|
||||||
var wellReamProcessMaps = await wellReamProcessMapRepository.GetAsync(new WellReamProcessMapRequest
|
var wellReamProcessMaps = await processMapPlanWellReamRepository.GetAsync(new[] { new ProcessMapPlanRequest
|
||||||
{
|
{
|
||||||
IdWell = idWell.Value,
|
IdWell = idWell.Value,
|
||||||
UpdateFrom = updateFrom
|
UpdateFrom = updateFrom
|
||||||
}, cancellationToken);
|
}}, cancellationToken);
|
||||||
|
|
||||||
return Ok(wellReamProcessMaps);
|
return Ok(wellReamProcessMaps);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user