forked from ddrilling/AsbCloudServer
Удалена ProcessMapPlanWellDrillingDto
This commit is contained in:
parent
129ab9565f
commit
f6ab09f77f
@ -1,61 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Data.ProcessMaps;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public abstract class ProcessMapPlanBaseDto : IId, IWellRelated
|
|
||||||
{
|
|
||||||
/// <inheritdoc/>
|
|
||||||
[Required]
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Id скважины
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
[Range(1, int.MaxValue, ErrorMessage = "Id скважины не может быть меньше 1")]
|
|
||||||
public int IdWell { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Id пользователя
|
|
||||||
/// </summary>
|
|
||||||
public int IdUser { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Тип секции
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
[Range(1, int.MaxValue, ErrorMessage = "Id секции скважины не может быть меньше 1")]
|
|
||||||
public int IdWellSectionType { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Дата последнего изменения
|
|
||||||
/// </summary>
|
|
||||||
public DateTimeOffset LastUpdate { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Глубина по стволу от, м
|
|
||||||
/// <para>
|
|
||||||
/// на начало интервала
|
|
||||||
/// </para>
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
[Range(0, 99999.9, ErrorMessage = "Глубина не может быть отрицательной")]
|
|
||||||
public double DepthStart { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Глубина по стволу до, м
|
|
||||||
/// <para>
|
|
||||||
/// на конец интервала
|
|
||||||
/// </para>
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
[Range(0, 99999.9, ErrorMessage = "Глубина не может быть отрицательной")]
|
|
||||||
public double DepthEnd { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Комментарий
|
|
||||||
/// </summary>
|
|
||||||
public string? Comment { get; set; }
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Data.ProcessMaps;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// РТК план бурение скважины
|
|
||||||
/// </summary>
|
|
||||||
public class ProcessMapPlanWellDrillingDto : ProcessMapPlanBaseDto
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Id режима 0-ручной, 1-ротор, 2 - слайд
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
[Range(0, 2, ErrorMessage = "Id режима должен быть либо 0-ручной либо, 1-ротор либо 2-слайд")]
|
|
||||||
public int IdMode { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Нагрузка
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
public PlanLimitDto AxialLoad { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перепад давления
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
public PlanLimitDto Pressure { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Момент на ВСП
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
public PlanLimitDto TopDriveTorque { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Обороты на ВСП
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
public PlanLimitDto TopDriveSpeed { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Расход
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
public PlanLimitDto Flow { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Плановая механическая скорость, м/ч
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
[Range(0, 99999.9, ErrorMessage = "Плановая механическая скорость должно быть в пределах от 0 до 99999.9")]
|
|
||||||
public double RopPlan { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Плановый процент использования АКБ
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
[Range(0, 100, ErrorMessage = "Процент использования АКБ должен быть в пределах от 0 до 100")]
|
|
||||||
public double UsageSaub { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Плановый процент использования spin master
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
[Range(0, 100, ErrorMessage = "Процент использования spin master должен быть в пределах от 0 до 100")]
|
|
||||||
public double UsageSpin { get; set; }
|
|
||||||
}
|
|
@ -1,3 +1,4 @@
|
|||||||
|
using AsbCloudApp.Data.ProcessMapPlan;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
@ -6,7 +7,7 @@ namespace AsbCloudApp.Data.ProcessMaps;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// РТК план проработка скважины
|
/// РТК план проработка скважины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProcessMapPlanWellReamDto : AsbCloudApp.Data.ProcessMapPlan.ProcessMapPlanBaseDto, IValidatableObject
|
public class ProcessMapPlanWellReamDto : ProcessMapPlanBaseDto, IValidatableObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Количество повторений
|
/// Количество повторений
|
||||||
|
@ -2,6 +2,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Data.ProcessMapPlan;
|
||||||
|
|
||||||
namespace AsbCloudApp.Services.ProcessMaps;
|
namespace AsbCloudApp.Services.ProcessMaps;
|
||||||
|
|
||||||
@ -9,7 +10,7 @@ namespace AsbCloudApp.Services.ProcessMaps;
|
|||||||
/// РТК
|
/// РТК
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IProcessMapPlanService<T>
|
public interface IProcessMapPlanService<T>
|
||||||
where T : AsbCloudApp.Data.ProcessMapPlan.ProcessMapPlanBaseDto
|
where T : ProcessMapPlanBaseDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение РТК план по скважине
|
/// Получение РТК план по скважине
|
||||||
|
@ -101,48 +101,6 @@ namespace AsbCloudInfrastructure
|
|||||||
.Ignore(dst => dst.NotificationCategory,
|
.Ignore(dst => dst.NotificationCategory,
|
||||||
dst => dst.User);
|
dst => dst.User);
|
||||||
|
|
||||||
TypeAdapterConfig.GlobalSettings.Default.Config
|
|
||||||
.ForType<ProcessMapWellDrilling, ProcessMapPlanWellDrillingDto>()
|
|
||||||
.Map(dest => dest.AxialLoad, src => new PlanLimitDto
|
|
||||||
{
|
|
||||||
LimitMax = src.AxialLoadLimitMax,
|
|
||||||
Plan = src.AxialLoadPlan
|
|
||||||
})
|
|
||||||
.Map(dest => dest.Flow, src => new PlanLimitDto
|
|
||||||
{
|
|
||||||
LimitMax = src.FlowLimitMax,
|
|
||||||
Plan = src.FlowPlan
|
|
||||||
})
|
|
||||||
.Map(dest => dest.Pressure, src => new PlanLimitDto
|
|
||||||
{
|
|
||||||
LimitMax = src.PressureLimitMax,
|
|
||||||
Plan = src.PressurePlan
|
|
||||||
})
|
|
||||||
.Map(dest => dest.TopDriveSpeed, src => new PlanLimitDto
|
|
||||||
{
|
|
||||||
LimitMax = src.TopDriveSpeedLimitMax,
|
|
||||||
Plan = src.TopDriveSpeedPlan
|
|
||||||
})
|
|
||||||
.Map(dest => dest.TopDriveTorque, src => new PlanLimitDto
|
|
||||||
{
|
|
||||||
LimitMax = src.TopDriveTorqueLimitMax,
|
|
||||||
Plan = src.TopDriveTorquePlan
|
|
||||||
});
|
|
||||||
|
|
||||||
TypeAdapterConfig.GlobalSettings.Default.Config
|
|
||||||
.ForType<ProcessMapPlanWellDrillingDto, ProcessMapWellDrilling>()
|
|
||||||
.Map(dest => dest.AxialLoadPlan, src => src.AxialLoad.Plan)
|
|
||||||
.Map(dest => dest.AxialLoadLimitMax, src => src.AxialLoad.LimitMax)
|
|
||||||
.Map(dest => dest.FlowPlan, src => src.Flow.Plan)
|
|
||||||
.Map(dest => dest.FlowLimitMax, src => src.Flow.LimitMax)
|
|
||||||
.Map(dest => dest.PressurePlan, src => src.Pressure.Plan)
|
|
||||||
.Map(dest => dest.PressureLimitMax, src => src.Pressure.LimitMax)
|
|
||||||
.Map(dest => dest.TopDriveSpeedPlan, src => src.TopDriveSpeed.Plan)
|
|
||||||
.Map(dest => dest.TopDriveSpeedLimitMax, src => src.TopDriveSpeed.LimitMax)
|
|
||||||
.Map(dest => dest.TopDriveTorquePlan, src => src.TopDriveTorque.Plan)
|
|
||||||
.Map(dest => dest.TopDriveTorqueLimitMax, src => src.TopDriveTorque.LimitMax);
|
|
||||||
|
|
||||||
|
|
||||||
TypeAdapterConfig.GlobalSettings.Default.Config
|
TypeAdapterConfig.GlobalSettings.Default.Config
|
||||||
.ForType<TimeBalanceRecord, TimeBalanceRecordDto>()
|
.ForType<TimeBalanceRecord, TimeBalanceRecordDto>()
|
||||||
.Map(dest => dest.DurationHours, src => new PlanFactDto<double?>()
|
.Map(dest => dest.DurationHours, src => new PlanFactDto<double?>()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Data.ProcessMapPlan;
|
||||||
using AsbCloudApp.Data.ProcessMaps;
|
using AsbCloudApp.Data.ProcessMaps;
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
using AsbCloudApp.Requests;
|
using AsbCloudApp.Requests;
|
||||||
@ -12,7 +13,7 @@ using System.Threading.Tasks;
|
|||||||
namespace AsbCloudInfrastructure.Services.ProcessMaps;
|
namespace AsbCloudInfrastructure.Services.ProcessMaps;
|
||||||
|
|
||||||
public class ProcessMapPlanService<T> : AsbCloudApp.Services.ProcessMaps.IProcessMapPlanService<T>
|
public class ProcessMapPlanService<T> : AsbCloudApp.Services.ProcessMaps.IProcessMapPlanService<T>
|
||||||
where T : AsbCloudApp.Data.ProcessMapPlan.ProcessMapPlanBaseDto
|
where T : ProcessMapPlanBaseDto
|
||||||
{
|
{
|
||||||
private readonly ICrudRepository<WellSectionTypeDto> wellSectionTypeRepository;
|
private readonly ICrudRepository<WellSectionTypeDto> wellSectionTypeRepository;
|
||||||
private readonly IChangeLogRepository<T, ProcessMapPlanBaseRequestWithWell> processMapPlanBaseRepository;
|
private readonly IChangeLogRepository<T, ProcessMapPlanBaseRequestWithWell> processMapPlanBaseRepository;
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Data.ProcessMapPlan;
|
||||||
using AsbCloudApp.Data.ProcessMaps;
|
using AsbCloudApp.Data.ProcessMaps;
|
||||||
using AsbCloudApp.Exceptions;
|
using AsbCloudApp.Exceptions;
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
@ -11,6 +7,11 @@ using AsbCloudApp.Services;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
||||||
|
|
||||||
@ -22,167 +23,167 @@ namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
|||||||
[Authorize]
|
[Authorize]
|
||||||
public class WellSectionPlanController : ControllerBase
|
public class WellSectionPlanController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
private readonly IWellSectionPlanRepository wellSectionPlanRepository;
|
private readonly IWellSectionPlanRepository wellSectionPlanRepository;
|
||||||
private readonly ICrudRepository<WellSectionTypeDto> wellSectionRepository;
|
private readonly ICrudRepository<WellSectionTypeDto> wellSectionRepository;
|
||||||
|
|
||||||
public WellSectionPlanController(IWellService wellService,
|
public WellSectionPlanController(IWellService wellService,
|
||||||
IWellSectionPlanRepository wellSectionPlanRepository,
|
IWellSectionPlanRepository wellSectionPlanRepository,
|
||||||
ICrudRepository<WellSectionTypeDto> wellSectionRepository)
|
ICrudRepository<WellSectionTypeDto> wellSectionRepository)
|
||||||
{
|
{
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
this.wellSectionPlanRepository = wellSectionPlanRepository;
|
this.wellSectionPlanRepository = wellSectionPlanRepository;
|
||||||
this.wellSectionRepository = wellSectionRepository;
|
this.wellSectionRepository = wellSectionRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: так же следует вынести в базовый контроллер
|
//TODO: так же следует вынести в базовый контроллер
|
||||||
private int IdUser
|
private int IdUser
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var idUser = User.GetUserId();
|
var idUser = User.GetUserId();
|
||||||
|
|
||||||
if (!idUser.HasValue)
|
if (!idUser.HasValue)
|
||||||
throw new ForbidException("Неизвестный пользователь");
|
throw new ForbidException("Неизвестный пользователь");
|
||||||
|
|
||||||
return idUser.Value;
|
return idUser.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавить секцию
|
/// Добавить секцию
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell">Идентификатор скважины</param>
|
/// <param name="idWell">Идентификатор скважины</param>
|
||||||
/// <param name="wellSection">Секция скважины - план</param>
|
/// <param name="wellSection">Секция скважины - план</param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Permission]
|
[Permission]
|
||||||
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||||
public async Task<IActionResult> InsertAsync(int idWell, WellSectionPlanDto wellSection, CancellationToken cancellationToken)
|
public async Task<IActionResult> InsertAsync(int idWell, WellSectionPlanDto wellSection, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
wellSection.IdWell = idWell;
|
wellSection.IdWell = idWell;
|
||||||
wellSection.IdUser = IdUser;
|
wellSection.IdUser = IdUser;
|
||||||
|
|
||||||
await CheckIsExistsWellSectionTypeAsync(wellSection.IdSectionType, cancellationToken);
|
|
||||||
|
|
||||||
await AssertUserAccessToWell(idWell, cancellationToken);
|
|
||||||
|
|
||||||
var wellSectionId = await wellSectionPlanRepository.InsertAsync(wellSection, cancellationToken);
|
await CheckIsExistsWellSectionTypeAsync(wellSection.IdSectionType, cancellationToken);
|
||||||
|
|
||||||
return Ok(wellSectionId);
|
await AssertUserAccessToWell(idWell, cancellationToken);
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Обновить секцию
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="idWell">Идентификатор скважины</param>
|
|
||||||
/// <param name="wellSection">Секция скважины - план</param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPut]
|
|
||||||
[Permission]
|
|
||||||
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
|
||||||
public async Task<IActionResult> UpdateAsync(int idWell, WellSectionPlanDto wellSection, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
wellSection.IdWell = idWell;
|
|
||||||
wellSection.IdUser = IdUser;
|
|
||||||
wellSection.LastUpdateDate = DateTimeOffset.UtcNow;
|
|
||||||
|
|
||||||
await CheckIsExistsWellSectionTypeAsync(wellSection.IdSectionType, cancellationToken);
|
var wellSectionId = await wellSectionPlanRepository.InsertAsync(wellSection, cancellationToken);
|
||||||
|
|
||||||
await AssertUserAccessToWell(idWell, cancellationToken);
|
|
||||||
|
|
||||||
var wellSectionId = await wellSectionPlanRepository.UpdateAsync(wellSection, cancellationToken);
|
return Ok(wellSectionId);
|
||||||
|
}
|
||||||
|
|
||||||
if (wellSectionId == ICrudRepository<WellSectionPlanDto>.ErrorIdNotFound)
|
/// <summary>
|
||||||
return this.ValidationBadRequest(nameof(wellSection.Id), $"Секции скважины с Id: {wellSection.Id} не существует");
|
/// Обновить секцию
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell">Идентификатор скважины</param>
|
||||||
|
/// <param name="wellSection">Секция скважины - план</param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPut]
|
||||||
|
[Permission]
|
||||||
|
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||||
|
public async Task<IActionResult> UpdateAsync(int idWell, WellSectionPlanDto wellSection, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
wellSection.IdWell = idWell;
|
||||||
|
wellSection.IdUser = IdUser;
|
||||||
|
wellSection.LastUpdateDate = DateTimeOffset.UtcNow;
|
||||||
|
|
||||||
return Ok(wellSectionId);
|
await CheckIsExistsWellSectionTypeAsync(wellSection.IdSectionType, cancellationToken);
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
await AssertUserAccessToWell(idWell, cancellationToken);
|
||||||
/// Получить типы секций
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="idWell">Идентификатор скважины</param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("wellSectionTypes")]
|
|
||||||
[ProducesResponseType(typeof(IEnumerable<WellSectionTypeDto>), StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
|
||||||
public async Task<IActionResult> GetWellSectionTypesAsync(int idWell, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
await AssertUserAccessToWell(idWell, cancellationToken);
|
|
||||||
|
|
||||||
var wellSectionTypes = await wellSectionPlanRepository.GetWellSectionTypesAsync(idWell, cancellationToken);
|
var wellSectionId = await wellSectionPlanRepository.UpdateAsync(wellSection, cancellationToken);
|
||||||
|
|
||||||
if (!wellSectionTypes.Any())
|
if (wellSectionId == ICrudRepository<WellSectionPlanDto>.ErrorIdNotFound)
|
||||||
return NoContent();
|
return this.ValidationBadRequest(nameof(wellSection.Id), $"Секции скважины с Id: {wellSection.Id} не существует");
|
||||||
|
|
||||||
return Ok(wellSectionTypes);
|
return Ok(wellSectionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить список секций
|
/// Получить типы секций
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell">Идентификатор скважины</param>
|
/// <param name="idWell">Идентификатор скважины</param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet("wellSectionTypes")]
|
||||||
[ProducesResponseType(typeof(IEnumerable<WellSectionPlanDto>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(IEnumerable<WellSectionTypeDto>), StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||||
public async Task<IActionResult> GetPlanWellSectionsAsync(int idWell, CancellationToken cancellationToken)
|
public async Task<IActionResult> GetWellSectionTypesAsync(int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await AssertUserAccessToWell(idWell, cancellationToken);
|
await AssertUserAccessToWell(idWell, cancellationToken);
|
||||||
|
|
||||||
var planWellSections = await wellSectionPlanRepository.GetByIdWellAsync(idWell, cancellationToken);
|
var wellSectionTypes = await wellSectionPlanRepository.GetWellSectionTypesAsync(idWell, cancellationToken);
|
||||||
|
|
||||||
if (!planWellSections.Any())
|
|
||||||
return NoContent();
|
|
||||||
|
|
||||||
return Ok(planWellSections);
|
if (!wellSectionTypes.Any())
|
||||||
}
|
return NoContent();
|
||||||
|
|
||||||
/// <summary>
|
return Ok(wellSectionTypes);
|
||||||
/// Удалить секцию
|
}
|
||||||
/// </summary>
|
|
||||||
/// <param name="idWell">Идентификатор скважины</param>
|
|
||||||
/// <param name="id">Идентификатор плановой секции</param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpDelete]
|
|
||||||
[Permission]
|
|
||||||
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
|
||||||
public async Task<IActionResult> DeleteAsync(int idWell, int id, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
await AssertUserAccessToWell(idWell, cancellationToken);
|
|
||||||
|
|
||||||
var deletedWellSectionPlanCount = await wellSectionPlanRepository.DeleteAsync(id, cancellationToken);
|
/// <summary>
|
||||||
|
/// Получить список секций
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell">Идентификатор скважины</param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(typeof(IEnumerable<WellSectionPlanDto>), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||||
|
public async Task<IActionResult> GetPlanWellSectionsAsync(int idWell, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
await AssertUserAccessToWell(idWell, cancellationToken);
|
||||||
|
|
||||||
return Ok(deletedWellSectionPlanCount);
|
var planWellSections = await wellSectionPlanRepository.GetByIdWellAsync(idWell, cancellationToken);
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: нужно создать базовый контроллер связанный со скважиной и вынести этот метод туда. Данный метод много где дублируется
|
if (!planWellSections.Any())
|
||||||
private async Task AssertUserAccessToWell(int idWell, CancellationToken cancellationToken)
|
return NoContent();
|
||||||
{
|
|
||||||
var idCompany = User.GetCompanyId();
|
|
||||||
|
|
||||||
if (!idCompany.HasValue || !await wellService.IsCompanyInvolvedInWellAsync(idCompany.Value, idWell, cancellationToken))
|
return Ok(planWellSections);
|
||||||
throw new ForbidException("Нет доступа к скважине");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: тоже нужно вынести в базовый контроллер
|
/// <summary>
|
||||||
private async Task CheckIsExistsWellSectionTypeAsync(int idWellSectionType, CancellationToken cancellationToken)
|
/// Удалить секцию
|
||||||
{
|
/// </summary>
|
||||||
_ = await wellSectionRepository.GetOrDefaultAsync(idWellSectionType, cancellationToken)
|
/// <param name="idWell">Идентификатор скважины</param>
|
||||||
?? throw new ArgumentInvalidException(nameof(ProcessMapPlanWellDrillingDto.IdWellSectionType),
|
/// <param name="id">Идентификатор плановой секции</param>
|
||||||
$"Тип секции с Id: {idWellSectionType} не найден");
|
/// <param name="cancellationToken"></param>
|
||||||
}
|
/// <returns></returns>
|
||||||
|
[HttpDelete]
|
||||||
|
[Permission]
|
||||||
|
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||||
|
public async Task<IActionResult> DeleteAsync(int idWell, int id, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
await AssertUserAccessToWell(idWell, cancellationToken);
|
||||||
|
|
||||||
|
var deletedWellSectionPlanCount = await wellSectionPlanRepository.DeleteAsync(id, cancellationToken);
|
||||||
|
|
||||||
|
return Ok(deletedWellSectionPlanCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: нужно создать базовый контроллер связанный со скважиной и вынести этот метод туда. Данный метод много где дублируется
|
||||||
|
private async Task AssertUserAccessToWell(int idWell, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
|
if (!idCompany.HasValue || !await wellService.IsCompanyInvolvedInWellAsync(idCompany.Value, idWell, cancellationToken))
|
||||||
|
throw new ForbidException("Нет доступа к скважине");
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: тоже нужно вынести в базовый контроллер
|
||||||
|
private async Task CheckIsExistsWellSectionTypeAsync(int idWellSectionType, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
_ = await wellSectionRepository.GetOrDefaultAsync(idWellSectionType, cancellationToken)
|
||||||
|
?? throw new ArgumentInvalidException(nameof(ProcessMapPlanDrillingDto.IdWellSectionType),
|
||||||
|
$"Тип секции с Id: {idWellSectionType} не найден");
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Data.ProcessMapPlan;
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
@ -6,7 +7,6 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AsbCloudApp.Data.ProcessMaps;
|
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
@ -22,7 +22,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
private readonly IWellCompositeRepository wellCompositeRepository;
|
private readonly IWellCompositeRepository wellCompositeRepository;
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
|
|
||||||
public WellCompositeController(IWellCompositeRepository wellCompositeRepository,
|
public WellCompositeController(IWellCompositeRepository wellCompositeRepository,
|
||||||
IWellService wellService)
|
IWellService wellService)
|
||||||
{
|
{
|
||||||
this.wellCompositeRepository = wellCompositeRepository;
|
this.wellCompositeRepository = wellCompositeRepository;
|
||||||
@ -73,7 +73,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("compositeProcessMap")]
|
[HttpGet("compositeProcessMap")]
|
||||||
[Permission]
|
[Permission]
|
||||||
[ProducesResponseType(typeof(IEnumerable<ProcessMapPlanWellDrillingDto>), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(IEnumerable<ProcessMapPlanDrillingDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> GetCompositeProcessMap(int idWell, CancellationToken token)
|
public async Task<IActionResult> GetCompositeProcessMap(int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||||
|
Loading…
Reference in New Issue
Block a user