Record.Values

This commit is contained in:
Michał Zieliński
2023-08-21 13:00:05 +02:00
parent d51abf90ee
commit e8c64059fb
11 changed files with 792 additions and 13 deletions

View File

@@ -2,7 +2,36 @@ import { Base } from './base.model';
export class Record extends Base {
code?: string;
value?: number;
value1?: number;
value2?: number;
value3?: number;
value4?: number;
value5?: number;
value6?: number;
value8?: number;
value9?: number;
value10?: number;
value11?: number;
value12?: number;
value13?: number;
value14?: number;
value15?: number;
value16?: number;
value17?: number;
value18?: number;
value19?: number;
value20?: number;
value21?: number;
value22?: number;
value23?: number;
value24?: number;
value25?: number;
value26?: number;
value27?: number;
value28?: number;
value29?: number;
value30?: number;
value31?: number;
desc1?: string;
desc2?: string;
desc3?: string;

View File

@@ -55,7 +55,7 @@ export class LayerDetailComponent implements OnInit {
this.form.disable();
this.document.created = `${this.datePipe.transform(this.document.createdAt?.toDate(), 'short')}, ${this.document.createdBy?.userName}`;
this.dataSource.sort.sort({ id: 'code', start: 'desc' } as MatSortable);
this.valueSum = this.document.records.map(t => t.value || 0).reduce((acc, value) => acc + value, 0);
this.valueSum = this.document.records.map(t => t.value1 || 0).reduce((acc, value) => acc + value, 0);
}
private async load(): Promise<Layer> {
return await Layer.getById(this.route$.snapshot.paramMap.get('id') || "", this.http$);

View File

@@ -74,6 +74,7 @@ export class LayersListComponent implements OnInit {
this.dataSource.data = await Layer.getList(this._http, this.start, this.limit, this.codes);
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async addCode(event: any) {
const value = (event.target.value || '').trim();
if (value) {

View File

@@ -22,7 +22,7 @@ namespace WebAPI.Exports
List<IList<object>> data = new List<IList<object>>() { new List<object>() { layer.Name!, layer.Number! } };
foreach (Record record in layer.Records!)
{
data.Add(new List<object> { record.Code!, record.Value });
data.Add(new List<object> { record.Code!, record.Value1! });
}
Google.Apis.Drive.v3.Data.File body = new Google.Apis.Drive.v3.Data.File();

View File

@@ -0,0 +1,291 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using WebAPI;
#nullable disable
namespace WebAPI.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20230821105757_Record.Values")]
partial class RecordValues
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("WebAPI.Models.Layer", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<Guid>("CreatedById")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("datetime2");
b.Property<Guid>("ModifiedById")
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Number")
.HasColumnType("int");
b.Property<string>("Source")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CreatedById");
b.HasIndex("ModifiedById");
b.ToTable("Layers");
});
modelBuilder.Entity("WebAPI.Models.Record", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("Code")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<Guid>("CreatedById")
.HasColumnType("uniqueidentifier");
b.Property<string>("Desc1")
.HasColumnType("nvarchar(max)");
b.Property<string>("Desc2")
.HasColumnType("nvarchar(max)");
b.Property<string>("Desc3")
.HasColumnType("nvarchar(max)");
b.Property<string>("Desc4")
.HasColumnType("nvarchar(max)");
b.Property<string>("Desc5")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<Guid>("LayerId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("datetime2");
b.Property<Guid>("ModifiedById")
.HasColumnType("uniqueidentifier");
b.Property<float?>("Value1")
.HasColumnType("real");
b.Property<float?>("Value10")
.HasColumnType("real");
b.Property<float?>("Value11")
.HasColumnType("real");
b.Property<float?>("Value12")
.HasColumnType("real");
b.Property<float?>("Value13")
.HasColumnType("real");
b.Property<float?>("Value14")
.HasColumnType("real");
b.Property<float?>("Value15")
.HasColumnType("real");
b.Property<float?>("Value16")
.HasColumnType("real");
b.Property<float?>("Value17")
.HasColumnType("real");
b.Property<float?>("Value18")
.HasColumnType("real");
b.Property<float?>("Value19")
.HasColumnType("real");
b.Property<float?>("Value2")
.HasColumnType("real");
b.Property<float?>("Value20")
.HasColumnType("real");
b.Property<float?>("Value21")
.HasColumnType("real");
b.Property<float?>("Value22")
.HasColumnType("real");
b.Property<float?>("Value23")
.HasColumnType("real");
b.Property<float?>("Value24")
.HasColumnType("real");
b.Property<float?>("Value25")
.HasColumnType("real");
b.Property<float?>("Value26")
.HasColumnType("real");
b.Property<float?>("Value27")
.HasColumnType("real");
b.Property<float?>("Value28")
.HasColumnType("real");
b.Property<float?>("Value29")
.HasColumnType("real");
b.Property<float?>("Value3")
.HasColumnType("real");
b.Property<float?>("Value30")
.HasColumnType("real");
b.Property<float?>("Value31")
.HasColumnType("real");
b.Property<float?>("Value4")
.HasColumnType("real");
b.Property<float?>("Value5")
.HasColumnType("real");
b.Property<float?>("Value6")
.HasColumnType("real");
b.Property<float?>("Value7")
.HasColumnType("real");
b.Property<float?>("Value8")
.HasColumnType("real");
b.Property<float?>("Value9")
.HasColumnType("real");
b.HasKey("Id");
b.HasIndex("CreatedById");
b.HasIndex("LayerId");
b.HasIndex("ModifiedById");
b.ToTable("Records");
});
modelBuilder.Entity("WebAPI.Models.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("WebAPI.Models.Layer", b =>
{
b.HasOne("WebAPI.Models.User", "CreatedBy")
.WithMany()
.HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WebAPI.Models.User", "ModifiedBy")
.WithMany()
.HasForeignKey("ModifiedById")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CreatedBy");
b.Navigation("ModifiedBy");
});
modelBuilder.Entity("WebAPI.Models.Record", b =>
{
b.HasOne("WebAPI.Models.User", "CreatedBy")
.WithMany()
.HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WebAPI.Models.Layer", null)
.WithMany("Records")
.HasForeignKey("LayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WebAPI.Models.User", "ModifiedBy")
.WithMany()
.HasForeignKey("ModifiedById")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CreatedBy");
b.Navigation("ModifiedBy");
});
modelBuilder.Entity("WebAPI.Models.Layer", b =>
{
b.Navigation("Records");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,339 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace WebAPI.Migrations
{
/// <inheritdoc />
public partial class RecordValues : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Value",
table: "Records");
migrationBuilder.AddColumn<float>(
name: "Value1",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value10",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value11",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value12",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value13",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value14",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value15",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value16",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value17",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value18",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value19",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value2",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value20",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value21",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value22",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value23",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value24",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value25",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value26",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value27",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value28",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value29",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value3",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value30",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value31",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value4",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value5",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value6",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value7",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value8",
table: "Records",
type: "real",
nullable: true);
migrationBuilder.AddColumn<float>(
name: "Value9",
table: "Records",
type: "real",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Value1",
table: "Records");
migrationBuilder.DropColumn(
name: "Value10",
table: "Records");
migrationBuilder.DropColumn(
name: "Value11",
table: "Records");
migrationBuilder.DropColumn(
name: "Value12",
table: "Records");
migrationBuilder.DropColumn(
name: "Value13",
table: "Records");
migrationBuilder.DropColumn(
name: "Value14",
table: "Records");
migrationBuilder.DropColumn(
name: "Value15",
table: "Records");
migrationBuilder.DropColumn(
name: "Value16",
table: "Records");
migrationBuilder.DropColumn(
name: "Value17",
table: "Records");
migrationBuilder.DropColumn(
name: "Value18",
table: "Records");
migrationBuilder.DropColumn(
name: "Value19",
table: "Records");
migrationBuilder.DropColumn(
name: "Value2",
table: "Records");
migrationBuilder.DropColumn(
name: "Value20",
table: "Records");
migrationBuilder.DropColumn(
name: "Value21",
table: "Records");
migrationBuilder.DropColumn(
name: "Value22",
table: "Records");
migrationBuilder.DropColumn(
name: "Value23",
table: "Records");
migrationBuilder.DropColumn(
name: "Value24",
table: "Records");
migrationBuilder.DropColumn(
name: "Value25",
table: "Records");
migrationBuilder.DropColumn(
name: "Value26",
table: "Records");
migrationBuilder.DropColumn(
name: "Value27",
table: "Records");
migrationBuilder.DropColumn(
name: "Value28",
table: "Records");
migrationBuilder.DropColumn(
name: "Value29",
table: "Records");
migrationBuilder.DropColumn(
name: "Value3",
table: "Records");
migrationBuilder.DropColumn(
name: "Value30",
table: "Records");
migrationBuilder.DropColumn(
name: "Value31",
table: "Records");
migrationBuilder.DropColumn(
name: "Value4",
table: "Records");
migrationBuilder.DropColumn(
name: "Value5",
table: "Records");
migrationBuilder.DropColumn(
name: "Value6",
table: "Records");
migrationBuilder.DropColumn(
name: "Value7",
table: "Records");
migrationBuilder.DropColumn(
name: "Value8",
table: "Records");
migrationBuilder.DropColumn(
name: "Value9",
table: "Records");
migrationBuilder.AddColumn<float>(
name: "Value",
table: "Records",
type: "real",
nullable: false,
defaultValue: 0f);
}
}
}

View File

@@ -17,7 +17,7 @@ namespace WebAPI.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.7")
.HasAnnotation("ProductVersion", "7.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
@@ -109,7 +109,97 @@ namespace WebAPI.Migrations
b.Property<Guid>("ModifiedById")
.HasColumnType("uniqueidentifier");
b.Property<float>("Value")
b.Property<float?>("Value1")
.HasColumnType("real");
b.Property<float?>("Value10")
.HasColumnType("real");
b.Property<float?>("Value11")
.HasColumnType("real");
b.Property<float?>("Value12")
.HasColumnType("real");
b.Property<float?>("Value13")
.HasColumnType("real");
b.Property<float?>("Value14")
.HasColumnType("real");
b.Property<float?>("Value15")
.HasColumnType("real");
b.Property<float?>("Value16")
.HasColumnType("real");
b.Property<float?>("Value17")
.HasColumnType("real");
b.Property<float?>("Value18")
.HasColumnType("real");
b.Property<float?>("Value19")
.HasColumnType("real");
b.Property<float?>("Value2")
.HasColumnType("real");
b.Property<float?>("Value20")
.HasColumnType("real");
b.Property<float?>("Value21")
.HasColumnType("real");
b.Property<float?>("Value22")
.HasColumnType("real");
b.Property<float?>("Value23")
.HasColumnType("real");
b.Property<float?>("Value24")
.HasColumnType("real");
b.Property<float?>("Value25")
.HasColumnType("real");
b.Property<float?>("Value26")
.HasColumnType("real");
b.Property<float?>("Value27")
.HasColumnType("real");
b.Property<float?>("Value28")
.HasColumnType("real");
b.Property<float?>("Value29")
.HasColumnType("real");
b.Property<float?>("Value3")
.HasColumnType("real");
b.Property<float?>("Value30")
.HasColumnType("real");
b.Property<float?>("Value31")
.HasColumnType("real");
b.Property<float?>("Value4")
.HasColumnType("real");
b.Property<float?>("Value5")
.HasColumnType("real");
b.Property<float?>("Value6")
.HasColumnType("real");
b.Property<float?>("Value7")
.HasColumnType("real");
b.Property<float?>("Value8")
.HasColumnType("real");
b.Property<float?>("Value9")
.HasColumnType("real");
b.HasKey("Id");

View File

@@ -8,11 +8,40 @@ namespace WebAPI.Models
[Key]
public Guid Id { get; set; }
[Required]
public string? Code { get; set; } // number
[Required]
public float Value { get; set; } // string
//Description fields
public string? Desc1 { get; set; } // Desc1 => Value1
public string? Code { get; set; }
public float? Value1 { get; set; }
public float? Value2 { get; set; }
public float? Value3 { get; set; }
public float? Value4 { get; set; }
public float? Value5 { get; set; }
public float? Value6 { get; set; }
public float? Value7 { get; set; }
public float? Value8 { get; set; }
public float? Value9 { get; set; }
public float? Value10 { get; set; }
public float? Value11 { get; set; }
public float? Value12 { get; set; }
public float? Value13 { get; set; }
public float? Value14 { get; set; }
public float? Value15 { get; set; }
public float? Value16 { get; set; }
public float? Value17 { get; set; }
public float? Value18 { get; set; }
public float? Value19 { get; set; }
public float? Value20 { get; set; }
public float? Value21 { get; set; }
public float? Value22 { get; set; }
public float? Value23 { get; set; }
public float? Value24 { get; set; }
public float? Value25 { get; set; }
public float? Value26 { get; set; }
public float? Value27 { get; set; }
public float? Value28 { get; set; }
public float? Value29 { get; set; }
public float? Value30 { get; set; }
public float? Value31 { get; set; }
//Description fields
public string? Desc1 { get; set; }
public string? Desc2 { get; set; }
public string? Desc3 { get; set; }
public string? Desc4 { get; set; }

View File

@@ -38,7 +38,7 @@ namespace WebAPI.dataParsers
record.Id = Guid.NewGuid();
record.Code = data[0][i];
record.Desc1 = data[j][0];
record.Value = value;
record.Value1 = value;
record.CreatedAt = DateTime.UtcNow;
record.ModifiedAt= DateTime.UtcNow;
records.Add(record);

View File

@@ -33,7 +33,7 @@ namespace WebAPI.dataParsers
Record record = new Record();
record.Id = Guid.NewGuid();
record.Code = data[i][0].ToString();
record.Value = value;
record.Value1 = value;
record.CreatedAt = DateTime.UtcNow;
record.ModifiedAt = DateTime.UtcNow;
records.Add(record);

View File

@@ -47,7 +47,7 @@ namespace WebAPI.dataParsers
Record record = new Record();
record.Id = Guid.NewGuid();
record.Code = data[1][i].ToString();
record.Value = value;
record.Value1 = value;
record.CreatedAt = DateTime.UtcNow;
record.ModifiedAt = DateTime.UtcNow;
records.Add(record);