diff --git a/AsbCloudApp/Services/IDetectedOperationService.cs b/AsbCloudApp/Services/IDetectedOperationService.cs
index 0a0bd999..aaa5cc1c 100644
--- a/AsbCloudApp/Services/IDetectedOperationService.cs
+++ b/AsbCloudApp/Services/IDetectedOperationService.cs
@@ -30,6 +30,14 @@ namespace AsbCloudApp.Services
///
///
Task GetAsync(DetectedOperationRequest request, CancellationToken token);
+
+ ///
+ /// Получить автоматически определенные по телеметрии операции
+ ///
+ ///
+ ///
+ ///
+ Task?> GetOperationsAsync(DetectedOperationRequest request, CancellationToken token);
///
/// Удалить операции
@@ -37,6 +45,7 @@ namespace AsbCloudApp.Services
///
///
///
+
Task DeleteAsync(DetectedOperationRequest request, CancellationToken token);
///
diff --git a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs
index eecaebc0..3e8b3df2 100644
--- a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs
+++ b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs
@@ -64,7 +64,7 @@ namespace AsbCloudInfrastructure.Services.DetectOperations
return result;
}
- private async Task?> GetOperationsAsync(DetectedOperationRequest request, CancellationToken token)
+ public async Task?> GetOperationsAsync(DetectedOperationRequest request, CancellationToken token)
{
var well = await wellService.GetOrDefaultAsync(request.IdWell, token);
if (well?.IdTelemetry is null || well.Timezone is null)
diff --git a/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeService.cs b/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeService.cs
index b2422ed0..35403caa 100644
--- a/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeService.cs
+++ b/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeService.cs
@@ -86,7 +86,20 @@ namespace AsbCloudInfrastructure.Services.Subsystems
var data = await GetOperationTimeAsync(request, token);
if (data is null)
return null;
- var statList = await CalcStatAsync(data, request, token);
+
+ var detectedOperationsRequest = new DetectedOperationRequest()
+ {
+ IdWell = request.IdWell,
+ IdsCategories = new List() {
+ 1,3
+ },
+ LtDate = request.LtDate,
+ GtDate = request.GtDate,
+ };
+ var detectedOperations = await detectedOperationService.GetOperationsAsync(detectedOperationsRequest, token);
+ var depthInterval = GetDepthInterval(detectedOperations);
+
+ var statList = CalcStat(data,depthInterval,request, token);
return statList;
}
@@ -110,73 +123,59 @@ namespace AsbCloudInfrastructure.Services.Subsystems
return items;
}
- private async Task> CalcStatAsync(IEnumerable dtos, SubsystemOperationTimeRequest request, CancellationToken token)
+ private IEnumerable CalcStat(IEnumerable dtos, (double depthIntervalRotor, double depthIntervalSlide) depthInterval, SubsystemOperationTimeRequest request, CancellationToken token)
{
var groupedDataSubsystems = dtos
.GroupBy(o => o.IdSubsystem);
-
- var detectedOperationsRequest = new DetectedOperationRequest()
- {
- IdWell = request.IdWell,
- IdsCategories = new List() {
- 1,3
- },
- LtDate = request.LtDate,
- GtDate = request.GtDate,
- };
- var detectedOperations = await detectedOperationService.GetAsync(detectedOperationsRequest, token);
-
var periodGroupTotal = dtos.Sum(o => (o.DateEnd - o.DateStart).TotalHours);
-
- var gtDate = request.GtDate ?? dtos.Min(o => o.DateStart);
- var ltDate = request.LtDate ?? dtos.Max(o => o.DateEnd);
-
-
- var periodRequest = (ltDate - gtDate).TotalHours;
-
var result = groupedDataSubsystems.Select(g =>
{
+ double depthIntervalSubsystem = 0;
+ //AKB - MSE
+ if (g.Key == 1 | g.Key == 2)
+ {
+ depthIntervalSubsystem = depthInterval.depthIntervalRotor + depthInterval.depthIntervalSlide;
+ }
+ //Spin
+ if (g.Key == 65536)
+ {
+ depthIntervalSubsystem = depthInterval.depthIntervalSlide;
+ }
+ //Torque
+ if (g.Key == 65537)
+ {
+ depthIntervalSubsystem = depthInterval.depthIntervalRotor;
+ }
+
var periodGroup = g.Sum(o => (o.DateEnd - o.DateStart).TotalHours);
var periodGroupDepth = g.Sum(o => o.DepthEnd - o.DepthStart);
- var depthInterval = GetDepthInterval(g.Key, detectedOperations.Operations);
+ //
var subsystemStat = new SubsystemStatDto()
{
IdSubsystem = g.Key,
SubsystemName = subsystemService.GetOrDefault(g.Key)?.Name ?? "unknown",
UsedTimeHours = periodGroup,
- KUsage = periodGroupDepth / depthInterval,
+ KUsage = periodGroupDepth / depthIntervalSubsystem,
SumDepthInterval = periodGroupDepth,
OperationCount = g.Count()
};
+ if(subsystemStat.KUsage > 100)
+ subsystemStat.KUsage = 100;
return subsystemStat;
});
return result;
}
- private double GetDepthInterval (int idSubsystem, IEnumerable? detectedOperations)
+ private (double,double) GetDepthInterval (IEnumerable? detectedOperations)
{
+ var depthInterval = (depthIntervalRotor:(double)0, depthIntervalSlide: (double)0);
if (detectedOperations is null)
- return 0;
- var depthIntervalRotor = detectedOperations.Where(o => o.IdCategory == 1)
+ return depthInterval;
+ depthInterval.depthIntervalRotor = detectedOperations.Where(o => o.IdCategory == 1)
.Sum(o => o.DepthEnd - o.DepthStart);
- var depthIntervalSlide = detectedOperations.Where(o => o.IdCategory == 3)
- .Sum(o => o.DepthEnd - o.DepthStart);
- //AKB - MSE
- if (idSubsystem == 1 | idSubsystem ==2)
- {
- return depthIntervalRotor + depthIntervalSlide;
- }
- //Spin
- if (idSubsystem == 65536)
- {
- return depthIntervalSlide;
- }
- //Torque
- if (idSubsystem == 65537)
- {
- return depthIntervalRotor;
- }
- return 0;
+ depthInterval.depthIntervalSlide = detectedOperations.Where(o => o.IdCategory == 3)
+ .Sum(o => o.DepthEnd - o.DepthStart);
+ return depthInterval;
}
private IQueryable? BuildQuery(SubsystemOperationTimeRequest request)