2022-07-14 03:47:11 +05:00
|
|
|
|
using AsbCloudApp.Data.Subsystems;
|
2022-07-18 18:51:49 +05:00
|
|
|
|
using AsbCloudApp.Requests;
|
2022-07-14 03:47:11 +05:00
|
|
|
|
using AsbCloudApp.Services;
|
2022-07-18 18:51:49 +05:00
|
|
|
|
using AsbCloudApp.Services.Subsystems;
|
2022-07-14 03:47:11 +05:00
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudWebApi.Controllers.Subsystems
|
|
|
|
|
{
|
2022-07-18 18:51:49 +05:00
|
|
|
|
|
|
|
|
|
|
2022-07-14 03:47:11 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Наработка подсистем
|
|
|
|
|
/// </summary>
|
2022-07-18 18:51:49 +05:00
|
|
|
|
[Route("api/[controller]")]
|
2022-07-14 03:47:11 +05:00
|
|
|
|
[ApiController]
|
|
|
|
|
[Authorize]
|
|
|
|
|
|
|
|
|
|
public class OperatingTimeSubsystemController : ControllerBase
|
|
|
|
|
{
|
2022-07-18 18:51:49 +05:00
|
|
|
|
private readonly ISubsystemOperationTimeService subsystemOperationTimeService;
|
|
|
|
|
private readonly IWellService wellService;
|
|
|
|
|
|
|
|
|
|
public OperatingTimeSubsystemController(ISubsystemOperationTimeService subsystemOperationTimeService, IWellService wellService)
|
|
|
|
|
{
|
|
|
|
|
this.subsystemOperationTimeService = subsystemOperationTimeService;
|
|
|
|
|
this.wellService = wellService;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// получить статистику
|
|
|
|
|
/// </summary>
|
2022-08-01 13:55:51 +05:00
|
|
|
|
[HttpGet("stat")]
|
2022-07-18 18:51:49 +05:00
|
|
|
|
[ProducesResponseType(typeof(IEnumerable<SubsystemStatisticsDto>), (int)System.Net.HttpStatusCode.OK)]
|
|
|
|
|
public async Task<IActionResult> GetStatisticsAsync(CancellationToken token = default)
|
|
|
|
|
{
|
|
|
|
|
var subsystemResult = new List<SubsystemStatisticsDto>()
|
|
|
|
|
{
|
|
|
|
|
new SubsystemStatisticsDto(){
|
|
|
|
|
IdSubsystem = 1,
|
|
|
|
|
Subsystem = "test1",
|
2022-08-01 13:55:51 +05:00
|
|
|
|
UsedTime = System.TimeSpan.MinValue,
|
2022-07-18 18:51:49 +05:00
|
|
|
|
K2 = System.TimeSpan.MinValue,
|
|
|
|
|
KUsage = System.TimeSpan.MinValue
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
new SubsystemStatisticsDto(){
|
|
|
|
|
IdSubsystem = 2,
|
|
|
|
|
Subsystem = "test2",
|
2022-08-01 13:55:51 +05:00
|
|
|
|
UsedTime = System.TimeSpan.MinValue,
|
2022-07-18 18:51:49 +05:00
|
|
|
|
K2 = System.TimeSpan.Zero,
|
|
|
|
|
KUsage = System.TimeSpan.Zero
|
|
|
|
|
},
|
|
|
|
|
new SubsystemStatisticsDto(){
|
|
|
|
|
IdSubsystem = 3,
|
|
|
|
|
Subsystem = "test3",
|
2022-08-01 13:55:51 +05:00
|
|
|
|
UsedTime = System.TimeSpan.MinValue,
|
2022-07-18 18:51:49 +05:00
|
|
|
|
K2 = System.TimeSpan.MaxValue,
|
|
|
|
|
KUsage = System.TimeSpan.MaxValue
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return Ok(subsystemResult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// получить список подсистем общий.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpGet("subsystem")]
|
|
|
|
|
[ProducesResponseType(typeof(IEnumerable<SubsystemDto>), (int)System.Net.HttpStatusCode.OK)]
|
2022-08-01 13:55:51 +05:00
|
|
|
|
public async Task<IActionResult> GetSubsystemAsync([FromQuery] int idWell, CancellationToken token = default)
|
2022-07-18 18:51:49 +05:00
|
|
|
|
{
|
|
|
|
|
var result = await subsystemOperationTimeService.GetSubsystemAsync(idWell, token);
|
|
|
|
|
return Ok(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// получить список наработок подсистем
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpGet("operationTime")]
|
|
|
|
|
[ProducesResponseType(typeof(IEnumerable<SubsystemOperationTimeDto>), (int)System.Net.HttpStatusCode.OK)]
|
|
|
|
|
public async Task<IActionResult> GetOperationTimeAsync(
|
|
|
|
|
[FromQuery] SubsystemOperationTimeRequest request,
|
|
|
|
|
CancellationToken token = default)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var result = await subsystemOperationTimeService.GetOperationTimeAsync(request, token);
|
|
|
|
|
return Ok(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Удалить наработки.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpDelete]
|
|
|
|
|
[Permission]
|
|
|
|
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
|
|
|
|
public async Task<IActionResult> DeleteAsync(
|
|
|
|
|
[FromQuery] SubsystemOperationTimeRequest request,
|
|
|
|
|
CancellationToken token)
|
|
|
|
|
{
|
|
|
|
|
var result = await subsystemOperationTimeService.DeleteAsync(request, token);
|
|
|
|
|
return Ok(result);
|
|
|
|
|
}
|
2022-07-14 03:47:11 +05:00
|
|
|
|
}
|
2022-07-18 18:51:49 +05:00
|
|
|
|
}
|