forked from ddrilling/AsbCloudServer
Рефакторинг
This commit is contained in:
parent
0570c4f4e4
commit
8b15297a74
@ -14,9 +14,9 @@ public class SubsystemActiveWellStatDto
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public SubsystemStatDto? SubsystemAPD { get; set; }
|
public SubsystemStatDto? SubsystemAPD { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Наработки подсистемы СПИН
|
/// Наработки подсистемы с осцилляцией
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SubsystemStatDto? SubsystemSpinMaster { get; set; }
|
public SubsystemStatDto? SubsystemOscillation { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Наработки подсистемы ТОРК
|
/// Наработки подсистемы ТОРК
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -20,22 +20,22 @@ namespace AsbCloudApp.Requests
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Больше или равно дате
|
/// Больше или равно дате
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? GeDate { get; set; }
|
public DateTimeOffset? GeDate { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Меньше или равно дате
|
/// Меньше или равно дате
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? LtDate { get; set; }
|
public DateTimeOffset? LeDate { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Больше или равно глубины забоя
|
/// Больше или равно глубины забоя
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double? GtDepth { get; set; }
|
public double? GeDepth { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Меньше или равно глубины забоя
|
/// Меньше или равно глубины забоя
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double? LtDepth { get; set; }
|
public double? LeDepth { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||||
@ -45,20 +45,20 @@ namespace AsbCloudApp.Requests
|
|||||||
$"Должно быть больше {validationMinDate:O})",
|
$"Должно быть больше {validationMinDate:O})",
|
||||||
new[] { nameof(GeDate) });
|
new[] { nameof(GeDate) });
|
||||||
|
|
||||||
if (LtDate.HasValue && GeDate.HasValue)
|
if (LeDate.HasValue && GeDate.HasValue)
|
||||||
{
|
{
|
||||||
if (LtDate < GeDate)
|
if (LeDate < GeDate)
|
||||||
yield return new ValidationResult(
|
yield return new ValidationResult(
|
||||||
$"{nameof(LtDate)} должно быть больше {nameof(GeDate)}. ({LtDate:O} < {GeDate:O})",
|
$"{nameof(LeDate)} должно быть больше {nameof(GeDate)}. ({LeDate:O} < {GeDate:O})",
|
||||||
new[] { nameof(LtDate), nameof(GeDate) });
|
new[] { nameof(LeDate), nameof(GeDate) });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LtDepth.HasValue && GtDepth.HasValue)
|
if (LeDepth.HasValue && GeDepth.HasValue)
|
||||||
{
|
{
|
||||||
if (LtDepth < GtDepth)
|
if (LeDepth < GeDepth)
|
||||||
yield return new ValidationResult(
|
yield return new ValidationResult(
|
||||||
$"{nameof(LtDepth)} должно быть больше {nameof(GtDepth)}. ({LtDepth} < {GtDepth})",
|
$"{nameof(LeDepth)} должно быть больше {nameof(GeDepth)}. ({LeDepth} < {GeDepth})",
|
||||||
new[] { nameof(LtDepth), nameof(GtDepth) });
|
new[] { nameof(LeDepth), nameof(GeDepth) });
|
||||||
}
|
}
|
||||||
|
|
||||||
yield break;
|
yield break;
|
||||||
|
@ -319,7 +319,7 @@ public class DailyReportService : IDailyReportService
|
|||||||
{
|
{
|
||||||
IdWell = dailyReport.IdWell,
|
IdWell = dailyReport.IdWell,
|
||||||
GeDate = dailyReport.Date,
|
GeDate = dailyReport.Date,
|
||||||
LtDate = dailyReport.Date.AddHours(24)
|
LeDate = dailyReport.Date.AddHours(24)
|
||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
|
|
||||||
var subsystems = subsystemsStatPerWell
|
var subsystems = subsystemsStatPerWell
|
||||||
|
@ -10,17 +10,16 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AsbCloudInfrastructure.Services.DetectOperations;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.Subsystems;
|
namespace AsbCloudInfrastructure.Services.Subsystems;
|
||||||
|
|
||||||
internal class SubsystemService : ISubsystemService
|
internal class SubsystemService : ISubsystemService
|
||||||
{
|
{
|
||||||
private const int IdEnabledSubsystemSpinMaster = 128;
|
|
||||||
|
|
||||||
private const int IdSubsystemAPD = 1;
|
private const int IdSubsystemAPD = 1;
|
||||||
private const int IdSubsystemAPDRotor = 11;
|
private const int IdSubsystemAPDRotor = 11;
|
||||||
private const int IdSubsystemAPDSlide = 12;
|
private const int IdSubsystemAPDSlide = 12;
|
||||||
private const int IdSubsystemSpinMaster = 65536;
|
private const int IdSubsystemOscillation = 65536;
|
||||||
|
|
||||||
private readonly ICrudRepository<SubsystemDto> subsystemRepository;
|
private readonly ICrudRepository<SubsystemDto> subsystemRepository;
|
||||||
|
|
||||||
@ -50,10 +49,10 @@ internal class SubsystemService : ISubsystemService
|
|||||||
IdsOperationCategories = WellOperationCategory.MechanicalDrillingSubIds,
|
IdsOperationCategories = WellOperationCategory.MechanicalDrillingSubIds,
|
||||||
|
|
||||||
GeDateStart = request.GeDate,
|
GeDateStart = request.GeDate,
|
||||||
LeDateStart = request.LtDate,
|
LeDateStart = request.LeDate,
|
||||||
|
|
||||||
GeDepthStart = request.GtDepth,
|
GeDepthStart = request.GeDepth,
|
||||||
LeDepthStart = request.LtDepth,
|
LeDepthStart = request.LeDepth,
|
||||||
};
|
};
|
||||||
|
|
||||||
var operations = await detectedOperationService.GetOperationSummaryAsync(detectedOperationSummaryRequest,
|
var operations = await detectedOperationService.GetOperationSummaryAsync(detectedOperationSummaryRequest,
|
||||||
@ -66,7 +65,9 @@ internal class SubsystemService : ISubsystemService
|
|||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<SubsystemActiveWellStatDto>> GetStatByActiveWells(int idCompany, DateTime? gtDate, DateTime? ltDate,
|
public async Task<IEnumerable<SubsystemActiveWellStatDto>> GetStatByActiveWells(int idCompany,
|
||||||
|
DateTime? gtDate,
|
||||||
|
DateTime? ltDate,
|
||||||
CancellationToken token)
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var activeWells = await wellService.GetAsync(new() { IdCompany = idCompany, IdState = 1 }, token);
|
var activeWells = await wellService.GetAsync(new() { IdCompany = idCompany, IdState = 1 }, token);
|
||||||
@ -98,7 +99,10 @@ internal class SubsystemService : ISubsystemService
|
|||||||
nameof(groupOperations.Key)),
|
nameof(groupOperations.Key)),
|
||||||
};
|
};
|
||||||
|
|
||||||
var operationsWithEnableSubsystems = groupOperations.Where(o => o.EnabledSubsystems >= 1);
|
var operationsWithEnableSubsystems = groupOperations.Where(o =>
|
||||||
|
(EnabledSubsystemsFlags.AutoRotor |
|
||||||
|
EnabledSubsystemsFlags.AutoSlide |
|
||||||
|
EnabledSubsystemsFlags.AutoOscillation).HasEnabledSubsystems(o.EnabledSubsystems));
|
||||||
|
|
||||||
var subsystemStat = new SubsystemStatDto
|
var subsystemStat = new SubsystemStatDto
|
||||||
{
|
{
|
||||||
@ -120,17 +124,18 @@ internal class SubsystemService : ISubsystemService
|
|||||||
|
|
||||||
if (apdSlidePart is not null)
|
if (apdSlidePart is not null)
|
||||||
{
|
{
|
||||||
var operationsWithSpinMaster = operations.Where(s => s.EnabledSubsystems == IdEnabledSubsystemSpinMaster);
|
var operationsWithOscillation =
|
||||||
|
operations.Where(o => EnabledSubsystemsFlags.AutoOscillation.HasEnabledSubsystems(o.EnabledSubsystems));
|
||||||
|
|
||||||
var spinMaster = new SubsystemStatDto
|
var spinMaster = new SubsystemStatDto
|
||||||
{
|
{
|
||||||
IdSubsystem = IdSubsystemSpinMaster,
|
IdSubsystem = IdSubsystemOscillation,
|
||||||
SubsystemName = subsystems.FirstOrDefault(s => s.Id == IdSubsystemSpinMaster)?.Name ?? "unknown",
|
SubsystemName = subsystems.FirstOrDefault(s => s.Id == IdSubsystemOscillation)?.Name ?? "unknown",
|
||||||
UsedTimeHours = operationsWithSpinMaster.Sum(o => o.SumDurationHours),
|
UsedTimeHours = operationsWithOscillation.Sum(o => o.SumDurationHours),
|
||||||
SumOperationDepthInterval = apdSlidePart.SumOperationDepthInterval,
|
SumOperationDepthInterval = apdSlidePart.SumOperationDepthInterval,
|
||||||
SumOperationDurationHours = apdSlidePart.SumOperationDurationHours,
|
SumOperationDurationHours = apdSlidePart.SumOperationDurationHours,
|
||||||
SumDepthInterval = operationsWithSpinMaster.Sum(o => o.SumDepthIntervals),
|
SumDepthInterval = operationsWithOscillation.Sum(o => o.SumDepthIntervals),
|
||||||
OperationCount = operationsWithSpinMaster.Sum(s => s.Count)
|
OperationCount = operationsWithOscillation.Sum(s => s.Count)
|
||||||
};
|
};
|
||||||
|
|
||||||
spinMaster.KUsage = spinMaster.SumDepthInterval / spinMaster.SumOperationDepthInterval;
|
spinMaster.KUsage = spinMaster.SumDepthInterval / spinMaster.SumOperationDepthInterval;
|
||||||
@ -161,7 +166,9 @@ internal class SubsystemService : ISubsystemService
|
|||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<IEnumerable<SubsystemActiveWellStatDto>> GetStatAsync(IEnumerable<WellDto> wells, DateTime? gtDate, DateTime? ltDate,
|
private async Task<IEnumerable<SubsystemActiveWellStatDto>> GetStatAsync(IEnumerable<WellDto> wells,
|
||||||
|
DateTime? gtDate,
|
||||||
|
DateTime? ltDate,
|
||||||
CancellationToken token)
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
if (!wells.Any())
|
if (!wells.Any())
|
||||||
@ -210,7 +217,7 @@ internal class SubsystemService : ISubsystemService
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
wellStat.SubsystemAPD = subsystemStat.FirstOrDefault(s => s.IdSubsystem == IdSubsystemAPD);
|
wellStat.SubsystemAPD = subsystemStat.FirstOrDefault(s => s.IdSubsystem == IdSubsystemAPD);
|
||||||
wellStat.SubsystemSpinMaster = subsystemStat.FirstOrDefault(s => s.IdSubsystem == IdSubsystemSpinMaster);
|
wellStat.SubsystemOscillation = subsystemStat.FirstOrDefault(s => s.IdSubsystem == IdSubsystemOscillation);
|
||||||
}
|
}
|
||||||
|
|
||||||
return wellsStat;
|
return wellsStat;
|
||||||
|
@ -156,7 +156,7 @@ public class WellInfoService
|
|||||||
|
|
||||||
var wellSubsystemStat = subsystemStat.FirstOrDefault(s => s.Well.Id == well.Id);
|
var wellSubsystemStat = subsystemStat.FirstOrDefault(s => s.Well.Id == well.Id);
|
||||||
wellMapInfo.SaubUsage = wellSubsystemStat?.SubsystemAPD?.KUsage ?? 0d;
|
wellMapInfo.SaubUsage = wellSubsystemStat?.SubsystemAPD?.KUsage ?? 0d;
|
||||||
wellMapInfo.SpinUsage = wellSubsystemStat?.SubsystemSpinMaster?.KUsage ?? 0d;
|
wellMapInfo.SpinUsage = wellSubsystemStat?.SubsystemOscillation?.KUsage ?? 0d;
|
||||||
wellMapInfo.TorqueKUsage = wellSubsystemStat?.SubsystemTorqueMaster?.KUsage ?? 0d;
|
wellMapInfo.TorqueKUsage = wellSubsystemStat?.SubsystemTorqueMaster?.KUsage ?? 0d;
|
||||||
wellMapInfo.TvdLagDays = wellOperationsStat?.TvdLagDays;
|
wellMapInfo.TvdLagDays = wellOperationsStat?.TvdLagDays;
|
||||||
wellMapInfo.TvdDrillingDays = wellOperationsStat?.TvdDrillingDays;
|
wellMapInfo.TvdDrillingDays = wellOperationsStat?.TvdDrillingDays;
|
||||||
|
Loading…
Reference in New Issue
Block a user