From 9150004850db6376ad32a2edbbd48be3d94d5a8c Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 6 Aug 2021 17:40:34 +0200 Subject: [PATCH 01/15] Revisione fattore riduzione grafici (dimezza se > 1 week) --- GWMS.UI/Components/PlantDetail.razor.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/GWMS.UI/Components/PlantDetail.razor.cs b/GWMS.UI/Components/PlantDetail.razor.cs index b9e9f0b..a1c6620 100644 --- a/GWMS.UI/Components/PlantDetail.razor.cs +++ b/GWMS.UI/Components/PlantDetail.razor.cs @@ -130,11 +130,8 @@ namespace GWMS.UI.Components { int answ = 1; int numCount = _currItem.LevelTS.Count; - if (numCount > 200) - answ = 4; - else if (numCount > 150) - answ = 3; - else if (numCount >= 50) + // passo a 2h se > 1 week + if (numCount > 168) answ = 2; redFact = answ; } From 570e6bda0637562fe0e2dcf1e2a7c2bcccefd1d3 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 6 Aug 2021 18:22:03 +0200 Subject: [PATCH 02/15] Aggiunta migrazione nuovi dati OrderQty x riordino --- .../20210806162035_AddOrderDefQty.Designer.cs | 875 ++++++++++++++++++ .../20210806162035_AddOrderDefQty.cs | 81 ++ .../Migrations/GWMSContextModelSnapshot.cs | 11 +- 3 files changed, 965 insertions(+), 2 deletions(-) create mode 100644 GWMS.Data/Migrations/20210806162035_AddOrderDefQty.Designer.cs create mode 100644 GWMS.Data/Migrations/20210806162035_AddOrderDefQty.cs diff --git a/GWMS.Data/Migrations/20210806162035_AddOrderDefQty.Designer.cs b/GWMS.Data/Migrations/20210806162035_AddOrderDefQty.Designer.cs new file mode 100644 index 0000000..5792773 --- /dev/null +++ b/GWMS.Data/Migrations/20210806162035_AddOrderDefQty.Designer.cs @@ -0,0 +1,875 @@ +// +using System; +using GWMS.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace GWMS.Data.Migrations +{ + [DbContext(typeof(GWMSContext))] + [Migration("20210806162035_AddOrderDefQty")] + partial class AddOrderDefQty + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 64) + .HasAnnotation("ProductVersion", "5.0.7"); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.AnKeyValModel", b => + { + b.Property("KeyName") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Descript") + .HasMaxLength(250) + .HasColumnType("varchar(250)") + .HasComment("Descrizione dell'item"); + + b.Property("ValFloat") + .HasColumnType("int"); + + b.Property("ValInt") + .HasColumnType("int"); + + b.Property("ValString") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("KeyName"); + + b.ToTable("AnKeyVal"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.ConfigModel", b => + { + b.Property("KeyName") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Note") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Val") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ValStd") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("Valore di default/riferimento per la variabile"); + + b.HasKey("KeyName"); + + b.ToTable("Config"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.ItemModel", b => + { + b.Property("ItemId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ItemCode") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("ItemDesc") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("ItemType") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("UM") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("ItemId"); + + b.ToTable("Items"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.ListValModel", b => + { + b.Property("TabName") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("TabName"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("FieldName"); + + b.Property("Val") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("Val"); + + b.Property("Descript") + .HasMaxLength(250) + .HasColumnType("varchar(250)") + .HasColumnName("Descript"); + + b.Property("Ordinal") + .HasColumnType("int") + .HasColumnName("Ordinal"); + + b.HasKey("TabName", "FieldName", "Val"); + + b.ToTable("ListVal"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DtETA") + .HasColumnType("datetime(6)"); + + b.Property("DtExecEnd") + .HasColumnType("datetime(6)"); + + b.Property("DtExecStart") + .HasColumnType("datetime(6)"); + + b.Property("DtOrder") + .HasColumnType("datetime(6)"); + + b.Property("ExecutionQty") + .HasColumnType("double"); + + b.Property("OrderCode") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("OrderDesc") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("OrderQty") + .HasColumnType("double"); + + b.Property("PlantId") + .HasColumnType("int"); + + b.Property("SupplierId") + .HasColumnType("int"); + + b.Property("TransporterId") + .HasColumnType("int"); + + b.HasKey("OrderId"); + + b.HasIndex("PlantId"); + + b.HasIndex("SupplierId"); + + b.HasIndex("TransporterId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantDetailModel", b => + { + b.Property("PlantId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("LevelMax") + .HasColumnType("double"); + + b.Property("LevelReorder") + .HasColumnType("double"); + + b.Property("OrderQtyStd") + .HasColumnType("double"); + + b.Property("PlantCode") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("PlantDesc") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("PlantId"); + + b.ToTable("PlantDetail"); + + b.HasData( + new + { + PlantId = 1, + LevelMax = 26000.0, + LevelReorder = 15000.0, + OrderQtyStd = 18000.0, + PlantCode = "PIZ03", + PlantDesc = "Collecchio" + }, + new + { + PlantId = 2, + LevelMax = 28000.0, + LevelReorder = 15000.0, + OrderQtyStd = 18000.0, + PlantCode = "PIZ04", + PlantDesc = "Noceto" + }, + new + { + PlantId = 3, + LevelMax = 24000.0, + LevelReorder = 15000.0, + OrderQtyStd = 18000.0, + PlantCode = "PIZ05", + PlantDesc = "Baganzola" + }, + new + { + PlantId = 4, + LevelMax = 26000.0, + LevelReorder = 15000.0, + OrderQtyStd = 18000.0, + PlantCode = "PIZ08", + PlantDesc = "Pilastrello" + }); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantLogModel", b => + { + b.Property("PlantDataId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DtEvent") + .HasColumnType("datetime(6)"); + + b.Property("FluxType") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("PlantId") + .HasColumnType("int"); + + b.Property("ValNumber") + .HasColumnType("double"); + + b.Property("ValString") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("PlantDataId"); + + b.HasIndex("PlantId"); + + b.ToTable("PlantLog"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantStatusModel", b => + { + b.Property("PlantId") + .HasColumnType("int"); + + b.Property("FluxType") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("DtEvent") + .HasColumnType("datetime(6)"); + + b.Property("ValNumber") + .HasColumnType("double"); + + b.Property("ValString") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("PlantId", "FluxType"); + + b.ToTable("PlantStatus"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.RebootLogModel", b => + { + b.Property("RecordId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DtEvent") + .HasColumnType("datetime(6)"); + + b.Property("Item") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Payload") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("RecordId"); + + b.ToTable("RebootLog"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.SupplierModel", b => + { + b.Property("SupplierId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("SupplierCode") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SupplierDesc") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("SupplierId"); + + b.ToTable("Supplier"); + + b.HasData( + new + { + SupplierId = 1, + SupplierCode = "LIQUIGAS", + SupplierDesc = "Liquigas" + }, + new + { + SupplierId = 2, + SupplierCode = "VULKANGAS", + SupplierDesc = "Vulkangas" + }); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.TransporterModel", b => + { + b.Property("TransporterId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("PositionLatitude") + .HasColumnType("double"); + + b.Property("PositionLongitude") + .HasColumnType("double"); + + b.Property("PositionUpdated") + .HasColumnType("datetime(6)"); + + b.Property("TransporterCode") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("TransporterDesc") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("TransporterId"); + + b.ToTable("Transporter"); + + b.HasData( + new + { + TransporterId = 1, + PositionLatitude = 0.0, + PositionLongitude = 0.0, + PositionUpdated = new DateTime(2021, 8, 6, 18, 20, 35, 347, DateTimeKind.Local).AddTicks(1664), + TransporterCode = "LEVO", + TransporterDesc = "Levorato" + }, + new + { + TransporterId = 2, + PositionLatitude = 0.0, + PositionLongitude = 0.0, + PositionUpdated = new DateTime(2021, 8, 6, 18, 20, 35, 347, DateTimeKind.Local).AddTicks(2482), + TransporterCode = "TRAF", + TransporterDesc = "Traffik" + }); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.UserModel", b => + { + b.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuthKey") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Firstname") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Lang") + .HasMaxLength(10) + .HasColumnType("varchar(10)"); + + b.Property("Lastname") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Livello") + .HasColumnType("int"); + + b.Property("MaskPlantId") + .HasColumnType("int"); + + b.Property("MaskSupplierId") + .HasColumnType("int"); + + b.Property("MaskTranspId") + .HasColumnType("int"); + + b.Property("SaltPasswd") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("UserName") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("UserId"); + + b.ToTable("Users"); + + b.HasData( + new + { + UserId = 1, + AuthKey = "th1sIsTh3R1vrOfThNgt98", + Email = "samuele@steamware.net", + Firstname = "Samuele", + IsActive = true, + Lang = "IT", + Lastname = "Locatelli", + Livello = 1, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "samuele.locatelli" + }, + new + { + UserId = 2, + AuthKey = "th1sIsTh3R1vrOfThNgt91", + Email = "giancarlo@steamware.net", + Firstname = "Giancarlo", + IsActive = true, + Lang = "IT", + Lastname = "Rottoli", + Livello = 1, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "giancarlo.rottoli" + }, + new + { + UserId = 3, + AuthKey = "th1sIsTh3R1vrOfThNgt93", + Email = "info@steamware.net", + Firstname = "Steamware", + IsActive = true, + Lang = "IT", + Lastname = "Admin", + Livello = 1, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "steamw.admin" + }, + new + { + UserId = 4, + AuthKey = "th1sIsTh3R1vrOfThNgt97", + Email = "a.pizzaferri@pizzaferripetroli.it", + Firstname = "Angelo", + IsActive = true, + Lang = "IT", + Lastname = "Pizzaferri", + Livello = 2, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "angelo.pizzaferri" + }, + new + { + UserId = 5, + AuthKey = "th1sIsTh3R1vrOfThNgt99", + Email = "andrei.valeanu@winnlab.it", + Firstname = "Andrei", + IsActive = true, + Lang = "IT", + Lastname = "Valeanu", + Livello = 2, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "andrei.valeanu" + }, + new + { + UserId = 6, + AuthKey = "th1sIsTh3R1vrOfThNgt92", + Email = "info@steamware.net", + Firstname = "User", + IsActive = true, + Lang = "IT", + Lastname = "LIQUIGAS", + Livello = 4, + MaskPlantId = 0, + MaskSupplierId = 1, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "liquigas.user01" + }, + new + { + UserId = 7, + AuthKey = "th1sIsTh3R1vrOfThNgt94", + Email = "info@steamware.net", + Firstname = "User", + IsActive = true, + Lang = "IT", + Lastname = "VULKANGAS", + Livello = 4, + MaskPlantId = 0, + MaskSupplierId = 2, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "vulkangas.user01" + }, + new + { + UserId = 8, + AuthKey = "th1sIsTh3R1vrOfThNgt95", + Email = "info@steamware.net", + Firstname = "User", + IsActive = true, + Lang = "IT", + Lastname = "LEVORATO", + Livello = 4, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 1, + SaltPasswd = "", + UserName = "levorato.user01" + }, + new + { + UserId = 9, + AuthKey = "th1sIsTh3R1vrOfThNgt96", + Email = "info@steamware.net", + Firstname = "User", + IsActive = true, + Lang = "IT", + Lastname = "TRAFFIK", + Livello = 4, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 2, + SaltPasswd = "", + UserName = "traffik.user01" + }, + new + { + UserId = 10, + AuthKey = "th1sIsTh3R1vrOfThNgt96", + Email = "info@steamware.net", + Firstname = "Stazione", + IsActive = true, + Lang = "IT", + Lastname = "Collecchio", + Livello = 3, + MaskPlantId = 1, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "piz03.user01" + }, + new + { + UserId = 11, + AuthKey = "th1sIsTh3R1vrOfThNgt96", + Email = "info@steamware.net", + Firstname = "Stazione", + IsActive = true, + Lang = "IT", + Lastname = "Noceto", + Livello = 3, + MaskPlantId = 2, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "piz04.user01" + }, + new + { + UserId = 12, + AuthKey = "th1sIsTh3R1vrOfThNgt96", + Email = "info@steamware.net", + Firstname = "Stazione", + IsActive = true, + Lang = "IT", + Lastname = "Baganzola", + Livello = 3, + MaskPlantId = 3, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "piz05.user01" + }, + new + { + UserId = 13, + AuthKey = "th1sIsTh3R1vrOfThNgt96", + Email = "info@steamware.net", + Firstname = "Stazione", + IsActive = true, + Lang = "IT", + Lastname = "Pilastrello", + Livello = 3, + MaskPlantId = 4, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "piz08.user01" + }); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.WeekPlanModel", b => + { + b.Property("WeekPlanId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DayNum") + .HasColumnType("int"); + + b.Property("DeliveryHour") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("PlantId") + .HasColumnType("int"); + + b.Property("SupplierId") + .HasColumnType("int"); + + b.Property("TransporterId") + .HasColumnType("int"); + + b.HasKey("WeekPlanId"); + + b.HasIndex("PlantId"); + + b.HasIndex("SupplierId"); + + b.HasIndex("TransporterId"); + + b.ToTable("WeekPlan"); + + b.HasData( + new + { + WeekPlanId = 1, + DayNum = 1, + DeliveryHour = 20, + Note = "18K", + PlantId = 2, + SupplierId = 1, + TransporterId = 1 + }, + new + { + WeekPlanId = 2, + DayNum = 2, + DeliveryHour = 20, + Note = "18K", + PlantId = 2, + SupplierId = 1, + TransporterId = 1 + }, + new + { + WeekPlanId = 3, + DayNum = 3, + DeliveryHour = 20, + Note = "18K", + PlantId = 2, + SupplierId = 1, + TransporterId = 2 + }, + new + { + WeekPlanId = 4, + DayNum = 4, + DeliveryHour = 15, + Note = "9K", + PlantId = 2, + SupplierId = 1, + TransporterId = 1 + }, + new + { + WeekPlanId = 5, + DayNum = 4, + DeliveryHour = 20, + Note = "18K", + PlantId = 2, + SupplierId = 1, + TransporterId = 1 + }, + new + { + WeekPlanId = 6, + DayNum = 6, + DeliveryHour = 20, + Note = "18K", + PlantId = 2, + SupplierId = 1, + TransporterId = 1 + }, + new + { + WeekPlanId = 7, + DayNum = 2, + DeliveryHour = 14, + Note = "3K", + PlantId = 3, + SupplierId = 1, + TransporterId = 1 + }, + new + { + WeekPlanId = 8, + DayNum = 2, + DeliveryHour = 15, + Note = "15K", + PlantId = 4, + SupplierId = 1, + TransporterId = 1 + }, + new + { + WeekPlanId = 9, + DayNum = 2, + DeliveryHour = 17, + Note = "18K", + PlantId = 1, + SupplierId = 2, + TransporterId = 2 + }); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.OrderModel", b => + { + b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant") + .WithMany() + .HasForeignKey("PlantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GWMS.Data.DatabaseModels.SupplierModel", "Supplier") + .WithMany() + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GWMS.Data.DatabaseModels.TransporterModel", "Transporter") + .WithMany() + .HasForeignKey("TransporterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Plant"); + + b.Navigation("Supplier"); + + b.Navigation("Transporter"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantLogModel", b => + { + b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant") + .WithMany() + .HasForeignKey("PlantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Plant"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantStatusModel", b => + { + b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant") + .WithMany() + .HasForeignKey("PlantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Plant"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.WeekPlanModel", b => + { + b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant") + .WithMany() + .HasForeignKey("PlantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GWMS.Data.DatabaseModels.SupplierModel", "Supplier") + .WithMany() + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GWMS.Data.DatabaseModels.TransporterModel", "Transporter") + .WithMany() + .HasForeignKey("TransporterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Plant"); + + b.Navigation("Supplier"); + + b.Navigation("Transporter"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/GWMS.Data/Migrations/20210806162035_AddOrderDefQty.cs b/GWMS.Data/Migrations/20210806162035_AddOrderDefQty.cs new file mode 100644 index 0000000..005ed10 --- /dev/null +++ b/GWMS.Data/Migrations/20210806162035_AddOrderDefQty.cs @@ -0,0 +1,81 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace GWMS.Data.Migrations +{ + public partial class AddOrderDefQty : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "OrderQtyStd", + table: "PlantDetail", + type: "double", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.UpdateData( + table: "PlantDetail", + keyColumn: "PlantId", + keyValue: 1, + column: "OrderQtyStd", + value: 18000.0); + + migrationBuilder.UpdateData( + table: "PlantDetail", + keyColumn: "PlantId", + keyValue: 2, + column: "OrderQtyStd", + value: 18000.0); + + migrationBuilder.UpdateData( + table: "PlantDetail", + keyColumn: "PlantId", + keyValue: 3, + column: "OrderQtyStd", + value: 18000.0); + + migrationBuilder.UpdateData( + table: "PlantDetail", + keyColumn: "PlantId", + keyValue: 4, + column: "OrderQtyStd", + value: 18000.0); + + migrationBuilder.UpdateData( + table: "Transporter", + keyColumn: "TransporterId", + keyValue: 1, + column: "PositionUpdated", + value: new DateTime(2021, 8, 6, 18, 20, 35, 347, DateTimeKind.Local).AddTicks(1664)); + + migrationBuilder.UpdateData( + table: "Transporter", + keyColumn: "TransporterId", + keyValue: 2, + column: "PositionUpdated", + value: new DateTime(2021, 8, 6, 18, 20, 35, 347, DateTimeKind.Local).AddTicks(2482)); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "OrderQtyStd", + table: "PlantDetail"); + + migrationBuilder.UpdateData( + table: "Transporter", + keyColumn: "TransporterId", + keyValue: 1, + column: "PositionUpdated", + value: new DateTime(2021, 8, 6, 15, 40, 12, 341, DateTimeKind.Local).AddTicks(9521)); + + migrationBuilder.UpdateData( + table: "Transporter", + keyColumn: "TransporterId", + keyValue: 2, + column: "PositionUpdated", + value: new DateTime(2021, 8, 6, 15, 40, 12, 341, DateTimeKind.Local).AddTicks(9901)); + } + } +} diff --git a/GWMS.Data/Migrations/GWMSContextModelSnapshot.cs b/GWMS.Data/Migrations/GWMSContextModelSnapshot.cs index ad32f55..7c87d70 100644 --- a/GWMS.Data/Migrations/GWMSContextModelSnapshot.cs +++ b/GWMS.Data/Migrations/GWMSContextModelSnapshot.cs @@ -189,6 +189,9 @@ namespace GWMS.Data.Migrations b.Property("LevelReorder") .HasColumnType("double"); + b.Property("OrderQtyStd") + .HasColumnType("double"); + b.Property("PlantCode") .HasMaxLength(100) .HasColumnType("varchar(100)"); @@ -207,6 +210,7 @@ namespace GWMS.Data.Migrations PlantId = 1, LevelMax = 26000.0, LevelReorder = 15000.0, + OrderQtyStd = 18000.0, PlantCode = "PIZ03", PlantDesc = "Collecchio" }, @@ -215,6 +219,7 @@ namespace GWMS.Data.Migrations PlantId = 2, LevelMax = 28000.0, LevelReorder = 15000.0, + OrderQtyStd = 18000.0, PlantCode = "PIZ04", PlantDesc = "Noceto" }, @@ -223,6 +228,7 @@ namespace GWMS.Data.Migrations PlantId = 3, LevelMax = 24000.0, LevelReorder = 15000.0, + OrderQtyStd = 18000.0, PlantCode = "PIZ05", PlantDesc = "Baganzola" }, @@ -231,6 +237,7 @@ namespace GWMS.Data.Migrations PlantId = 4, LevelMax = 26000.0, LevelReorder = 15000.0, + OrderQtyStd = 18000.0, PlantCode = "PIZ08", PlantDesc = "Pilastrello" }); @@ -378,7 +385,7 @@ namespace GWMS.Data.Migrations TransporterId = 1, PositionLatitude = 0.0, PositionLongitude = 0.0, - PositionUpdated = new DateTime(2021, 8, 6, 15, 40, 12, 341, DateTimeKind.Local).AddTicks(9521), + PositionUpdated = new DateTime(2021, 8, 6, 18, 20, 35, 347, DateTimeKind.Local).AddTicks(1664), TransporterCode = "LEVO", TransporterDesc = "Levorato" }, @@ -387,7 +394,7 @@ namespace GWMS.Data.Migrations TransporterId = 2, PositionLatitude = 0.0, PositionLongitude = 0.0, - PositionUpdated = new DateTime(2021, 8, 6, 15, 40, 12, 341, DateTimeKind.Local).AddTicks(9901), + PositionUpdated = new DateTime(2021, 8, 6, 18, 20, 35, 347, DateTimeKind.Local).AddTicks(2482), TransporterCode = "TRAF", TransporterDesc = "Traffik" }); From f9a66b1371572000880ec107b7e2f7574ce1ce0b Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 6 Aug 2021 18:22:16 +0200 Subject: [PATCH 03/15] Aggiunta bozza gestione creazione riordini automatici (da schedulare?) --- GWMS.Data/Controllers/GWMSController.cs | 37 ++++++++++++ GWMS.Data/DTO/PlantDTO.cs | 3 + GWMS.Data/DatabaseModels/PlantDetailModel.cs | 2 +- GWMS.Data/ModelBuilderExtensions.cs | 8 +-- GWMS.UI/Data/GWMSDataService.cs | 60 ++++++++++++++++++-- GWMS.UI/GWMS.UI.csproj | 2 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 9 files changed, 105 insertions(+), 13 deletions(-) diff --git a/GWMS.Data/Controllers/GWMSController.cs b/GWMS.Data/Controllers/GWMSController.cs index 4fd2f17..61601e6 100644 --- a/GWMS.Data/Controllers/GWMSController.cs +++ b/GWMS.Data/Controllers/GWMSController.cs @@ -190,6 +190,20 @@ namespace GWMS.Data.Controllers return dbResult; } + public List GetOrdersOpen(int PlantId) + { + var dbResult = dbCtx + .DbSetOrders + .Where(x => (x.PlantId == PlantId || PlantId == 0) && (x.DtExecStart < x.DtOrder)) + .Include(p => p.Plant) + .Include(s => s.Supplier) + .Include(t => t.Transporter) + .OrderByDescending(x => x.DtOrder) + .ToList(); + + return dbResult; + } + public PlantDetailModel GetPlant(int PlantId) { var dbResult = dbCtx @@ -319,6 +333,27 @@ namespace GWMS.Data.Controllers return answ; } + /// + /// Aggiunta in blocco di Ordini + /// + /// + /// + public bool OrderInsert(List newItems) + { + bool done = false; + try + { + dbCtx + .DbSetOrders + .AddRange(newItems); + dbCtx.SaveChanges(); + done = true; + } + catch (Exception exc) + { } + return done; + } + /// /// Aggiorna un Ordine /// @@ -443,6 +478,8 @@ namespace GWMS.Data.Controllers PlantDesc = currPlant.PlantDesc, LevelAct = actLevel, LevelMax = currPlant.LevelMax, + LevelReorder = currPlant.LevelReorder, + OrderQtyStd = currPlant.OrderQtyStd, PressAct = PressAct, LevelTS = LevelTS, PressTS = PressTS, diff --git a/GWMS.Data/DTO/PlantDTO.cs b/GWMS.Data/DTO/PlantDTO.cs index d03c146..f4c3778 100644 --- a/GWMS.Data/DTO/PlantDTO.cs +++ b/GWMS.Data/DTO/PlantDTO.cs @@ -21,6 +21,9 @@ namespace GWMS.Data.DTO public double LevelMax { get; set; } = 99999; public double LevelAct { get; set; } = 0; + public double LevelReorder { get; set; } = 0; + public double OrderQtyStd { get; set; } = 0; + public int LevelRatio { diff --git a/GWMS.Data/DatabaseModels/PlantDetailModel.cs b/GWMS.Data/DatabaseModels/PlantDetailModel.cs index 46761cb..c77c0b7 100644 --- a/GWMS.Data/DatabaseModels/PlantDetailModel.cs +++ b/GWMS.Data/DatabaseModels/PlantDetailModel.cs @@ -30,7 +30,7 @@ namespace GWMS.Data.DatabaseModels public double LevelReorder { get; set; } = 0; - //public double PressMax { get; set; } = 9999; + public double OrderQtyStd { get; set; } = 1000; //public double PressAct { get; set; } = 0; diff --git a/GWMS.Data/ModelBuilderExtensions.cs b/GWMS.Data/ModelBuilderExtensions.cs index fb434ac..fc21a75 100644 --- a/GWMS.Data/ModelBuilderExtensions.cs +++ b/GWMS.Data/ModelBuilderExtensions.cs @@ -37,10 +37,10 @@ namespace GWMS.Data // inizializzazione dei valori di default x Plant modelBuilder.Entity().HasData( - new PlantDetailModel { PlantId = 1, PlantCode = "PIZ03", PlantDesc = "Collecchio", LevelMax = 26000, LevelReorder = 15000 }, - new PlantDetailModel { PlantId = 2, PlantCode = "PIZ04", PlantDesc = "Noceto", LevelMax = 28000, LevelReorder = 15000 }, - new PlantDetailModel { PlantId = 3, PlantCode = "PIZ05", PlantDesc = "Baganzola", LevelMax = 24000, LevelReorder = 15000 }, - new PlantDetailModel { PlantId = 4, PlantCode = "PIZ08", PlantDesc = "Pilastrello", LevelMax = 26000, LevelReorder = 15000 } + new PlantDetailModel { PlantId = 1, PlantCode = "PIZ03", PlantDesc = "Collecchio", LevelMax = 26000, LevelReorder = 15000, OrderQtyStd = 18000 }, + new PlantDetailModel { PlantId = 2, PlantCode = "PIZ04", PlantDesc = "Noceto", LevelMax = 28000, LevelReorder = 15000, OrderQtyStd = 18000 }, + new PlantDetailModel { PlantId = 3, PlantCode = "PIZ05", PlantDesc = "Baganzola", LevelMax = 24000, LevelReorder = 15000, OrderQtyStd = 18000 }, + new PlantDetailModel { PlantId = 4, PlantCode = "PIZ08", PlantDesc = "Pilastrello", LevelMax = 26000, LevelReorder = 15000, OrderQtyStd = 18000 } // new PlantDetailModel { PlantId = 1, PlantCode = "PIZ03", PlantDesc = "Collecchio", LevelMax = 26000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 }, //new PlantDetailModel { PlantId = 2, PlantCode = "PIZ04", PlantDesc = "Noceto", LevelMax = 28000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 }, //new PlantDetailModel { PlantId = 3, PlantCode = "PIZ05", PlantDesc = "Baganzola", LevelMax = 24000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 }, diff --git a/GWMS.UI/Data/GWMSDataService.cs b/GWMS.UI/Data/GWMSDataService.cs index 84137ee..4b19896 100644 --- a/GWMS.UI/Data/GWMSDataService.cs +++ b/GWMS.UI/Data/GWMSDataService.cs @@ -234,6 +234,41 @@ namespace GWMS.UI.Data return $"DATA:{dataType}"; } + /// + /// effettua verifica x tutti i plant, se livello > livello riordino e NON ci sono ordini APERTI in arrivo --> lancia ordine + /// + public async void checkLevels() + { + List NewOrders = new List(); + DateTime adesso = DateTime.Now; + int supplierId = 1; + int transporterId = 1; + double qtyOrd = 0; + // faccio ciclo x tutti gli impianti + var currPlantData = await PlantsGetAll(); + foreach (var item in currPlantData) + { + // recupero ordini x il plant + var currOrderOpen = await OrdersGetOpen(item.PlantId); + // calcolo delta ordinato + qtyOrd = currOrderOpen.Sum(x => x.OrderQty); + // verifico il livello attuale + i valori degli ordini APERTI rispetto al livello di riordino... + if (item.LevelAct + qtyOrd < item.LevelReorder) + { + // FARE !!! FIXME TODO calcolo supplier/transporter da tab WeekPlan + supplierId = 1; + transporterId = 1; + // stacco un NUOVO ordine di quantità finita + NewOrders.Add(new OrderModel() { DtOrder = adesso, OrderQty = item.OrderQtyStd, PlantId = item.PlantId, OrderCode = $"O{item.PlantId:00}{adesso:yyMMddHH}", OrderDesc = $"Ordine {item.PlantDesc} - {adesso}", SupplierId = supplierId, TransporterId = transporterId }); + } + } + if (NewOrders.Count > 0) + { + // effettuo inserimento ordini! + dbController.OrderInsert(NewOrders); + } + } + public async Task> ConfigGetAll() { //return Task.FromResult(dbController.ActionsGetAll()); @@ -355,6 +390,25 @@ namespace GWMS.UI.Data return await Task.FromResult(dbResult); } + /// + /// Elenco degli ordini ancora aperti x il Plant + /// + /// + /// + public async Task> OrdersGetOpen(int PlantId) + { + List dbResult = new List(); + + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = dbController.GetOrdersOpen(PlantId); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Info($"Effettuata lettura da DB per OrdersGetOpen | PlantId: {PlantId} | {ts.TotalMilliseconds} ms"); + + return await Task.FromResult(dbResult); + } + public void OrderUpdate(OrderModel currItem) { try @@ -595,8 +649,7 @@ namespace GWMS.UI.Data //dbController.ResetController(); dbController.WeekPlanDelete(currItem); string cacheKey = $"DATA:WEEKPLAN:List"; - var redisDataList = Encoding.UTF8.GetBytes(""); - await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true)); + await distributedCache.RemoveAsync(cacheKey); } catch { @@ -623,8 +676,7 @@ namespace GWMS.UI.Data //dbController.ResetController(); dbController.WeekPlanUpdate(currItem); string cacheKey = $"DATA:WEEKPLAN:List"; - var redisDataList = Encoding.UTF8.GetBytes(""); - await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true)); + await distributedCache.RemoveAsync(cacheKey); } catch { diff --git a/GWMS.UI/GWMS.UI.csproj b/GWMS.UI/GWMS.UI.csproj index 15573cf..5e603b9 100644 --- a/GWMS.UI/GWMS.UI.csproj +++ b/GWMS.UI/GWMS.UI.csproj @@ -2,7 +2,7 @@ net5.0 - 1.0.2108.0617 + 1.0.2108.0618 95c9f021-52d1-4390-a670-5810b7b777b0 diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index f2ea01a..61a6ced 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ GWMS - Gas Warehouse Management System -

Versione: 1.0.2108.0617

+

Versione: 1.0.2108.0618


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 765c537..c670a70 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2108.0617 +1.0.2108.0618 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index e6d66f9..fd921fa 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2108.0617 + 1.0.2108.0618 http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html false From 70ce9ee91c07a0c1d215fc436f40a47bf16b9d64 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 6 Aug 2021 18:43:18 +0200 Subject: [PATCH 04/15] Aggiunto appunti x gestione riordino automatico (DA VALIDARE) --- GWMS.UI/Data/GWMSDataService.cs | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/GWMS.UI/Data/GWMSDataService.cs b/GWMS.UI/Data/GWMSDataService.cs index 4b19896..b1ce82d 100644 --- a/GWMS.UI/Data/GWMSDataService.cs +++ b/GWMS.UI/Data/GWMSDataService.cs @@ -245,7 +245,8 @@ namespace GWMS.UI.Data int transporterId = 1; double qtyOrd = 0; // faccio ciclo x tutti gli impianti - var currPlantData = await PlantsGetAll(); + List currPlantData = await PlantsGetAll(); + List fullWeekPlan = WeekPlanGet().Result; foreach (var item in currPlantData) { // recupero ordini x il plant @@ -255,9 +256,19 @@ namespace GWMS.UI.Data // verifico il livello attuale + i valori degli ordini APERTI rispetto al livello di riordino... if (item.LevelAct + qtyOrd < item.LevelReorder) { - // FARE !!! FIXME TODO calcolo supplier/transporter da tab WeekPlan - supplierId = 1; - transporterId = 1; + // (FARE !!! VERIFICA!!!!) + // calcolo supplier/transporter da tab WeekPlan + var dailyPlan = fullWeekPlan.Where(x => x.PlantId == item.PlantId && (int)x.DayNum == ((int)adesso.DayOfWeek + 1)).FirstOrDefault(); + if (dailyPlan != null) + { + supplierId = dailyPlan.SupplierId; + transporterId = dailyPlan.TransporterId; + } + else + { + supplierId = 1; + transporterId = 1; + } // stacco un NUOVO ordine di quantità finita NewOrders.Add(new OrderModel() { DtOrder = adesso, OrderQty = item.OrderQtyStd, PlantId = item.PlantId, OrderCode = $"O{item.PlantId:00}{adesso:yyMMddHH}", OrderDesc = $"Ordine {item.PlantDesc} - {adesso}", SupplierId = supplierId, TransporterId = transporterId }); } @@ -266,6 +277,20 @@ namespace GWMS.UI.Data { // effettuo inserimento ordini! dbController.OrderInsert(NewOrders); + + // invio email x ogni fornitore x i NUOVI ordini inseriti + var orders4supp = NewOrders.GroupBy(g => g.SupplierId).FirstOrDefault(); + foreach (var item in orders4supp) + { + // invio email di notifica nuovi ordini inseriti + } + + // invio email x ogni fornitore x i NUOVI ordini inseriti + var orders4transp = NewOrders.GroupBy(g => g.TransporterId).FirstOrDefault(); + foreach (var item in orders4transp) + { + // invio email di notifica nuovi ordini inseriti + } } } From 24e76181e687f9b06d9c210b211d757e7ddbb40d Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 6 Aug 2021 18:49:26 +0200 Subject: [PATCH 05/15] appuntata gestione verifica livelli su insert FLog --- GWMS.UI/Controllers/IOBController.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/GWMS.UI/Controllers/IOBController.cs b/GWMS.UI/Controllers/IOBController.cs index 0433890..1924598 100644 --- a/GWMS.UI/Controllers/IOBController.cs +++ b/GWMS.UI/Controllers/IOBController.cs @@ -286,6 +286,10 @@ namespace GWMS.UI.Controllers List plData = rawData.fluxData.Select(jpl => _DataService.convertFluxToPL(currPlant.PlantId, jpl)).ToList(); //insert! fatto = await _DataService.PlantLogInsert(plData); + // effettuo SEMPRE verifica per ricalcolo ordini... + + // FIXME TODO FARE !!! + //_DataService.checkLevels(); } } if (fatto) From 08d0134f8c66eb1e26f6aac8219f4a2da164ad64 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 6 Aug 2021 18:49:39 +0200 Subject: [PATCH 06/15] refresh metodi gestione ricalcolo ordini --- GWMS.UI/Controllers/IOBController.cs | 8 +- GWMS.UI/Data/GWMSDataService.cs | 115 +++++++++++++++------------ 2 files changed, 68 insertions(+), 55 deletions(-) diff --git a/GWMS.UI/Controllers/IOBController.cs b/GWMS.UI/Controllers/IOBController.cs index 1924598..1800673 100644 --- a/GWMS.UI/Controllers/IOBController.cs +++ b/GWMS.UI/Controllers/IOBController.cs @@ -248,6 +248,9 @@ namespace GWMS.UI.Controllers newData.Add(newItem); // insert! fatto = await _DataService.PlantLogInsert(newData); + + // effettuo SEMPRE verifica per ricalcolo ordini... + _DataService.checkLevels(); } } catch (Exception exc) @@ -286,10 +289,9 @@ namespace GWMS.UI.Controllers List plData = rawData.fluxData.Select(jpl => _DataService.convertFluxToPL(currPlant.PlantId, jpl)).ToList(); //insert! fatto = await _DataService.PlantLogInsert(plData); - // effettuo SEMPRE verifica per ricalcolo ordini... - // FIXME TODO FARE !!! - //_DataService.checkLevels(); + // effettuo SEMPRE verifica per ricalcolo ordini... + _DataService.checkLevels(); } } if (fatto) diff --git a/GWMS.UI/Data/GWMSDataService.cs b/GWMS.UI/Data/GWMSDataService.cs index b1ce82d..26e9b74 100644 --- a/GWMS.UI/Data/GWMSDataService.cs +++ b/GWMS.UI/Data/GWMSDataService.cs @@ -186,58 +186,7 @@ namespace GWMS.UI.Data return mHash(string.Format("ExeTask:{0}", idxMacchina)); } - protected string getCacheKey(string TableName, SelectOrderData CurrFilter) - { - string answ = $"{TableName}:P_{CurrFilter.PlantId:00}:S_{CurrFilter.SupplierId:00}:T_{CurrFilter.TransporterId:00}:D_{CurrFilter.DateStart:yyyyMMddHHmm}_{CurrFilter.DateEnd:yyyyMMddHHmm}"; - return answ; - } - - protected async Task> PlantLogGetLastByFlux(int PlantId) - { - List lastValues = new List(); - // cerco in cache - string cacheKey = $"DATA:PLANTS:LastFlux:{PlantId}"; - string rawData; - var redisDataList = await distributedCache.GetAsync(cacheKey); - if (redisDataList != null) - { - rawData = Encoding.UTF8.GetString(redisDataList); - lastValues = JsonConvert.DeserializeObject>(rawData); - } - // altrimenti DB e salvo... - else - { - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - lastValues = dbController.PlantLogGetLastByFlux(PlantId); - rawData = JsonConvert.SerializeObject(lastValues); - redisDataList = Encoding.UTF8.GetBytes(rawData); - await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true)); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Info($"Effettuata lettura da DB + caching per PlantLogGetLastByFlux: {ts.TotalMilliseconds} ms"); - } - return await Task.FromResult(lastValues); - } - - #endregion Protected Methods - - #region Public Methods - - /// - /// Hash Redis contenente i dati MP di una specifico TYPE (es StatusMacchina, StateMachineIngressi, ...) - /// - /// - /// - public static string mHash(string dataType) - { - return $"DATA:{dataType}"; - } - - /// - /// effettua verifica x tutti i plant, se livello > livello riordino e NON ci sono ordini APERTI in arrivo --> lancia ordine - /// - public async void checkLevels() + protected async void checkCreateOrders() { List NewOrders = new List(); DateTime adesso = DateTime.Now; @@ -294,6 +243,68 @@ namespace GWMS.UI.Data } } + protected string getCacheKey(string TableName, SelectOrderData CurrFilter) + { + string answ = $"{TableName}:P_{CurrFilter.PlantId:00}:S_{CurrFilter.SupplierId:00}:T_{CurrFilter.TransporterId:00}:D_{CurrFilter.DateStart:yyyyMMddHHmm}_{CurrFilter.DateEnd:yyyyMMddHHmm}"; + return answ; + } + + protected async Task> PlantLogGetLastByFlux(int PlantId) + { + List lastValues = new List(); + // cerco in cache + string cacheKey = $"DATA:PLANTS:LastFlux:{PlantId}"; + string rawData; + var redisDataList = await distributedCache.GetAsync(cacheKey); + if (redisDataList != null) + { + rawData = Encoding.UTF8.GetString(redisDataList); + lastValues = JsonConvert.DeserializeObject>(rawData); + } + // altrimenti DB e salvo... + else + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + lastValues = dbController.PlantLogGetLastByFlux(PlantId); + rawData = JsonConvert.SerializeObject(lastValues); + redisDataList = Encoding.UTF8.GetBytes(rawData); + await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true)); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Info($"Effettuata lettura da DB + caching per PlantLogGetLastByFlux: {ts.TotalMilliseconds} ms"); + } + return await Task.FromResult(lastValues); + } + + #endregion Protected Methods + + #region Public Methods + + /// + /// Hash Redis contenente i dati MP di una specifico TYPE (es StatusMacchina, StateMachineIngressi, ...) + /// + /// + /// + public static string mHash(string dataType) + { + return $"DATA:{dataType}"; + } + + /// + /// effettua verifica x tutti i plant, se livello > livello riordino e NON ci sono ordini APERTI in arrivo --> lancia ordine + /// + public void checkLevels() + { + // effettuo verifica veto ricalcolo ordini da cache... + + // se non ho veto --> controllo + // FIXME TODO FARE !!! + //checkCreateOrders(); + + // imposto nuovo veto... + } + public async Task> ConfigGetAll() { //return Task.FromResult(dbController.ActionsGetAll()); From 259cba1dc87fbf979fa5e4935f46a502b606fb58 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 9 Aug 2021 16:39:49 +0200 Subject: [PATCH 07/15] refresh modelli x ordini --- GWMS.Data/DatabaseModels/OrderModel.cs | 4 ++++ GWMS.Data/DatabaseModels/PlantDetailModel.cs | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/GWMS.Data/DatabaseModels/OrderModel.cs b/GWMS.Data/DatabaseModels/OrderModel.cs index cf1ba78..953ca6f 100644 --- a/GWMS.Data/DatabaseModels/OrderModel.cs +++ b/GWMS.Data/DatabaseModels/OrderModel.cs @@ -44,6 +44,10 @@ namespace GWMS.Data.DatabaseModels public double ExecutionQty { get; set; } = 0; + public double LevelStart { get; set; } = 0; + + public double LevelEnd { get; set; } = 1; + [ForeignKey("PlantId")] public virtual PlantDetailModel Plant { get; set; } diff --git a/GWMS.Data/DatabaseModels/PlantDetailModel.cs b/GWMS.Data/DatabaseModels/PlantDetailModel.cs index c77c0b7..5442d25 100644 --- a/GWMS.Data/DatabaseModels/PlantDetailModel.cs +++ b/GWMS.Data/DatabaseModels/PlantDetailModel.cs @@ -26,12 +26,14 @@ namespace GWMS.Data.DatabaseModels [MaxLength(250)] public string PlantDesc { get; set; } = ""; - public double LevelMax { get; set; } = 9999; + public double LevelMax { get; set; } = 29999; public double LevelReorder { get; set; } = 0; public double OrderQtyStd { get; set; } = 1000; + //public double LastLevelMax { get; set; } = 0; + //public double PressAct { get; set; } = 0; //public double PressBHMax { get; set; } = 9999; From 7cd86f0036f43289142bf8a09679671a1e7f471f Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 9 Aug 2021 16:39:56 +0200 Subject: [PATCH 08/15] aggiunta migrations --- .../20210809143652_OrderFillData.Designer.cs | 881 ++++++++++++++++++ .../20210809143652_OrderFillData.cs | 64 ++ .../Migrations/GWMSContextModelSnapshot.cs | 10 +- 3 files changed, 953 insertions(+), 2 deletions(-) create mode 100644 GWMS.Data/Migrations/20210809143652_OrderFillData.Designer.cs create mode 100644 GWMS.Data/Migrations/20210809143652_OrderFillData.cs diff --git a/GWMS.Data/Migrations/20210809143652_OrderFillData.Designer.cs b/GWMS.Data/Migrations/20210809143652_OrderFillData.Designer.cs new file mode 100644 index 0000000..20a3542 --- /dev/null +++ b/GWMS.Data/Migrations/20210809143652_OrderFillData.Designer.cs @@ -0,0 +1,881 @@ +// +using System; +using GWMS.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace GWMS.Data.Migrations +{ + [DbContext(typeof(GWMSContext))] + [Migration("20210809143652_OrderFillData")] + partial class OrderFillData + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 64) + .HasAnnotation("ProductVersion", "5.0.7"); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.AnKeyValModel", b => + { + b.Property("KeyName") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Descript") + .HasMaxLength(250) + .HasColumnType("varchar(250)") + .HasComment("Descrizione dell'item"); + + b.Property("ValFloat") + .HasColumnType("int"); + + b.Property("ValInt") + .HasColumnType("int"); + + b.Property("ValString") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("KeyName"); + + b.ToTable("AnKeyVal"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.ConfigModel", b => + { + b.Property("KeyName") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Note") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Val") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ValStd") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("Valore di default/riferimento per la variabile"); + + b.HasKey("KeyName"); + + b.ToTable("Config"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.ItemModel", b => + { + b.Property("ItemId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ItemCode") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("ItemDesc") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("ItemType") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("UM") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("ItemId"); + + b.ToTable("Items"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.ListValModel", b => + { + b.Property("TabName") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("TabName"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("FieldName"); + + b.Property("Val") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("Val"); + + b.Property("Descript") + .HasMaxLength(250) + .HasColumnType("varchar(250)") + .HasColumnName("Descript"); + + b.Property("Ordinal") + .HasColumnType("int") + .HasColumnName("Ordinal"); + + b.HasKey("TabName", "FieldName", "Val"); + + b.ToTable("ListVal"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DtETA") + .HasColumnType("datetime(6)"); + + b.Property("DtExecEnd") + .HasColumnType("datetime(6)"); + + b.Property("DtExecStart") + .HasColumnType("datetime(6)"); + + b.Property("DtOrder") + .HasColumnType("datetime(6)"); + + b.Property("ExecutionQty") + .HasColumnType("double"); + + b.Property("LevelEnd") + .HasColumnType("double"); + + b.Property("LevelStart") + .HasColumnType("double"); + + b.Property("OrderCode") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("OrderDesc") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("OrderQty") + .HasColumnType("double"); + + b.Property("PlantId") + .HasColumnType("int"); + + b.Property("SupplierId") + .HasColumnType("int"); + + b.Property("TransporterId") + .HasColumnType("int"); + + b.HasKey("OrderId"); + + b.HasIndex("PlantId"); + + b.HasIndex("SupplierId"); + + b.HasIndex("TransporterId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantDetailModel", b => + { + b.Property("PlantId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("LevelMax") + .HasColumnType("double"); + + b.Property("LevelReorder") + .HasColumnType("double"); + + b.Property("OrderQtyStd") + .HasColumnType("double"); + + b.Property("PlantCode") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("PlantDesc") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("PlantId"); + + b.ToTable("PlantDetail"); + + b.HasData( + new + { + PlantId = 1, + LevelMax = 26000.0, + LevelReorder = 15000.0, + OrderQtyStd = 18000.0, + PlantCode = "PIZ03", + PlantDesc = "Collecchio" + }, + new + { + PlantId = 2, + LevelMax = 28000.0, + LevelReorder = 15000.0, + OrderQtyStd = 18000.0, + PlantCode = "PIZ04", + PlantDesc = "Noceto" + }, + new + { + PlantId = 3, + LevelMax = 24000.0, + LevelReorder = 15000.0, + OrderQtyStd = 18000.0, + PlantCode = "PIZ05", + PlantDesc = "Baganzola" + }, + new + { + PlantId = 4, + LevelMax = 26000.0, + LevelReorder = 15000.0, + OrderQtyStd = 18000.0, + PlantCode = "PIZ08", + PlantDesc = "Pilastrello" + }); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantLogModel", b => + { + b.Property("PlantDataId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DtEvent") + .HasColumnType("datetime(6)"); + + b.Property("FluxType") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("PlantId") + .HasColumnType("int"); + + b.Property("ValNumber") + .HasColumnType("double"); + + b.Property("ValString") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("PlantDataId"); + + b.HasIndex("PlantId"); + + b.ToTable("PlantLog"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantStatusModel", b => + { + b.Property("PlantId") + .HasColumnType("int"); + + b.Property("FluxType") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("DtEvent") + .HasColumnType("datetime(6)"); + + b.Property("ValNumber") + .HasColumnType("double"); + + b.Property("ValString") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("PlantId", "FluxType"); + + b.ToTable("PlantStatus"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.RebootLogModel", b => + { + b.Property("RecordId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DtEvent") + .HasColumnType("datetime(6)"); + + b.Property("Item") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Payload") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("RecordId"); + + b.ToTable("RebootLog"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.SupplierModel", b => + { + b.Property("SupplierId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("SupplierCode") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SupplierDesc") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("SupplierId"); + + b.ToTable("Supplier"); + + b.HasData( + new + { + SupplierId = 1, + SupplierCode = "LIQUIGAS", + SupplierDesc = "Liquigas" + }, + new + { + SupplierId = 2, + SupplierCode = "VULKANGAS", + SupplierDesc = "Vulkangas" + }); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.TransporterModel", b => + { + b.Property("TransporterId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("PositionLatitude") + .HasColumnType("double"); + + b.Property("PositionLongitude") + .HasColumnType("double"); + + b.Property("PositionUpdated") + .HasColumnType("datetime(6)"); + + b.Property("TransporterCode") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("TransporterDesc") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("TransporterId"); + + b.ToTable("Transporter"); + + b.HasData( + new + { + TransporterId = 1, + PositionLatitude = 0.0, + PositionLongitude = 0.0, + PositionUpdated = new DateTime(2021, 8, 9, 16, 36, 52, 691, DateTimeKind.Local).AddTicks(9092), + TransporterCode = "LEVO", + TransporterDesc = "Levorato" + }, + new + { + TransporterId = 2, + PositionLatitude = 0.0, + PositionLongitude = 0.0, + PositionUpdated = new DateTime(2021, 8, 9, 16, 36, 52, 691, DateTimeKind.Local).AddTicks(9470), + TransporterCode = "TRAF", + TransporterDesc = "Traffik" + }); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.UserModel", b => + { + b.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuthKey") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Firstname") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Lang") + .HasMaxLength(10) + .HasColumnType("varchar(10)"); + + b.Property("Lastname") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Livello") + .HasColumnType("int"); + + b.Property("MaskPlantId") + .HasColumnType("int"); + + b.Property("MaskSupplierId") + .HasColumnType("int"); + + b.Property("MaskTranspId") + .HasColumnType("int"); + + b.Property("SaltPasswd") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("UserName") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("UserId"); + + b.ToTable("Users"); + + b.HasData( + new + { + UserId = 1, + AuthKey = "th1sIsTh3R1vrOfThNgt98", + Email = "samuele@steamware.net", + Firstname = "Samuele", + IsActive = true, + Lang = "IT", + Lastname = "Locatelli", + Livello = 1, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "samuele.locatelli" + }, + new + { + UserId = 2, + AuthKey = "th1sIsTh3R1vrOfThNgt91", + Email = "giancarlo@steamware.net", + Firstname = "Giancarlo", + IsActive = true, + Lang = "IT", + Lastname = "Rottoli", + Livello = 1, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "giancarlo.rottoli" + }, + new + { + UserId = 3, + AuthKey = "th1sIsTh3R1vrOfThNgt93", + Email = "info@steamware.net", + Firstname = "Steamware", + IsActive = true, + Lang = "IT", + Lastname = "Admin", + Livello = 1, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "steamw.admin" + }, + new + { + UserId = 4, + AuthKey = "th1sIsTh3R1vrOfThNgt97", + Email = "a.pizzaferri@pizzaferripetroli.it", + Firstname = "Angelo", + IsActive = true, + Lang = "IT", + Lastname = "Pizzaferri", + Livello = 2, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "angelo.pizzaferri" + }, + new + { + UserId = 5, + AuthKey = "th1sIsTh3R1vrOfThNgt99", + Email = "andrei.valeanu@winnlab.it", + Firstname = "Andrei", + IsActive = true, + Lang = "IT", + Lastname = "Valeanu", + Livello = 2, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "andrei.valeanu" + }, + new + { + UserId = 6, + AuthKey = "th1sIsTh3R1vrOfThNgt92", + Email = "info@steamware.net", + Firstname = "User", + IsActive = true, + Lang = "IT", + Lastname = "LIQUIGAS", + Livello = 4, + MaskPlantId = 0, + MaskSupplierId = 1, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "liquigas.user01" + }, + new + { + UserId = 7, + AuthKey = "th1sIsTh3R1vrOfThNgt94", + Email = "info@steamware.net", + Firstname = "User", + IsActive = true, + Lang = "IT", + Lastname = "VULKANGAS", + Livello = 4, + MaskPlantId = 0, + MaskSupplierId = 2, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "vulkangas.user01" + }, + new + { + UserId = 8, + AuthKey = "th1sIsTh3R1vrOfThNgt95", + Email = "info@steamware.net", + Firstname = "User", + IsActive = true, + Lang = "IT", + Lastname = "LEVORATO", + Livello = 4, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 1, + SaltPasswd = "", + UserName = "levorato.user01" + }, + new + { + UserId = 9, + AuthKey = "th1sIsTh3R1vrOfThNgt96", + Email = "info@steamware.net", + Firstname = "User", + IsActive = true, + Lang = "IT", + Lastname = "TRAFFIK", + Livello = 4, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 2, + SaltPasswd = "", + UserName = "traffik.user01" + }, + new + { + UserId = 10, + AuthKey = "th1sIsTh3R1vrOfThNgt96", + Email = "info@steamware.net", + Firstname = "Stazione", + IsActive = true, + Lang = "IT", + Lastname = "Collecchio", + Livello = 3, + MaskPlantId = 1, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "piz03.user01" + }, + new + { + UserId = 11, + AuthKey = "th1sIsTh3R1vrOfThNgt96", + Email = "info@steamware.net", + Firstname = "Stazione", + IsActive = true, + Lang = "IT", + Lastname = "Noceto", + Livello = 3, + MaskPlantId = 2, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "piz04.user01" + }, + new + { + UserId = 12, + AuthKey = "th1sIsTh3R1vrOfThNgt96", + Email = "info@steamware.net", + Firstname = "Stazione", + IsActive = true, + Lang = "IT", + Lastname = "Baganzola", + Livello = 3, + MaskPlantId = 3, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "piz05.user01" + }, + new + { + UserId = 13, + AuthKey = "th1sIsTh3R1vrOfThNgt96", + Email = "info@steamware.net", + Firstname = "Stazione", + IsActive = true, + Lang = "IT", + Lastname = "Pilastrello", + Livello = 3, + MaskPlantId = 4, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "piz08.user01" + }); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.WeekPlanModel", b => + { + b.Property("WeekPlanId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DayNum") + .HasColumnType("int"); + + b.Property("DeliveryHour") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("PlantId") + .HasColumnType("int"); + + b.Property("SupplierId") + .HasColumnType("int"); + + b.Property("TransporterId") + .HasColumnType("int"); + + b.HasKey("WeekPlanId"); + + b.HasIndex("PlantId"); + + b.HasIndex("SupplierId"); + + b.HasIndex("TransporterId"); + + b.ToTable("WeekPlan"); + + b.HasData( + new + { + WeekPlanId = 1, + DayNum = 1, + DeliveryHour = 20, + Note = "18K", + PlantId = 2, + SupplierId = 1, + TransporterId = 1 + }, + new + { + WeekPlanId = 2, + DayNum = 2, + DeliveryHour = 20, + Note = "18K", + PlantId = 2, + SupplierId = 1, + TransporterId = 1 + }, + new + { + WeekPlanId = 3, + DayNum = 3, + DeliveryHour = 20, + Note = "18K", + PlantId = 2, + SupplierId = 1, + TransporterId = 2 + }, + new + { + WeekPlanId = 4, + DayNum = 4, + DeliveryHour = 15, + Note = "9K", + PlantId = 2, + SupplierId = 1, + TransporterId = 1 + }, + new + { + WeekPlanId = 5, + DayNum = 4, + DeliveryHour = 20, + Note = "18K", + PlantId = 2, + SupplierId = 1, + TransporterId = 1 + }, + new + { + WeekPlanId = 6, + DayNum = 6, + DeliveryHour = 20, + Note = "18K", + PlantId = 2, + SupplierId = 1, + TransporterId = 1 + }, + new + { + WeekPlanId = 7, + DayNum = 2, + DeliveryHour = 14, + Note = "3K", + PlantId = 3, + SupplierId = 1, + TransporterId = 1 + }, + new + { + WeekPlanId = 8, + DayNum = 2, + DeliveryHour = 15, + Note = "15K", + PlantId = 4, + SupplierId = 1, + TransporterId = 1 + }, + new + { + WeekPlanId = 9, + DayNum = 2, + DeliveryHour = 17, + Note = "18K", + PlantId = 1, + SupplierId = 2, + TransporterId = 2 + }); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.OrderModel", b => + { + b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant") + .WithMany() + .HasForeignKey("PlantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GWMS.Data.DatabaseModels.SupplierModel", "Supplier") + .WithMany() + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GWMS.Data.DatabaseModels.TransporterModel", "Transporter") + .WithMany() + .HasForeignKey("TransporterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Plant"); + + b.Navigation("Supplier"); + + b.Navigation("Transporter"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantLogModel", b => + { + b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant") + .WithMany() + .HasForeignKey("PlantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Plant"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantStatusModel", b => + { + b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant") + .WithMany() + .HasForeignKey("PlantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Plant"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.WeekPlanModel", b => + { + b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant") + .WithMany() + .HasForeignKey("PlantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GWMS.Data.DatabaseModels.SupplierModel", "Supplier") + .WithMany() + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GWMS.Data.DatabaseModels.TransporterModel", "Transporter") + .WithMany() + .HasForeignKey("TransporterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Plant"); + + b.Navigation("Supplier"); + + b.Navigation("Transporter"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/GWMS.Data/Migrations/20210809143652_OrderFillData.cs b/GWMS.Data/Migrations/20210809143652_OrderFillData.cs new file mode 100644 index 0000000..b3b37ef --- /dev/null +++ b/GWMS.Data/Migrations/20210809143652_OrderFillData.cs @@ -0,0 +1,64 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace GWMS.Data.Migrations +{ + public partial class OrderFillData : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "LevelEnd", + table: "Order", + type: "double", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "LevelStart", + table: "Order", + type: "double", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.UpdateData( + table: "Transporter", + keyColumn: "TransporterId", + keyValue: 1, + column: "PositionUpdated", + value: new DateTime(2021, 8, 9, 16, 36, 52, 691, DateTimeKind.Local).AddTicks(9092)); + + migrationBuilder.UpdateData( + table: "Transporter", + keyColumn: "TransporterId", + keyValue: 2, + column: "PositionUpdated", + value: new DateTime(2021, 8, 9, 16, 36, 52, 691, DateTimeKind.Local).AddTicks(9470)); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "LevelEnd", + table: "Order"); + + migrationBuilder.DropColumn( + name: "LevelStart", + table: "Order"); + + migrationBuilder.UpdateData( + table: "Transporter", + keyColumn: "TransporterId", + keyValue: 1, + column: "PositionUpdated", + value: new DateTime(2021, 8, 6, 18, 20, 35, 347, DateTimeKind.Local).AddTicks(1664)); + + migrationBuilder.UpdateData( + table: "Transporter", + keyColumn: "TransporterId", + keyValue: 2, + column: "PositionUpdated", + value: new DateTime(2021, 8, 6, 18, 20, 35, 347, DateTimeKind.Local).AddTicks(2482)); + } + } +} diff --git a/GWMS.Data/Migrations/GWMSContextModelSnapshot.cs b/GWMS.Data/Migrations/GWMSContextModelSnapshot.cs index 7c87d70..1682d20 100644 --- a/GWMS.Data/Migrations/GWMSContextModelSnapshot.cs +++ b/GWMS.Data/Migrations/GWMSContextModelSnapshot.cs @@ -146,6 +146,12 @@ namespace GWMS.Data.Migrations b.Property("ExecutionQty") .HasColumnType("double"); + b.Property("LevelEnd") + .HasColumnType("double"); + + b.Property("LevelStart") + .HasColumnType("double"); + b.Property("OrderCode") .HasMaxLength(100) .HasColumnType("varchar(100)"); @@ -385,7 +391,7 @@ namespace GWMS.Data.Migrations TransporterId = 1, PositionLatitude = 0.0, PositionLongitude = 0.0, - PositionUpdated = new DateTime(2021, 8, 6, 18, 20, 35, 347, DateTimeKind.Local).AddTicks(1664), + PositionUpdated = new DateTime(2021, 8, 9, 16, 36, 52, 691, DateTimeKind.Local).AddTicks(9092), TransporterCode = "LEVO", TransporterDesc = "Levorato" }, @@ -394,7 +400,7 @@ namespace GWMS.Data.Migrations TransporterId = 2, PositionLatitude = 0.0, PositionLongitude = 0.0, - PositionUpdated = new DateTime(2021, 8, 6, 18, 20, 35, 347, DateTimeKind.Local).AddTicks(2482), + PositionUpdated = new DateTime(2021, 8, 9, 16, 36, 52, 691, DateTimeKind.Local).AddTicks(9470), TransporterCode = "TRAF", TransporterDesc = "Traffik" }); From 2428daedb4b98466102be7e6e45348a91785cfa0 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 9 Aug 2021 19:14:52 +0200 Subject: [PATCH 09/15] Aggiunta logica editing, delete, insert ordini! --- GWMS.Data/Controllers/GWMSController.cs | 24 +++++++++ GWMS.Data/ModelBuilderExtensions.cs | 6 +-- GWMS.UI/Components/OrderAdminEditor.razor | 32 +++++++++-- GWMS.UI/Components/PlantDetail.razor.cs | 4 +- GWMS.UI/Components/WeekPlanEditor.razor | 2 +- GWMS.UI/Controllers/IOBController.cs | 25 ++++++++- GWMS.UI/Data/GWMSDataService.cs | 66 +++++++++++++++++++---- GWMS.UI/Data/SelectData.cs | 2 +- GWMS.UI/GWMS.UI.csproj | 2 +- GWMS.UI/Pages/Orders.razor | 11 ++++ GWMS.UI/Pages/Orders.razor.cs | 43 ++++++++++++++- GWMS.UI/appsettings.Development.json | 4 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 15 files changed, 199 insertions(+), 28 deletions(-) diff --git a/GWMS.Data/Controllers/GWMSController.cs b/GWMS.Data/Controllers/GWMSController.cs index 61601e6..76267b9 100644 --- a/GWMS.Data/Controllers/GWMSController.cs +++ b/GWMS.Data/Controllers/GWMSController.cs @@ -333,6 +333,30 @@ namespace GWMS.Data.Controllers return answ; } + /// + /// Eliminazione di un ordine + /// + /// + /// + public bool OrderDelete(OrderModel Item2Del) + { + bool done = false; + try + { + if (Item2Del != null) + { + dbCtx + .DbSetOrders + .Remove(Item2Del); + dbCtx.SaveChanges(); + done = true; + } + } + catch (Exception exc) + { } + return done; + } + /// /// Aggiunta in blocco di Ordini /// diff --git a/GWMS.Data/ModelBuilderExtensions.cs b/GWMS.Data/ModelBuilderExtensions.cs index fc21a75..ae66fee 100644 --- a/GWMS.Data/ModelBuilderExtensions.cs +++ b/GWMS.Data/ModelBuilderExtensions.cs @@ -37,10 +37,10 @@ namespace GWMS.Data // inizializzazione dei valori di default x Plant modelBuilder.Entity().HasData( - new PlantDetailModel { PlantId = 1, PlantCode = "PIZ03", PlantDesc = "Collecchio", LevelMax = 26000, LevelReorder = 15000, OrderQtyStd = 18000 }, + new PlantDetailModel { PlantId = 1, PlantCode = "PIZ03", PlantDesc = "Collecchio", LevelMax = 26000, LevelReorder = 15000, OrderQtyStd = 9000 }, new PlantDetailModel { PlantId = 2, PlantCode = "PIZ04", PlantDesc = "Noceto", LevelMax = 28000, LevelReorder = 15000, OrderQtyStd = 18000 }, - new PlantDetailModel { PlantId = 3, PlantCode = "PIZ05", PlantDesc = "Baganzola", LevelMax = 24000, LevelReorder = 15000, OrderQtyStd = 18000 }, - new PlantDetailModel { PlantId = 4, PlantCode = "PIZ08", PlantDesc = "Pilastrello", LevelMax = 26000, LevelReorder = 15000, OrderQtyStd = 18000 } + new PlantDetailModel { PlantId = 3, PlantCode = "PIZ05", PlantDesc = "Baganzola", LevelMax = 24000, LevelReorder = 15000, OrderQtyStd = 9000 }, + new PlantDetailModel { PlantId = 4, PlantCode = "PIZ08", PlantDesc = "Pilastrello", LevelMax = 26000, LevelReorder = 15000, OrderQtyStd = 9000 } // new PlantDetailModel { PlantId = 1, PlantCode = "PIZ03", PlantDesc = "Collecchio", LevelMax = 26000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 }, //new PlantDetailModel { PlantId = 2, PlantCode = "PIZ04", PlantDesc = "Noceto", LevelMax = 28000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 }, //new PlantDetailModel { PlantId = 3, PlantCode = "PIZ05", PlantDesc = "Baganzola", LevelMax = 24000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 }, diff --git a/GWMS.UI/Components/OrderAdminEditor.razor b/GWMS.UI/Components/OrderAdminEditor.razor index 92fafaa..36dce08 100644 --- a/GWMS.UI/Components/OrderAdminEditor.razor +++ b/GWMS.UI/Components/OrderAdminEditor.razor @@ -8,6 +8,7 @@ @inject MessageService AppMService @inject GWMSDataService DataService @inject IConfiguration Configuration +@inject IJSRuntime JSRuntime
    @@ -20,7 +21,7 @@
    -
    +
    @@ -64,12 +65,19 @@
    -
    +
    - +
    - +
    +
    + +
    +
    + +
    +
    @@ -135,6 +143,22 @@ await DataReset.InvokeAsync(0); } + private async Task deleteRecord() + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare l'ordine selezionato??")) + return; + + if (_currItem != null) + { + DataService.OrderDelete(_currItem); + await DataUpdated.InvokeAsync(1); + } + else + { + Console.WriteLine("User null!"); + } + } + protected override async Task OnInitializedAsync() { await ReloadAllData(); diff --git a/GWMS.UI/Components/PlantDetail.razor.cs b/GWMS.UI/Components/PlantDetail.razor.cs index a1c6620..ef2baa2 100644 --- a/GWMS.UI/Components/PlantDetail.razor.cs +++ b/GWMS.UI/Components/PlantDetail.razor.cs @@ -131,7 +131,7 @@ namespace GWMS.UI.Components int answ = 1; int numCount = _currItem.LevelTS.Count; // passo a 2h se > 1 week - if (numCount > 168) + if (numCount > 120) answ = 2; redFact = answ; } @@ -156,7 +156,7 @@ namespace GWMS.UI.Components private List GetLineChartLabels() { fixRedFactor(); - var answ = _currItem.LevelTS.Where((cat, index) => index % redFact == 0).Select(x => x.DtEvent.ToString("dd.MM HH")).ToList(); + var answ = _currItem.LevelTS.Where((cat, index) => index % redFact == 0).Select(x => x.DtEvent.ToString("dd/MM HH")).ToList(); return answ; } diff --git a/GWMS.UI/Components/WeekPlanEditor.razor b/GWMS.UI/Components/WeekPlanEditor.razor index caaf8b2..d547d7b 100644 --- a/GWMS.UI/Components/WeekPlanEditor.razor +++ b/GWMS.UI/Components/WeekPlanEditor.razor @@ -206,7 +206,7 @@ private async Task deleteRecord() { - if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler eliminare la consegna selezionata??")) + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare la consegna selezionata??")) return; if (_currItem != null) diff --git a/GWMS.UI/Controllers/IOBController.cs b/GWMS.UI/Controllers/IOBController.cs index 1800673..184838b 100644 --- a/GWMS.UI/Controllers/IOBController.cs +++ b/GWMS.UI/Controllers/IOBController.cs @@ -90,6 +90,29 @@ namespace GWMS.UI.Controllers return $"OK"; } + /// + /// Esegue verifica livelli ed eventuale creazione ordini refill + /// + /// GET: IOB/checkLevels/SIMUL_03 + /// + /// + /// + [HttpGet("checkLevels/{id}")] + public async Task checkLevels(string id) + { + bool fatto = false; + // ...verifica per ricalcolo ordini... + fatto = await _DataService.checkLevels(); + if (fatto) + { + return "Ok"; + } + else + { + return "NO"; + } + } + // DELETE api/IOB/5 [HttpDelete("{id}")] public void Delete(int id) @@ -291,7 +314,7 @@ namespace GWMS.UI.Controllers fatto = await _DataService.PlantLogInsert(plData); // effettuo SEMPRE verifica per ricalcolo ordini... - _DataService.checkLevels(); + await _DataService.checkLevels(); } } if (fatto) diff --git a/GWMS.UI/Data/GWMSDataService.cs b/GWMS.UI/Data/GWMSDataService.cs index 26e9b74..715cd95 100644 --- a/GWMS.UI/Data/GWMSDataService.cs +++ b/GWMS.UI/Data/GWMSDataService.cs @@ -186,8 +186,9 @@ namespace GWMS.UI.Data return mHash(string.Format("ExeTask:{0}", idxMacchina)); } - protected async void checkCreateOrders() + protected async Task checkCreateOrders() { + bool fatto = false; List NewOrders = new List(); DateTime adesso = DateTime.Now; int supplierId = 1; @@ -219,7 +220,7 @@ namespace GWMS.UI.Data transporterId = 1; } // stacco un NUOVO ordine di quantità finita - NewOrders.Add(new OrderModel() { DtOrder = adesso, OrderQty = item.OrderQtyStd, PlantId = item.PlantId, OrderCode = $"O{item.PlantId:00}{adesso:yyMMddHH}", OrderDesc = $"Ordine {item.PlantDesc} - {adesso}", SupplierId = supplierId, TransporterId = transporterId }); + NewOrders.Add(new OrderModel() { DtOrder = adesso, OrderQty = item.OrderQtyStd, PlantId = item.PlantId, OrderCode = $"O{item.PlantCode}{adesso:yyMMddHH}", OrderDesc = $"Ordine {item.PlantDesc} - {adesso}", SupplierId = supplierId, TransporterId = transporterId }); } } if (NewOrders.Count > 0) @@ -240,7 +241,9 @@ namespace GWMS.UI.Data { // invio email di notifica nuovi ordini inseriti } + fatto = true; } + return fatto; } protected string getCacheKey(string TableName, SelectOrderData CurrFilter) @@ -294,15 +297,40 @@ namespace GWMS.UI.Data /// /// effettua verifica x tutti i plant, se livello > livello riordino e NON ci sono ordini APERTI in arrivo --> lancia ordine /// - public void checkLevels() + public async Task checkLevels() { + bool fatto = false; // effettuo verifica veto ricalcolo ordini da cache... - - // se non ho veto --> controllo - // FIXME TODO FARE !!! - //checkCreateOrders(); - - // imposto nuovo veto... + DateTime adesso = DateTime.Now; + DateTime vetoCheck = adesso.AddMinutes(1); + string cacheKey = "DATA:CHECKLEVEL"; + string rawData; + try + { + var redisDataList = await distributedCache.GetAsync(cacheKey); + // se non ho veto --> controllo + if (redisDataList != null) + { + rawData = Encoding.UTF8.GetString(redisDataList); + vetoCheck = JsonConvert.DeserializeObject(rawData); + } + else + { + vetoCheck = adesso.AddMinutes(-1); + } + if (adesso > vetoCheck) + { + fatto = await checkCreateOrders(); + // imposto nuovo veto a 5 min... + vetoCheck = adesso.AddMinutes(5); + rawData = JsonConvert.SerializeObject(vetoCheck); + redisDataList = Encoding.UTF8.GetBytes(rawData); + await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(false)); + } + } + catch + { } + return fatto; } public async Task> ConfigGetAll() @@ -412,6 +440,20 @@ namespace GWMS.UI.Data return answ; } + public async void OrderDelete(OrderModel currItem) + { + try + { + dbController.OrderDelete(currItem); + dbController.ResetController(); + string cacheKey = $"DATA:WEEKPLAN:List"; + await distributedCache.RemoveAsync(cacheKey); + } + catch + { + } + } + public async Task> OrdersGetFilt(SelectOrderData CurrFilter) { List dbResult = new List(); @@ -450,6 +492,7 @@ namespace GWMS.UI.Data try { dbController.OrderUpdate(currItem); + dbController.ResetController(); } catch { @@ -596,6 +639,11 @@ namespace GWMS.UI.Data return await Task.FromResult(dbController.RegenDB(1, numDays, stepMin, maxHourRate)); } + public void ResetController() + { + dbController.ResetController(); + } + public void rollBackEdit(object item) { dbController.rollBackEntity(item); diff --git a/GWMS.UI/Data/SelectData.cs b/GWMS.UI/Data/SelectData.cs index 473f77d..b1b4bbb 100644 --- a/GWMS.UI/Data/SelectData.cs +++ b/GWMS.UI/Data/SelectData.cs @@ -25,7 +25,7 @@ namespace GWMS.UI.Data public static SelectData Init(int minRound, int numDayPrev) { TimeSpan DayElapsed = DateTime.Now.Subtract(DateTime.Today); - int minDay = (int)(DayElapsed.TotalMinutes / minRound) * minRound; + int minDay = (int)((DayElapsed.TotalMinutes / minRound) + 1) * minRound; DateTime endRounded = DateTime.Today.AddMinutes(minDay); SelectData answ = new SelectData() { diff --git a/GWMS.UI/GWMS.UI.csproj b/GWMS.UI/GWMS.UI.csproj index 5e603b9..37fac1b 100644 --- a/GWMS.UI/GWMS.UI.csproj +++ b/GWMS.UI/GWMS.UI.csproj @@ -2,7 +2,7 @@ net5.0 - 1.0.2108.0618 + 1.0.2108.0919 95c9f021-52d1-4390-a670-5810b7b777b0 diff --git a/GWMS.UI/Pages/Orders.razor b/GWMS.UI/Pages/Orders.razor index c73bf78..b2613d0 100644 --- a/GWMS.UI/Pages/Orders.razor +++ b/GWMS.UI/Pages/Orders.razor @@ -65,6 +65,17 @@
    +
    +
    + +
    +
    +
    + @if (ShowAddNew) + { + + } +
    diff --git a/GWMS.UI/Pages/Orders.razor.cs b/GWMS.UI/Pages/Orders.razor.cs index 577f56d..3b9a436 100644 --- a/GWMS.UI/Pages/Orders.razor.cs +++ b/GWMS.UI/Pages/Orders.razor.cs @@ -180,6 +180,20 @@ namespace GWMS.UI.Pages #endregion Protected Properties + #region Public Properties + + public bool ShowAddNew + { + get + { + bool answ = false; + answ = (SelSupplierId > 0 && SelPlantId > 0); + return answ; + } + } + + #endregion Public Properties + #region Private Methods private void OnDateEndChanged(DateTime? date) @@ -204,6 +218,32 @@ namespace GWMS.UI.Pages #region Protected Methods + /// + /// Creazione nuovo record Ordine + /// + protected void CreateNew() + { + var currPlant = PlantsList.Where(x => x.PlantId == SelPlantId).FirstOrDefault(); + var currSuppl = SuppliersList.Where(x => x.SupplierId == SelSupplierId).FirstOrDefault(); + if (currPlant != null && currSuppl != null) + { + DateTime adesso = DateTime.Now; + // creo un nuovo record + currRecord = new OrderModel() + { + DtOrder = adesso, + PlantId = SelPlantId, + SupplierId = SelSupplierId, + OrderDesc = $"Ord Man {currPlant.PlantDesc} - {adesso}", + OrderQty = 1000, + TransporterId = 1, + OrderCode = $"O{currPlant.PlantCode}{adesso:yyMMddHH}", + }; + // aggiorno filtro + AppMService.Order_Filter = SelectOrderData.Init(5, 7); + } + } + protected void Edit(OrderModel selRecord) { currRecord = selRecord; @@ -241,7 +281,7 @@ namespace GWMS.UI.Pages currRecord = null; } - protected async Task ResetFilter(SelectOrderData newFilter) + protected async Task ResetFilter() { currRecord = null; SearchRecords = null; @@ -259,6 +299,7 @@ namespace GWMS.UI.Pages protected async Task UpdateData() { currRecord = null; + DataService.ResetController(); await ReloadData(); } diff --git a/GWMS.UI/appsettings.Development.json b/GWMS.UI/appsettings.Development.json index b3efb2c..4006e89 100644 --- a/GWMS.UI/appsettings.Development.json +++ b/GWMS.UI/appsettings.Development.json @@ -6,6 +6,6 @@ "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } - }, - "ZCodeUrl": "http://10.74.82.218/zcode/" + } + //"ZCodeUrl": "http://10.74.82.218/zcode/" } \ No newline at end of file diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 61a6ced..7da77a1 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ GWMS - Gas Warehouse Management System -

    Versione: 1.0.2108.0618

    +

    Versione: 1.0.2108.0919


    Note di rilascio:
    • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index c670a70..e5b337a 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2108.0618 +1.0.2108.0919 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index fd921fa..9ecd6b7 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2108.0618 + 1.0.2108.0919 http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html false From 52595458c53bb62ada783dd60451389ecbc0cf8a Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 9 Aug 2021 19:16:48 +0200 Subject: [PATCH 10/15] Aggiunto in editing anche il trasportatore --- GWMS.UI/Components/OrderAdminEditor.razor | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/GWMS.UI/Components/OrderAdminEditor.razor b/GWMS.UI/Components/OrderAdminEditor.razor index 36dce08..6b0d4bd 100644 --- a/GWMS.UI/Components/OrderAdminEditor.razor +++ b/GWMS.UI/Components/OrderAdminEditor.razor @@ -39,14 +39,19 @@
      - @*
      -
      - - - -
      - -
      *@ +
      +
      + + + +
      + + @foreach (var item in transpList) + { + + } + +
      @@ -88,6 +93,7 @@ @code { private List suppList; + private List transpList; protected OrderModel _currItem = new OrderModel(); protected int _supplierId { get; set; } = 0; @@ -167,6 +173,7 @@ protected async Task ReloadAllData() { suppList = await DataService.SuppliersGetAll(); + transpList = await DataService.TransportersGetAll(); } /// From 6c7a1a5cfa04a974b3f7cccd032a2ca6e6899de9 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 9 Aug 2021 19:23:20 +0200 Subject: [PATCH 11/15] =?UTF-8?q?Eggiunto=20editing=20quantit=C3=A0=20su?= =?UTF-8?q?=20ordini?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GWMS.UI/Components/OrderAdminEditor.razor | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/GWMS.UI/Components/OrderAdminEditor.razor b/GWMS.UI/Components/OrderAdminEditor.razor index 6b0d4bd..dd1b3e4 100644 --- a/GWMS.UI/Components/OrderAdminEditor.razor +++ b/GWMS.UI/Components/OrderAdminEditor.razor @@ -53,14 +53,14 @@
      -
      +
      - +
      Note @@ -68,6 +68,17 @@
      +
      + +
      +
      + + + +
      + +
      +
      From 3bb30bcbdd2095486ff8d9a451faac320312b9c7 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 9 Aug 2021 19:40:21 +0200 Subject: [PATCH 12/15] Bozza controllo show chiusi --- GWMS.UI/Data/SelectOrderData.cs | 6 ++++++ GWMS.UI/Pages/Orders.razor | 10 ++++++++++ GWMS.UI/Pages/Orders.razor.cs | 22 ++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/GWMS.UI/Data/SelectOrderData.cs b/GWMS.UI/Data/SelectOrderData.cs index c2dc59f..fb6fab7 100644 --- a/GWMS.UI/Data/SelectOrderData.cs +++ b/GWMS.UI/Data/SelectOrderData.cs @@ -9,8 +9,12 @@ namespace GWMS.UI.Data { #region Public Properties + public bool HideClosed { get; set; } = true; + public int PlantId { get; set; } = 0; + public int SupplierId { get; set; } = 0; + public int TransporterId { get; set; } = 0; #endregion Public Properties @@ -34,6 +38,8 @@ namespace GWMS.UI.Data if (!(obj is SelectOrderData item)) return false; + if (HideClosed != item.HideClosed) + return false; if (PlantId != item.PlantId) return false; if (SupplierId != item.SupplierId) diff --git a/GWMS.UI/Pages/Orders.razor b/GWMS.UI/Pages/Orders.razor index b2613d0..73b56ff 100644 --- a/GWMS.UI/Pages/Orders.razor +++ b/GWMS.UI/Pages/Orders.razor @@ -11,6 +11,16 @@
      +
      +
      +
      +
      +
      + + +
      +
      +
      diff --git a/GWMS.UI/Pages/Orders.razor.cs b/GWMS.UI/Pages/Orders.razor.cs index 3b9a436..a209657 100644 --- a/GWMS.UI/Pages/Orders.razor.cs +++ b/GWMS.UI/Pages/Orders.razor.cs @@ -43,6 +43,28 @@ namespace GWMS.UI.Pages } } + private bool HideClosed + { + get + { + bool answ = true; + if (AppMService.Order_Filter != null) + { + answ = AppMService.Order_Filter.HideClosed; + } + return answ; + } + set + { + if (!AppMService.Order_Filter.HideClosed.Equals(value)) + { + AppMService.Order_Filter.HideClosed = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + } + private bool isLoading { get; set; } = false; private int numRecord From 49687fda7e3be8349bb01ba0ccd1e4d4832c4b65 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 10 Aug 2021 10:21:13 +0200 Subject: [PATCH 13/15] Completato editing esteso x ordini --- GWMS.UI/Components/OrderAdminEditor.razor | 139 +++++++++++++++++----- GWMS.UI/GWMS.UI.csproj | 2 +- GWMS.UI/Pages/Orders.razor | 30 ++++- GWMS.UI/appsettings.Development.json | 4 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 7 files changed, 142 insertions(+), 39 deletions(-) diff --git a/GWMS.UI/Components/OrderAdminEditor.razor b/GWMS.UI/Components/OrderAdminEditor.razor index dd1b3e4..0a9b3fb 100644 --- a/GWMS.UI/Components/OrderAdminEditor.razor +++ b/GWMS.UI/Components/OrderAdminEditor.razor @@ -7,6 +7,7 @@ @inject MessageService AppMService @inject GWMSDataService DataService +@inject NavigationManager NavManager @inject IConfiguration Configuration @inject IJSRuntime JSRuntime @@ -18,15 +19,33 @@
      -
      +
      -
      +
      -
      +
      - + + + +
      + +
      +
      +
      +
      +
      + +
      + +
      +
      +
      +
      +
      +
      @@ -38,14 +57,14 @@
      -
      +
      - +
      - + @foreach (var item in transpList) { @@ -53,50 +72,98 @@
      -
      +
      - +
      - - Note - + note
      -
      - +
      - - + +
      +
      + kg +
      -
      -
      - -
      -
      -
      -
      - -
      -
      - +
      +
      +
      + +
      +
      +
      + +
      + @if (editAll) + { +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + +
      + +
      + inizio carico +
      +
      +
      +
      +
      +
      + +
      + +
      + fine carico +
      +
      +
      +
      +
      +
      +
      +
      + + + +
      + +
      + kg +
      +
      +
      +
      +
      +
      + }
      @@ -122,6 +189,8 @@ } } + private bool editAll { get; set; } = false; + [Parameter] public EventCallback DataReset { get; set; } [Parameter] @@ -185,6 +254,22 @@ { suppList = await DataService.SuppliersGetAll(); transpList = await DataService.TransportersGetAll(); + + // vedere anche https://www.mikesdotnetting.com/article/340/working-with-query-strings-in-blazor + var uri = NavManager.ToAbsoluteUri(NavManager.Uri); + var currMode = GetQueryParm("currMode"); + if (!string.IsNullOrEmpty(currMode)) + { + editAll = currMode.Equals("debug"); + } + } + + // Blazor: get query parm from the URL + protected string GetQueryParm(string parmName) + { + var uriBuilder = new UriBuilder(NavManager.Uri); + var q = System.Web.HttpUtility.ParseQueryString(uriBuilder.Query); + return q[parmName] ?? ""; } /// diff --git a/GWMS.UI/GWMS.UI.csproj b/GWMS.UI/GWMS.UI.csproj index 37fac1b..78471b6 100644 --- a/GWMS.UI/GWMS.UI.csproj +++ b/GWMS.UI/GWMS.UI.csproj @@ -2,7 +2,7 @@ net5.0 - 1.0.2108.0919 + 1.0.2108.1010 95c9f021-52d1-4390-a670-5810b7b777b0 diff --git a/GWMS.UI/Pages/Orders.razor b/GWMS.UI/Pages/Orders.razor index 73b56ff..9b95b36 100644 --- a/GWMS.UI/Pages/Orders.razor +++ b/GWMS.UI/Pages/Orders.razor @@ -115,7 +115,9 @@ Data Ordine Ordine Fornitore - Qta + Richiesta + Carico + Effettivo @@ -133,13 +135,29 @@ @record.OrderCode | @record.OrderDesc -
      -
      [@record.Supplier.SupplierCode]
      -
      @record.Supplier.SupplierDesc
      +
      + @record.Supplier.SupplierDesc
      -
      @record.Transporter.TransporterCode | @record.Transporter.TransporterDesc
      +
      @record.Transporter.TransporterDesc
      + + + @record.OrderQty.ToString("N0") + + + @if (!record.DtExecStart.Equals(@record.DtExecEnd)) + { +
      + @record.DtExecStart.Date.ToString("ddd dd/MM/yyyyy") +
      +
      @record.DtExecStart.TimeOfDay --> @record.DtExecEnd.TimeOfDay
      + } + + + @if (record.ExecutionQty > 0) + { + @record.ExecutionQty.ToString("N0") + } - @record.OrderQty.ToString("N0") } diff --git a/GWMS.UI/appsettings.Development.json b/GWMS.UI/appsettings.Development.json index 4006e89..b3efb2c 100644 --- a/GWMS.UI/appsettings.Development.json +++ b/GWMS.UI/appsettings.Development.json @@ -6,6 +6,6 @@ "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } - } - //"ZCodeUrl": "http://10.74.82.218/zcode/" + }, + "ZCodeUrl": "http://10.74.82.218/zcode/" } \ No newline at end of file diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 7da77a1..b9bd11a 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ GWMS - Gas Warehouse Management System -

      Versione: 1.0.2108.0919

      +

      Versione: 1.0.2108.1010


      Note di rilascio:
      • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index e5b337a..83b7ae1 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2108.0919 +1.0.2108.1010 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 9ecd6b7..cb979c5 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2108.0919 + 1.0.2108.1010 http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html false From 2ed39e6df02700def77892676ea32be53f8411f5 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 10 Aug 2021 10:31:39 +0200 Subject: [PATCH 14/15] Fix reset cache post update + fix filtro aperti --- GWMS.Data/Controllers/GWMSController.cs | 6 ++-- GWMS.UI/Data/GWMSDataService.cs | 20 +++++++++-- GWMS.UI/Data/SelectOrderData.cs | 8 ++--- GWMS.UI/Pages/Orders.razor | 4 +-- GWMS.UI/Pages/Orders.razor.cs | 44 ++++++++++++------------- 5 files changed, 47 insertions(+), 35 deletions(-) diff --git a/GWMS.Data/Controllers/GWMSController.cs b/GWMS.Data/Controllers/GWMSController.cs index 76267b9..203c217 100644 --- a/GWMS.Data/Controllers/GWMSController.cs +++ b/GWMS.Data/Controllers/GWMSController.cs @@ -176,11 +176,11 @@ namespace GWMS.Data.Controllers return dbResult; } - public List GetOrdersFilt(int PlantId, int SupplierId, int TransporterId, DateTime DtStart, DateTime DtEnd) + public List GetOrdersFilt(int PlantId, int SupplierId, int TransporterId, DateTime DtStart, DateTime DtEnd, bool ShowClosed) { var dbResult = dbCtx .DbSetOrders - .Where(x => (x.PlantId == PlantId || PlantId == 0) && (x.SupplierId == SupplierId || SupplierId == 0) && (x.TransporterId == TransporterId || TransporterId == 0) && (x.DtOrder >= DtStart && x.DtOrder <= DtEnd)) + .Where(x => (x.PlantId == PlantId || PlantId == 0) && (x.SupplierId == SupplierId || SupplierId == 0) && (x.TransporterId == TransporterId || TransporterId == 0) && (x.DtOrder >= DtStart && x.DtOrder <= DtEnd) && (x.ExecutionQty == 0 || ShowClosed)) .Include(p => p.Plant) .Include(s => s.Supplier) .Include(t => t.Transporter) @@ -461,7 +461,7 @@ namespace GWMS.Data.Controllers var rawOrderData = dbCtxMult .DbSetOrders - .Where(x => x.PlantId == PlantId) + .Where(x => x.PlantId == PlantId && x.ExecutionQty == 0) .OrderBy(x => x.DtOrder) .Take(maxRecords) .ToList(); diff --git a/GWMS.UI/Data/GWMSDataService.cs b/GWMS.UI/Data/GWMSDataService.cs index 715cd95..2cb4cc8 100644 --- a/GWMS.UI/Data/GWMSDataService.cs +++ b/GWMS.UI/Data/GWMSDataService.cs @@ -252,6 +252,20 @@ namespace GWMS.UI.Data return answ; } + /// + /// invalida tutta la cache in caso di update + /// + /// + protected async void invalidateAllCache() + { + await distributedCache.RemoveAsync("DATA:CONFIG"); + await distributedCache.RemoveAsync("DATA:CHECKLEVEL"); + await distributedCache.RemoveAsync("DATA:PLANTS:ListDTO"); + await distributedCache.RemoveAsync("DATA:SUPPL:List"); + await distributedCache.RemoveAsync("DATA:TRANSP:List"); + await distributedCache.RemoveAsync("DATA:WEEKPLAN:List"); + } + protected async Task> PlantLogGetLastByFlux(int PlantId) { List lastValues = new List(); @@ -445,9 +459,8 @@ namespace GWMS.UI.Data try { dbController.OrderDelete(currItem); + invalidateAllCache(); dbController.ResetController(); - string cacheKey = $"DATA:WEEKPLAN:List"; - await distributedCache.RemoveAsync(cacheKey); } catch { @@ -460,7 +473,7 @@ namespace GWMS.UI.Data Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); - dbResult = dbController.GetOrdersFilt(CurrFilter.PlantId, CurrFilter.SupplierId, CurrFilter.TransporterId, CurrFilter.DateStart, CurrFilter.DateEnd); + dbResult = dbController.GetOrdersFilt(CurrFilter.PlantId, CurrFilter.SupplierId, CurrFilter.TransporterId, CurrFilter.DateStart, CurrFilter.DateEnd, CurrFilter.ShowClosed); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; Log.Info($"Effettuata lettura da DB per OrdersGetFilt: {ts.TotalMilliseconds} ms"); @@ -492,6 +505,7 @@ namespace GWMS.UI.Data try { dbController.OrderUpdate(currItem); + invalidateAllCache(); dbController.ResetController(); } catch diff --git a/GWMS.UI/Data/SelectOrderData.cs b/GWMS.UI/Data/SelectOrderData.cs index fb6fab7..569d0a5 100644 --- a/GWMS.UI/Data/SelectOrderData.cs +++ b/GWMS.UI/Data/SelectOrderData.cs @@ -9,10 +9,8 @@ namespace GWMS.UI.Data { #region Public Properties - public bool HideClosed { get; set; } = true; - public int PlantId { get; set; } = 0; - + public bool ShowClosed { get; set; } = false; public int SupplierId { get; set; } = 0; public int TransporterId { get; set; } = 0; @@ -30,7 +28,7 @@ namespace GWMS.UI.Data public static new SelectOrderData Init(int minRound, int numDayPrev) { var selD = SelectData.Init(minRound, numDayPrev); - return new SelectOrderData() { DateStart = selD.DateStart, DateEnd = selD.DateEnd }; + return new SelectOrderData() { DateStart = selD.DateStart, DateEnd = selD.DateEnd, ShowClosed = false }; } public override bool Equals(object obj) @@ -38,7 +36,7 @@ namespace GWMS.UI.Data if (!(obj is SelectOrderData item)) return false; - if (HideClosed != item.HideClosed) + if (ShowClosed != item.ShowClosed) return false; if (PlantId != item.PlantId) return false; diff --git a/GWMS.UI/Pages/Orders.razor b/GWMS.UI/Pages/Orders.razor index 9b95b36..96b6bfb 100644 --- a/GWMS.UI/Pages/Orders.razor +++ b/GWMS.UI/Pages/Orders.razor @@ -16,8 +16,8 @@
        - - + +
      diff --git a/GWMS.UI/Pages/Orders.razor.cs b/GWMS.UI/Pages/Orders.razor.cs index a209657..a51373c 100644 --- a/GWMS.UI/Pages/Orders.razor.cs +++ b/GWMS.UI/Pages/Orders.razor.cs @@ -43,28 +43,6 @@ namespace GWMS.UI.Pages } } - private bool HideClosed - { - get - { - bool answ = true; - if (AppMService.Order_Filter != null) - { - answ = AppMService.Order_Filter.HideClosed; - } - return answ; - } - set - { - if (!AppMService.Order_Filter.HideClosed.Equals(value)) - { - AppMService.Order_Filter.HideClosed = value; - var pUpd = Task.Run(async () => await ReloadData()); - pUpd.Wait(); - } - } - } - private bool isLoading { get; set; } = false; private int numRecord @@ -127,6 +105,28 @@ namespace GWMS.UI.Pages private bool ShowCharts { get; set; } = false; + private bool ShowClosed + { + get + { + bool answ = true; + if (AppMService.Order_Filter != null) + { + answ = AppMService.Order_Filter.ShowClosed; + } + return answ; + } + set + { + if (!AppMService.Order_Filter.ShowClosed.Equals(value)) + { + AppMService.Order_Filter.ShowClosed = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + } + #endregion Private Properties #region Protected Properties From 2f27d2bd0bbe4304f60abbd90f8c86910ba19315 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 10 Aug 2021 13:02:53 +0200 Subject: [PATCH 15/15] COmpletato editing e cambio codice ordine in caso di modifica totale --- GWMS.Data/Controllers/GWMSController.cs | 6 ++++++ GWMS.UI/Data/GWMSDataService.cs | 2 +- GWMS.UI/GWMS.UI.csproj | 2 +- GWMS.UI/Pages/Orders.razor.cs | 2 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 7 files changed, 12 insertions(+), 6 deletions(-) diff --git a/GWMS.Data/Controllers/GWMSController.cs b/GWMS.Data/Controllers/GWMSController.cs index 203c217..a3f8061 100644 --- a/GWMS.Data/Controllers/GWMSController.cs +++ b/GWMS.Data/Controllers/GWMSController.cs @@ -394,6 +394,12 @@ namespace GWMS.Data.Controllers .FirstOrDefault(); if (currData != null) { + // se ho modificato data --> cambio codice ordine! + if (!dbCtx.Entry(updItem).OriginalValues["DtOrder"].Equals(dbCtx.Entry(updItem).CurrentValues["DtOrder"])) + { + updItem.OrderCode = $"O{updItem.Plant.PlantCode}{updItem.DtOrder:yyMMddHHmm}"; + updItem.OrderDesc = $"Ordine {updItem.Plant.PlantDesc} - {updItem.DtOrder}"; + } dbCtx.Entry(updItem).State = EntityState.Modified; } else diff --git a/GWMS.UI/Data/GWMSDataService.cs b/GWMS.UI/Data/GWMSDataService.cs index 2cb4cc8..0495f21 100644 --- a/GWMS.UI/Data/GWMSDataService.cs +++ b/GWMS.UI/Data/GWMSDataService.cs @@ -220,7 +220,7 @@ namespace GWMS.UI.Data transporterId = 1; } // stacco un NUOVO ordine di quantità finita - NewOrders.Add(new OrderModel() { DtOrder = adesso, OrderQty = item.OrderQtyStd, PlantId = item.PlantId, OrderCode = $"O{item.PlantCode}{adesso:yyMMddHH}", OrderDesc = $"Ordine {item.PlantDesc} - {adesso}", SupplierId = supplierId, TransporterId = transporterId }); + NewOrders.Add(new OrderModel() { DtOrder = adesso, OrderQty = item.OrderQtyStd, PlantId = item.PlantId, OrderCode = $"O{item.PlantCode}{adesso:yyMMddHHmm}", OrderDesc = $"Ordine {item.PlantDesc} - {adesso}", SupplierId = supplierId, TransporterId = transporterId }); } } if (NewOrders.Count > 0) diff --git a/GWMS.UI/GWMS.UI.csproj b/GWMS.UI/GWMS.UI.csproj index 78471b6..a8d933d 100644 --- a/GWMS.UI/GWMS.UI.csproj +++ b/GWMS.UI/GWMS.UI.csproj @@ -2,7 +2,7 @@ net5.0 - 1.0.2108.1010 + 1.0.2108.1012 95c9f021-52d1-4390-a670-5810b7b777b0 diff --git a/GWMS.UI/Pages/Orders.razor.cs b/GWMS.UI/Pages/Orders.razor.cs index a51373c..d8e9533 100644 --- a/GWMS.UI/Pages/Orders.razor.cs +++ b/GWMS.UI/Pages/Orders.razor.cs @@ -259,7 +259,7 @@ namespace GWMS.UI.Pages OrderDesc = $"Ord Man {currPlant.PlantDesc} - {adesso}", OrderQty = 1000, TransporterId = 1, - OrderCode = $"O{currPlant.PlantCode}{adesso:yyMMddHH}", + OrderCode = $"O{currPlant.PlantCode}{adesso:yyMMddHHmm}", }; // aggiorno filtro AppMService.Order_Filter = SelectOrderData.Init(5, 7); diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index b9bd11a..676eaa3 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ GWMS - Gas Warehouse Management System -

      Versione: 1.0.2108.1010

      +

      Versione: 1.0.2108.1012


      Note di rilascio:
      • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 83b7ae1..9fef9f8 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2108.1010 +1.0.2108.1012 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index cb979c5..469aac1 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2108.1010 + 1.0.2108.1012 http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html false