forked from ddrilling/AsbCloudServer
Правки после ревью
This commit is contained in:
parent
7f4966a0bd
commit
72bb234179
@ -6,7 +6,7 @@ namespace AsbCloudApp.Data.ProcessMaps;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// РТК план проработка скважины
|
/// РТК план проработка скважины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProcessMapPlanWellReamDto : ProcessMapPlanBaseDto
|
public class ProcessMapPlanWellReamDto : ProcessMapPlanBaseDto, IValidatableObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Количество повторений
|
/// Количество повторений
|
||||||
|
@ -25,7 +25,6 @@ public interface IProcessMapPlanRepository<TDto> : IRepositoryWellRelated<TDto>
|
|||||||
/// Удалить РТК по скважине
|
/// Удалить РТК по скважине
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell"></param>
|
/// <param name="idWell"></param>
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> RemoveByWellAsync(int idWell, CancellationToken cancellationToken);
|
Task<int> RemoveByWellAsync(int idWell);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ namespace AsbCloudApp.Services.ProcessMaps;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сервис импорта РТК
|
/// Сервис импорта РТК
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IProcessMapImportService
|
public interface IProcessMapPlanImportService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Загрузить данные из файла
|
/// Загрузить данные из файла
|
@ -2,12 +2,12 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace AsbCloudApp.Services.ProcessMaps;
|
namespace AsbCloudApp.Services.ProcessMaps.WellDrilling;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сервис экспорт РТК
|
/// Сервис экспорт РТК
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IProcessMapReportExportService
|
public interface IProcessMapReportWellDrillingExportService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сформировать файл с данными
|
/// Сформировать файл с данными
|
@ -3,10 +3,10 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AsbCloudApp.Data.ProcessMaps.Report;
|
using AsbCloudApp.Data.ProcessMaps.Report;
|
||||||
|
|
||||||
namespace AsbCloudApp.Services.ProcessMaps.WellDrillingProcessMap;
|
namespace AsbCloudApp.Services.ProcessMaps.WellDrilling;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сервис формирования отчёта РТК
|
/// Сервис формирования отчёта РТК бурение
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IProcessMapReportWellDrillingService
|
public interface IProcessMapReportWellDrillingService
|
||||||
{
|
{
|
@ -10,7 +10,7 @@ using AsbCloudApp.Services;
|
|||||||
using AsbCloudApp.Services.AutoGeneratedDailyReports;
|
using AsbCloudApp.Services.AutoGeneratedDailyReports;
|
||||||
using AsbCloudApp.Services.Notifications;
|
using AsbCloudApp.Services.Notifications;
|
||||||
using AsbCloudApp.Services.ProcessMaps;
|
using AsbCloudApp.Services.ProcessMaps;
|
||||||
using AsbCloudApp.Services.ProcessMaps.WellDrillingProcessMap;
|
using AsbCloudApp.Services.ProcessMaps.WellDrilling;
|
||||||
using AsbCloudApp.Services.Subsystems;
|
using AsbCloudApp.Services.Subsystems;
|
||||||
using AsbCloudApp.Services.WellOperationImport;
|
using AsbCloudApp.Services.WellOperationImport;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
@ -183,7 +183,7 @@ namespace AsbCloudInfrastructure
|
|||||||
services.AddTransient<ITimezoneService, TimezoneService>();
|
services.AddTransient<ITimezoneService, TimezoneService>();
|
||||||
services.AddTransient<IWellService, WellService>();
|
services.AddTransient<IWellService, WellService>();
|
||||||
services.AddTransient<IWellOperationImportService, WellOperationImportService>();
|
services.AddTransient<IWellOperationImportService, WellOperationImportService>();
|
||||||
services.AddTransient<IProcessMapReportExportService, WellDrillingProcessMapReportExportService>();
|
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<IScheduleReportService, ScheduleReportService>();
|
||||||
@ -196,8 +196,8 @@ namespace AsbCloudInfrastructure
|
|||||||
services.AddTransient<IWellFinalDocumentsService, WellFinalDocumentsService>();
|
services.AddTransient<IWellFinalDocumentsService, WellFinalDocumentsService>();
|
||||||
services.AddTransient<IFileCategoryService, FileCategoryService>();
|
services.AddTransient<IFileCategoryService, FileCategoryService>();
|
||||||
services.AddTransient<ILimitingParameterService, LimitingParameterService>();
|
services.AddTransient<ILimitingParameterService, LimitingParameterService>();
|
||||||
services.AddTransient<IProcessMapReportWellDrillingService, WellDrillingProcessMapReportService>();
|
services.AddTransient<IProcessMapReportWellDrillingService, ProcessMapReportWellDrillingService>();
|
||||||
services.AddTransient<IProcessMapImportService, WellDrillingProcessMapImportService>();
|
services.AddTransient<IProcessMapPlanImportService, ProcessMapPlanWellDrillingImportService>();
|
||||||
services.AddTransient<WellInfoService>();
|
services.AddTransient<WellInfoService>();
|
||||||
services.AddTransient<IHelpPageService, HelpPageService>();
|
services.AddTransient<IHelpPageService, HelpPageService>();
|
||||||
|
|
||||||
|
@ -32,20 +32,6 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> RemoveByWellAsync(int idWell, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var query = GetQuery().Where(x => x.IdWell == idWell);
|
|
||||||
|
|
||||||
dbSet.RemoveRange(query);
|
|
||||||
|
|
||||||
var result = await dbContext.SaveChangesAsync(cancellationToken);
|
|
||||||
|
|
||||||
if(result > 0)
|
|
||||||
DropCache();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IEnumerable<TDto>> GetByIdWellAsync(IEnumerable<int> idsWells, CancellationToken token)
|
public async Task<IEnumerable<TDto>> GetByIdWellAsync(IEnumerable<int> idsWells, CancellationToken token)
|
||||||
{
|
{
|
||||||
if (!idsWells.Any())
|
if (!idsWells.Any())
|
||||||
|
@ -30,19 +30,20 @@ public class ProcessMapPlanRepository<TDto, TEntity> : CrudWellRelatedRepository
|
|||||||
|
|
||||||
public async Task<IEnumerable<TDto>> GetAsync(IEnumerable<ProcessMapPlanRequest> requests, CancellationToken cancellationToken)
|
public async Task<IEnumerable<TDto>> GetAsync(IEnumerable<ProcessMapPlanRequest> requests, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var entities = await BuildQuery(requests)
|
var query = BuildQuery(requests);
|
||||||
.ToArrayAsync(cancellationToken);
|
|
||||||
|
var entities = await query.ToArrayAsync(cancellationToken);
|
||||||
|
|
||||||
return entities.Select(Convert);
|
return entities.Select(Convert);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<int> RemoveByWellAsync(int idWell, CancellationToken cancellationToken)
|
public Task<int> RemoveByWellAsync(int idWell)
|
||||||
{
|
{
|
||||||
var query = GetQuery().Where(x => x.IdWell == idWell);
|
var query = GetQuery().Where(x => x.IdWell == idWell);
|
||||||
|
|
||||||
dbSet.RemoveRange(query);
|
dbSet.RemoveRange(query);
|
||||||
|
|
||||||
return dbContext.SaveChangesAsync(cancellationToken);
|
return dbContext.SaveChangesAsync(CancellationToken.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IQueryable<TEntity> BuildQuery(IEnumerable<ProcessMapPlanRequest> requests)
|
private IQueryable<TEntity> BuildQuery(IEnumerable<ProcessMapPlanRequest> requests)
|
||||||
|
@ -18,7 +18,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMaps.WellDrillingProcessMap;
|
|||||||
/*
|
/*
|
||||||
* password for ProcessMapImportTemplate.xlsx is ASB2020!
|
* password for ProcessMapImportTemplate.xlsx is ASB2020!
|
||||||
*/
|
*/
|
||||||
public class WellDrillingProcessMapImportService : IProcessMapImportService
|
public class ProcessMapPlanWellDrillingImportService : IProcessMapPlanImportService
|
||||||
{
|
{
|
||||||
private readonly IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> processMapPlanWellDrillingRepository;
|
private readonly IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> processMapPlanWellDrillingRepository;
|
||||||
private readonly ICrudRepository<WellSectionTypeDto> wellSectionTypeRepository;
|
private readonly ICrudRepository<WellSectionTypeDto> wellSectionTypeRepository;
|
||||||
@ -49,7 +49,7 @@ public class WellDrillingProcessMapImportService : IProcessMapImportService
|
|||||||
|
|
||||||
private WellSectionTypeDto[] sections = null!;
|
private WellSectionTypeDto[] sections = null!;
|
||||||
|
|
||||||
public WellDrillingProcessMapImportService(IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> processMapPlanWellDrillingRepository,
|
public ProcessMapPlanWellDrillingImportService(IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> processMapPlanWellDrillingRepository,
|
||||||
ICrudRepository<WellSectionTypeDto> wellSectionTypeRepository,
|
ICrudRepository<WellSectionTypeDto> wellSectionTypeRepository,
|
||||||
IWellService wellService)
|
IWellService wellService)
|
||||||
{
|
{
|
||||||
@ -68,7 +68,7 @@ public class WellDrillingProcessMapImportService : IProcessMapImportService
|
|||||||
var wellDrillingProcessMaps = ParseWorkBook(workBook);
|
var wellDrillingProcessMaps = ParseWorkBook(workBook);
|
||||||
|
|
||||||
if (deleteProcessMapPlansBeforeImport)
|
if (deleteProcessMapPlansBeforeImport)
|
||||||
await processMapPlanWellDrillingRepository.RemoveByWellAsync(idWell, cancellationToken);
|
await processMapPlanWellDrillingRepository.RemoveByWellAsync(idWell);
|
||||||
|
|
||||||
foreach (var wellDrillingProcessMap in wellDrillingProcessMaps)
|
foreach (var wellDrillingProcessMap in wellDrillingProcessMaps)
|
||||||
{
|
{
|
@ -0,0 +1,110 @@
|
|||||||
|
using System;
|
||||||
|
using AsbCloudApp.Data.ProcessMaps.Report;
|
||||||
|
using AsbCloudApp.Data.SAUB;
|
||||||
|
|
||||||
|
namespace AsbCloudInfrastructure.Services.ProcessMaps.WellDrilling.Report.Data;
|
||||||
|
|
||||||
|
internal class ParamStat
|
||||||
|
{
|
||||||
|
private double spWSum;
|
||||||
|
private double pvWSum;
|
||||||
|
private double limitMaxWSum;
|
||||||
|
|
||||||
|
private double deltaDepthSum;
|
||||||
|
|
||||||
|
private readonly Func<TelemetryDataSaubStatDto, double> getterSp;
|
||||||
|
private readonly Func<TelemetryDataSaubStatDto, double> getterPv;
|
||||||
|
private readonly Func<TelemetryDataSaubStatDto, double>? getterLimitMax;
|
||||||
|
|
||||||
|
private readonly int idFeedRegulator;
|
||||||
|
private readonly int idMode;
|
||||||
|
private TelemetryDataSaubStatDto? previous;
|
||||||
|
|
||||||
|
public double SpUsageDepth { get; private set; }
|
||||||
|
private static double spUsageTotal;
|
||||||
|
|
||||||
|
public ParamStat(Func<TelemetryDataSaubStatDto, double> getterSp,
|
||||||
|
Func<TelemetryDataSaubStatDto, double> getterPv,
|
||||||
|
Func<TelemetryDataSaubStatDto, double>? getterLimitMax,
|
||||||
|
int idFeedRegulator,
|
||||||
|
int idMode)
|
||||||
|
{
|
||||||
|
this.getterSp = getterSp;
|
||||||
|
this.getterPv = getterPv;
|
||||||
|
this.getterLimitMax = getterLimitMax;
|
||||||
|
this.idFeedRegulator = idFeedRegulator;
|
||||||
|
this.idMode = idMode;
|
||||||
|
spUsageTotal = 0d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateStat(TelemetryDataSaubStatDto current)
|
||||||
|
{
|
||||||
|
if (previous is not null)
|
||||||
|
{
|
||||||
|
var deltaDepth = current.WellDepthMin - previous.WellDepthMin;
|
||||||
|
if (deltaDepth > 0)
|
||||||
|
{
|
||||||
|
var deltaDepthHalf = deltaDepth / 2;
|
||||||
|
|
||||||
|
double CalculateWeight(Func<TelemetryDataSaubStatDto, double> getter) =>
|
||||||
|
(getter(previous!) + getter(current)) * deltaDepthHalf;
|
||||||
|
|
||||||
|
spWSum += CalculateWeight(getterSp);
|
||||||
|
pvWSum += CalculateWeight(getterPv);
|
||||||
|
if (getterLimitMax is not null)
|
||||||
|
limitMaxWSum += CalculateWeight(getterLimitMax!);
|
||||||
|
|
||||||
|
if (current.IdFeedRegulator is not null)
|
||||||
|
if (current.IdFeedRegulator == idFeedRegulator)
|
||||||
|
{
|
||||||
|
SpUsageDepth += deltaDepth;
|
||||||
|
spUsageTotal += deltaDepth;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var pvErr = (getterSp(current) - getterPv(current)) / getterSp(current);
|
||||||
|
if (pvErr < 0.03d) //3%
|
||||||
|
{
|
||||||
|
SpUsageDepth += deltaDepth;
|
||||||
|
spUsageTotal += deltaDepth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deltaDepthSum += deltaDepth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
previous = current;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProcessMapReportWellDrillingParamsDto MakeParams(double? spPlan)
|
||||||
|
{
|
||||||
|
var result = new ProcessMapReportWellDrillingParamsDto
|
||||||
|
{
|
||||||
|
SetpointPlan = spPlan,
|
||||||
|
Fact = DivideValByDepth(pvWSum),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (idMode == 0)
|
||||||
|
{
|
||||||
|
result.SetpointFact = null;
|
||||||
|
result.Limit = null;
|
||||||
|
result.SetpointUsage = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.SetpointFact = DivideValByDepth(spWSum);
|
||||||
|
result.Limit = getterLimitMax is not null ? DivideValByDepth(limitMaxWSum) : null;
|
||||||
|
result.SetpointUsage = deltaDepthSum > 0d ? 100d * SpUsageDepth / spUsageTotal : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double? DivideValByDepth(double? val)
|
||||||
|
{
|
||||||
|
if (val is null || val == 0d || deltaDepthSum == 0d)
|
||||||
|
return null;
|
||||||
|
return val / deltaDepthSum;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using AsbCloudApp.Data.SAUB;
|
using AsbCloudApp.Data.SAUB;
|
||||||
|
using AsbCloudInfrastructure.Services.ProcessMaps.WellDrilling.Report.Data;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.ProcessMaps.WellDrillingProcessMap.Report.Data;
|
namespace AsbCloudInfrastructure.Services.ProcessMaps.WellDrillingProcessMap.Report.Data;
|
||||||
|
|
@ -6,13 +6,12 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AsbCloudApp.Data.ProcessMaps.Report;
|
using AsbCloudApp.Data.ProcessMaps.Report;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudApp.Services.ProcessMaps;
|
using AsbCloudApp.Services.ProcessMaps.WellDrilling;
|
||||||
using AsbCloudApp.Services.ProcessMaps.WellDrillingProcessMap;
|
|
||||||
using ClosedXML.Excel;
|
using ClosedXML.Excel;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.ProcessMaps.WellDrillingProcessMap.Report;
|
namespace AsbCloudInfrastructure.Services.ProcessMaps.WellDrillingProcessMap.Report;
|
||||||
|
|
||||||
public class WellDrillingProcessMapReportExportService : IProcessMapReportExportService
|
public class ProcessMapReportWellDrillingExportService : IProcessMapReportWellDrillingExportService
|
||||||
{
|
{
|
||||||
const int firstColumn = 2;
|
const int firstColumn = 2;
|
||||||
const int lastColumn = 42;
|
const int lastColumn = 42;
|
||||||
@ -22,7 +21,7 @@ public class WellDrillingProcessMapReportExportService : IProcessMapReportExport
|
|||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
private readonly IProcessMapReportWellDrillingService processMapReportWellDrillingService;
|
private readonly IProcessMapReportWellDrillingService processMapReportWellDrillingService;
|
||||||
|
|
||||||
public WellDrillingProcessMapReportExportService(IWellService wellService,
|
public ProcessMapReportWellDrillingExportService(IWellService wellService,
|
||||||
IProcessMapReportWellDrillingService processMapReportWellDrillingService)
|
IProcessMapReportWellDrillingService processMapReportWellDrillingService)
|
||||||
{
|
{
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
@ -9,19 +9,19 @@ using AsbCloudApp.Data.SAUB;
|
|||||||
using AsbCloudApp.Exceptions;
|
using AsbCloudApp.Exceptions;
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudApp.Services.ProcessMaps.WellDrillingProcessMap;
|
using AsbCloudApp.Services.ProcessMaps.WellDrilling;
|
||||||
using AsbCloudInfrastructure.Services.ProcessMaps.WellDrillingProcessMap.Report.Data;
|
using AsbCloudInfrastructure.Services.ProcessMaps.WellDrillingProcessMap.Report.Data;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.ProcessMaps.WellDrillingProcessMap.Report;
|
namespace AsbCloudInfrastructure.Services.ProcessMaps.WellDrillingProcessMap.Report;
|
||||||
|
|
||||||
public class WellDrillingProcessMapReportService : IProcessMapReportWellDrillingService
|
public class ProcessMapReportWellDrillingService : IProcessMapReportWellDrillingService
|
||||||
{
|
{
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
private readonly IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> processMapPlanWellDrillingRepository;
|
private readonly IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> processMapPlanWellDrillingRepository;
|
||||||
private readonly ITelemetryDataSaubService telemetryDataSaubService;
|
private readonly ITelemetryDataSaubService telemetryDataSaubService;
|
||||||
private readonly IWellOperationRepository wellOperationRepository;
|
private readonly IWellOperationRepository wellOperationRepository;
|
||||||
|
|
||||||
public WellDrillingProcessMapReportService(IWellService wellService,
|
public ProcessMapReportWellDrillingService(IWellService wellService,
|
||||||
IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> processMapPlanWellDrillingRepository,
|
IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> processMapPlanWellDrillingRepository,
|
||||||
ITelemetryDataSaubService telemetryDataSaubService,
|
ITelemetryDataSaubService telemetryDataSaubService,
|
||||||
IWellOperationRepository wellOperationRepository)
|
IWellOperationRepository wellOperationRepository)
|
@ -1,112 +0,0 @@
|
|||||||
using System;
|
|
||||||
using AsbCloudApp.Data.ProcessMaps.Report;
|
|
||||||
using AsbCloudApp.Data.SAUB;
|
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.ProcessMaps.WellDrillingProcessMap.Report.Data;
|
|
||||||
|
|
||||||
internal class ParamStat
|
|
||||||
{
|
|
||||||
private double spWSum;
|
|
||||||
private double pvWSum;
|
|
||||||
private double limitMaxWSum;
|
|
||||||
|
|
||||||
private double deltaDepthSum;
|
|
||||||
|
|
||||||
private readonly Func<TelemetryDataSaubStatDto, double> getterSp;
|
|
||||||
private readonly Func<TelemetryDataSaubStatDto, double> getterPv;
|
|
||||||
private readonly Func<TelemetryDataSaubStatDto, double>? getterLimitMax;
|
|
||||||
|
|
||||||
private readonly int idFeedRegulator;
|
|
||||||
private readonly int idMode;
|
|
||||||
private TelemetryDataSaubStatDto? previous;
|
|
||||||
|
|
||||||
public double SpUsageDepth { get; private set; }
|
|
||||||
private static double spUsageTotal;
|
|
||||||
|
|
||||||
public ParamStat(Func<TelemetryDataSaubStatDto, double> getterSp,
|
|
||||||
Func<TelemetryDataSaubStatDto, double> getterPv,
|
|
||||||
Func<TelemetryDataSaubStatDto, double>? getterLimitMax,
|
|
||||||
int idFeedRegulator,
|
|
||||||
int idMode)
|
|
||||||
{
|
|
||||||
this.getterSp = getterSp;
|
|
||||||
this.getterPv = getterPv;
|
|
||||||
this.getterLimitMax = getterLimitMax;
|
|
||||||
this.idFeedRegulator = idFeedRegulator;
|
|
||||||
this.idMode = idMode;
|
|
||||||
spUsageTotal = 0d;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateStat(TelemetryDataSaubStatDto current)
|
|
||||||
{
|
|
||||||
if (previous is not null)
|
|
||||||
{
|
|
||||||
var deltaDepth = current.WellDepthMin - previous.WellDepthMin;
|
|
||||||
if (deltaDepth > 0)
|
|
||||||
{
|
|
||||||
var deltaDepthHalf = deltaDepth / 2;
|
|
||||||
|
|
||||||
double CalculateWeight(Func<TelemetryDataSaubStatDto, double> getter) =>
|
|
||||||
(getter(previous!) + getter(current)) * deltaDepthHalf;
|
|
||||||
|
|
||||||
spWSum += CalculateWeight(getterSp);
|
|
||||||
pvWSum += CalculateWeight(getterPv);
|
|
||||||
if (getterLimitMax is not null)
|
|
||||||
limitMaxWSum += CalculateWeight(getterLimitMax!);
|
|
||||||
|
|
||||||
if (current.IdFeedRegulator is not null)
|
|
||||||
{
|
|
||||||
if (current.IdFeedRegulator == idFeedRegulator)
|
|
||||||
{
|
|
||||||
SpUsageDepth += deltaDepth;
|
|
||||||
spUsageTotal += deltaDepth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var pvErr = (getterSp(current) - getterPv(current)) / getterSp(current);
|
|
||||||
if (pvErr < 0.03d) //3%
|
|
||||||
{
|
|
||||||
SpUsageDepth += deltaDepth;
|
|
||||||
spUsageTotal += deltaDepth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
deltaDepthSum += deltaDepth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
previous = current;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProcessMapReportWellDrillingParamsDto MakeParams(double? spPlan)
|
|
||||||
{
|
|
||||||
var result = new ProcessMapReportWellDrillingParamsDto
|
|
||||||
{
|
|
||||||
SetpointPlan = spPlan,
|
|
||||||
Fact = DivideValByDepth(pvWSum),
|
|
||||||
};
|
|
||||||
|
|
||||||
if (idMode == 0)
|
|
||||||
{
|
|
||||||
result.SetpointFact = null;
|
|
||||||
result.Limit = null;
|
|
||||||
result.SetpointUsage = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result.SetpointFact = DivideValByDepth(spWSum);
|
|
||||||
result.Limit = getterLimitMax is not null ? DivideValByDepth(limitMaxWSum) : null;
|
|
||||||
result.SetpointUsage = deltaDepthSum > 0d ? 100d * SpUsageDepth / spUsageTotal : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private double? DivideValByDepth(double? val)
|
|
||||||
{
|
|
||||||
if (val is null || val == 0d || deltaDepthSum == 0d)
|
|
||||||
return null;
|
|
||||||
return val / deltaDepthSum;
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,10 +5,13 @@ using AsbCloudApp.Data;
|
|||||||
using AsbCloudApp.Data.ProcessMaps;
|
using AsbCloudApp.Data.ProcessMaps;
|
||||||
using AsbCloudApp.Exceptions;
|
using AsbCloudApp.Exceptions;
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
|
using AsbCloudWebApi.SignalR;
|
||||||
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 Microsoft.AspNetCore.SignalR;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
||||||
|
|
||||||
@ -21,38 +24,47 @@ namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
|||||||
public abstract class ProcessMapBaseController<T> : ControllerBase
|
public abstract class ProcessMapBaseController<T> : ControllerBase
|
||||||
where T : ProcessMapPlanBaseDto
|
where T : ProcessMapPlanBaseDto
|
||||||
{
|
{
|
||||||
|
private readonly IHubContext<TelemetryHub> telemetryHubContext;
|
||||||
|
private readonly ITelemetryService telemetryService;
|
||||||
|
|
||||||
|
public abstract string SignalRMethod { get; }
|
||||||
|
|
||||||
protected int IdUser
|
protected 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
private readonly IUserRepository userRepository;
|
private readonly IUserRepository userRepository;
|
||||||
private readonly ICrudRepository<WellSectionTypeDto> wellSectionRepository;
|
private readonly ICrudRepository<WellSectionTypeDto> wellSectionRepository;
|
||||||
|
|
||||||
protected readonly IRepositoryWellRelated<T> repository;
|
protected readonly IProcessMapPlanRepository<T> repository;
|
||||||
|
|
||||||
protected ProcessMapBaseController(IWellService wellService,
|
protected ProcessMapBaseController(IWellService wellService,
|
||||||
IProcessMapPlanRepository<T> repository,
|
IProcessMapPlanRepository<T> repository,
|
||||||
IUserRepository userRepository,
|
IUserRepository userRepository,
|
||||||
ICrudRepository<WellSectionTypeDto> wellSectionRepository)
|
ICrudRepository<WellSectionTypeDto> wellSectionRepository,
|
||||||
|
IHubContext<TelemetryHub> telemetryHubContext,
|
||||||
|
ITelemetryService telemetryService)
|
||||||
{
|
{
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
this.userRepository = userRepository;
|
this.userRepository = userRepository;
|
||||||
this.wellSectionRepository = wellSectionRepository;
|
this.wellSectionRepository = wellSectionRepository;
|
||||||
|
this.telemetryHubContext = telemetryHubContext;
|
||||||
|
this.telemetryService = telemetryService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Создание РТК
|
/// Создание плановой РТК
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="processMap">Тело запроса</param>
|
/// <param name="processMap">Тело запроса</param>
|
||||||
/// <param name="idWell">Id скважины</param>
|
/// <param name="idWell">Id скважины</param>
|
||||||
@ -64,8 +76,8 @@ public abstract class ProcessMapBaseController<T> : ControllerBase
|
|||||||
public virtual async Task<IActionResult> InsertAsync(T processMap, int idWell, CancellationToken cancellationToken)
|
public virtual async Task<IActionResult> InsertAsync(T processMap, int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
processMap.IdWell = idWell;
|
processMap.IdWell = idWell;
|
||||||
processMap.IdUser = IdUser;
|
processMap.IdUser = IdUser;
|
||||||
processMap.LastUpdate = DateTime.UtcNow;
|
processMap.LastUpdate = DateTime.UtcNow;
|
||||||
|
|
||||||
await CheckIsExistsWellSectionTypeAsync(processMap.IdWellSectionType, cancellationToken);
|
await CheckIsExistsWellSectionTypeAsync(processMap.IdWellSectionType, cancellationToken);
|
||||||
|
|
||||||
@ -73,11 +85,13 @@ public abstract class ProcessMapBaseController<T> : ControllerBase
|
|||||||
|
|
||||||
var result = await repository.InsertAsync(processMap, cancellationToken);
|
var result = await repository.InsertAsync(processMap, cancellationToken);
|
||||||
|
|
||||||
return Ok(result);
|
await NotifyUsersBySignalR(idWell, cancellationToken);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обновление РТК
|
/// Обновление плановой РТК
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="processMap">Тело запроса</param>
|
/// <param name="processMap">Тело запроса</param>
|
||||||
/// <param name="idWell">Id скважины</param>
|
/// <param name="idWell">Id скважины</param>
|
||||||
@ -88,9 +102,9 @@ public abstract class ProcessMapBaseController<T> : ControllerBase
|
|||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
public virtual async Task<IActionResult> UpdateAsync(T processMap, int idWell, CancellationToken cancellationToken)
|
public virtual async Task<IActionResult> UpdateAsync(T processMap, int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
processMap.IdWell = idWell;
|
processMap.IdWell = idWell;
|
||||||
processMap.IdUser = IdUser;
|
processMap.IdUser = IdUser;
|
||||||
processMap.LastUpdate = DateTime.UtcNow;
|
processMap.LastUpdate = DateTime.UtcNow;
|
||||||
|
|
||||||
await CheckIsExistsWellSectionTypeAsync(processMap.IdWellSectionType, cancellationToken);
|
await CheckIsExistsWellSectionTypeAsync(processMap.IdWellSectionType, cancellationToken);
|
||||||
|
|
||||||
@ -98,14 +112,16 @@ public abstract class ProcessMapBaseController<T> : ControllerBase
|
|||||||
|
|
||||||
var result = await repository.UpdateAsync(processMap, cancellationToken);
|
var result = await repository.UpdateAsync(processMap, cancellationToken);
|
||||||
|
|
||||||
if (result == ICrudRepository<T>.ErrorIdNotFound)
|
if (result == ICrudRepository<T>.ErrorIdNotFound)
|
||||||
return this.ValidationBadRequest(nameof(processMap.Id), $"РТК с Id: {processMap.Id} не существует");
|
return this.ValidationBadRequest(nameof(processMap.Id), $"РТК с Id: {processMap.Id} не существует");
|
||||||
|
|
||||||
return Ok(result);
|
await NotifyUsersBySignalR(idWell, cancellationToken);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление РТК
|
/// Удаление плановой РТК
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Id удаляемой РТК</param>
|
/// <param name="id">Id удаляемой РТК</param>
|
||||||
/// <param name="idWell">Id скважины</param>
|
/// <param name="idWell">Id скважины</param>
|
||||||
@ -113,14 +129,15 @@ public abstract class ProcessMapBaseController<T> : ControllerBase
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
|
||||||
public virtual async Task<IActionResult> DeleteAsync(int id, int idWell, CancellationToken cancellationToken)
|
public virtual async Task<IActionResult> DeleteAsync(int id, int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await AssertUserHasAccessToEditProcessMapAsync(idWell, cancellationToken);
|
await AssertUserHasAccessToEditProcessMapAsync(idWell, cancellationToken);
|
||||||
|
|
||||||
var result = await repository.DeleteAsync(id, cancellationToken);
|
var result = await repository.DeleteAsync(id, cancellationToken);
|
||||||
|
|
||||||
return Ok(result);
|
await NotifyUsersBySignalR(idWell, cancellationToken);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -130,27 +147,62 @@ public abstract class ProcessMapBaseController<T> : ControllerBase
|
|||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
||||||
public async Task<IActionResult> GetAsync(int idWell, CancellationToken cancellationToken)
|
public async Task<IActionResult> GetAsync(int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var processMaps = await repository.GetByIdWellAsync(idWell, cancellationToken);
|
var processMaps = await repository.GetByIdWellAsync(idWell, cancellationToken);
|
||||||
|
|
||||||
return Ok(processMaps);
|
return Ok(processMaps);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение РТК по телеметрии
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uid">Уникальный ключ телеметрии</param>
|
||||||
|
/// <param name="updateFrom">Дата с которой требуется получить РТК</param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("/api/[controller]/telemetry/{uid}")]
|
||||||
|
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
|
public async Task<IActionResult> GetProcessMapPlanByTelemetry(string uid, DateTime updateFrom, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
|
||||||
|
|
||||||
|
if (!idWell.HasValue)
|
||||||
|
return this.ValidationBadRequest(nameof(uid), $"Wrong uid {uid}");
|
||||||
|
|
||||||
|
var wellDrillingProcessMaps = await repository.GetAsync(new[] { new ProcessMapPlanRequest
|
||||||
|
{
|
||||||
|
IdWell = idWell.Value,
|
||||||
|
UpdateFrom = updateFrom
|
||||||
|
}}, cancellationToken);
|
||||||
|
|
||||||
|
return Ok(wellDrillingProcessMaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task AssertUserHasAccessToEditProcessMapAsync(int idWell, CancellationToken cancellationToken)
|
protected async Task AssertUserHasAccessToEditProcessMapAsync(int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var well = await wellService.GetOrDefaultAsync(idWell, cancellationToken)
|
var well = await wellService.GetOrDefaultAsync(idWell, cancellationToken)
|
||||||
?? throw new ArgumentInvalidException(nameof(idWell),$"Скважины с {idWell} не существует");
|
?? throw new ArgumentInvalidException(nameof(idWell), $"Скважины с {idWell} не существует");
|
||||||
|
|
||||||
var idCompany = User.GetCompanyId();
|
var idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
if (!idCompany.HasValue ||
|
if (!idCompany.HasValue ||
|
||||||
!await wellService.IsCompanyInvolvedInWellAsync(idCompany.Value, idWell, cancellationToken))
|
!await wellService.IsCompanyInvolvedInWellAsync(idCompany.Value, idWell, cancellationToken))
|
||||||
throw new ForbidException("Нет доступа к скважине");
|
throw new ForbidException("Нет доступа к скважине");
|
||||||
|
|
||||||
if (well.IdState == 2 && !userRepository.HasPermission(IdUser, "ProcessMap.editCompletedWell"))
|
if (well.IdState == 2 && !userRepository.HasPermission(IdUser, "ProcessMap.editCompletedWell"))
|
||||||
throw new ForbidException("Недостаточно прав для редактирования РТК завершенной скважины");
|
throw new ForbidException("Недостаточно прав для редактирования РТК завершенной скважины");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async Task NotifyUsersBySignalR(int idWell, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var wellDrillingProcessMaps = await repository.GetByIdWellAsync(idWell, cancellationToken);
|
||||||
|
|
||||||
|
await telemetryHubContext.Clients
|
||||||
|
.Group($"{SignalRMethod}_{idWell}")
|
||||||
|
.SendAsync("UpdateProcessMap", wellDrillingProcessMaps, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CheckIsExistsWellSectionTypeAsync(int idWellSectionType, CancellationToken cancellationToken)
|
private async Task CheckIsExistsWellSectionTypeAsync(int idWellSectionType, CancellationToken cancellationToken)
|
||||||
|
@ -4,11 +4,10 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Data.ProcessMaps;
|
using AsbCloudApp.Data.ProcessMaps;
|
||||||
using AsbCloudApp.Exceptions;
|
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudApp.Services.ProcessMaps;
|
using AsbCloudApp.Services.ProcessMaps;
|
||||||
using AsbCloudApp.Services.ProcessMaps.WellDrillingProcessMap;
|
using AsbCloudApp.Services.ProcessMaps.WellDrilling;
|
||||||
using AsbCloudWebApi.SignalR;
|
using AsbCloudWebApi.SignalR;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@ -18,74 +17,26 @@ namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
|||||||
|
|
||||||
public class ProcessMapWellDrillingController : ProcessMapBaseController<ProcessMapPlanWellDrillingDto>
|
public class ProcessMapWellDrillingController : ProcessMapBaseController<ProcessMapPlanWellDrillingDto>
|
||||||
{
|
{
|
||||||
private readonly IHubContext<TelemetryHub> telemetryHubContext;
|
private readonly IProcessMapReportWellDrillingService processMapReportWellDrillingService;
|
||||||
|
private readonly IProcessMapReportWellDrillingExportService processMapReportWellDrillingExportService;
|
||||||
|
private readonly IProcessMapPlanImportService processMapPlanImportService;
|
||||||
|
|
||||||
private readonly IProcessMapReportWellDrillingService wellDrillingProcessMapReportService;
|
public override string SignalRMethod => "ProcessMapWellDrilling";
|
||||||
private readonly IProcessMapReportExportService wellDrillingProcessMapReportExportService;
|
|
||||||
private readonly IProcessMapImportService wellDrillingProcessMapImportService;
|
|
||||||
|
|
||||||
public ProcessMapWellDrillingController(IWellService wellService,
|
public ProcessMapWellDrillingController(IWellService wellService,
|
||||||
IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> repository,
|
IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> repository,
|
||||||
IUserRepository userRepository,
|
IUserRepository userRepository,
|
||||||
|
IProcessMapReportWellDrillingExportService processMapReportWellDrillingExportService,
|
||||||
|
IProcessMapPlanImportService processMapPlanImportService,
|
||||||
|
IProcessMapReportWellDrillingService processMapReportWellDrillingService,
|
||||||
|
ICrudRepository<WellSectionTypeDto> wellSectionRepository,
|
||||||
IHubContext<TelemetryHub> telemetryHubContext,
|
IHubContext<TelemetryHub> telemetryHubContext,
|
||||||
IProcessMapReportExportService wellDrillingProcessMapReportExportService,
|
ITelemetryService telemetryService)
|
||||||
IProcessMapImportService wellDrillingProcessMapImportService,
|
: base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService)
|
||||||
IProcessMapReportWellDrillingService wellDrillingProcessMapReportService,
|
|
||||||
ICrudRepository<WellSectionTypeDto> wellSectionRepository)
|
|
||||||
: base(wellService, repository, userRepository, wellSectionRepository)
|
|
||||||
{
|
{
|
||||||
this.telemetryHubContext = telemetryHubContext;
|
this.processMapReportWellDrillingExportService = processMapReportWellDrillingExportService;
|
||||||
this.wellDrillingProcessMapReportExportService = wellDrillingProcessMapReportExportService;
|
this.processMapPlanImportService = processMapPlanImportService;
|
||||||
this.wellDrillingProcessMapImportService = wellDrillingProcessMapImportService;
|
this.processMapReportWellDrillingService = processMapReportWellDrillingService;
|
||||||
this.wellDrillingProcessMapReportService = wellDrillingProcessMapReportService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание РТК
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="processMap">Тело запроса</param>
|
|
||||||
/// <param name="idWell">Id скважины</param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public override async Task<IActionResult> InsertAsync(ProcessMapPlanWellDrillingDto processMap, int idWell, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var result = await base.InsertAsync(processMap, idWell, cancellationToken);
|
|
||||||
|
|
||||||
await NotifyUsersBySignalR(idWell, cancellationToken);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Обновление РТК
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="processMap">Тело запроса</param>
|
|
||||||
/// <param name="idWell">Id скважины</param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public override async Task<IActionResult> UpdateAsync(ProcessMapPlanWellDrillingDto processMap, int idWell, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var result = await base.UpdateAsync(processMap, idWell, cancellationToken);
|
|
||||||
|
|
||||||
await NotifyUsersBySignalR(idWell, cancellationToken);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление РТК
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id">Id удаляемой РТК</param>
|
|
||||||
/// <param name="idWell">Id скважины</param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public override async Task<IActionResult> DeleteAsync(int id, int idWell, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var result = await base.DeleteAsync(id, idWell, cancellationToken);
|
|
||||||
|
|
||||||
await NotifyUsersBySignalR(idWell, cancellationToken);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -98,7 +49,7 @@ public class ProcessMapWellDrillingController : ProcessMapBaseController<Process
|
|||||||
[ProducesResponseType(typeof(ProcessMapPlanWellDrillingDto), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(ProcessMapPlanWellDrillingDto), StatusCodes.Status200OK)]
|
||||||
public async Task<IActionResult> GetReportAsync(int idWell, CancellationToken cancellationToken)
|
public async Task<IActionResult> GetReportAsync(int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var report = await wellDrillingProcessMapReportService.GetAsync(idWell, cancellationToken);
|
var report = await processMapReportWellDrillingService.GetAsync(idWell, cancellationToken);
|
||||||
|
|
||||||
return Ok(report);
|
return Ok(report);
|
||||||
}
|
}
|
||||||
@ -114,7 +65,7 @@ public class ProcessMapWellDrillingController : ProcessMapBaseController<Process
|
|||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
public async Task<IActionResult> ExportReportAsync(int idWell, CancellationToken cancellationToken)
|
public async Task<IActionResult> ExportReportAsync(int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var report = await wellDrillingProcessMapReportExportService.ExportAsync(idWell, cancellationToken);
|
var report = await processMapReportWellDrillingExportService.ExportAsync(idWell, cancellationToken);
|
||||||
|
|
||||||
if (report is null)
|
if (report is null)
|
||||||
return NoContent();
|
return NoContent();
|
||||||
@ -146,7 +97,7 @@ public class ProcessMapWellDrillingController : ProcessMapBaseController<Process
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await wellDrillingProcessMapImportService.ImportAsync(idWell,
|
await processMapPlanImportService.ImportAsync(idWell,
|
||||||
IdUser,
|
IdUser,
|
||||||
(options & 1) > 0,
|
(options & 1) > 0,
|
||||||
stream,
|
stream,
|
||||||
@ -173,7 +124,7 @@ public class ProcessMapWellDrillingController : ProcessMapBaseController<Process
|
|||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
public async Task<IActionResult> ExportAsync(int idWell, CancellationToken cancellationToken)
|
public async Task<IActionResult> ExportAsync(int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var processMapsFile = await wellDrillingProcessMapImportService.ExportAsync(idWell, cancellationToken);
|
var processMapsFile = await processMapPlanImportService.ExportAsync(idWell, cancellationToken);
|
||||||
|
|
||||||
return File(processMapsFile.File, "application/octet-stream", processMapsFile.Name);
|
return File(processMapsFile.File, "application/octet-stream", processMapsFile.Name);
|
||||||
}
|
}
|
||||||
@ -186,16 +137,7 @@ public class ProcessMapWellDrillingController : ProcessMapBaseController<Process
|
|||||||
[ProducesResponseType(typeof(PhysicalFileResult), StatusCodes.Status200OK, "application/octet-stream")]
|
[ProducesResponseType(typeof(PhysicalFileResult), StatusCodes.Status200OK, "application/octet-stream")]
|
||||||
public async Task<IActionResult> GetTemplateAsync(CancellationToken cancellationToken)
|
public async Task<IActionResult> GetTemplateAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var template = await wellDrillingProcessMapImportService.GetExcelTemplateStreamAsync(cancellationToken);
|
var template = await processMapPlanImportService.GetExcelTemplateStreamAsync(cancellationToken);
|
||||||
return File(template.File, "application/octet-stream", template.Name);
|
return File(template.File, "application/octet-stream", template.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task NotifyUsersBySignalR(int idWell, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var wellDrillingProcessMaps = await repository.GetByIdWellAsync(idWell, cancellationToken);
|
|
||||||
|
|
||||||
await telemetryHubContext.Clients
|
|
||||||
.Group($"well_{idWell}")
|
|
||||||
.SendAsync("UpdateProcessMap", wellDrillingProcessMaps, cancellationToken);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -2,6 +2,8 @@
|
|||||||
using AsbCloudApp.Data.ProcessMaps;
|
using AsbCloudApp.Data.ProcessMaps;
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
|
using AsbCloudWebApi.SignalR;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
||||||
|
|
||||||
@ -10,8 +12,12 @@ public class ProcessMapWellReamController : ProcessMapBaseController<ProcessMapP
|
|||||||
public ProcessMapWellReamController(IWellService wellService,
|
public ProcessMapWellReamController(IWellService wellService,
|
||||||
IProcessMapPlanRepository<ProcessMapPlanWellReamDto> repository,
|
IProcessMapPlanRepository<ProcessMapPlanWellReamDto> repository,
|
||||||
IUserRepository userRepository,
|
IUserRepository userRepository,
|
||||||
ICrudRepository<WellSectionTypeDto> wellSectionRepository)
|
ICrudRepository<WellSectionTypeDto> wellSectionRepository,
|
||||||
: base(wellService, repository, userRepository, wellSectionRepository)
|
IHubContext<TelemetryHub> telemetryHubContext,
|
||||||
|
ITelemetryService telemetryService)
|
||||||
|
: base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string SignalRMethod => "ProccessMapWellReam";
|
||||||
}
|
}
|
@ -1,87 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AsbCloudApp.Data.ProcessMaps;
|
|
||||||
using AsbCloudApp.Repositories;
|
|
||||||
using AsbCloudApp.Requests;
|
|
||||||
using AsbCloudApp.Services;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers.SAUB;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Данные РТК для SAUB
|
|
||||||
/// </summary>
|
|
||||||
[ApiController]
|
|
||||||
[Route("api/[controller]")]
|
|
||||||
public class TelemetryProcessMapController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly ITelemetryService telemetryService;
|
|
||||||
private readonly IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> processMapPlanWellDrillingRepository;
|
|
||||||
private readonly IProcessMapPlanRepository<ProcessMapPlanWellReamDto> processMapPlanWellReamRepository;
|
|
||||||
|
|
||||||
public TelemetryProcessMapController(ITelemetryService telemetryService,
|
|
||||||
IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto> processMapPlanWellDrillingRepository,
|
|
||||||
IProcessMapPlanRepository<ProcessMapPlanWellReamDto> processMapPlanWellReamRepository)
|
|
||||||
{
|
|
||||||
this.telemetryService = telemetryService;
|
|
||||||
this.processMapPlanWellDrillingRepository = processMapPlanWellDrillingRepository;
|
|
||||||
this.processMapPlanWellReamRepository = processMapPlanWellReamRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение РТК бурение по Uid телеметрии
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uid">Уникальный Id телеметрии</param>
|
|
||||||
/// <param name="updateFrom">Дата с которой требуется получить РТК</param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("processMapPlanWellDrilling")]
|
|
||||||
[ProducesResponseType(typeof(IEnumerable<ProcessMapPlanWellDrillingDto>), StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
|
||||||
public async Task<IActionResult> GetProcessMapPlanWellDrillingByUidAsync(string uid, DateTime updateFrom, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
|
|
||||||
|
|
||||||
if (!idWell.HasValue)
|
|
||||||
return this.ValidationBadRequest(nameof(uid), $"Wrong uid {uid}");
|
|
||||||
|
|
||||||
var wellDrillingProcessMaps = await processMapPlanWellDrillingRepository.GetAsync(new[] { new ProcessMapPlanRequest
|
|
||||||
{
|
|
||||||
IdWell = idWell.Value,
|
|
||||||
UpdateFrom = updateFrom
|
|
||||||
}}, cancellationToken);
|
|
||||||
|
|
||||||
return Ok(wellDrillingProcessMaps);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение РТК проработки по Uid телеметрии
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uid">Уникальный Id телеметрии</param>
|
|
||||||
/// <param name="updateFrom">Дата с которой требуется получить РТК</param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("processMapPlanWellReam")]
|
|
||||||
[ProducesResponseType(typeof(IEnumerable<ProcessMapPlanWellReamDto>), StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
|
||||||
public async Task<IActionResult> GetProcessMapPlanWellReamByUidAsync(string uid, DateTime updateFrom,
|
|
||||||
CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
|
|
||||||
|
|
||||||
if (!idWell.HasValue)
|
|
||||||
return this.ValidationBadRequest(nameof(uid), $"Wrong uid {uid}");
|
|
||||||
|
|
||||||
var wellReamProcessMaps = await processMapPlanWellReamRepository.GetAsync(new[] { new ProcessMapPlanRequest
|
|
||||||
{
|
|
||||||
IdWell = idWell.Value,
|
|
||||||
UpdateFrom = updateFrom
|
|
||||||
}}, cancellationToken);
|
|
||||||
|
|
||||||
return Ok(wellReamProcessMaps);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user