forked from ddrilling/AsbCloudServer
3 метода get для ProcessMapPlanBaseController
This commit is contained in:
parent
edd5ca695f
commit
792790556c
64
AsbCloudApp/Data/ChangeLogDto.cs
Normal file
64
AsbCloudApp/Data/ChangeLogDto.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using AsbCloudApp.Data.User;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Data;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Часть записи описывающая изменение
|
||||||
|
/// </summary>
|
||||||
|
public class ChangeLogDto<T>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Запись
|
||||||
|
/// </summary>
|
||||||
|
public required T Item { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ИД записи
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Автор
|
||||||
|
/// </summary>
|
||||||
|
public UserDto? Author { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Автор
|
||||||
|
/// </summary>
|
||||||
|
public UserDto? Editor { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Дата создания записи
|
||||||
|
/// </summary>
|
||||||
|
public DateTimeOffset Creation { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Дата устаревания (например при удалении)
|
||||||
|
/// </summary>
|
||||||
|
public DateTimeOffset? Obsolete { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ИД состояния записи:
|
||||||
|
/// <list type="table">
|
||||||
|
/// <item>
|
||||||
|
/// <term>0</term>
|
||||||
|
/// <description>актуальная запись</description>
|
||||||
|
/// </item>
|
||||||
|
/// <item>
|
||||||
|
/// <term>1</term>
|
||||||
|
/// <description>замененная запись</description>
|
||||||
|
/// </item>
|
||||||
|
/// <item>
|
||||||
|
/// <term>2</term>
|
||||||
|
/// <description>удаленная запись</description>
|
||||||
|
/// </item>
|
||||||
|
/// </list>
|
||||||
|
/// </summary>
|
||||||
|
public int IdState { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Id заменяемой записи
|
||||||
|
/// </summary>
|
||||||
|
public int? IdPrevious { get; set; }
|
||||||
|
}
|
@ -1,23 +1,23 @@
|
|||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Data;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Threading;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using AsbCloudApp.Exceptions;
|
|
||||||
using AsbCloudApp.Requests;
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using AsbCloudApp.Services;
|
|
||||||
using System.Linq;
|
|
||||||
using AsbCloudApp.Data;
|
|
||||||
using AsbCloudApp.Requests.ParserOptions;
|
|
||||||
using AsbCloudApp.Data.ProcessMaps;
|
using AsbCloudApp.Data.ProcessMaps;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using AsbCloudApp.Exceptions;
|
||||||
|
using AsbCloudApp.Repositories;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
using AsbCloudApp.Requests.ExportOptions;
|
using AsbCloudApp.Requests.ExportOptions;
|
||||||
|
using AsbCloudApp.Requests.ParserOptions;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudApp.Services.Export;
|
using AsbCloudApp.Services.Export;
|
||||||
using AsbCloudApp.Services.Parsers;
|
using AsbCloudApp.Services.Parsers;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
||||||
|
|
||||||
@ -33,16 +33,19 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
|
|||||||
private readonly IChangeLogRepository<TDto, ProcessMapPlanBaseRequestWithWell> repository;
|
private readonly IChangeLogRepository<TDto, ProcessMapPlanBaseRequestWithWell> repository;
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
private readonly IParserService<TDto, WellRelatedParserRequest> parserService;
|
private readonly IParserService<TDto, WellRelatedParserRequest> parserService;
|
||||||
|
private readonly ITelemetryService telemetryService;
|
||||||
private readonly IExportService<WellRelatedExportRequest> processMapPlanExportService;
|
private readonly IExportService<WellRelatedExportRequest> processMapPlanExportService;
|
||||||
|
|
||||||
protected ProcessMapPlanBaseController(IChangeLogRepository<TDto, ProcessMapPlanBaseRequestWithWell> repository,
|
protected ProcessMapPlanBaseController(IChangeLogRepository<TDto, ProcessMapPlanBaseRequestWithWell> repository,
|
||||||
IWellService wellService,
|
IWellService wellService,
|
||||||
IParserService<TDto, WellRelatedParserRequest> parserService,
|
IParserService<TDto, WellRelatedParserRequest> parserService,
|
||||||
IExportService<WellRelatedExportRequest> processMapPlanExportService)
|
IExportService<WellRelatedExportRequest> processMapPlanExportService,
|
||||||
|
ITelemetryService telemetryService)
|
||||||
{
|
{
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
this.parserService = parserService;
|
this.parserService = parserService;
|
||||||
|
this.telemetryService = telemetryService;
|
||||||
this.processMapPlanExportService = processMapPlanExportService;
|
this.processMapPlanExportService = processMapPlanExportService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +61,7 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
public async Task<IActionResult> InsertRange([FromRoute][Range(0,int.MaxValue)] int idWell, IEnumerable<TDto> dtos, CancellationToken token)
|
public async Task<IActionResult> InsertRange([FromRoute][Range(0, int.MaxValue)] int idWell, IEnumerable<TDto> dtos, CancellationToken token)
|
||||||
{
|
{
|
||||||
var idUser = await AssertUserHasAccessToWell(idWell, token);
|
var idUser = await AssertUserHasAccessToWell(idWell, token);
|
||||||
|
|
||||||
@ -131,21 +134,71 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
|
|||||||
/// Получение
|
/// Получение
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell"></param>
|
/// <param name="idWell"></param>
|
||||||
/// <param name="request"></param>
|
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
public async Task<ActionResult<IEnumerable<TDto>>> Get([FromRoute] int idWell, [FromQuery] ProcessMapPlanBaseRequest request, CancellationToken token)
|
public async Task<ActionResult<IEnumerable<TDto>>> Get([FromRoute] int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
await AssertUserHasAccessToWell(idWell, token);
|
await AssertUserHasAccessToWell(idWell, token);
|
||||||
|
|
||||||
var serviceRequest = new ProcessMapPlanBaseRequestWithWell(request, idWell);
|
var serviceRequest = new ProcessMapPlanBaseRequestWithWell(idWell);
|
||||||
var result = await repository.Get(serviceRequest, token);
|
var result = await repository.Get(serviceRequest, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell"></param>
|
||||||
|
/// <param name="moment"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("history")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
|
public async Task<ActionResult<IEnumerable<ChangeLogDto<TDto>>>> Get([FromRoute] int idWell, DateTimeOffset? moment, CancellationToken token)
|
||||||
|
{
|
||||||
|
await AssertUserHasAccessToWell(idWell, token);
|
||||||
|
|
||||||
|
var serviceRequest = new ProcessMapPlanBaseRequestWithWell(new ProcessMapPlanBaseRequest()
|
||||||
|
{
|
||||||
|
Moment = moment,
|
||||||
|
}, idWell);
|
||||||
|
|
||||||
|
var result = await repository.GetChangeLog(serviceRequest, null, token);
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uid"></param>
|
||||||
|
/// <param name="updateFrom"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("/api/telemetry/{uid}/[controller]")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
|
public async Task<ActionResult<IEnumerable<ChangeLogDto<TDto>>>> Get(string uid, DateTimeOffset? updateFrom, CancellationToken token)
|
||||||
|
{
|
||||||
|
var idWell = telemetryService.GetIdWellByTelemetryUid(uid) ?? -1;
|
||||||
|
|
||||||
|
if (idWell < 0)
|
||||||
|
return this.ValidationBadRequest(nameof(uid), "Скважина по uid не найдена");
|
||||||
|
|
||||||
|
await AssertUserHasAccessToWell(idWell, token);
|
||||||
|
|
||||||
|
var serviceRequest = new ProcessMapPlanBaseRequestWithWell(new ProcessMapPlanBaseRequest()
|
||||||
|
{
|
||||||
|
UpdateFrom = updateFrom,
|
||||||
|
}, idWell);
|
||||||
|
|
||||||
|
var result = await repository.GetChangeLog(serviceRequest, null, token);
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Изменения за определенную дату
|
/// Изменения за определенную дату
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -156,7 +209,7 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
|
|||||||
[HttpGet("changeLog")]
|
[HttpGet("changeLog")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
public async Task<ActionResult<IEnumerable<TDto>>> GetChangeLog([FromRoute] int idWell, [FromQuery] DateOnly? date, CancellationToken token)
|
public async Task<ActionResult<IEnumerable<ChangeLogDto<TDto>>>> GetChangeLog([FromRoute] int idWell, [FromQuery] DateOnly? date, CancellationToken token)
|
||||||
{
|
{
|
||||||
await AssertUserHasAccessToWell(idWell, token);
|
await AssertUserHasAccessToWell(idWell, token);
|
||||||
|
|
||||||
|
@ -15,8 +15,9 @@ public class ProcessMapPlanDrillingController : ProcessMapPlanBaseController<Pro
|
|||||||
public ProcessMapPlanDrillingController(IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> repository,
|
public ProcessMapPlanDrillingController(IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> repository,
|
||||||
IWellService wellService,
|
IWellService wellService,
|
||||||
ProcessMapPlanDrillingParser parserService,
|
ProcessMapPlanDrillingParser parserService,
|
||||||
|
ITelemetryService telemetryService,
|
||||||
ProcessMapPlanDrillingExportService processMapPlanExportService)
|
ProcessMapPlanDrillingExportService processMapPlanExportService)
|
||||||
: base(repository, wellService, parserService, processMapPlanExportService)
|
: base(repository, wellService, parserService, processMapPlanExportService, telemetryService)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +15,9 @@ public class ProcessMapPlanReamController : ProcessMapPlanBaseController<Process
|
|||||||
public ProcessMapPlanReamController(IChangeLogRepository<ProcessMapPlanReamDto, ProcessMapPlanBaseRequestWithWell> repository,
|
public ProcessMapPlanReamController(IChangeLogRepository<ProcessMapPlanReamDto, ProcessMapPlanBaseRequestWithWell> repository,
|
||||||
IWellService wellService,
|
IWellService wellService,
|
||||||
ProcessMapPlanReamParser parserService,
|
ProcessMapPlanReamParser parserService,
|
||||||
|
ITelemetryService telemetryService,
|
||||||
ProcessMapPlanReamExportService processMapPlanExportService)
|
ProcessMapPlanReamExportService processMapPlanExportService)
|
||||||
: base(repository, wellService, parserService, processMapPlanExportService)
|
: base(repository, wellService, parserService, processMapPlanExportService, telemetryService)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user