forked from ddrilling/AsbCloudServer
BIG. Add timescaleDB into DB.
Adapt contect to use hypertables. Refactor TelemetryDataBaseService to avoid duplicate keys and try to save as more as posible
This commit is contained in:
parent
4d9dc72bd4
commit
864d851b6a
@ -2,7 +2,7 @@
|
||||
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
public interface ITelemetryData: IId
|
||||
public interface ITelemetryData
|
||||
{
|
||||
int IdTelemetry { get; set; }
|
||||
DateTime Date { get; set; }
|
||||
|
@ -7,8 +7,6 @@ namespace AsbCloudApp.Data
|
||||
/// </summary>
|
||||
public class TelemetryDataSaubDto : ITelemetryData
|
||||
{
|
||||
public int Id { get; set; }
|
||||
//[JsonPropertyName("date")]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -8,7 +8,6 @@ namespace AsbCloudApp.Data
|
||||
{
|
||||
public class TelemetryDataSpinDto : ITelemetryData
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int IdTelemetry { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public float? TopDriveSpeed { get; set; }
|
||||
|
2763
AsbCloudDb/Migrations/20211112073708_Replace_PK_of_telemetryData_to_compositeKey.Designer.cs
generated
Normal file
2763
AsbCloudDb/Migrations/20211112073708_Replace_PK_of_telemetryData_to_compositeKey.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,92 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class Replace_PK_of_telemetryData_to_compositeKey : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_t_telemetry_data_spin",
|
||||
table: "t_telemetry_data_spin");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_t_telemetry_data_spin_id_telemetry",
|
||||
table: "t_telemetry_data_spin");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_t_telemetry_data_saub",
|
||||
table: "t_telemetry_data_saub");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_t_telemetry_data_saub_id_telemetry",
|
||||
table: "t_telemetry_data_saub");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "id",
|
||||
table: "t_telemetry_data_spin");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "id",
|
||||
table: "t_telemetry_data_saub");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_t_telemetry_data_spin",
|
||||
table: "t_telemetry_data_spin",
|
||||
columns: new[] { "id_telemetry", "date" });
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_t_telemetry_data_saub",
|
||||
table: "t_telemetry_data_saub",
|
||||
columns: new[] { "id_telemetry", "date" });
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_t_telemetry_data_spin",
|
||||
table: "t_telemetry_data_spin");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_t_telemetry_data_saub",
|
||||
table: "t_telemetry_data_saub");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "id",
|
||||
table: "t_telemetry_data_spin",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "id",
|
||||
table: "t_telemetry_data_saub",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_t_telemetry_data_spin",
|
||||
table: "t_telemetry_data_spin",
|
||||
column: "id");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_t_telemetry_data_saub",
|
||||
table: "t_telemetry_data_saub",
|
||||
column: "id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_telemetry_data_spin_id_telemetry",
|
||||
table: "t_telemetry_data_spin",
|
||||
column: "id_telemetry");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_telemetry_data_saub_id_telemetry",
|
||||
table: "t_telemetry_data_saub",
|
||||
column: "id_telemetry");
|
||||
}
|
||||
}
|
||||
}
|
@ -893,11 +893,14 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.TelemetryDataSaub", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
b.Property<int>("IdTelemetry")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id_telemetry");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date")
|
||||
.HasComment("'2021-10-19 18:23:54+05'");
|
||||
|
||||
b.Property<float?>("AxialLoad")
|
||||
.HasColumnType("real")
|
||||
@ -959,11 +962,6 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("block_speed_sp_slide")
|
||||
.HasComment("Талевый блок. Задание скорости для режима слайда");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date")
|
||||
.HasComment("'2021-10-19 18:23:54+05'");
|
||||
|
||||
b.Property<float?>("Flow")
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("flow")
|
||||
@ -1004,10 +1002,6 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("id_feed_regulator")
|
||||
.HasComment("Текущий критерий бурения");
|
||||
|
||||
b.Property<int>("IdTelemetry")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_telemetry");
|
||||
|
||||
b.Property<int?>("IdUser")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_user")
|
||||
@ -1088,9 +1082,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("well_depth")
|
||||
.HasComment("Глубина забоя");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IdTelemetry");
|
||||
b.HasKey("IdTelemetry", "Date");
|
||||
|
||||
b.ToTable("t_telemetry_data_saub");
|
||||
|
||||
@ -1100,11 +1092,14 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.TelemetryDataSpin", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
b.Property<int>("IdTelemetry")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id_telemetry");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date")
|
||||
.HasComment("'2021-10-19 18:23:54+05'");
|
||||
|
||||
b.Property<float?>("BreakAngleK")
|
||||
.HasColumnType("real")
|
||||
@ -1116,20 +1111,11 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("break_angle_left")
|
||||
.HasComment("Угол торможения влево при работе по моменту");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date")
|
||||
.HasComment("'2021-10-19 18:23:54+05'");
|
||||
|
||||
b.Property<float?>("EncoderResolution")
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("encoder_resolution ")
|
||||
.HasComment(" Разрешение энкодера");
|
||||
|
||||
b.Property<int>("IdTelemetry")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_telemetry");
|
||||
|
||||
b.Property<short?>("Mode")
|
||||
.HasColumnType("smallint")
|
||||
.HasColumnName("mode")
|
||||
@ -1409,9 +1395,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("w2810")
|
||||
.HasComment(" автоматический сброс блокировки");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IdTelemetry");
|
||||
b.HasKey("IdTelemetry", "Date");
|
||||
|
||||
b.ToTable("t_telemetry_data_spin");
|
||||
|
||||
@ -2431,16 +2415,16 @@ namespace AsbCloudDb.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.User", "Author")
|
||||
b.HasOne("AsbCloudDb.Model.User", "User")
|
||||
.WithMany("FileMarks")
|
||||
.HasForeignKey("IdUser")
|
||||
.HasConstraintName("t_user_t_file_mark_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Author");
|
||||
|
||||
b.Navigation("FileInfo");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Measure", b =>
|
||||
|
@ -105,6 +105,8 @@ namespace AsbCloudDb.Model
|
||||
.HasForeignKey(d => d.IdTelemetry)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("t_telemetry_data_saub_t_telemetry_id_fk");
|
||||
|
||||
entity.HasKey(nameof(ITelemetryData.IdTelemetry), nameof(ITelemetryData.Date));
|
||||
});
|
||||
|
||||
modelBuilder.Entity<TelemetryDataSpin>(entity =>
|
||||
@ -114,6 +116,8 @@ namespace AsbCloudDb.Model
|
||||
.HasForeignKey(d => d.IdTelemetry)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("t_telemetry_data_spin_t_telemetry_id_fk");
|
||||
|
||||
entity.HasKey(nameof(ITelemetryData.IdTelemetry), nameof(ITelemetryData.Date));
|
||||
});
|
||||
|
||||
modelBuilder.Entity<TelemetryMessage>(entity =>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace AsbCloudDb.Model
|
||||
{
|
||||
public interface ITelemetryData: IId
|
||||
public interface ITelemetryData
|
||||
{
|
||||
int IdTelemetry { get; set; }
|
||||
DateTime Date { get; set; }
|
||||
|
@ -11,10 +11,6 @@ namespace AsbCloudDb.Model
|
||||
[Table("t_telemetry_data_saub"), Comment("набор основных данных по SAUB")]
|
||||
public partial class TelemetryDataSaub : ITelemetryData
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("id_telemetry")]
|
||||
public int IdTelemetry { get; set; }
|
||||
|
||||
|
@ -9,10 +9,6 @@ namespace AsbCloudDb.Model
|
||||
[Table("t_telemetry_data_spin"), Comment("набор основных данных по SpinMaster")]
|
||||
public class TelemetryDataSpin : ITelemetryData
|
||||
{
|
||||
[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'")]
|
||||
|
@ -16,7 +16,8 @@ dotnet ef migrations remvoe <MigrationName> --project AsbCloudDb
|
||||
|
||||
#backup
|
||||
```
|
||||
sudo -u postgres pg_dump -U postgres postgres -W | gzip > 2021-09-27_dump.sql.gz
|
||||
sudo -u postgres pg_dump -Fc -U postgres postgres -W | gzip > 2021-09-27_dump.sql.gz
|
||||
sudo -u postgres pg_dump -Fc -U postgres postgres -W > 2021-11-13_dump.sql.gz
|
||||
```
|
||||
|
||||
#restore
|
||||
|
8
AsbCloudDb/UsefulQueries/TimescaleDB.sql
Normal file
8
AsbCloudDb/UsefulQueries/TimescaleDB.sql
Normal file
@ -0,0 +1,8 @@
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
|
||||
SELECT create_hypertable(
|
||||
'tsd.t_tele',
|
||||
'time',
|
||||
'id_t',
|
||||
1500,
|
||||
chunk_time_interval => interval '92 day');
|
48
AsbCloudDb/install pg timescale.md
Normal file
48
AsbCloudDb/install pg timescale.md
Normal file
@ -0,0 +1,48 @@
|
||||
# install postgresql
|
||||
```
|
||||
sudo apt install postgresql-common
|
||||
sudo sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
|
||||
sudo apt install postgresql-14
|
||||
```
|
||||
# install timescaledb
|
||||
|
||||
Add repo:
|
||||
```
|
||||
sudo sh -c "echo 'deb [signed-by=/usr/share/keyrings/timescale.keyring] https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -c -s) main' > /etc/apt/sources.list.d/timescaledb.list"
|
||||
wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/timescale.keyring
|
||||
sudo apt-get update
|
||||
sudo apt install timescaledb-2-postgresql-14
|
||||
```
|
||||
|
||||
## config timescale
|
||||
Run configurator/installer
|
||||
```
|
||||
sudo service postgresql stop
|
||||
sudo timescaledb-tune
|
||||
```
|
||||
|
||||
## change postgres default password
|
||||
```
|
||||
sudo service postgresql start
|
||||
sudo -u postgres psql postgres -p 5499
|
||||
alter user postgres with password 'q';
|
||||
```
|
||||
|
||||
## External access to postgres
|
||||
|
||||
### in config file
|
||||
**/etc/postgresql/14/main/postgresql.conf**
|
||||
|
||||
allow external access - replace `listen_addresses = 'local'` to `listen_addresses = '*'`
|
||||
|
||||
change port - replace `port = '5433'` to `port = '5499'`
|
||||
|
||||
### in config file
|
||||
**/etc/postgresql/14/main/pg_hba.conf**
|
||||
|
||||
Add line to allow your IP:
|
||||
`host all all <your ip>/32 scram-sha-256`
|
||||
|
||||
### check connection:
|
||||
`psql -h <server ip> -p 5499 -d postgres -U postgres -W`
|
||||
|
@ -90,7 +90,7 @@ namespace AsbSaubReport
|
||||
orderby item.Date
|
||||
select new DataSaubReport
|
||||
{
|
||||
Id = item.Id,
|
||||
//Id = item.Id,
|
||||
Date = item.Date,
|
||||
Mode = item.Mode,
|
||||
WellDepth = item.WellDepth,
|
||||
|
@ -42,7 +42,6 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
where d.IdTelemetry == telemetryId
|
||||
select new
|
||||
{
|
||||
d.Id,
|
||||
d.WellDepth,
|
||||
d.BitDepth,
|
||||
d.Date
|
||||
@ -51,7 +50,7 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
var m = (int)Math.Round(1d * depthToTimeData.Count() / 2048);
|
||||
|
||||
if (m > 1)
|
||||
depthToTimeData = depthToTimeData.Where(d => d.Id % m == 0);
|
||||
depthToTimeData = depthToTimeData.Where((d, i) => (((d.Date.DayOfYear * 24 + d.Date.Hour) * 60 + d.Date.Minute) * 60 + d.Date.Second) % m == 0);
|
||||
|
||||
return await depthToTimeData.Select(d => new WellDepthToDayDto
|
||||
{
|
||||
|
@ -3,8 +3,10 @@ using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudInfrastructure.Services.Cache;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@ -21,6 +23,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
protected readonly CacheTable<Telemetry> cacheTelemetry;
|
||||
protected readonly CacheTable<TelemetryUser> cacheTelemetryUsers;
|
||||
protected readonly CacheTable<Well> cacheWells;
|
||||
private static int disorderId = (int)DateTime.Now.Ticks % 99;
|
||||
|
||||
public TelemetryDataBaseService(
|
||||
IAsbCloudDbContext db,
|
||||
@ -42,29 +45,95 @@ namespace AsbCloudInfrastructure.Services
|
||||
return 0;
|
||||
|
||||
var idTelemetry = telemetryService.GetOrCreateTemetryIdByUid(uid);
|
||||
var dtoMinDate = dtos.Min(d => d.Date);
|
||||
var dtoMaxDate = dtos.Max(d => d.Date);
|
||||
var lastTelemetryDate = telemetryService.GetLastTelemetryDate(uid);
|
||||
var dtosList = dtos.OrderBy(d => d.Date).ToList();
|
||||
|
||||
telemetryService.SaveRequestDate(uid, dtoMaxDate);
|
||||
var dtoMinDate = dtosList.First().Date;
|
||||
var dtoMaxDate = dtosList.Last().Date;
|
||||
|
||||
if (dtosList.Count > 1)
|
||||
{
|
||||
var duplicates = new List<TDto>(8);
|
||||
for (int i = 1; i < dtosList.Count; i++)
|
||||
if (dtosList[i - 1].Date == dtosList[i].Date || lastTelemetryDate == dtosList[i - 1].Date)
|
||||
duplicates.Add(dtosList[i - 1]);
|
||||
foreach (var duplicate in duplicates)
|
||||
dtosList.Remove(duplicate);
|
||||
}
|
||||
|
||||
var dataSet = db.Set<TModel>();
|
||||
|
||||
//var oldData = dataSet.Where(d=> d.IdTelemetry == idTelemetry
|
||||
// && d.Date > dtoMinDate
|
||||
// && d.Date < dtoMaxDate);
|
||||
|
||||
//dataSet.RemoveRange(oldData);
|
||||
|
||||
foreach (var dto in dtos)
|
||||
if(lastTelemetryDate > dtoMinDate)
|
||||
{
|
||||
dto.IdTelemetry = idTelemetry;
|
||||
var data = Convert(dto);
|
||||
data.Id = 0;
|
||||
dataSet.Add(data);
|
||||
var oldData = dataSet.Where(d => d.IdTelemetry == idTelemetry
|
||||
&& d.Date > dtoMinDate
|
||||
&& d.Date < dtoMaxDate);
|
||||
dataSet.RemoveRange(oldData);
|
||||
await db.SaveChangesAsync(token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
telemetryService.SaveRequestDate(uid, dtoMaxDate);
|
||||
|
||||
var entities = new List<EntityEntry<TModel>>(dtosList.Count);
|
||||
try
|
||||
{
|
||||
foreach (var dto in dtosList)
|
||||
{
|
||||
dto.IdTelemetry = idTelemetry;
|
||||
dto.Date = dto.Date.AddMilliseconds((disorderId++) % 99);
|
||||
var data = Convert(dto);
|
||||
var entry = dataSet.Add(data);
|
||||
entities.Add(entry);
|
||||
}
|
||||
return await db.SaveChangesAsync(token).ConfigureAwait(false);
|
||||
}
|
||||
catch (DbUpdateException ex)
|
||||
{
|
||||
Trace.WriteLine(ex.Message);
|
||||
foreach (var entity in entities)
|
||||
entity.State = EntityState.Detached;
|
||||
|
||||
foreach (var dto in dtosList)
|
||||
{
|
||||
dto.IdTelemetry = idTelemetry;
|
||||
dto.Date = dto.Date.AddMilliseconds((disorderId++) % 100);
|
||||
var data = Convert(dto);
|
||||
var entry = dataSet.Add(data);
|
||||
entities.Add(entry);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return await db.SaveChangesAsync(token).ConfigureAwait(false);
|
||||
}
|
||||
catch (DbUpdateException ex2)
|
||||
{
|
||||
Trace.WriteLine("2-nd :" + ex2.Message);
|
||||
foreach (var entity in entities)
|
||||
entity.State = EntityState.Detached;
|
||||
|
||||
entities.Clear();
|
||||
int i = 0;
|
||||
foreach (var dto in dtosList)
|
||||
{
|
||||
dto.IdTelemetry = idTelemetry;
|
||||
dto.Date = dto.Date.AddMilliseconds((disorderId++) % 100);
|
||||
var data = Convert(dto);
|
||||
dataSet.Add(data);
|
||||
|
||||
try
|
||||
{
|
||||
i += await db.SaveChangesAsync(token).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Trace.WriteLine($"Fail to save data telemerty uid: {uid}, idTelemetry {idTelemetry} count: {data.Date}.");
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual async Task<IEnumerable<TDto>> GetAsync(int idWell,
|
||||
DateTime dateBegin = default, double intervalSec = 600d,
|
||||
@ -105,7 +174,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
var m = (int)Math.Round(1d * fullDataCount / approxPointsCount);
|
||||
if (m > 1)
|
||||
query = query.Where(d => d.Id % m == 0);
|
||||
query = query.Where((d) => (((d.Date.DayOfYear*24 + d.Date.Hour)*60 + d.Date.Minute)*60 + d.Date.Second) % m == 0);
|
||||
}
|
||||
|
||||
var entities = await query
|
||||
|
@ -17,72 +17,71 @@ namespace AsbCloudWebApi
|
||||
if (RuntimeTypeModel.Default.IsDefined(type))
|
||||
return;
|
||||
RuntimeTypeModel.Default.Add(type, false)
|
||||
.Add(1, nameof(TelemetryDataSpinDto.Id))
|
||||
.Add(2, nameof(TelemetryDataSpinDto.IdTelemetry))
|
||||
.Add(3, nameof(TelemetryDataSpinDto.Date))
|
||||
.Add(4, nameof(TelemetryDataSpinDto.TopDriveSpeed))
|
||||
.Add(5, nameof(TelemetryDataSpinDto.TopDriveSpeedMin))
|
||||
.Add(6, nameof(TelemetryDataSpinDto.TopDriveSpeedMax))
|
||||
.Add(7, nameof(TelemetryDataSpinDto.TopDriveSpeedOffset))
|
||||
.Add(8, nameof(TelemetryDataSpinDto.TopDriveSpeedErr))
|
||||
.Add(9, nameof(TelemetryDataSpinDto.TopDriveTorque))
|
||||
.Add(10, nameof(TelemetryDataSpinDto.TopDriveTorqueMin))
|
||||
.Add(11, nameof(TelemetryDataSpinDto.TopDriveTorqueMax))
|
||||
.Add(12, nameof(TelemetryDataSpinDto.TopDriveTorqueOffset))
|
||||
.Add(13, nameof(TelemetryDataSpinDto.TopDriveTorqueErr))
|
||||
.Add(14, nameof(TelemetryDataSpinDto.TopDriveSpeedSpFrom))
|
||||
.Add(15, nameof(TelemetryDataSpinDto.TopDriveSpeedSpFromMin))
|
||||
.Add(16, nameof(TelemetryDataSpinDto.TopDriveSpeedSpFromMax))
|
||||
.Add(17, nameof(TelemetryDataSpinDto.TopDriveSpeedSpFromOffset))
|
||||
.Add(18, nameof(TelemetryDataSpinDto.TopDriveSpeedSpFromErr))
|
||||
.Add(19, nameof(TelemetryDataSpinDto.TopDriveTorqueSpFrom))
|
||||
.Add(20, nameof(TelemetryDataSpinDto.TopDriveTorqueSpFromMin))
|
||||
.Add(21, nameof(TelemetryDataSpinDto.TopDriveTorqueSpFromMax))
|
||||
.Add(22, nameof(TelemetryDataSpinDto.TopDriveTorqueSpFromOffset))
|
||||
.Add(23, nameof(TelemetryDataSpinDto.TopDriveTorqueSpFromErr))
|
||||
.Add(24, nameof(TelemetryDataSpinDto.TopDriveSpeedSpTo))
|
||||
.Add(25, nameof(TelemetryDataSpinDto.TopDriveSpeedSpToMin))
|
||||
.Add(26, nameof(TelemetryDataSpinDto.TopDriveSpeedSpToMax))
|
||||
.Add(27, nameof(TelemetryDataSpinDto.TopDriveSpeedSpToOffset))
|
||||
.Add(28, nameof(TelemetryDataSpinDto.TopDriveSpeedSpToErr))
|
||||
.Add(29, nameof(TelemetryDataSpinDto.TopDriveTorqueSpTo))
|
||||
.Add(30, nameof(TelemetryDataSpinDto.TopDriveTorqueSpToMin))
|
||||
.Add(31, nameof(TelemetryDataSpinDto.TopDriveTorqueSpToMax))
|
||||
.Add(32, nameof(TelemetryDataSpinDto.TopDriveTorqueSpToOffset))
|
||||
.Add(33, nameof(TelemetryDataSpinDto.TopDriveTorqueSpToErr))
|
||||
.Add(34, nameof(TelemetryDataSpinDto.W2800))
|
||||
.Add(35, nameof(TelemetryDataSpinDto.W2810))
|
||||
.Add(36, nameof(TelemetryDataSpinDto.Mode))
|
||||
.Add(37, nameof(TelemetryDataSpinDto.W2808))
|
||||
.Add(38, nameof(TelemetryDataSpinDto.TorqueStarting))
|
||||
.Add(39, nameof(TelemetryDataSpinDto.RotorTorqueAvg))
|
||||
.Add(40, nameof(TelemetryDataSpinDto.EncoderResolution))
|
||||
.Add(41, nameof(TelemetryDataSpinDto.Ratio))
|
||||
.Add(42, nameof(TelemetryDataSpinDto.TorqueRightLimit))
|
||||
.Add(43, nameof(TelemetryDataSpinDto.TorqueLeftLimit))
|
||||
.Add(44, nameof(TelemetryDataSpinDto.RevolsRightLimit))
|
||||
.Add(45, nameof(TelemetryDataSpinDto.RevolsLeftLimit))
|
||||
.Add(46, nameof(TelemetryDataSpinDto.SpeedRightSp))
|
||||
.Add(47, nameof(TelemetryDataSpinDto.SpeedLeftSp))
|
||||
.Add(48, nameof(TelemetryDataSpinDto.RevolsRightTotal))
|
||||
.Add(49, nameof(TelemetryDataSpinDto.RevolsLeftTotal))
|
||||
.Add(50, nameof(TelemetryDataSpinDto.TurnRightOnceByTorque))
|
||||
.Add(51, nameof(TelemetryDataSpinDto.TurnLeftOnceByTorque))
|
||||
.Add(52, nameof(TelemetryDataSpinDto.TurnRightOnceByAngle))
|
||||
.Add(53, nameof(TelemetryDataSpinDto.TurnLeftOnceByAngle))
|
||||
.Add(54, nameof(TelemetryDataSpinDto.TurnRightOnceByRevols))
|
||||
.Add(55, nameof(TelemetryDataSpinDto.TurnLeftOnceByRevols))
|
||||
.Add(56, nameof(TelemetryDataSpinDto.BreakAngleK))
|
||||
.Add(57, nameof(TelemetryDataSpinDto.ReverseKTorque))
|
||||
.Add(58, nameof(TelemetryDataSpinDto.PositionZero))
|
||||
.Add(59, nameof(TelemetryDataSpinDto.PositionRight))
|
||||
.Add(60, nameof(TelemetryDataSpinDto.TorqueRampTime))
|
||||
.Add(61, nameof(TelemetryDataSpinDto.Ver))
|
||||
.Add(62, nameof(TelemetryDataSpinDto.ReverseSpeedSpZeroTime))
|
||||
.Add(63, nameof(TelemetryDataSpinDto.UnlockBySectorOut))
|
||||
.Add(64, nameof(TelemetryDataSpinDto.PidMuxTorqueLeftLimit))
|
||||
.Add(65, nameof(TelemetryDataSpinDto.State))
|
||||
.Add(66, nameof(TelemetryDataSpinDto.BreakAngleLeft));
|
||||
.Add(1, nameof(TelemetryDataSpinDto.IdTelemetry))
|
||||
.Add(2, nameof(TelemetryDataSpinDto.Date))
|
||||
.Add(3, nameof(TelemetryDataSpinDto.TopDriveSpeed))
|
||||
.Add(4, nameof(TelemetryDataSpinDto.TopDriveSpeedMin))
|
||||
.Add(5, nameof(TelemetryDataSpinDto.TopDriveSpeedMax))
|
||||
.Add(6, nameof(TelemetryDataSpinDto.TopDriveSpeedOffset))
|
||||
.Add(7, nameof(TelemetryDataSpinDto.TopDriveSpeedErr))
|
||||
.Add(8, nameof(TelemetryDataSpinDto.TopDriveTorque))
|
||||
.Add(9, nameof(TelemetryDataSpinDto.TopDriveTorqueMin))
|
||||
.Add(10, nameof(TelemetryDataSpinDto.TopDriveTorqueMax))
|
||||
.Add(11, nameof(TelemetryDataSpinDto.TopDriveTorqueOffset))
|
||||
.Add(12, nameof(TelemetryDataSpinDto.TopDriveTorqueErr))
|
||||
.Add(13, nameof(TelemetryDataSpinDto.TopDriveSpeedSpFrom))
|
||||
.Add(14, nameof(TelemetryDataSpinDto.TopDriveSpeedSpFromMin))
|
||||
.Add(15, nameof(TelemetryDataSpinDto.TopDriveSpeedSpFromMax))
|
||||
.Add(16, nameof(TelemetryDataSpinDto.TopDriveSpeedSpFromOffset))
|
||||
.Add(17, nameof(TelemetryDataSpinDto.TopDriveSpeedSpFromErr))
|
||||
.Add(18, nameof(TelemetryDataSpinDto.TopDriveTorqueSpFrom))
|
||||
.Add(19, nameof(TelemetryDataSpinDto.TopDriveTorqueSpFromMin))
|
||||
.Add(20, nameof(TelemetryDataSpinDto.TopDriveTorqueSpFromMax))
|
||||
.Add(21, nameof(TelemetryDataSpinDto.TopDriveTorqueSpFromOffset))
|
||||
.Add(22, nameof(TelemetryDataSpinDto.TopDriveTorqueSpFromErr))
|
||||
.Add(23, nameof(TelemetryDataSpinDto.TopDriveSpeedSpTo))
|
||||
.Add(24, nameof(TelemetryDataSpinDto.TopDriveSpeedSpToMin))
|
||||
.Add(25, nameof(TelemetryDataSpinDto.TopDriveSpeedSpToMax))
|
||||
.Add(26, nameof(TelemetryDataSpinDto.TopDriveSpeedSpToOffset))
|
||||
.Add(27, nameof(TelemetryDataSpinDto.TopDriveSpeedSpToErr))
|
||||
.Add(28, nameof(TelemetryDataSpinDto.TopDriveTorqueSpTo))
|
||||
.Add(29, nameof(TelemetryDataSpinDto.TopDriveTorqueSpToMin))
|
||||
.Add(30, nameof(TelemetryDataSpinDto.TopDriveTorqueSpToMax))
|
||||
.Add(31, nameof(TelemetryDataSpinDto.TopDriveTorqueSpToOffset))
|
||||
.Add(32, nameof(TelemetryDataSpinDto.TopDriveTorqueSpToErr))
|
||||
.Add(33, nameof(TelemetryDataSpinDto.W2800))
|
||||
.Add(34, nameof(TelemetryDataSpinDto.W2810))
|
||||
.Add(35, nameof(TelemetryDataSpinDto.Mode))
|
||||
.Add(36, nameof(TelemetryDataSpinDto.W2808))
|
||||
.Add(37, nameof(TelemetryDataSpinDto.TorqueStarting))
|
||||
.Add(38, nameof(TelemetryDataSpinDto.RotorTorqueAvg))
|
||||
.Add(39, nameof(TelemetryDataSpinDto.EncoderResolution))
|
||||
.Add(40, nameof(TelemetryDataSpinDto.Ratio))
|
||||
.Add(41, nameof(TelemetryDataSpinDto.TorqueRightLimit))
|
||||
.Add(42, nameof(TelemetryDataSpinDto.TorqueLeftLimit))
|
||||
.Add(43, nameof(TelemetryDataSpinDto.RevolsRightLimit))
|
||||
.Add(44, nameof(TelemetryDataSpinDto.RevolsLeftLimit))
|
||||
.Add(45, nameof(TelemetryDataSpinDto.SpeedRightSp))
|
||||
.Add(46, nameof(TelemetryDataSpinDto.SpeedLeftSp))
|
||||
.Add(47, nameof(TelemetryDataSpinDto.RevolsRightTotal))
|
||||
.Add(48, nameof(TelemetryDataSpinDto.RevolsLeftTotal))
|
||||
.Add(49, nameof(TelemetryDataSpinDto.TurnRightOnceByTorque))
|
||||
.Add(50, nameof(TelemetryDataSpinDto.TurnLeftOnceByTorque))
|
||||
.Add(51, nameof(TelemetryDataSpinDto.TurnRightOnceByAngle))
|
||||
.Add(52, nameof(TelemetryDataSpinDto.TurnLeftOnceByAngle))
|
||||
.Add(53, nameof(TelemetryDataSpinDto.TurnRightOnceByRevols))
|
||||
.Add(54, nameof(TelemetryDataSpinDto.TurnLeftOnceByRevols))
|
||||
.Add(55, nameof(TelemetryDataSpinDto.BreakAngleK))
|
||||
.Add(56, nameof(TelemetryDataSpinDto.ReverseKTorque))
|
||||
.Add(57, nameof(TelemetryDataSpinDto.PositionZero))
|
||||
.Add(58, nameof(TelemetryDataSpinDto.PositionRight))
|
||||
.Add(59, nameof(TelemetryDataSpinDto.TorqueRampTime))
|
||||
.Add(60, nameof(TelemetryDataSpinDto.Ver))
|
||||
.Add(61, nameof(TelemetryDataSpinDto.ReverseSpeedSpZeroTime))
|
||||
.Add(62, nameof(TelemetryDataSpinDto.UnlockBySectorOut))
|
||||
.Add(63, nameof(TelemetryDataSpinDto.PidMuxTorqueLeftLimit))
|
||||
.Add(64, nameof(TelemetryDataSpinDto.State))
|
||||
.Add(65, nameof(TelemetryDataSpinDto.BreakAngleLeft));
|
||||
}
|
||||
|
||||
static void EnshureRegisteredDataSaub()
|
||||
@ -91,45 +90,44 @@ namespace AsbCloudWebApi
|
||||
if (RuntimeTypeModel.Default.IsDefined(type))
|
||||
return;
|
||||
RuntimeTypeModel.Default.Add(type, false)
|
||||
.Add(1, nameof(TelemetryDataSaubDto.Id))
|
||||
.Add(1, nameof(TelemetryDataSaubDto.IdTelemetry))
|
||||
.Add(2, nameof(TelemetryDataSaubDto.Date))
|
||||
.Add(3, nameof(TelemetryDataSaubDto.Mode))
|
||||
.Add(4, nameof(TelemetryDataSaubDto.IdTelemetry))
|
||||
.Add(5, nameof(TelemetryDataSaubDto.User))
|
||||
.Add(6, nameof(TelemetryDataSaubDto.WellDepth))
|
||||
.Add(7, nameof(TelemetryDataSaubDto.BitDepth))
|
||||
.Add(8, nameof(TelemetryDataSaubDto.BlockPosition))
|
||||
.Add(9, nameof(TelemetryDataSaubDto.BlockPositionMin))
|
||||
.Add(10, nameof(TelemetryDataSaubDto.BlockPositionMax))
|
||||
.Add(11, nameof(TelemetryDataSaubDto.BlockSpeed))
|
||||
.Add(12, nameof(TelemetryDataSaubDto.BlockSpeedSp))
|
||||
.Add(13, nameof(TelemetryDataSaubDto.BlockSpeedSpRotor))
|
||||
.Add(14, nameof(TelemetryDataSaubDto.BlockSpeedSpSlide))
|
||||
.Add(15, nameof(TelemetryDataSaubDto.BlockSpeedSpDevelop))
|
||||
.Add(16, nameof(TelemetryDataSaubDto.Pressure))
|
||||
.Add(17, nameof(TelemetryDataSaubDto.PressureIdle))
|
||||
.Add(18, nameof(TelemetryDataSaubDto.PressureSp))
|
||||
.Add(19, nameof(TelemetryDataSaubDto.PressureSpRotor))
|
||||
.Add(20, nameof(TelemetryDataSaubDto.PressureSpSlide))
|
||||
.Add(21, nameof(TelemetryDataSaubDto.PressureSpDevelop))
|
||||
.Add(22, nameof(TelemetryDataSaubDto.PressureDeltaLimitMax))
|
||||
.Add(23, nameof(TelemetryDataSaubDto.AxialLoad))
|
||||
.Add(24, nameof(TelemetryDataSaubDto.AxialLoadSp))
|
||||
.Add(25, nameof(TelemetryDataSaubDto.AxialLoadLimitMax))
|
||||
.Add(26, nameof(TelemetryDataSaubDto.HookWeight))
|
||||
.Add(27, nameof(TelemetryDataSaubDto.HookWeightIdle))
|
||||
.Add(28, nameof(TelemetryDataSaubDto.HookWeightLimitMin))
|
||||
.Add(29, nameof(TelemetryDataSaubDto.HookWeightLimitMax))
|
||||
.Add(30, nameof(TelemetryDataSaubDto.RotorTorque))
|
||||
.Add(31, nameof(TelemetryDataSaubDto.RotorTorqueIdle))
|
||||
.Add(32, nameof(TelemetryDataSaubDto.RotorTorqueSp))
|
||||
.Add(33, nameof(TelemetryDataSaubDto.RotorTorqueLimitMax))
|
||||
.Add(34, nameof(TelemetryDataSaubDto.RotorSpeed))
|
||||
.Add(35, nameof(TelemetryDataSaubDto.Flow))
|
||||
.Add(36, nameof(TelemetryDataSaubDto.FlowIdle))
|
||||
.Add(37, nameof(TelemetryDataSaubDto.FlowDeltaLimitMax))
|
||||
.Add(38, nameof(TelemetryDataSaubDto.IdFeedRegulator))
|
||||
.Add(39, nameof(TelemetryDataSaubDto.MseState));
|
||||
.Add(4, nameof(TelemetryDataSaubDto.User))
|
||||
.Add(5, nameof(TelemetryDataSaubDto.WellDepth))
|
||||
.Add(6, nameof(TelemetryDataSaubDto.BitDepth))
|
||||
.Add(7, nameof(TelemetryDataSaubDto.BlockPosition))
|
||||
.Add(8, nameof(TelemetryDataSaubDto.BlockPositionMin))
|
||||
.Add(9, nameof(TelemetryDataSaubDto.BlockPositionMax))
|
||||
.Add(10, nameof(TelemetryDataSaubDto.BlockSpeed))
|
||||
.Add(11, nameof(TelemetryDataSaubDto.BlockSpeedSp))
|
||||
.Add(12, nameof(TelemetryDataSaubDto.BlockSpeedSpRotor))
|
||||
.Add(13, nameof(TelemetryDataSaubDto.BlockSpeedSpSlide))
|
||||
.Add(14, nameof(TelemetryDataSaubDto.BlockSpeedSpDevelop))
|
||||
.Add(15, nameof(TelemetryDataSaubDto.Pressure))
|
||||
.Add(16, nameof(TelemetryDataSaubDto.PressureIdle))
|
||||
.Add(17, nameof(TelemetryDataSaubDto.PressureSp))
|
||||
.Add(18, nameof(TelemetryDataSaubDto.PressureSpRotor))
|
||||
.Add(19, nameof(TelemetryDataSaubDto.PressureSpSlide))
|
||||
.Add(20, nameof(TelemetryDataSaubDto.PressureSpDevelop))
|
||||
.Add(21, nameof(TelemetryDataSaubDto.PressureDeltaLimitMax))
|
||||
.Add(22, nameof(TelemetryDataSaubDto.AxialLoad))
|
||||
.Add(23, nameof(TelemetryDataSaubDto.AxialLoadSp))
|
||||
.Add(24, nameof(TelemetryDataSaubDto.AxialLoadLimitMax))
|
||||
.Add(25, nameof(TelemetryDataSaubDto.HookWeight))
|
||||
.Add(26, nameof(TelemetryDataSaubDto.HookWeightIdle))
|
||||
.Add(27, nameof(TelemetryDataSaubDto.HookWeightLimitMin))
|
||||
.Add(28, nameof(TelemetryDataSaubDto.HookWeightLimitMax))
|
||||
.Add(29, nameof(TelemetryDataSaubDto.RotorTorque))
|
||||
.Add(30, nameof(TelemetryDataSaubDto.RotorTorqueIdle))
|
||||
.Add(31, nameof(TelemetryDataSaubDto.RotorTorqueSp))
|
||||
.Add(32, nameof(TelemetryDataSaubDto.RotorTorqueLimitMax))
|
||||
.Add(33, nameof(TelemetryDataSaubDto.RotorSpeed))
|
||||
.Add(34, nameof(TelemetryDataSaubDto.Flow))
|
||||
.Add(35, nameof(TelemetryDataSaubDto.FlowIdle))
|
||||
.Add(36, nameof(TelemetryDataSaubDto.FlowDeltaLimitMax))
|
||||
.Add(37, nameof(TelemetryDataSaubDto.IdFeedRegulator))
|
||||
.Add(38, nameof(TelemetryDataSaubDto.MseState));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user