Фиксация для слияния

This commit is contained in:
Lyudmila Romanova 2022-06-10 11:58:49 +05:00
parent 42e2c57c1b
commit 6c89c32ab3
20 changed files with 41402 additions and 6 deletions

View File

@ -6,4 +6,8 @@
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Linq" Version="4.3.0" />
</ItemGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,87 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class AddDeillerModel : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_well_type",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "",
comment: "Название",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldNullable: true,
oldComment: "Название");
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_well_section_type",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "",
comment: "Название",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldNullable: true,
oldComment: "Название");
migrationBuilder.CreateTable(
name: "t_driller",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Имя"),
surname = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Фамилия"),
patronymic = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Отчество")
},
constraints: table =>
{
table.PrimaryKey("PK_t_driller", x => x.id);
},
comment: "Бурильщик");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_driller");
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_well_type",
type: "character varying(255)",
maxLength: 255,
nullable: true,
comment: "Название",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldComment: "Название");
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_well_section_type",
type: "character varying(255)",
maxLength: 255,
nullable: true,
comment: "Название",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldComment: "Название");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class AddSchedule : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class ChangeDateSchedule : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,61 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class AddSchedule1 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "t_schedule",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
id_driller = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор бурильщика"),
id_well = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор скважины"),
shift_start = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Начало смены"),
shift_end = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Конец смены"),
drill_start = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Начало бурение"),
drill_end = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Конец бурения")
},
constraints: table =>
{
table.PrimaryKey("PK_t_schedule", x => x.id);
table.ForeignKey(
name: "FK_t_schedule_t_driller_id_driller",
column: x => x.id_driller,
principalTable: "t_driller",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_t_schedule_t_well_id_well",
column: x => x.id_well,
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
},
comment: "График работы бурильщика");
migrationBuilder.CreateIndex(
name: "IX_t_schedule_id_driller",
table: "t_schedule",
column: "id_driller");
migrationBuilder.CreateIndex(
name: "IX_t_schedule_id_well",
table: "t_schedule",
column: "id_well");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_schedule");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class AddInvertLink : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class ChangeModel : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class ChangeModel2 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_t_schedule_t_driller_id_driller",
table: "t_schedule");
migrationBuilder.AddForeignKey(
name: "t_schedule_t_driller_id_driller",
table: "t_schedule",
column: "id_driller",
principalTable: "t_driller",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "t_schedule_t_driller_id_driller",
table: "t_schedule");
migrationBuilder.AddForeignKey(
name: "FK_t_schedule_t_driller_id_driller",
table: "t_schedule",
column: "id_driller",
principalTable: "t_driller",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -868,6 +868,57 @@ namespace AsbCloudDb.Migrations
});
});
modelBuilder.Entity("AsbCloudDb.Model.OperationValue", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id")
.HasComment("Идентификатор");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<double>("DepthEnd")
.HasColumnType("double precision")
.HasColumnName("depth_end")
.HasComment("Конечная глубина");
b.Property<double>("DepthStart")
.HasColumnType("double precision")
.HasColumnName("depth_start")
.HasComment("Старотовая глубина");
b.Property<int>("IdOperationCategory")
.HasColumnType("integer")
.HasColumnName("id_operation_category")
.HasComment("Ид категории операции");
b.Property<int>("IdWell")
.HasColumnType("integer")
.HasColumnName("id_well")
.HasComment("Ид скважины");
b.Property<double>("StandardValue")
.HasColumnType("double precision")
.HasColumnName("standard_value")
.HasComment("Нормативный показатель");
b.Property<double>("TargetValue")
.HasColumnType("double precision")
.HasColumnName("target_value")
.HasComment("Целевой показатель");
b.HasKey("Id");
b.HasIndex("IdOperationCategory");
b.HasIndex("IdWell");
b.ToTable("t_operationvalue");
b.HasComment("Целевые/нормативные показатели операции");
});
modelBuilder.Entity("AsbCloudDb.Model.Permission", b =>
{
b.Property<int>("Id")
@ -5468,6 +5519,25 @@ namespace AsbCloudDb.Migrations
b.Navigation("Well");
});
modelBuilder.Entity("AsbCloudDb.Model.OperationValue", b =>
{
b.HasOne("AsbCloudDb.Model.WellOperationCategory", "OperationCategory")
.WithMany()
.HasForeignKey("IdOperationCategory")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AsbCloudDb.Model.Well", "Well")
.WithMany()
.HasForeignKey("IdWell")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("OperationCategory");
b.Navigation("Well");
});
modelBuilder.Entity("AsbCloudDb.Model.RelationCompanyWell", b =>
{
b.HasOne("AsbCloudDb.Model.Company", "Company")

View File

@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;

View File

@ -0,0 +1,97 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.SAUB;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services;
using AsbCloudInfrastructure.Services.Cache;
using AsbCloudInfrastructure.Services.DetectOperations;
using Moq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
namespace AsbCloudWebApi.Tests.ServicesTests
{
public class DetectedOperationServiceTest
{
private readonly AsbCloudDbContext context;
private readonly CacheDb cacheDb;
private readonly DetectedOperationService service;
#region Задача данных
private Deposit deposit = new Deposit { Id = 1, Caption = "Депозит 1" };
private Cluster cluster = new Cluster { Id = 1, Caption = "Кластер 1", IdDeposit = 1, Timezone = new SimpleTimezone() };
private Well well = new Well
{
Id = 1,
Caption = "Test well 1",
IdTelemetry=1,
IdCluster = 1,
Timezone = new SimpleTimezone { Hours = 5 }
};
private Driller driller = new Driller
{
Id = 1,
Name = "Тестовый",
Patronymic = "Тест",
Surname = "Тестович"
};
private DetectedOperation do1 = new DetectedOperation
{
Id = 1,
IdCategory = 1,
IdTelemetry = 1,
DateStart = DateTimeOffset.Parse("2022-05-16T10:00:00.286Z"),
DateEnd = DateTimeOffset.Parse("2022-05-16T18:00:00.286Z"),
DepthStart = 100,
DepthEnd = 1000
};
private Telemetry telemetry = new Telemetry
{
Id=1,
RemoteUid = Guid.NewGuid().ToString()
};
#endregion
public DetectedOperationServiceTest()
{
context = TestHelpter.MakeTestContext();
context.SaveChanges();
context.Telemetries.Add(telemetry);
context.Deposits.Add(deposit);
context.Clusters.Add(cluster);
context.Wells.Add(well);
context.Drillers.Add(driller);
context.DetectedOperations.Add(do1);
context.SaveChanges();
var timezone = new SimpleTimezoneDto { Hours = 5 };
var wellServiceMock = new Mock<IWellService>();
wellServiceMock.Setup(s => s.GetTimezone(It.IsAny<int>())).Returns(timezone);
var operationValueService = new OperationValueService(context);
var scheduleService = new ScheduleService(context, wellServiceMock.Object);
service = new DetectedOperationService(context, wellServiceMock.Object, operationValueService, scheduleService);
AsbCloudInfrastructure.DependencyInjection.MapsterSetup();
}
~DetectedOperationServiceTest()
{
}
[Fact]
public async Task Count_grouping_by_driller()
{
var count = 10;
var list = await service.GetAsync(1, null, CancellationToken.None);
Assert.Equal(3, count);
}
}
}

View File

@ -34,8 +34,8 @@ namespace AsbCloudWebApi.Tests.ServicesTests
{
IdWell = dto?.IdWell ?? 1,
IdDriller = dto?.IdDriller ?? 1,
ShiftStart = dto?.ShiftStart ?? new TimeOnly(10, 00),
ShiftEnd = dto?.ShiftEnd ?? new TimeOnly(18, 00),
//ShiftStart = dto?.ShiftStart ?? new TimeOnly(10, 00),
//ShiftEnd = dto?.ShiftEnd ?? new TimeOnly(18, 00),
DrillStart = dto?.DrillStart ?? DateTime.Parse("2022-05-16T10:00:00.286Z"),
DrillEnd = dto?.DrillEnd ?? DateTime.Parse("2022-05-16T18:00:00.286Z")
};
@ -114,8 +114,8 @@ namespace AsbCloudWebApi.Tests.ServicesTests
public async Task GetDriller_by_workTime_shift1()
{
var dto = MakeScheduleDto();
dto.ShiftStart = new TimeOnly(8, 00);
dto.ShiftEnd = new TimeOnly(20, 00);
//dto.ShiftStart = new TimeOnly(8, 00);
//dto.ShiftEnd = new TimeOnly(20, 00);
var id = await scheduleService.InsertAsync(dto, CancellationToken.None);
var drillerWorkTime = new DateTime(
dto.DrillStart.Year,
@ -130,8 +130,8 @@ namespace AsbCloudWebApi.Tests.ServicesTests
public async Task GetDriller_by_workTime_shift2()
{
var dto = MakeScheduleDto();
dto.ShiftStart = new TimeOnly(20, 00);
dto.ShiftEnd = new TimeOnly(8, 00);
//dto.ShiftStart = new TimeOnly(20, 00);
//dto.ShiftEnd = new TimeOnly(8, 00);
var id = await scheduleService.InsertAsync(dto, CancellationToken.None);
var drillerWorkTime = new DateTime(
dto.DrillStart.Year,

View File

@ -0,0 +1,8 @@
{
"profiles": {
"WSL": {
"commandName": "WSL2",
"distributionName": ""
}
}
}