CS2-29: Изменены имя и поля модели DrillingAnalysis (на TelemetryAnalysis)

This commit is contained in:
KharchenkoVV 2021-07-19 15:31:50 +05:00 committed by Фролов
parent f30cafcb1e
commit e3c4b262d9
17 changed files with 173 additions and 193 deletions

View File

@ -5,7 +5,7 @@ namespace AsbCloudApp.Data
{
public class OperationInfoDto
{
public DateTime IntervalBegin { get; set; }
public DateTimeOffset IntervalBegin { get; set; }
public IEnumerable<OperationDetailsDto> Operations { get; set; }
}
}

View File

@ -14,6 +14,6 @@ namespace AsbCloudApp.Services
DateTime begin = default, DateTime end = default);
IEnumerable<OperationInfoDto> GetOperationsToInterval(int wellId,
int intervalHoursTimestamp, int workBeginTimestamp);
DrillingAnalysis GetDrillingAnalysis(IEnumerable<DataSaubBase> dataSaubBases);
TelemetryAnalysis GetDrillingAnalysis(IEnumerable<DataSaubBase> dataSaubBases);
}
}

View File

@ -26,7 +26,7 @@ namespace AsbCloudDb.Model
public virtual DbSet<Well> Wells { get; set; }
public virtual DbSet<Report> Reports { get; set; }
public virtual DbSet<Operation> Operations { get; set; }
public virtual DbSet<DrillingAnalysis> DrillingAnalysis { get; set; }
public virtual DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; }
//public AsbCloudDbContext(string connectionString = "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
//{
@ -88,7 +88,7 @@ namespace AsbCloudDb.Model
.HasConstraintName("t_telemetry_user_t_telemetry_id_fk");
});
modelBuilder.Entity<DrillingAnalysis>(entity =>
modelBuilder.Entity<TelemetryAnalysis>(entity =>
{
entity.HasOne(d => d.Telemetry)
.WithMany(p => p.Analysis)

View File

@ -1,88 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace AsbCloudDb.Model
{
[Table("t_analysis"), Comment("События на скважине")]
public class DrillingAnalysis
{
[Key]
[Column("id")]
public int Id { get; set; }
[Column("id_telemetry")]
public int IdTelemetry { get; set; }
[Column("date", TypeName = "timestamp with time zone"), Comment("'2021-10-19 18:23:54+05'")]
public DateTime Date { get; set; }
[Column("unix_date", TypeName = "bigint"), Comment("Unix timestamp для Linq запросов с вычислением дат")]
public long UnixDate { get; set; }
[Column("duration"), Comment("Кол-во секунд после предыдущей операции")]
public int Duration { get; set; }
[Column("id_operation")]
public int? IdOperation { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdTelemetry))]
[InverseProperty(nameof(Model.Telemetry.Analysis))]
public virtual Telemetry Telemetry { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdOperation))]
[InverseProperty(nameof(Model.Operation.Analysis))]
public virtual Operation Operation { get; set; }
[Column("depth_changes"), Comment("Глубина забоя увеличивается")]
public bool IsDepthChanges { get; set; }
[Column("depth_not_changes"), Comment("Глубина забоя не увеличивается")]
public bool IsDepthNotChanges { get; set; }
[Column("bit_is_rising"), Comment("Долото поднимается")]
public bool IsBitRising { get; set; }
[Column("bit_goes_down"), Comment("Глубина спускается")]
public bool IsBitGoesDown { get; set; }
[Column("bit_stands_still"), Comment("Положение долота не изменяется")]
public bool IsBitStandsStill { get; set; }
[Column("bit_depth_less_20"), Comment("Положение долота меньше 20м")]
public bool IsBitDepthLess20 { get; set; }
[Column("block_is_rising"), Comment("Талевый блок поднимается")]
public bool IsBlockRising { get; set; }
[Column("block_goes_down"), Comment("Талевый блок спускается")]
public bool IsBlockGoesDown { get; set; }
[Column("block_stands_still"), Comment("Положение блок не изменяется")]
public bool IsBlockStandsStill { get; set; }
[Column("rotor_speed_less_3"), Comment("Обороты ротора ниже 3")]
public bool IsRotorSpeedLess3 { get; set; }
[Column("rotor_speed_more_3"), Comment("Обороты ротора выше 3")]
public bool IsRotorSpeedMore3 { get; set; }
[Column("pressure_less_20"), Comment("Давление менее 20")]
public bool IsPressureLess20 { get; set; }
[Column("pressure_more_20"), Comment("Давоение более 20")]
public bool IsPressureMore20 { get; set; }
[Column("hook_weight_not_changes"), Comment("Вес на крюке не меняется")]
public bool IsHookWeightNotChanges { get; set; }
[Column("hook_weight_less_3"), Comment("Вес на крюке менее 3т")]
public bool IsHookWeightLess3 { get; set; }
}
}

