forked from ddrilling/AsbCloudServer
refact #1
This commit is contained in:
parent
169968da44
commit
3c84648eec
@ -7,6 +7,11 @@ namespace AsbCloudApp.Data
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class PlannedTrajectoryDto
|
public class PlannedTrajectoryDto
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ИД строки с координатами
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ИД скважины
|
/// ИД скважины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -14,7 +19,7 @@ namespace AsbCloudApp.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дата загрузки
|
/// Дата загрузки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTimeOffset Date { get; set; }
|
public DateTimeOffset UpdateDate { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ИД пользователя
|
/// ИД пользователя
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,30 +1,31 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace AsbCloudApp.Services
|
namespace AsbCloudApp.Services
|
||||||
{
|
{
|
||||||
|
#nullable enable
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сервис загрузки и обработки плановой траектории из файла
|
/// Сервис загрузки и обработки плановой траектории из файла
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IPlannedTrajectoryImportService
|
public interface IPlannedTrajectoryImportService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// шаблон для заполнения плановой траектории
|
/// скачать шаблон для заполнения плановой траектории
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Stream GetTemplateFile();
|
Stream GetTemplateFile();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// загрузить строки плановой траектории в .xlsx
|
/// загрузить текущую плановую траекторию в .xlsx
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell"></param>
|
/// <param name="idWell"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Stream ExportRows(int idWell);
|
Stream Export(int idWell);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// закгрузить из excel координаты плановой траектории
|
/// импортировать из excel плановую траекторию
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell"></param>
|
/// <param name="idWell"></param>
|
||||||
/// <param name="idUser"></param>
|
/// <param name="idUser"></param>
|
||||||
/// <param name="stream"></param>
|
/// <param name="stream"></param>
|
||||||
/// <param name="deleteWellOperationsBeforeImport">Очистить старые перед импортом (если файл проходит валидацию)</param>
|
/// <param name="deleteWellOperationsBeforeImport">Очистить старые координаты перед импортом (если файл проходит валидацию)</param>
|
||||||
void Import(int idWell, int idUser, Stream stream, bool deleteWellOperationsBeforeImport = false);
|
void Import(int idWell, int idUser, Stream stream, bool deleteWellOperationsBeforeImport = false);
|
||||||
}
|
}
|
||||||
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudApp.Services
|
namespace AsbCloudApp.Services
|
||||||
{
|
{
|
||||||
|
#nullable enable
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// CRUD для работы с плановой траекторией из клиента
|
/// CRUD для работы с плановой траекторией из клиента
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -17,7 +18,7 @@ namespace AsbCloudApp.Services
|
|||||||
/// <param name="idWell"></param>
|
/// <param name="idWell"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<PlannedTrajectoryDto>> GetCoordinates(int idWell, CancellationToken token);
|
Task<IEnumerable<PlannedTrajectoryDto>?> GetCoordinatesAsync(int idWell, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавить строки с координатами
|
/// Добавить строки с координатами
|
||||||
@ -43,11 +44,12 @@ namespace AsbCloudApp.Services
|
|||||||
CancellationToken token);
|
CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удалить строку с координатами
|
/// Удалить строки с координатами
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ids"></param>
|
/// <param name="ids"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> DeleteAsync(IEnumerable<int> ids, CancellationToken token);
|
Task<int> DeleteRangeAsync(IEnumerable<int> ids, CancellationToken token);
|
||||||
}
|
}
|
||||||
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
||||||
{
|
{
|
||||||
|
#nullable enable
|
||||||
public class PlannedTrajectoryImportService : IPlannedTrajectoryImportService
|
public class PlannedTrajectoryImportService : IPlannedTrajectoryImportService
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -51,7 +52,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream ExportRows(int idWell)
|
public Stream Export(int idWell)
|
||||||
{
|
{
|
||||||
var plannedTrajectorys = db.PlannedTrajectorys
|
var plannedTrajectorys = db.PlannedTrajectorys
|
||||||
.Where(o => o.IdWell == idWell)
|
.Where(o => o.IdWell == idWell)
|
||||||
@ -252,5 +253,6 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
return trajectoryRow;
|
return trajectoryRow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> DeleteAsync(IEnumerable<int> ids, CancellationToken token)
|
public async Task<int> DeleteRangeAsync(IEnumerable<int> ids, CancellationToken token)
|
||||||
{
|
{
|
||||||
var query = db.PlannedTrajectorys.Where(e => ids.Contains(e.Id));
|
var query = db.PlannedTrajectorys.Where(e => ids.Contains(e.Id));
|
||||||
db.PlannedTrajectorys.RemoveRange(query);
|
db.PlannedTrajectorys.RemoveRange(query);
|
||||||
@ -46,16 +46,16 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<PlannedTrajectoryDto>?> GetCoordinates(int idWell, CancellationToken token)
|
public async Task<IEnumerable<PlannedTrajectoryDto>?> GetCoordinatesAsync(int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
var well = wellService.GetOrDefault(idWell);
|
var well = wellService.GetOrDefault(idWell);
|
||||||
if (well is null || well.Timezone is null)
|
if (well is null || well.Timezone is null)
|
||||||
throw new ArgumentInvalidException("idWell doesn`t exist", nameof(idWell));
|
throw new ArgumentInvalidException("idWell doesn`t exist", nameof(idWell));
|
||||||
var query = db.PlannedTrajectorys
|
var query = db.PlannedTrajectorys
|
||||||
.Where(x => x.IdWell == idWell);
|
.Where(x => x.IdWell == idWell);
|
||||||
var entities = await query
|
var entities = await query
|
||||||
.OrderBy(e => e.LoadDate)
|
.OrderBy(e => e.LoadDate)
|
||||||
.ToListAsync(token);
|
.ToListAsync(token);
|
||||||
var result = entities
|
var result = entities
|
||||||
.Select(r => Convert(r));
|
.Select(r => Convert(r));
|
||||||
return result;
|
return result;
|
||||||
|
@ -40,7 +40,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[Route("template")]
|
[Route("template")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public IActionResult GetTamplate()
|
public IActionResult GetTemplate()
|
||||||
{
|
{
|
||||||
var stream = plannedTrajectoryImportService.GetTemplateFile();
|
var stream = plannedTrajectoryImportService.GetTemplateFile();
|
||||||
var fileName = "ЕЦП_шаблон_файла_плановая_траектория.xlsx";
|
var fileName = "ЕЦП_шаблон_файла_плановая_траектория.xlsx";
|
||||||
@ -68,7 +68,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
idWell, token).ConfigureAwait(false))
|
idWell, token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var stream = plannedTrajectoryImportService.ExportRows(idWell);
|
var stream = plannedTrajectoryImportService.Export(idWell);
|
||||||
var fileName = await wellService.GetWellCaptionByIdAsync(idWell, token) + "_plannedTrajectory.xlsx";
|
var fileName = await wellService.GetWellCaptionByIdAsync(idWell, token) + "_plannedTrajectory.xlsx";
|
||||||
return File(stream, "application/octet-stream", fileName);
|
return File(stream, "application/octet-stream", fileName);
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <param name="token"> Токен отмены задачи </param>
|
/// <param name="token"> Токен отмены задачи </param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
//[Permission]
|
[Permission]
|
||||||
[Route("import/{options}")]
|
[Route("import/{options}")]
|
||||||
public async Task<IActionResult> ImportAsync(int idWell,
|
public async Task<IActionResult> ImportAsync(int idWell,
|
||||||
[FromForm] IFormFileCollection files,
|
[FromForm] IFormFileCollection files,
|
||||||
@ -145,7 +145,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
idWell, token).ConfigureAwait(false))
|
idWell, token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = plannedTrajectoryService.GetCoordinates(idWell,token);
|
var result = plannedTrajectoryService.GetCoordinatesAsync(idWell,token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
token).ConfigureAwait(false))
|
token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await plannedTrajectoryService.DeleteAsync(new int[] { idRow }, token)
|
var result = await plannedTrajectoryService.DeleteRangeAsync(new int[] { idRow }, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
|
Loading…
Reference in New Issue
Block a user