forked from ddrilling/AsbCloudServer
merge from dev to wellbores
This commit is contained in:
commit
4a72504ee8
@ -5,21 +5,10 @@ namespace AsbCloudApp.Data.AutogeneratedDailyReport;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Базовая информация о суточном отчёте
|
/// Базовая информация о суточном отчёте
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AutoGeneratedDailyReportInfoDto
|
public class AutoGeneratedDailyReportInfoDto : ReportInfoDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дата формирования отчёта
|
/// Дата формирования отчёта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateOnly ReportDate { get; set; }
|
public DateOnly ReportDate { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Название файла
|
|
||||||
/// </summary>
|
|
||||||
public string FileName { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Размер файла
|
|
||||||
/// </summary>
|
|
||||||
public int FileSize { get; set; }
|
|
||||||
|
|
||||||
}
|
}
|
26
AsbCloudApp/Data/DrillTestReport/DrillTestReportDataDto.cs
Normal file
26
AsbCloudApp/Data/DrillTestReport/DrillTestReportDataDto.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using AsbCloudApp.Data.SAUB;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Data.DrillTestReport
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Информация о drill test, выгружаемая в отчете
|
||||||
|
/// </summary>
|
||||||
|
public class DrillTestReportDataDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Данные для отчета
|
||||||
|
/// </summary>
|
||||||
|
public DrillTestDto Data { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Заголовок отчета
|
||||||
|
/// </summary>
|
||||||
|
public string Caption { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Дата отчета
|
||||||
|
/// </summary>
|
||||||
|
public DateTime Date { get; set; } = DateTime.Now;
|
||||||
|
}
|
||||||
|
}
|
25
AsbCloudApp/Data/DrillTestReport/DrillTestReportInfoDto.cs
Normal file
25
AsbCloudApp/Data/DrillTestReport/DrillTestReportInfoDto.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Data.DrillTestReport
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Базовая информация о drill_test отчёте
|
||||||
|
/// </summary>
|
||||||
|
public class DrillTestReportInfoDto : ReportInfoDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Идентификатор отчета
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Проходка
|
||||||
|
/// </summary>
|
||||||
|
public float DrillDepth { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Дата и время
|
||||||
|
/// </summary>
|
||||||
|
public DateTime DateTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
18
AsbCloudApp/Data/ReportInfoDto.cs
Normal file
18
AsbCloudApp/Data/ReportInfoDto.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
namespace AsbCloudApp.Data
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Справочная информация об отчете
|
||||||
|
/// </summary>
|
||||||
|
public class ReportInfoDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Название файла
|
||||||
|
/// </summary>
|
||||||
|
public string FileName { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Размер файла
|
||||||
|
/// </summary>
|
||||||
|
public int FileSize { get; set; } = 0;
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,11 @@ namespace AsbCloudApp.Data.SAUB
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float DepthStart { get; set; }
|
public float DepthStart { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Связанная с drill_test телеметрия
|
||||||
|
/// </summary>
|
||||||
|
public TelemetryDto? Telemetry { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Параметры теста
|
/// Параметры теста
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
public float? DepthSpeed { get; set; }
|
public float? DepthSpeed { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Время бурения шага
|
/// Время бурения шага, сек
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float? TimeDrillStep { get; set; }
|
public float? TimeDrillStep { get; set; }
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace AsbCloudApp.Exceptions
|
namespace AsbCloudApp.Exceptions
|
||||||
{
|
{
|
||||||
@ -8,9 +10,9 @@ namespace AsbCloudApp.Exceptions
|
|||||||
public class ArgumentInvalidException : Exception
|
public class ArgumentInvalidException : Exception
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// название аргумента
|
/// словарь с ошибками, где ключ - имя аргумента, а значение - массив из одного сообщения
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ParamName { get; } = string.Empty;
|
public IDictionary<string, string[]> ErrorState { get; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// конструктор
|
/// конструктор
|
||||||
@ -20,7 +22,20 @@ namespace AsbCloudApp.Exceptions
|
|||||||
public ArgumentInvalidException(string paramName, string message)
|
public ArgumentInvalidException(string paramName, string message)
|
||||||
: base(message)
|
: base(message)
|
||||||
{
|
{
|
||||||
ParamName = paramName;
|
ErrorState = new Dictionary<string, string[]>() {
|
||||||
|
{ paramName, new[]{ message } }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="paramsNames"></param>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
public ArgumentInvalidException(string[] paramsNames, string message)
|
||||||
|
: base(message)
|
||||||
|
{
|
||||||
|
ErrorState = paramsNames.ToDictionary(paramName => paramName, item => new[] { message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using AsbCloudApp.Data.SAUB;
|
using AsbCloudApp.Data.SAUB;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -9,6 +11,24 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IDrillTestRepository
|
public interface IDrillTestRepository
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Получить данные drill_test в соответствии с параметрами запроса
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idTelemetry">ключ телеметрии</param>
|
||||||
|
/// <param name="request">запрос</param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<DrillTestDto>> GetAllAsync(int idTelemetry, FileReportRequest request, CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить запись drill_test
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idTelemetry">ключ телеметрии</param>
|
||||||
|
/// <param name="id">ключ записи drill_test</param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<DrillTestDto> GetAsync(int idTelemetry, int id, CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сохранить данные drill_test
|
/// Сохранить данные drill_test
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Requests;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Параметры запроса для получения авто-генерируемых суточных отчётов
|
|
||||||
/// </summary>
|
|
||||||
public class AutoGeneratedDailyReportRequest : RequestBase
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Дата начала периода
|
|
||||||
/// </summary>
|
|
||||||
public DateOnly? StartDate { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Дата конца периода
|
|
||||||
/// </summary>
|
|
||||||
public DateOnly? FinishDate { get; set; }
|
|
||||||
}
|
|
19
AsbCloudApp/Requests/FileReportRequest.cs
Normal file
19
AsbCloudApp/Requests/FileReportRequest.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Requests;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Параметры запроса для получения отчетов (файлов)
|
||||||
|
/// </summary>
|
||||||
|
public class FileReportRequest : RequestBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Дата начала периода
|
||||||
|
/// </summary>
|
||||||
|
public DateOnly? GeDate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Дата конца периода
|
||||||
|
/// </summary>
|
||||||
|
public DateOnly? LeDate { get; set; }
|
||||||
|
}
|
@ -1,20 +0,0 @@
|
|||||||
using System.IO;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AsbCloudApp.Data.AutogeneratedDailyReport;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Services.AutoGeneratedDailyReports;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сервис для генерации файлов авто-генерируемых суточный отчётов
|
|
||||||
/// </summary>
|
|
||||||
public interface IAutoGeneratedDailyReportMakerService
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Генерация файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="report"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<Stream> MakeReportAsync(AutoGeneratedDailyReportDto report, CancellationToken cancellationToken);
|
|
||||||
}
|
|
@ -21,7 +21,7 @@ public interface IAutoGeneratedDailyReportService
|
|||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<PaginationContainer<AutoGeneratedDailyReportInfoDto>> GetListAsync(int idWell,
|
Task<PaginationContainer<AutoGeneratedDailyReportInfoDto>> GetListAsync(int idWell,
|
||||||
AutoGeneratedDailyReportRequest request,
|
FileReportRequest request,
|
||||||
CancellationToken cancellationToken);
|
CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
35
AsbCloudApp/Services/IDrillTestReportService.cs
Normal file
35
AsbCloudApp/Services/IDrillTestReportService.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Data.DrillTestReport;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Services
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// сервис по работе с отчетами drill test
|
||||||
|
/// </summary>
|
||||||
|
public interface IDrillTestReportService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Список файлов drill test
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell">ключ скважины</param>
|
||||||
|
/// <param name="request">параметры запроса</param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<PaginationContainer<DrillTestReportInfoDto>> GetListAsync(int idWell,
|
||||||
|
FileReportRequest request,
|
||||||
|
CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Генерация файла с отчётом
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell">ключ скважины</param>
|
||||||
|
/// <param name="id">ключ drill test записи</param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<(string fileName, Stream stream)> GenerateAsync(int idWell, int id, CancellationToken cancellationToken);
|
||||||
|
}
|
||||||
|
}
|
19
AsbCloudApp/Services/IReportMakerService.cs
Normal file
19
AsbCloudApp/Services/IReportMakerService.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Services;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сервис для генерации файлов отчётов
|
||||||
|
/// </summary>
|
||||||
|
public interface IReportMakerService<T>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Генерация файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="report">модель с данными для построения отчета</param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<Stream> MakeReportAsync(T report, CancellationToken cancellationToken);
|
||||||
|
}
|
@ -161,6 +161,8 @@
|
|||||||
|
|
||||||
new() { Id = 527, Name = "Manual.delete", Description = "Разрешение на удаление инструкций"},
|
new() { Id = 527, Name = "Manual.delete", Description = "Разрешение на удаление инструкций"},
|
||||||
new (){ Id = 528, Name="WellContact.delete", Description="Разрешение на удаление контакта"},
|
new (){ Id = 528, Name="WellContact.delete", Description="Разрешение на удаление контакта"},
|
||||||
|
|
||||||
|
new (){ Id = 529, Name="DrillTestReport.get", Description="Разрешение на получение отчетов drill test"},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
<None Remove="CommonLibs\logo_720x404.png" />
|
<None Remove="CommonLibs\logo_720x404.png" />
|
||||||
<None Remove="CommonLibs\Readme.md" />
|
<None Remove="CommonLibs\Readme.md" />
|
||||||
<None Remove="Services\DailyReport\DailyReportTemplate.xlsx" />
|
<None Remove="Services\DailyReport\DailyReportTemplate.xlsx" />
|
||||||
|
<None Remove="Services\DrillTestReport\DrillTestReportTemplate.xlsx" />
|
||||||
<None Remove="Services\Trajectory\PlannedTrajectoryTemplate.xlsx" />
|
<None Remove="Services\Trajectory\PlannedTrajectoryTemplate.xlsx" />
|
||||||
<None Remove="Services\WellOperationService\ScheduleReportTemplate.xlsx" />
|
<None Remove="Services\WellOperationService\ScheduleReportTemplate.xlsx" />
|
||||||
<None Remove="Services\WellOperationService\WellOperationImportTemplate.xlsx" />
|
<None Remove="Services\WellOperationService\WellOperationImportTemplate.xlsx" />
|
||||||
@ -30,6 +31,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Services\DailyReport\DailyReportTemplate.xlsx" />
|
<EmbeddedResource Include="Services\DailyReport\DailyReportTemplate.xlsx" />
|
||||||
|
<EmbeddedResource Include="Services\DrillTestReport\DrillTestReportTemplate.xlsx" />
|
||||||
<EmbeddedResource Include="Services\Trajectory\PlannedTrajectoryTemplate.xlsx" />
|
<EmbeddedResource Include="Services\Trajectory\PlannedTrajectoryTemplate.xlsx" />
|
||||||
<EmbeddedResource Include="Services\WellOperationService\ScheduleReportTemplate.xlsx" />
|
<EmbeddedResource Include="Services\WellOperationService\ScheduleReportTemplate.xlsx" />
|
||||||
<EmbeddedResource Include="Services\AutoGeneratedDailyReports\AutogeneratedDailyReportTemplate.xlsx" />
|
<EmbeddedResource Include="Services\AutoGeneratedDailyReports\AutogeneratedDailyReportTemplate.xlsx" />
|
||||||
|
30
AsbCloudInfrastructure/AssemblyExtensions.cs
Normal file
30
AsbCloudInfrastructure/AssemblyExtensions.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudInfrastructure
|
||||||
|
{
|
||||||
|
public static class AssemblyExtensions
|
||||||
|
{
|
||||||
|
public static async Task<Stream> GetTemplateCopyStreamAsync(this Assembly assembly, string templateName, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var resourceName = assembly
|
||||||
|
.GetManifestResourceNames()
|
||||||
|
.FirstOrDefault(n => n.EndsWith(templateName))!;
|
||||||
|
|
||||||
|
using var stream = Assembly.GetExecutingAssembly()
|
||||||
|
.GetManifestResourceStream(resourceName)!;
|
||||||
|
|
||||||
|
var memoryStream = new MemoryStream();
|
||||||
|
await stream.CopyToAsync(memoryStream, cancellationToken);
|
||||||
|
memoryStream.Position = 0;
|
||||||
|
|
||||||
|
return memoryStream;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data.AutogeneratedDailyReport;
|
||||||
|
using AsbCloudApp.Data.DrillTestReport;
|
||||||
using AsbCloudApp.Data.Manuals;
|
using AsbCloudApp.Data.Manuals;
|
||||||
using AsbCloudApp.Data.ProcessMaps;
|
using AsbCloudApp.Data.ProcessMaps;
|
||||||
using AsbCloudApp.Data.SAUB;
|
using AsbCloudApp.Data.SAUB;
|
||||||
@ -24,6 +25,7 @@ using AsbCloudInfrastructure.Services.AutoGeneratedDailyReports;
|
|||||||
using AsbCloudInfrastructure.Services.DailyReport;
|
using AsbCloudInfrastructure.Services.DailyReport;
|
||||||
using AsbCloudInfrastructure.Services.DetectOperations;
|
using AsbCloudInfrastructure.Services.DetectOperations;
|
||||||
using AsbCloudInfrastructure.Services.DrillingProgram;
|
using AsbCloudInfrastructure.Services.DrillingProgram;
|
||||||
|
using AsbCloudInfrastructure.Services.DrillTestReport;
|
||||||
using AsbCloudInfrastructure.Services.ProcessMaps.Report;
|
using AsbCloudInfrastructure.Services.ProcessMaps.Report;
|
||||||
using AsbCloudInfrastructure.Services.ProcessMaps.WellDrilling;
|
using AsbCloudInfrastructure.Services.ProcessMaps.WellDrilling;
|
||||||
using AsbCloudInfrastructure.Services.SAUB;
|
using AsbCloudInfrastructure.Services.SAUB;
|
||||||
@ -37,6 +39,7 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure
|
namespace AsbCloudInfrastructure
|
||||||
{
|
{
|
||||||
@ -186,7 +189,6 @@ namespace AsbCloudInfrastructure
|
|||||||
services.AddTransient<IProcessMapReportWellDrillingExportService, ProcessMapReportWellDrillingExportService>();
|
services.AddTransient<IProcessMapReportWellDrillingExportService, ProcessMapReportWellDrillingExportService>();
|
||||||
services.AddTransient<IPlannedTrajectoryImportService, PlannedTrajectoryImportService>();
|
services.AddTransient<IPlannedTrajectoryImportService, PlannedTrajectoryImportService>();
|
||||||
services.AddTransient<IWellOperationRepository, WellOperationRepository>();
|
services.AddTransient<IWellOperationRepository, WellOperationRepository>();
|
||||||
services.AddTransient<IScheduleReportService, ScheduleReportService>();
|
|
||||||
services.AddTransient<IDailyReportService, DailyReportService>();
|
services.AddTransient<IDailyReportService, DailyReportService>();
|
||||||
services.AddTransient<IDetectedOperationService, DetectedOperationService>();
|
services.AddTransient<IDetectedOperationService, DetectedOperationService>();
|
||||||
services.AddTransient<ISubsystemOperationTimeService, SubsystemOperationTimeService>();
|
services.AddTransient<ISubsystemOperationTimeService, SubsystemOperationTimeService>();
|
||||||
@ -275,7 +277,9 @@ namespace AsbCloudInfrastructure
|
|||||||
services.AddTransient<IWitsRecordRepository<AsbCloudApp.Data.WITS.Record61Dto>, WitsRecordRepository<AsbCloudApp.Data.WITS.Record61Dto, AsbCloudDb.Model.WITS.Record61>>();
|
services.AddTransient<IWitsRecordRepository<AsbCloudApp.Data.WITS.Record61Dto>, WitsRecordRepository<AsbCloudApp.Data.WITS.Record61Dto, AsbCloudDb.Model.WITS.Record61>>();
|
||||||
|
|
||||||
services.AddTransient<IAutoGeneratedDailyReportService, AutoGeneratedDailyReportService>();
|
services.AddTransient<IAutoGeneratedDailyReportService, AutoGeneratedDailyReportService>();
|
||||||
services.AddTransient<IAutoGeneratedDailyReportMakerService, AutoGeneratedDailyReportMakerService>();
|
services.AddTransient<IReportMakerService<AutoGeneratedDailyReportDto>, AutoGeneratedDailyReportMakerService>();
|
||||||
|
services.AddTransient<IDrillTestReportService, DrillTestReportService>();
|
||||||
|
services.AddTransient<IReportMakerService<DrillTestReportDataDto>, DrillTestReportMakerService>();
|
||||||
|
|
||||||
services.AddTransient<IManualDirectoryRepository, ManualDirectoryRepository>();
|
services.AddTransient<IManualDirectoryRepository, ManualDirectoryRepository>();
|
||||||
services.AddTransient<IManualCatalogService, ManualCatalogService>();
|
services.AddTransient<IManualCatalogService, ManualCatalogService>();
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
using AsbCloudApp.Data.SAUB;
|
using AsbCloudApp.Data.SAUB;
|
||||||
|
using AsbCloudApp.Exceptions;
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -16,6 +22,47 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
this.db = db;
|
this.db = db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<DrillTestDto>> GetAllAsync(int idTelemetry, FileReportRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var query = db.DrillTests
|
||||||
|
.Where(d => d.IdTelemetry == idTelemetry)
|
||||||
|
.Include(d => d.Telemetry)
|
||||||
|
.AsNoTracking();
|
||||||
|
|
||||||
|
if (request.GeDate.HasValue)
|
||||||
|
{
|
||||||
|
var startDateUTC = new DateTimeOffset(request.GeDate.Value.Year, request.GeDate.Value.Month, request.GeDate.Value.Day, 0, 0, 0, TimeSpan.Zero);
|
||||||
|
query = query.Where(q => q.TimeStampStart >= startDateUTC);
|
||||||
|
}
|
||||||
|
if (request.LeDate.HasValue)
|
||||||
|
{
|
||||||
|
var finishDateUTC = new DateTimeOffset(request.LeDate.Value.Year, request.LeDate.Value.Month, request.LeDate.Value.Day, 0, 0, 0, TimeSpan.Zero);
|
||||||
|
query = query.Where(q => q.TimeStampStart <= finishDateUTC);
|
||||||
|
}
|
||||||
|
|
||||||
|
var entities = await query.ToListAsync(cancellationToken);
|
||||||
|
var dtos = entities.Select(e => Convert(e));
|
||||||
|
|
||||||
|
return dtos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<DrillTestDto> GetAsync(int idTelemetry, int id, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var drillTest = await db.DrillTests
|
||||||
|
.Where(d => d.Id == id)
|
||||||
|
.Include(d => d.Telemetry)
|
||||||
|
.Where(d => d.Telemetry.Id == idTelemetry)
|
||||||
|
.FirstOrDefaultAsync(cancellationToken);
|
||||||
|
|
||||||
|
if (drillTest is null)
|
||||||
|
throw new ArgumentInvalidException(new string[] { nameof(id), nameof(idTelemetry) }, $"Drill test with id: {id} and idTelemetry: {idTelemetry} does not exist.");
|
||||||
|
|
||||||
|
var dto = Convert(drillTest);
|
||||||
|
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<int> SaveDataAsync(int idTelemetry, DrillTestDto dto, CancellationToken token)
|
public async Task<int> SaveDataAsync(int idTelemetry, DrillTestDto dto, CancellationToken token)
|
||||||
{
|
{
|
||||||
var entity = dto.Adapt<DrillTest>();
|
var entity = dto.Adapt<DrillTest>();
|
||||||
@ -24,5 +71,12 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
var result = await db.SaveChangesAsync(token);
|
var result = await db.SaveChangesAsync(token);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DrillTestDto Convert(DrillTest entity)
|
||||||
|
{
|
||||||
|
var dto = entity.Adapt<DrillTestDto>();
|
||||||
|
dto.TimeStampStart = dto.TimeStampStart.ToRemoteDateTime(dto.Telemetry?.TimeZone?.Hours ?? 0);
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,16 @@ using System.Reflection;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AsbCloudApp.Data.AutogeneratedDailyReport;
|
using AsbCloudApp.Data.AutogeneratedDailyReport;
|
||||||
using AsbCloudApp.Services.AutoGeneratedDailyReports;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudInfrastructure.Services.AutoGeneratedDailyReports.AutogeneratedDailyReportBlocks;
|
using AsbCloudInfrastructure.Services.AutoGeneratedDailyReports.AutogeneratedDailyReportBlocks;
|
||||||
using ClosedXML.Excel;
|
using ClosedXML.Excel;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.AutoGeneratedDailyReports;
|
namespace AsbCloudInfrastructure.Services.AutoGeneratedDailyReports;
|
||||||
|
|
||||||
public class AutoGeneratedDailyReportMakerService : IAutoGeneratedDailyReportMakerService
|
public class AutoGeneratedDailyReportMakerService : IReportMakerService<AutoGeneratedDailyReportDto>
|
||||||
{
|
{
|
||||||
|
private readonly string templateName = "AutogeneratedDailyReportTemplate.xlsx";
|
||||||
|
|
||||||
private readonly IEnumerable<IExcelBlockWriter> blockWriters = new List<IExcelBlockWriter>()
|
private readonly IEnumerable<IExcelBlockWriter> blockWriters = new List<IExcelBlockWriter>()
|
||||||
{
|
{
|
||||||
new HeadExcelBlockWriter(),
|
new HeadExcelBlockWriter(),
|
||||||
@ -23,7 +25,9 @@ public class AutoGeneratedDailyReportMakerService : IAutoGeneratedDailyReportMak
|
|||||||
|
|
||||||
public async Task<Stream> MakeReportAsync(AutoGeneratedDailyReportDto report, CancellationToken cancellationToken)
|
public async Task<Stream> MakeReportAsync(AutoGeneratedDailyReportDto report, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
using var excelTemplateStream = await GetExcelTemplateStreamAsync(cancellationToken);
|
using var excelTemplateStream = await Assembly
|
||||||
|
.GetExecutingAssembly()
|
||||||
|
.GetTemplateCopyStreamAsync(templateName, cancellationToken);
|
||||||
|
|
||||||
using var workbook = new XLWorkbook(excelTemplateStream, XLEventTracking.Disabled);
|
using var workbook = new XLWorkbook(excelTemplateStream, XLEventTracking.Disabled);
|
||||||
|
|
||||||
@ -36,22 +40,6 @@ public class AutoGeneratedDailyReportMakerService : IAutoGeneratedDailyReportMak
|
|||||||
return memoryStream;
|
return memoryStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Stream> GetExcelTemplateStreamAsync(CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var resourceName = Assembly.GetExecutingAssembly()
|
|
||||||
.GetManifestResourceNames()
|
|
||||||
.FirstOrDefault(n => n.EndsWith("AutogeneratedDailyReportTemplate.xlsx"))!;
|
|
||||||
|
|
||||||
using var stream = Assembly.GetExecutingAssembly()
|
|
||||||
.GetManifestResourceStream(resourceName)!;
|
|
||||||
|
|
||||||
var memoryStream = new MemoryStream();
|
|
||||||
await stream.CopyToAsync(memoryStream, cancellationToken);
|
|
||||||
memoryStream.Position = 0;
|
|
||||||
|
|
||||||
return memoryStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddToWorkbook(XLWorkbook workbook, AutoGeneratedDailyReportDto report)
|
private void AddToWorkbook(XLWorkbook workbook, AutoGeneratedDailyReportDto report)
|
||||||
{
|
{
|
||||||
const string sheetName = "Рапорт";
|
const string sheetName = "Рапорт";
|
||||||
|
@ -26,14 +26,14 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService
|
|||||||
private readonly ISubsystemOperationTimeService subsystemOperationTimeService;
|
private readonly ISubsystemOperationTimeService subsystemOperationTimeService;
|
||||||
private readonly ICrudRepository<SubsystemDto> subsystemRepository;
|
private readonly ICrudRepository<SubsystemDto> subsystemRepository;
|
||||||
private readonly ILimitingParameterService limitingParameterService;
|
private readonly ILimitingParameterService limitingParameterService;
|
||||||
private readonly IAutoGeneratedDailyReportMakerService autoGeneratedDailyReportMakerService;
|
private readonly IReportMakerService<AutoGeneratedDailyReportDto> autoGeneratedDailyReportMakerService;
|
||||||
|
|
||||||
public AutoGeneratedDailyReportService(IWellService wellService,
|
public AutoGeneratedDailyReportService(IWellService wellService,
|
||||||
IWellOperationRepository wellOperationRepository,
|
IWellOperationRepository wellOperationRepository,
|
||||||
ISubsystemOperationTimeService subsystemOperationTimeService,
|
ISubsystemOperationTimeService subsystemOperationTimeService,
|
||||||
ICrudRepository<SubsystemDto> subsystemRepository,
|
ICrudRepository<SubsystemDto> subsystemRepository,
|
||||||
ILimitingParameterService limitingParameterService,
|
ILimitingParameterService limitingParameterService,
|
||||||
IAutoGeneratedDailyReportMakerService autoGeneratedDailyReportMakerService)
|
IReportMakerService<AutoGeneratedDailyReportDto> autoGeneratedDailyReportMakerService)
|
||||||
{
|
{
|
||||||
this.wellOperationRepository = wellOperationRepository;
|
this.wellOperationRepository = wellOperationRepository;
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
@ -44,7 +44,7 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<PaginationContainer<AutoGeneratedDailyReportInfoDto>> GetListAsync(int idWell,
|
public async Task<PaginationContainer<AutoGeneratedDailyReportInfoDto>> GetListAsync(int idWell,
|
||||||
AutoGeneratedDailyReportRequest request,
|
FileReportRequest request,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var result = new PaginationContainer<AutoGeneratedDailyReportInfoDto>
|
var result = new PaginationContainer<AutoGeneratedDailyReportInfoDto>
|
||||||
@ -67,19 +67,19 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService
|
|||||||
if (datesRange is null)
|
if (datesRange is null)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
if (request.StartDate.HasValue)
|
if (request.GeDate.HasValue)
|
||||||
{
|
{
|
||||||
var startDate = new DateTime(request.StartDate.Value.Year, request.StartDate.Value.Month,
|
var startDate = new DateTime(request.GeDate.Value.Year, request.GeDate.Value.Month,
|
||||||
request.StartDate.Value.Day);
|
request.GeDate.Value.Day);
|
||||||
|
|
||||||
if(startDate.Date >= datesRange.From.Date)
|
if(startDate.Date >= datesRange.From.Date)
|
||||||
datesRange.From = startDate;
|
datesRange.From = startDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.FinishDate.HasValue)
|
if (request.LeDate.HasValue)
|
||||||
{
|
{
|
||||||
var finishDate = new DateTime(request.FinishDate.Value.Year, request.FinishDate.Value.Month,
|
var finishDate = new DateTime(request.LeDate.Value.Year, request.LeDate.Value.Month,
|
||||||
request.FinishDate.Value.Day);
|
request.LeDate.Value.Day);
|
||||||
|
|
||||||
if (finishDate.Date <= datesRange.To.Date)
|
if (finishDate.Date <= datesRange.To.Date)
|
||||||
datesRange.To = finishDate;
|
datesRange.To = finishDate;
|
||||||
|
@ -0,0 +1,90 @@
|
|||||||
|
using AsbCloudApp.Data.DrillTestReport;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
using ClosedXML.Excel;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudInfrastructure.Services.DrillTestReport
|
||||||
|
{
|
||||||
|
public class DrillTestReportMakerService : IReportMakerService<DrillTestReportDataDto>
|
||||||
|
{
|
||||||
|
private readonly string templateName = "DrillTestReportTemplate.xlsx";
|
||||||
|
private readonly string sheetName = "Лист1";
|
||||||
|
private readonly int startRowNumber = 8;
|
||||||
|
|
||||||
|
public async Task<Stream> MakeReportAsync(DrillTestReportDataDto report, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
using var excelTemplateStream = await Assembly.GetExecutingAssembly().GetTemplateCopyStreamAsync(templateName, cancellationToken);
|
||||||
|
|
||||||
|
using var workbook = new XLWorkbook(excelTemplateStream, XLEventTracking.Disabled);
|
||||||
|
|
||||||
|
AddToWorkbook(workbook, report);
|
||||||
|
|
||||||
|
MemoryStream memoryStream = new MemoryStream();
|
||||||
|
workbook.SaveAs(memoryStream, new SaveOptions { });
|
||||||
|
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
return memoryStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void AddToWorkbook(XLWorkbook workbook, DrillTestReportDataDto report)
|
||||||
|
{
|
||||||
|
var drillTestEntities = report.Data.Params;
|
||||||
|
if (!drillTestEntities.Any())
|
||||||
|
return;
|
||||||
|
|
||||||
|
var sheet = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetName)
|
||||||
|
?? throw new FileFormatException($"Книга excel не содержит листа {sheetName}.");
|
||||||
|
|
||||||
|
sheet.Cell(4, 2).Value = report.Caption;
|
||||||
|
sheet.Cell(5, 2)._SetValue(report.Date, setAllBorders: false);
|
||||||
|
|
||||||
|
var rowNumber = startRowNumber;
|
||||||
|
|
||||||
|
var stepWithMaxDepthSpeed = drillTestEntities.OrderByDescending(p => p.DepthSpeed).FirstOrDefault()!.Step;
|
||||||
|
var startDepth = report.Data.DepthStart;
|
||||||
|
var startDate = report.Data.TimeStampStart;
|
||||||
|
|
||||||
|
foreach (var drillTestEntity in drillTestEntities)
|
||||||
|
{
|
||||||
|
var endDepth = startDepth + (drillTestEntity.DepthDrillStep ?? 0);
|
||||||
|
var endDateTime = startDate.AddSeconds(drillTestEntity.TimeDrillStep ?? 0);
|
||||||
|
|
||||||
|
sheet.Cell(rowNumber, 2).Value = startDepth;
|
||||||
|
|
||||||
|
sheet.Cell(rowNumber, 3).Value = endDepth;
|
||||||
|
|
||||||
|
sheet.Cell(rowNumber, 4).Value = drillTestEntity.DepthDrillStep;
|
||||||
|
|
||||||
|
sheet.Cell(rowNumber, 5).Value = drillTestEntity.Workload;
|
||||||
|
|
||||||
|
sheet.Cell(rowNumber, 6).Value = drillTestEntity.Speed;
|
||||||
|
|
||||||
|
var cell = sheet.Cell(rowNumber, 7);
|
||||||
|
cell._SetValue(startDate.DateTime);
|
||||||
|
|
||||||
|
cell = sheet.Cell(rowNumber, 8);
|
||||||
|
cell._SetValue(endDateTime.DateTime);
|
||||||
|
|
||||||
|
sheet.Cell(rowNumber, 9).Value = Math.Round((drillTestEntity.TimeDrillStep ?? 0) / (60 * 60), 2);
|
||||||
|
|
||||||
|
sheet.Cell(rowNumber, 10).Value = drillTestEntity.DepthSpeed;
|
||||||
|
|
||||||
|
if (drillTestEntity.Step == stepWithMaxDepthSpeed)
|
||||||
|
{
|
||||||
|
var currentCells = sheet.Row(rowNumber).Cells(1, 10);
|
||||||
|
currentCells.Style.Fill.BackgroundColor = XLColor.Yellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
startDepth = endDepth;
|
||||||
|
startDate = endDateTime;
|
||||||
|
rowNumber++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Data.DrillTestReport;
|
||||||
|
using AsbCloudApp.Exceptions;
|
||||||
|
using AsbCloudApp.Repositories;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudInfrastructure.Services.DrillTestReport
|
||||||
|
{
|
||||||
|
public class DrillTestReportService : IDrillTestReportService
|
||||||
|
{
|
||||||
|
private readonly IWellService wellService;
|
||||||
|
private readonly IDrillTestRepository drillTestRepository;
|
||||||
|
private readonly ITelemetryService telemetryService;
|
||||||
|
private readonly IReportMakerService<DrillTestReportDataDto> drillTestReportMakerService;
|
||||||
|
|
||||||
|
public DrillTestReportService(
|
||||||
|
IWellService wellService,
|
||||||
|
IDrillTestRepository drillTestRepository,
|
||||||
|
ITelemetryService telemetryService,
|
||||||
|
IReportMakerService<DrillTestReportDataDto> drillTestReportMakerService)
|
||||||
|
{
|
||||||
|
this.wellService = wellService;
|
||||||
|
this.drillTestRepository = drillTestRepository;
|
||||||
|
this.telemetryService = telemetryService;
|
||||||
|
this.drillTestReportMakerService = drillTestReportMakerService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<(string fileName, Stream stream)> GenerateAsync(int idWell, int id, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var well = wellService.GetOrDefault(idWell);
|
||||||
|
if (well is null)
|
||||||
|
throw new ArgumentInvalidException(nameof(idWell), $"Well with id: {idWell} does not exist.");
|
||||||
|
if (well.IdTelemetry is null)
|
||||||
|
throw new ArgumentInvalidException(nameof(well.IdTelemetry), $"Well with id: {idWell} does not have telemetry.");
|
||||||
|
|
||||||
|
var dto = await drillTestRepository.GetAsync(well.IdTelemetry.Value, id, cancellationToken);
|
||||||
|
|
||||||
|
var report = new DrillTestReportDataDto()
|
||||||
|
{
|
||||||
|
Data = dto,
|
||||||
|
Caption = string.Format("Месторождение: {0}, куст: {1}, скважина: {2}",
|
||||||
|
well.Deposit ?? "-",
|
||||||
|
well.Cluster ?? "-",
|
||||||
|
well.Caption ?? "-"),
|
||||||
|
Date = DateTime.Now,
|
||||||
|
};
|
||||||
|
|
||||||
|
var fileName = string.Format("Drill_test_{0}.xlsx", dto.TimeStampStart.ToString("dd.mm.yyyy_HH_MM_ss"));
|
||||||
|
var stream = await drillTestReportMakerService.MakeReportAsync(report, cancellationToken);
|
||||||
|
|
||||||
|
return (fileName, stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<PaginationContainer<DrillTestReportInfoDto>> GetListAsync(int idWell, FileReportRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var telemetry = telemetryService.GetOrDefaultTelemetryByIdWell(idWell);
|
||||||
|
if (telemetry is null)
|
||||||
|
throw new Exception($"Telemetry with idWell: {idWell} does not exist.");
|
||||||
|
|
||||||
|
var result = new PaginationContainer<DrillTestReportInfoDto>
|
||||||
|
{
|
||||||
|
Skip = request.Skip ?? 0,
|
||||||
|
Take = request.Take ?? 10,
|
||||||
|
Items = Enumerable.Empty<DrillTestReportInfoDto>()
|
||||||
|
};
|
||||||
|
|
||||||
|
var reports = new List<DrillTestReportInfoDto>();
|
||||||
|
var timezone = telemetryService.GetTimezone(telemetry.Id);
|
||||||
|
|
||||||
|
var dtos = await drillTestRepository.GetAllAsync(telemetry.Id, request, cancellationToken);
|
||||||
|
foreach (var dto in dtos)
|
||||||
|
{
|
||||||
|
var remoteDateTime = dto.TimeStampStart.ToRemoteDateTime(timezone.Hours);
|
||||||
|
|
||||||
|
reports.Add(new DrillTestReportInfoDto
|
||||||
|
{
|
||||||
|
FileName = string.Format("Drill_test_{0}", dto.TimeStampStart.DateTime),
|
||||||
|
DrillDepth = (dto.Params
|
||||||
|
.Where(p => p.DepthDrillStep.HasValue)
|
||||||
|
.Sum(x => x.DepthDrillStep) ?? 0) + dto.DepthStart,
|
||||||
|
DateTime = dto.TimeStampStart.DateTime,
|
||||||
|
Id = dto.Id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
result.Items = reports;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
@ -92,12 +92,16 @@ internal static class XLExtentions
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal static IXLCell _SetValue(this IXLCell cell, DateTime value, string dateFormat = "DD.MM.YYYY HH:MM:SS")
|
internal static IXLCell _SetValue(this IXLCell cell, DateTime value, string dateFormat = "DD.MM.YYYY HH:MM:SS", bool setAllBorders = true)
|
||||||
{
|
{
|
||||||
cell.Value = value;
|
cell.Value = value;
|
||||||
|
if (setAllBorders == true)
|
||||||
|
{
|
||||||
cell.Style
|
cell.Style
|
||||||
.SetAllBorders()
|
.SetAllBorders()
|
||||||
.Alignment.WrapText = true;
|
.Alignment.WrapText = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
cell.Value = value;
|
cell.Value = value;
|
||||||
|
|
||||||
|
@ -25,7 +25,8 @@ public class AutoGeneratedDailyReportController : ControllerBase
|
|||||||
private readonly IAutoGeneratedDailyReportService autoGeneratedDailyReportService;
|
private readonly IAutoGeneratedDailyReportService autoGeneratedDailyReportService;
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
|
|
||||||
public AutoGeneratedDailyReportController(IAutoGeneratedDailyReportService autoGeneratedDailyReportService,
|
public AutoGeneratedDailyReportController(
|
||||||
|
IAutoGeneratedDailyReportService autoGeneratedDailyReportService,
|
||||||
IWellService wellService)
|
IWellService wellService)
|
||||||
{
|
{
|
||||||
this.autoGeneratedDailyReportService = autoGeneratedDailyReportService;
|
this.autoGeneratedDailyReportService = autoGeneratedDailyReportService;
|
||||||
@ -66,7 +67,7 @@ public class AutoGeneratedDailyReportController : ControllerBase
|
|||||||
[HttpGet("all")]
|
[HttpGet("all")]
|
||||||
[ProducesResponseType(typeof(PaginationContainer<AutoGeneratedDailyReportInfoDto>), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PaginationContainer<AutoGeneratedDailyReportInfoDto>), (int)HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> GetListAsync([FromRoute][Required] int idWell,
|
public async Task<IActionResult> GetListAsync([FromRoute][Required] int idWell,
|
||||||
[FromQuery] AutoGeneratedDailyReportRequest request,
|
[FromQuery] FileReportRequest request,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell, cancellationToken))
|
if (!await CanUserAccessToWellAsync(idWell, cancellationToken))
|
||||||
|
133
AsbCloudWebApi/Controllers/DrillTestController.cs
Normal file
133
AsbCloudWebApi/Controllers/DrillTestController.cs
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Data.DrillTestReport;
|
||||||
|
using AsbCloudApp.Data.SAUB;
|
||||||
|
using AsbCloudApp.Repositories;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
using AsbCloudWebApi.SignalR;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Net;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudWebApi.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Контроллер для drill_test отчётов
|
||||||
|
/// </summary>
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
public class DrillTestController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IDrillTestReportService drillTestReportService;
|
||||||
|
private readonly IDrillTestRepository drillTestRepository;
|
||||||
|
private readonly IWellService wellService;
|
||||||
|
private readonly ITelemetryService telemetryService;
|
||||||
|
private readonly IHubContext<TelemetryHub> telemetryHubContext;
|
||||||
|
|
||||||
|
public string SignalRMethodGetDataName { get; protected set; } = "ReceiveDrilltestData";
|
||||||
|
|
||||||
|
public DrillTestController(
|
||||||
|
IDrillTestReportService drillTestReportService,
|
||||||
|
IDrillTestRepository drillTestRepository,
|
||||||
|
IWellService wellService,
|
||||||
|
ITelemetryService telemetryService,
|
||||||
|
IHubContext<TelemetryHub> telemetryHubContext)
|
||||||
|
{
|
||||||
|
this.drillTestReportService = drillTestReportService;
|
||||||
|
this.drillTestRepository = drillTestRepository;
|
||||||
|
this.wellService = wellService;
|
||||||
|
this.telemetryService = telemetryService;
|
||||||
|
this.telemetryHubContext = telemetryHubContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Метод получения данных drill_test и drill_test_params от панели оператора.
|
||||||
|
/// Сохраняет в БД.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uid">уникальный идентификатор записи drill_test</param>
|
||||||
|
/// <param name="dto">запись drill test</param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[AllowAnonymous]
|
||||||
|
[HttpPost("api/telemetry/{uid}/[controller]")]
|
||||||
|
public async Task<IActionResult> PostDataAsync(
|
||||||
|
string uid,
|
||||||
|
[FromBody] DrillTestDto dto,
|
||||||
|
CancellationToken token)
|
||||||
|
{
|
||||||
|
var telemetry = telemetryService.GetOrCreateTelemetryByUid(uid);
|
||||||
|
if (telemetry is null)
|
||||||
|
throw new Exception($"Telemetry with RemoteUid: {uid} does not exist.");
|
||||||
|
|
||||||
|
await drillTestRepository.SaveDataAsync(telemetry.Id, dto, token);
|
||||||
|
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
|
||||||
|
if (idWell is not null)
|
||||||
|
_ = Task.Run(async () =>
|
||||||
|
{
|
||||||
|
var clients = telemetryHubContext.Clients.Group($"well_{idWell}");
|
||||||
|
await clients.SendAsync(SignalRMethodGetDataName, dto);
|
||||||
|
}, CancellationToken.None);
|
||||||
|
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Формирование отчёта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell">Id скважины</param>
|
||||||
|
/// <param name="id">Ключ entity test записи</param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("api/well/{idWell}/[controller]")]
|
||||||
|
[Permission]
|
||||||
|
[ProducesResponseType(typeof(PhysicalFileResult), (int)HttpStatusCode.OK, "application/octet-stream")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
public async Task<IActionResult> GenerateReportAsync([FromRoute] int idWell,
|
||||||
|
[FromQuery] int id,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (!await CanUserAccessToWellAsync(idWell, cancellationToken))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
|
var reportFile = await drillTestReportService.GenerateAsync(idWell, id, cancellationToken);
|
||||||
|
|
||||||
|
return File(reportFile.stream, "application/octet-stream", reportFile.fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Список файлов drill test отчётов
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell">Id скважины</param>
|
||||||
|
/// <param name="request">Параметры запроса</param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("api/well/{idWell}/[controller]/all")]
|
||||||
|
[Permission]
|
||||||
|
[ProducesResponseType(typeof(PaginationContainer<DrillTestReportInfoDto>), (int)HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> GetListAsync([FromRoute][Required] int idWell,
|
||||||
|
[FromQuery] FileReportRequest request,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (!await CanUserAccessToWellAsync(idWell, cancellationToken))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
|
var reports = await drillTestReportService.GetListAsync(idWell,
|
||||||
|
request,
|
||||||
|
cancellationToken);
|
||||||
|
|
||||||
|
return Ok(reports);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
int? idCompany = User.GetCompanyId();
|
||||||
|
return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
|
idWell, cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
@ -1,69 +0,0 @@
|
|||||||
using AsbCloudApp.Data.SAUB;
|
|
||||||
using AsbCloudApp.Repositories;
|
|
||||||
using AsbCloudApp.Services;
|
|
||||||
using AsbCloudWebApi.SignalR;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.SignalR;
|
|
||||||
using System;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers.SAUB
|
|
||||||
{
|
|
||||||
|
|
||||||
[Route("api/telemetry")]
|
|
||||||
[ApiController]
|
|
||||||
public class DrillTestController : ControllerBase
|
|
||||||
|
|
||||||
{
|
|
||||||
protected readonly IWellService wellService;
|
|
||||||
private readonly ITelemetryService telemetryService;
|
|
||||||
private readonly IDrillTestRepository drillTestRepository;
|
|
||||||
private readonly IHubContext<TelemetryHub> telemetryHubContext;
|
|
||||||
|
|
||||||
public string SignalRMethodGetDataName { get; protected set; } = "ReceiveDrilltestData";
|
|
||||||
|
|
||||||
public DrillTestController(
|
|
||||||
ITelemetryService telemetryService,
|
|
||||||
IDrillTestRepository drillTestRepository,
|
|
||||||
IWellService wellService,
|
|
||||||
IHubContext<TelemetryHub> telemetryHubContext)
|
|
||||||
{
|
|
||||||
this.telemetryService = telemetryService;
|
|
||||||
this.drillTestRepository = drillTestRepository;
|
|
||||||
this.wellService = wellService;
|
|
||||||
this.telemetryHubContext = telemetryHubContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Метод получения данных drill_test и drill_test_params от панели оператора.
|
|
||||||
/// Сохраняет в БД.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uid">уникальный идентификатор записи drill_test</param>
|
|
||||||
/// <param name="dto">запись drill test</param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("{uid}/[controller]")]
|
|
||||||
public async Task<IActionResult> PostDataAsync(
|
|
||||||
string uid,
|
|
||||||
[FromBody] DrillTestDto dto,
|
|
||||||
CancellationToken token)
|
|
||||||
{
|
|
||||||
var telemetry = telemetryService.GetOrCreateTelemetryByUid(uid);
|
|
||||||
if (telemetry is null)
|
|
||||||
throw new Exception($"Telemetry with RemoteUid: {uid} does not exist.");
|
|
||||||
|
|
||||||
await drillTestRepository.SaveDataAsync(telemetry.Id, dto, token);
|
|
||||||
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
|
|
||||||
if (idWell is not null)
|
|
||||||
_ = Task.Run(async () =>
|
|
||||||
{
|
|
||||||
var clients = telemetryHubContext.Clients.Group($"well_{idWell}");
|
|
||||||
await clients.SendAsync(SignalRMethodGetDataName, dto);
|
|
||||||
}, CancellationToken.None);
|
|
||||||
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -56,10 +56,7 @@ namespace AsbCloudWebApi.Middlewares
|
|||||||
|
|
||||||
private static string MakeJsonBody(ArgumentInvalidException ex)
|
private static string MakeJsonBody(ArgumentInvalidException ex)
|
||||||
{
|
{
|
||||||
var errors = new Dictionary<string, string[]> {
|
var problem = new ValidationProblemDetails(ex.ErrorState);
|
||||||
{ ex.ParamName, new[]{ ex.Message } }
|
|
||||||
};
|
|
||||||
var problem = new ValidationProblemDetails(errors);
|
|
||||||
var buffer = System.Text.Json.JsonSerializer.Serialize(problem);
|
var buffer = System.Text.Json.JsonSerializer.Serialize(problem);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
45
AsbCloudWebApi/Rest/DrillTest.http
Normal file
45
AsbCloudWebApi/Rest/DrillTest.http
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
@baseUrl = http://127.0.0.1:5000
|
||||||
|
@contentType = application/json
|
||||||
|
@contentTypeForFiles = application/octet-stream
|
||||||
|
@auth = Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiZGV2IiwiaWRDb21wYW55IjoiMSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6InJvb3QiLCJuYmYiOjE2OTc0MzcwMzEsImV4cCI6MTcyODk5NDYzMSwiaXNzIjoiYSIsImF1ZCI6ImEifQ.vB7Qb3K9gG77iP8y25zB3RcZIQk9cHkq3I1SkcooYJs
|
||||||
|
|
||||||
|
@uid = 20210101_000000000
|
||||||
|
@id = 1
|
||||||
|
@idWell = 55
|
||||||
|
|
||||||
|
### ïîëó÷åíèå äàííûõ drill test ñ ïàíåëè è ñîõðàíåíèå èõ â ÅÖÏ
|
||||||
|
POST {{baseUrl}}/api/telemetry/{{uid}}/DrillTest
|
||||||
|
Content-Type: {{contentType}}
|
||||||
|
accept: */*
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": {{id}},
|
||||||
|
"timeStampStart": "2023-10-23T08:55:36.882Z",
|
||||||
|
"depthStart": 10,
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"step": 1,
|
||||||
|
"workload": 2,
|
||||||
|
"speed": 3,
|
||||||
|
"depthSpeed": 4,
|
||||||
|
"timeDrillStep": 5,
|
||||||
|
"depthDrillStep": 15
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
### Ïîëó÷åíèå ñïèñêà ôàéëîâ drill test îò÷¸òîâ
|
||||||
|
GET {{baseUrl}}/api/well/{{idWell}}/DrillTest/all
|
||||||
|
Content-Type: {{contentType}}
|
||||||
|
accept: */*
|
||||||
|
Authorization: {{auth}}
|
||||||
|
|
||||||
|
### Ãåíåðàöèÿ ôàéëà ñ drill test îò÷¸òîì
|
||||||
|
GET {{baseUrl}}/api/well/{{idWell}}/DrillTest?id={{id}}
|
||||||
|
Content-Type: {{contentTypeForFiles}}
|
||||||
|
accept: */*
|
||||||
|
Authorization: {{auth}}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user