View File

@ -22,7 +22,7 @@ namespace AsbCloudDb.Model
DbSet<UserRole> UserRoles { get; set; }
DbSet<Report> Reports { get; set; }
DbSet<Operation> Operations { get; set; }
DbSet<DrillingAnalysis> DrillingAnalysis { get; set; }
DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; }
int SaveChanges();
int SaveChanges(bool acceptAllChangesOnSuccess);

View File

@ -14,7 +14,7 @@ namespace AsbCloudDb.Model
[Column("name"), Comment("Название операции")]
public string Name { get; set; }
[InverseProperty(nameof(DrillingAnalysis.Operation))]
public virtual ICollection<DrillingAnalysis> Analysis { get; set; }
[InverseProperty(nameof(TelemetryAnalysis.Operation))]
public virtual ICollection<TelemetryAnalysis> Analysis { get; set; }
}
}

View File

@ -43,7 +43,7 @@ namespace AsbCloudDb.Model
[InverseProperty(nameof(Event.Telemetry))]
public virtual ICollection<Event> Events { get; set; }
[InverseProperty(nameof(DrillingAnalysis.Telemetry))]
public virtual ICollection<DrillingAnalysis> Analysis { get; set; }
[InverseProperty(nameof(TelemetryAnalysis.Telemetry))]
public virtual ICollection<TelemetryAnalysis> Analysis { get; set; }
}
}

View File

@ -0,0 +1,83 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace AsbCloudDb.Model
{
[Table("t_telemetry_analysis"), Comment("События на скважине")]
public class TelemetryAnalysis
{
[Key]
[Column("id")]
public int Id { get; set; }
[Column("id_telemetry")]
public int IdTelemetry { get; set; }
[Column("id_operation")]
public int? IdOperation { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdTelemetry))]
[InverseProperty(nameof(Model.Telemetry.Analysis))]
public virtual Telemetry Telemetry { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdOperation))]
[InverseProperty(nameof(Model.Operation.Analysis))]
public virtual Operation Operation { get; set; }
[Column("unix_date", TypeName = "bigint"), Comment("Unix timestamp для Linq запросов с вычислением дат")]
public long UnixDate { get; set; }
[Column("duration_sec"), Comment("Кол-во секунд после предыдущей операции")]
public int Duration { get; set; }
[Column("well_depth"), Comment("Глубина, на которой закончилась операция")]
public double WellDepth { get; set; }
[Column("is_well_depth_increasing"), Comment("Глубина забоя увеличивается")]
public bool IsWellDepthIncreasing { get; set; }
[Column("is_well_depth_decreasing"), Comment("Глубина забоя не увеличивается")]
public bool IsWellDepthDecreasing { get; set; }
[Column("is_bit_position_increasing"), Comment("Долото спускается")]
public bool IsBitPositionIncreasing { get; set; }
[Column("is_bit_position_decreasing"), Comment("Долото поднимается")]
public bool IsBitPositionDecreasing { get; set; }
[Column("is_bit_posision_lt_20"), Comment("Положение долота меньше 20м")]
public bool IsBitDepthLess20 { get; set; }
[Column("is_block_posision_incresing"), Comment("Талевый блок спускается")]
public bool IsBlockPositionIncreasing { get; set; }
[Column("is_block_posision_decresing"), Comment("Талевый блок поднимается")]
public bool IsBlockPositionDecreasing { get; set; }
[Column("is_rotor_speed_lt_3"), Comment("Обороты ротора ниже 3")]
public bool IsRotorSpeedLt3 { get; set; }
[Column("is_rotor_speed_gt_3"), Comment("Обороты ротора выше 3")]
public bool IsRotorSpeedGt3 { get; set; }
[Column("is_pressure_lt_20"), Comment("Давление менее 20")]
public bool IsPressureLt20 { get; set; }
[Column("is_pressure_gt_20"), Comment("Давоение более 20")]
public bool IsPressureGt20 { get; set; }
[Column("is_hook_weight_not_changes"), Comment("Вес на крюке не меняется")]
public bool IsHookWeightNotChanges { get; set; }
[Column("is_hook_weight_lt_3"), Comment("Вес на крюке менее 3т")]
public bool IsHookWeightLt3 { get; set; }
}
}

