2022-12-28 17:38:53 +05:00
|
|
|
|
using AsbCloudApp.Requests;
|
2022-10-06 13:49:20 +05:00
|
|
|
|
using AsbCloudDb.Model;
|
2022-11-15 17:44:48 +05:00
|
|
|
|
using AsbCloudInfrastructure;
|
2022-12-28 17:38:53 +05:00
|
|
|
|
using AsbCloudInfrastructure.Repository;
|
|
|
|
|
using Microsoft.Extensions.Caching.Memory;
|
2022-05-05 10:06:15 +05:00
|
|
|
|
using System;
|
2022-12-30 15:24:48 +05:00
|
|
|
|
using System.Linq;
|
2022-10-06 13:49:20 +05:00
|
|
|
|
using System.Threading;
|
2021-10-26 17:22:32 +05:00
|
|
|
|
|
|
|
|
|
namespace ConsoleApp1
|
2021-04-02 17:28:07 +05:00
|
|
|
|
{
|
|
|
|
|
class Program
|
2021-10-03 20:08:17 +05:00
|
|
|
|
{
|
2022-10-06 13:49:20 +05:00
|
|
|
|
private static AsbCloudDbContext db = ServiceFactory.Context;
|
2022-11-15 17:44:48 +05:00
|
|
|
|
|
2022-10-06 13:49:20 +05:00
|
|
|
|
// use ServiceFactory to make services
|
|
|
|
|
static void Main(/*string[] args*/)
|
|
|
|
|
{
|
2022-11-15 17:44:48 +05:00
|
|
|
|
DependencyInjection.MapsterSetup();
|
|
|
|
|
var sw = System.Diagnostics.Stopwatch.StartNew();
|
2022-10-11 17:04:26 +05:00
|
|
|
|
|
2022-12-30 15:24:48 +05:00
|
|
|
|
var idTelemetry = 5;
|
2022-10-11 17:04:26 +05:00
|
|
|
|
|
2022-12-30 15:24:48 +05:00
|
|
|
|
var query = db.Set<TelemetryDataSaub>()
|
|
|
|
|
.Where(t => t.IdTelemetry == idTelemetry)
|
|
|
|
|
.Where(t => t.BlockPosition > 0.0001)
|
|
|
|
|
.Where(t => t.WellDepth > 0.0001)
|
|
|
|
|
.Where(t => t.WellDepth - t.BitDepth < 0.01)
|
|
|
|
|
.GroupBy(t => new { H = t.DateTime.Hour, W = Math.Truncate(t.WellDepth!.Value) })
|
|
|
|
|
.Select(g => new
|
|
|
|
|
{
|
|
|
|
|
Count = g.Count(),
|
|
|
|
|
|
|
|
|
|
DateMin = g.Min(t => t.DateTime),
|
|
|
|
|
DateMax = g.Max(t => t.DateTime),
|
|
|
|
|
|
|
|
|
|
WellDepthMin = g.Min(t => t.WellDepth),
|
|
|
|
|
WellDepthMax = g.Max(t => t.WellDepth),
|
|
|
|
|
|
|
|
|
|
Pressure = g.Average(t => t.Pressure),
|
|
|
|
|
PressureSp = g.Average(t => t.PressureSp),
|
|
|
|
|
PressureSpRotor = g.Average(t => t.PressureSpRotor),
|
|
|
|
|
PressureSpSlide = g.Average(t => t.PressureSpSlide),
|
|
|
|
|
PressureIdle = g.Average(t => t.PressureIdle),
|
|
|
|
|
PressureDeltaLimitMax = g.Average(t => t.PressureDeltaLimitMax),
|
|
|
|
|
|
|
|
|
|
AxialLoad = g.Average(t => t.AxialLoad),
|
|
|
|
|
AxialLoadSp = g.Average(t => t.AxialLoadSp),
|
|
|
|
|
AxialLoadLimitMax = g.Average(t => t.AxialLoadLimitMax),
|
|
|
|
|
|
|
|
|
|
RotorTorque = g.Average(t => t.RotorTorque),
|
|
|
|
|
RotorTorqueSp = g.Average(t => t.RotorTorqueSp),
|
|
|
|
|
RotorTorqueIdle = g.Average(t => t.RotorTorqueIdle),
|
|
|
|
|
|
|
|
|
|
BlockSpeed = g.Average(t => t.BlockSpeed),
|
|
|
|
|
BlockSpeedSp = g.Average(t => t.BlockSpeedSp),
|
|
|
|
|
BlockSpeedSpRotor = g.Average(t => t.BlockSpeedSpRotor),
|
|
|
|
|
BlockSpeedSpSlide = g.Average(t => t.BlockSpeedSpSlide),
|
|
|
|
|
})
|
|
|
|
|
.Where(s => s.WellDepthMin != s.WellDepthMax)
|
|
|
|
|
.Where(s => s.Count > 3)
|
|
|
|
|
.OrderBy(t => t.DateMin);
|
|
|
|
|
var data = query.ToArray();
|
2022-11-15 17:44:48 +05:00
|
|
|
|
sw.Stop();
|
|
|
|
|
Console.WriteLine($"total time: {sw.ElapsedMilliseconds} ms");
|
2022-12-30 15:24:48 +05:00
|
|
|
|
var count = data.Length;
|
2022-10-11 09:02:53 +05:00
|
|
|
|
Console.ReadLine();
|
2022-10-06 13:49:20 +05:00
|
|
|
|
}
|
2022-06-17 13:20:48 +05:00
|
|
|
|
}
|
2021-04-02 17:28:07 +05:00
|
|
|
|
}
|