View File

@ -29,6 +29,7 @@ namespace AsbCloudInfrastructure
services.AddTransient<IAuthService, AuthService>();
services.AddTransient<IWellService, WellService>();
services.AddTransient<IClusterService, ClusterService>();
services.AddTransient<ITelemetryService, TelemetryService>();
services.AddTransient<IDataService, DataService>();
services.AddTransient<IMessageService, MessageService>();

View File

@ -79,7 +79,7 @@ namespace AsbCloudInfrastructure.Services
return wellDepthToIntervalData;
}
public IEnumerable<OperationDurationDto> GetOperationsSummary(int wellId,
public IEnumerable<OperationDurationDto> GetOperationsSummary(int wellId,
DateTime begin = default, DateTime end = default)
{
var telemetry = telemetryService.GetTelemetryByWellId(wellId);
@ -87,9 +87,12 @@ namespace AsbCloudInfrastructure.Services
if (telemetry is null)
return null;
var operations = (from a in db.DrillingAnalysis
var unixBegin = (begin - new DateTime(1970, 1, 1)).TotalSeconds;
var unixEnd = (end - new DateTime(1970, 1, 1)).TotalSeconds;
var operations = (from a in db.TelemetryAnalysis
where a.IdTelemetry == telemetry.Id &&
a.Date > begin && a.Date < end &&
a.UnixDate > unixBegin && a.UnixDate < unixEnd &&
a.IdOperation != null
join o in db.Operations on a.IdOperation equals o.Id
group a by new { a.IdOperation, o.Name } into g
@ -115,7 +118,7 @@ namespace AsbCloudInfrastructure.Services
var timezoneOffset = telemetryService.GetTimezoneOffsetByTelemetryId(telemetry.Id);
var operations = (from a in db.DrillingAnalysis
var operations = (from a in db.TelemetryAnalysis
where a.IdTelemetry == telemetry.Id &&
a.IdOperation != null
join o in db.Operations on a.IdOperation equals o.Id
@ -125,14 +128,14 @@ namespace AsbCloudInfrastructure.Services
o.Name } into g
select new
{
IntervalStart = g.Min(d => d.Date).Date,
IntervalStart = g.Min(d => d.UnixDate),
OperationName = g.Key.Name,
OperationsDuration = g.Sum(an => an.Duration)
}).ToList();
var operationsGroupedByInterval = operations.GroupBy(op => op.IntervalStart)
.Select(o => new OperationInfoDto {
IntervalBegin = o.Key,
IntervalBegin = DateTimeOffset.FromUnixTimeSeconds(o.Key),
Operations = o.Select(opr => new OperationDetailsDto {
OperationName = opr.OperationName,
Duration = opr.OperationsDuration
@ -143,7 +146,7 @@ namespace AsbCloudInfrastructure.Services
return operationsGroupedByInterval;
}
public DrillingAnalysis GetDrillingAnalysis(IEnumerable<DataSaubBase> dataSaubBases)
public TelemetryAnalysis GetDrillingAnalysis(IEnumerable<DataSaubBase> dataSaubBases)
{
var lastSaubDate = dataSaubBases.Last().Date;
@ -177,27 +180,25 @@ namespace AsbCloudInfrastructure.Services
var IsBlockGoesDown = LinearFunctionCalculator.IsValueGoesUp(blockPositionChangingIndex, 0.0001);
var IsBlockStandsStill = LinearFunctionCalculator.IsValueNotChanges(blockPositionChangingIndex, (0.0001, -0.0001));
var drillingAnalysis = new DrillingAnalysis
var drillingAnalysis = new TelemetryAnalysis
{
IdTelemetry = dataSaubBases.First().IdTelemetry,
Date = lastSaubDate,
UnixDate = (long)(lastSaubDate - new DateTime(1970,1,1,0,0,0)).TotalSeconds,
UnixDate = (long)(lastSaubDate - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds,
Duration = (int)(dataSaubBases.Last().Date - dataSaubBases.ElementAt(dataSaubBases.Count() - 2).Date).TotalSeconds,
IsDepthChanges = LinearFunctionCalculator.IsValueChanges(wellDepthChangingIndex, (0.0001, -0.0001)),
IsDepthNotChanges = LinearFunctionCalculator.IsValueNotChanges(wellDepthChangingIndex, (0.0001, -0.0001)),
IsBitRising = LinearFunctionCalculator.IsValueGoesDown(bitPositionChangingIndex, -0.0001),
IsBitGoesDown = LinearFunctionCalculator.IsValueGoesUp(bitPositionChangingIndex, 0.0001),
IsBitStandsStill = LinearFunctionCalculator.IsValueNotChanges(bitPositionChangingIndex, (0.0001, -0.0001)),
WellDepth = (double)dataSaubBases.Last().WellDepth,
IsWellDepthDecreasing = LinearFunctionCalculator.IsValueGoesDown(wellDepthChangingIndex, -0.0001),
IsWellDepthIncreasing = LinearFunctionCalculator.IsValueGoesUp(wellDepthChangingIndex, 0.0001),
IsBitPositionDecreasing = LinearFunctionCalculator.IsValueGoesDown(bitPositionChangingIndex, -0.0001),
IsBitPositionIncreasing = LinearFunctionCalculator.IsValueGoesUp(bitPositionChangingIndex, 0.0001),
IsBitDepthLess20 = LinearFunctionCalculator.IsAverageLessThanBound(saubBitDepths, 20),
IsBlockRising = LinearFunctionCalculator.IsValueGoesDown(blockPositionChangingIndex, -0.0001),
IsBlockGoesDown = LinearFunctionCalculator.IsValueGoesUp(blockPositionChangingIndex, 0.0001),
IsBlockStandsStill = LinearFunctionCalculator.IsValueNotChanges(blockPositionChangingIndex, (0.0001, -0.0001)),
IsRotorSpeedLess3 = LinearFunctionCalculator.IsAverageLessThanBound(saubRotorSpeeds, 3),
IsRotorSpeedMore3 = LinearFunctionCalculator.IsAverageMoreThanBound(saubRotorSpeeds, 3),
IsPressureLess20 = LinearFunctionCalculator.IsAverageLessThanBound(saubPressures, 20),
IsPressureMore20 = LinearFunctionCalculator.IsAverageMoreThanBound(saubPressures, 20),
IsBlockPositionDecreasing = LinearFunctionCalculator.IsValueGoesDown(blockPositionChangingIndex, -0.0001),
IsBlockPositionIncreasing = LinearFunctionCalculator.IsValueGoesUp(blockPositionChangingIndex, 0.0001),
IsRotorSpeedLt3 = LinearFunctionCalculator.IsAverageLessThanBound(saubRotorSpeeds, 3),
IsRotorSpeedGt3 = LinearFunctionCalculator.IsAverageMoreThanBound(saubRotorSpeeds, 3),
IsPressureLt20 = LinearFunctionCalculator.IsAverageLessThanBound(saubPressures, 20),
IsPressureGt20 = LinearFunctionCalculator.IsAverageMoreThanBound(saubPressures, 20),
IsHookWeightNotChanges = LinearFunctionCalculator.IsValueNotChanges(hookWeightChangingIndex, (0.0001, -0.0001)),
IsHookWeightLess3 = LinearFunctionCalculator.IsAverageLessThanBound(saubHookWeights, 3),
IsHookWeightLt3 = LinearFunctionCalculator.IsAverageLessThanBound(saubHookWeights, 3),
IdOperation = 1
};
@ -205,37 +206,5 @@ namespace AsbCloudInfrastructure.Services
return drillingAnalysis;
}
private static double GetAForLinearFormula(IEnumerable<(double?, double)> rawData)
{
var (xSum, ySum, xySum, x2Sum) = GetFormulaVariables(rawData);
return (xSum * ySum - rawData.Count() * xySum) /
(xSum * xSum - rawData.Count() * x2Sum);
}
private static double GetBForLinearFormula(IEnumerable<(double?, double)> rawData)
{
var (xSum, ySum, xySum, x2Sum) = GetFormulaVariables(rawData);
return (xSum * xySum - x2Sum * ySum) /
(xSum * xSum - rawData.Count() * x2Sum);
}
private static (double xSum, double ySum, double xySum, double x2Sum) GetFormulaVariables(
IEnumerable<(double? value, double timestamp)> rawData)
{
var data = rawData.Select((d) => new
{
X = d.timestamp,
Y = d.value ?? 0.0
});
var xSum = data.Sum(d => d.X);
var ySum = data.Sum(d => d.Y);
var xySum = data.Sum(d => d.X * d.Y);
var x2Sum = data.Sum(d => d.X * d.X);
return (xSum, ySum, xySum, x2Sum);
}
}
}

View File

@ -108,7 +108,7 @@ namespace AsbCloudInfrastructure.Services
var drillingAnalysis = analyticsService.GetDrillingAnalysis(dataSaubs);
db.DrillingAnalysis.Add(drillingAnalysis);
db.TelemetryAnalysis.Add(drillingAnalysis);
}
}

View File

@ -25,19 +25,15 @@ namespace AsbCloudInfrastructure.Services
return (double)result;
}
public static bool IsValueChanges(double value,
(double upperBound, double lowerBound) bounds) =>
value >= bounds.upperBound || value <= bounds.lowerBound;
public static bool IsValueNotChanges(double value,
(double upperBound, double lowerBound) bounds) =>
value < bounds.upperBound && value > bounds.lowerBound;
public static bool IsValueGoesUp(double value, double bound) =>
value >= bound;
value > bound;
public static bool IsValueGoesDown(double value, double bound) =>
value <= bound;
value < bound;
public static bool IsAverageLessThanBound(IEnumerable<(double Value, double TotalSeconds)> values,
double bound) =>

View File

@ -7,6 +7,6 @@ namespace AsbCloudInfrastructure.Services
{
public int Order { get; set; }
public Operation Operation { get; set; }
public Func<DrillingAnalysis, bool> Detect { get; set; }
public Func<TelemetryAnalysis, bool> Detect { get; set; }
}
}

View File

@ -18,7 +18,8 @@ namespace AsbCloudInfrastructure.Services
Operation = operations.FirstOrDefault(o => o.Name.Equals("На поверхности")),
Detect = (data) =>
{
return data.IsDepthNotChanges && data.IsBitDepthLess20 && data.IsHookWeightLess3;
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing
&& data.IsBitDepthLess20 && data.IsHookWeightLt3;
}
},
new OperationDetector
@ -27,8 +28,10 @@ namespace AsbCloudInfrastructure.Services
Operation = operations.FirstOrDefault(o => o.Name.Equals("Удержание в клиньях")),
Detect = (data) =>
{
return data.IsDepthNotChanges && data.IsBitStandsStill &&
data.IsBlockStandsStill && data.IsHookWeightLess3;
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
!data.IsBitPositionIncreasing && !data.IsBitPositionDecreasing &&
data.IsBlockPositionDecreasing && !data.IsBlockPositionIncreasing &&
data.IsHookWeightLt3;
}
},
new OperationDetector
@ -37,8 +40,9 @@ namespace AsbCloudInfrastructure.Services
Operation = operations.FirstOrDefault(o => o.Name.Equals("Подъем с проработкой")),
Detect = (data) =>
{
return data.IsDepthNotChanges && data.IsBitRising &&
data.IsBlockRising && data.IsRotorSpeedMore3 && data.IsPressureMore20;
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
data.IsBitPositionDecreasing && data.IsBlockPositionDecreasing &&
data.IsRotorSpeedGt3 && data.IsPressureGt20;
}
},
new OperationDetector
@ -47,8 +51,9 @@ namespace AsbCloudInfrastructure.Services
Operation = operations.FirstOrDefault(o => o.Name.Equals("Спуск с проработкой")),
Detect = (data) =>
{
return data.IsDepthNotChanges && data.IsBitGoesDown &&
data.IsBlockGoesDown && data.IsRotorSpeedMore3 && data.IsPressureMore20;
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
data.IsBitPositionIncreasing && data.IsBitPositionIncreasing &&
data.IsRotorSpeedGt3 && data.IsPressureGt20;
}
},
new OperationDetector
@ -57,8 +62,9 @@ namespace AsbCloudInfrastructure.Services
Operation = operations.FirstOrDefault(o => o.Name.Equals("Подъем с промывкой")),
Detect = (data) =>
{
return data.IsDepthNotChanges && data.IsBitRising &&
data.IsBlockRising && data.IsRotorSpeedLess3 && data.IsPressureMore20;
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
data.IsBitPositionDecreasing && data.IsBitPositionDecreasing &&
data.IsRotorSpeedLt3 && data.IsPressureGt20;
}
},
new OperationDetector
@ -67,8 +73,9 @@ namespace AsbCloudInfrastructure.Services
Operation = operations.FirstOrDefault(o => o.Name.Equals("Спуск с промывкой")),
Detect = (data) =>
{
return data.IsDepthNotChanges && data.IsBitGoesDown &&
data.IsBlockGoesDown && data.IsRotorSpeedLess3 && data.IsPressureMore20;
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
data.IsBitPositionIncreasing && data.IsBlockPositionIncreasing &&
data.IsRotorSpeedLt3 && data.IsPressureGt20;
}
},
new OperationDetector
@ -77,8 +84,9 @@ namespace AsbCloudInfrastructure.Services
Operation = operations.FirstOrDefault(o => o.Name.Equals("Спуск в скважину")),
Detect = (data) =>
{
return data.IsDepthNotChanges && data.IsBitGoesDown &&
data.IsBlockGoesDown && data.IsRotorSpeedLess3 && data.IsPressureLess20;
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
data.IsBitPositionIncreasing && data.IsBlockPositionIncreasing &&
data.IsRotorSpeedLt3 && data.IsPressureLt20;
}
},
new OperationDetector
@ -87,8 +95,9 @@ namespace AsbCloudInfrastructure.Services
Operation = operations.FirstOrDefault(o => o.Name.Equals("Спуск с вращением")),
Detect = (data) =>
{
return data.IsDepthNotChanges && data.IsBitGoesDown &&
data.IsBlockGoesDown && data.IsRotorSpeedMore3 && data.IsPressureLess20;
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
data.IsBitPositionIncreasing && data.IsBlockPositionIncreasing &&
data.IsRotorSpeedGt3 && data.IsPressureLt20;
}
},
new OperationDetector
@ -97,8 +106,9 @@ namespace AsbCloudInfrastructure.Services
Operation = operations.FirstOrDefault(o => o.Name.Equals("Подъем из скважины")),
Detect = (data) =>
{
return data.IsDepthNotChanges && data.IsBitRising &&
data.IsBlockRising && data.IsRotorSpeedLess3 && data.IsPressureLess20;
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
data.IsBitPositionDecreasing && data.IsBlockPositionDecreasing &&
data.IsRotorSpeedLt3 && data.IsPressureLt20;
}
},
new OperationDetector
@ -107,8 +117,9 @@ namespace AsbCloudInfrastructure.Services
Operation = operations.FirstOrDefault(o => o.Name.Equals("Подъем с вращением")),
Detect = (data) =>
{
return data.IsDepthNotChanges && data.IsBitRising &&
data.IsBlockRising && data.IsRotorSpeedMore3 && data.IsPressureLess20;
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
data.IsBitPositionDecreasing && data.IsBlockPositionDecreasing &&
data.IsRotorSpeedGt3 && data.IsPressureLt20;
}
},
new OperationDetector
@ -117,8 +128,10 @@ namespace AsbCloudInfrastructure.Services
Operation = operations.FirstOrDefault(o => o.Name.Equals("Промывка в покое")),
Detect = (data) =>
{
return data.IsDepthNotChanges && data.IsBitStandsStill &&
data.IsBlockStandsStill && data.IsRotorSpeedLess3 && data.IsPressureMore20;
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
!data.IsBitPositionDecreasing && !data.IsBitPositionIncreasing &&
!data.IsBlockPositionDecreasing && !data.IsBlockPositionIncreasing &&
data.IsRotorSpeedLt3 && data.IsPressureGt20;
}
},
new OperationDetector
@ -127,8 +140,10 @@ namespace AsbCloudInfrastructure.Services
Operation = operations.FirstOrDefault(o => o.Name.Equals("Промывка с вращением")),
Detect = (data) =>
{
return data.IsDepthNotChanges && data.IsBitStandsStill &&
data.IsBlockStandsStill && data.IsRotorSpeedMore3 && data.IsPressureMore20;
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
!data.IsBitPositionDecreasing && !data.IsBitPositionIncreasing &&
!data.IsBlockPositionDecreasing && !data.IsBlockPositionIncreasing &&
data.IsRotorSpeedGt3 && data.IsPressureGt20;
}
},
new OperationDetector
@ -137,8 +152,10 @@ namespace AsbCloudInfrastructure.Services
Operation = operations.FirstOrDefault(o => o.Name.Equals("Неподвижное состояние")),
Detect = (data) =>
{
return data.IsDepthNotChanges && data.IsBitStandsStill && data.IsBlockStandsStill
&& data.IsRotorSpeedLess3 && data.IsPressureLess20 && data.IsHookWeightNotChanges;
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
!data.IsBitPositionDecreasing && !data.IsBitPositionIncreasing &&
!data.IsBlockPositionDecreasing && !data.IsBlockPositionIncreasing &&
data.IsRotorSpeedLt3 && data.IsPressureLt20 && data.IsHookWeightNotChanges;
}
},
new OperationDetector
@ -147,8 +164,10 @@ namespace AsbCloudInfrastructure.Services
Operation = operations.FirstOrDefault(o => o.Name.Equals("Вращение без циркуляции")),
Detect = (data) =>
{
return data.IsDepthNotChanges && data.IsBitStandsStill &&
data.IsBlockStandsStill && data.IsRotorSpeedMore3 && data.IsPressureLess20;
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
!data.IsBitPositionDecreasing && !data.IsBitPositionIncreasing &&
!data.IsBlockPositionDecreasing && !data.IsBlockPositionIncreasing &&
data.IsRotorSpeedGt3 && data.IsPressureLt20;
}
},
new OperationDetector
@ -160,7 +179,7 @@ namespace AsbCloudInfrastructure.Services
};
}
public Operation DetectOperation(DrillingAnalysis data) =>
public Operation DetectOperation(TelemetryAnalysis data) =>
detectors.OrderBy(d => d.Order).First(o => o.Detect(data)).Operation
?? new Operation { Id = 1, Name = "Невозможно определить операцию" };
}

View File

@ -11,11 +11,11 @@ using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services
{
public class СlusterService : IClusterService
public class ClusterService : IClusterService
{
private readonly IAsbCloudDbContext db;
public СlusterService(IAsbCloudDbContext db)
public ClusterService(IAsbCloudDbContext db)
{
this.db = db;
}

View File

@ -38,7 +38,7 @@ namespace AsbCloudWebApi.Tests.ControllersTests
.Returns(true);
controller = new AnalyticsController(analyticsService.Object,
wellService.Object);
wellService.Object);
var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
{
@ -129,7 +129,7 @@ namespace AsbCloudWebApi.Tests.ControllersTests
var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
{
new Claim("idCustomer", "1"),
new Claim("idCustomer", "1"),
}, "mock"));
newControllerInstance.ControllerContext = new ControllerContext()

View File

@ -48,7 +48,7 @@ namespace AsbCloudWebApi.Controllers
/// </summary>
/// <param name="clusterId"></param>
/// <returns></returns>
[HttpGet("{clusterId}")]
[HttpGet("{clusterId}/Analysis")]
[ProducesResponseType(typeof(IEnumerable<ClusterAnalysisDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetAnalysis(int clusterId)
{