слил
This commit is contained in:
commit
0409356c5e
@ -1,4 +1,6 @@
|
|||||||
using FactoryContracts.BindingModels;
|
using FactoryBusinessLogic.OfficePackage;
|
||||||
|
using FactoryBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using FactoryContracts.BindingModels;
|
||||||
using FactoryContracts.BusinessLogicsContracts;
|
using FactoryContracts.BusinessLogicsContracts;
|
||||||
using FactoryContracts.SearchModels;
|
using FactoryContracts.SearchModels;
|
||||||
using FactoryContracts.StoragesContracts;
|
using FactoryContracts.StoragesContracts;
|
||||||
@ -10,30 +12,54 @@ namespace FactoryBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
private readonly IMachineStorage _machineStorage;
|
private readonly IMachineStorage _machineStorage;
|
||||||
private readonly IProductStorage _productStorage;
|
private readonly IProductStorage _productStorage;
|
||||||
public StorekeeperReportLogic(IMachineStorage machineStorage, IProductStorage productStorage)
|
private readonly AbstractSaveToWord _saveToWord;
|
||||||
|
private readonly AbstractSaveToExcel _saveToExcel;
|
||||||
|
private readonly AbstractSaveToPdf _saveToPdf;
|
||||||
|
public StorekeeperReportLogic(IMachineStorage machineStorage, IProductStorage productStorage, AbstractSaveToWord saveToWord, AbstractSaveToExcel saveToExcel, AbstractSaveToPdf saveToPdf)
|
||||||
{
|
{
|
||||||
_machineStorage = machineStorage;
|
_machineStorage = machineStorage;
|
||||||
_productStorage = productStorage;
|
_productStorage = productStorage;
|
||||||
|
_saveToWord = saveToWord;
|
||||||
|
_saveToExcel = saveToExcel;
|
||||||
|
_saveToPdf = saveToPdf;
|
||||||
}
|
}
|
||||||
public List<ProductPlanProductionReportViewModel> GetPlanProductionsByProduct(List<ProductSearchModel> products)
|
public List<ProductPlanProductionReportViewModel> GetPlanProductionsByProduct(List<ProductSearchModel> products)
|
||||||
{
|
{
|
||||||
return _productStorage.GetPlanProductions(products);
|
List<int> ids = products.Select(x => (int)x.Id).ToList();
|
||||||
|
return _productStorage.GetPlanProductions(ids);
|
||||||
}
|
}
|
||||||
public List<MachinePeriodReportViewModel> GetMachines(ClientSearchModel client, ReportBindingModel model)
|
public List<MachinePeriodReportViewModel> GetMachines(ClientSearchModel client, ReportBindingModel model)
|
||||||
{
|
{
|
||||||
return _machineStorage.GetMachinesByPeriod(client, model);
|
return _machineStorage.GetMachinesByPeriod(client, model);
|
||||||
}
|
}
|
||||||
public void SaveMachinesToPdfFile(ReportBindingModel model)
|
public void SaveMachinesToPdfFile(ClientSearchModel client, ReportBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
_saveToPdf.CreateStorekeeperDoc(new StorekeeperPdfInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список станков",
|
||||||
|
DateFrom = model.DateFrom!.Value,
|
||||||
|
DateTo = model.DateTo!.Value,
|
||||||
|
Machines = GetMachines(client, model)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
public void SavePlanProductionsToExcelFile(ReportBindingModel model)
|
public void SavePlanProductionsToExcelFile(ReportBindingModel model, List<ProductSearchModel> products)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
_saveToExcel.CreateStorekeeperReport(new StorekeeperExcelInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список планов производств",
|
||||||
|
ProductPlanProductions = GetPlanProductionsByProduct(products)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
public void SavePlanProductionsToWordFile(ReportBindingModel model)
|
public void SavePlanProductionsToWordFile(ReportBindingModel model, List<ProductSearchModel> products)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
_saveToWord.CreateStorekeeperDoc(new StorekeeperWordInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список планов производств",
|
||||||
|
ProductPlanProductions = GetPlanProductionsByProduct(products)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,8 @@ namespace FactoryContracts.BusinessLogicsContracts
|
|||||||
{
|
{
|
||||||
List<ProductPlanProductionReportViewModel> GetPlanProductionsByProduct(List<ProductSearchModel> products);
|
List<ProductPlanProductionReportViewModel> GetPlanProductionsByProduct(List<ProductSearchModel> products);
|
||||||
List<MachinePeriodReportViewModel> GetMachines(ClientSearchModel client, ReportBindingModel model);
|
List<MachinePeriodReportViewModel> GetMachines(ClientSearchModel client, ReportBindingModel model);
|
||||||
void SavePlanProductionsToWordFile(ReportBindingModel model);
|
void SavePlanProductionsToWordFile(ReportBindingModel model, List<ProductSearchModel> products);
|
||||||
void SavePlanProductionsToExcelFile(ReportBindingModel model);
|
void SavePlanProductionsToExcelFile(ReportBindingModel model, List<ProductSearchModel> products);
|
||||||
void SaveMachinesToPdfFile(ReportBindingModel model);
|
void SaveMachinesToPdfFile(ClientSearchModel client, ReportBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace FactoryContracts.SearchModels
|
using FactoryDataModels.Enums;
|
||||||
|
|
||||||
|
namespace FactoryContracts.SearchModels
|
||||||
{
|
{
|
||||||
public class ClientSearchModel
|
public class ClientSearchModel
|
||||||
{
|
{
|
||||||
@ -7,5 +9,7 @@
|
|||||||
public string? Login { get; set; }
|
public string? Login { get; set; }
|
||||||
|
|
||||||
public string? Password { get; set; }
|
public string? Password { get; set; }
|
||||||
|
|
||||||
|
public ClientRole? Role { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,6 +18,6 @@ namespace FactoryContracts.StoragesContracts
|
|||||||
|
|
||||||
ProductViewModel? Delete(ProductBindingModel model);
|
ProductViewModel? Delete(ProductBindingModel model);
|
||||||
|
|
||||||
List<ProductPlanProductionReportViewModel> GetPlanProductions(List<ProductSearchModel> products);
|
List<ProductPlanProductionReportViewModel> GetPlanProductions(List<int> ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,27 +112,19 @@ namespace FactoryDatabaseImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ProductPlanProductionReportViewModel> GetPlanProductions(List<ProductSearchModel> products)
|
public List<ProductPlanProductionReportViewModel> GetPlanProductions(List<int> ids)
|
||||||
{
|
{
|
||||||
using var context = new FactoryDatabase();
|
using var context = new FactoryDatabase();
|
||||||
// not sure if it works
|
|
||||||
return context.Products
|
return context.Products
|
||||||
.Include(x => x.Client)
|
.Where(prod => ids.Contains(prod.Id))
|
||||||
.Include(x => x.Machines)
|
.Select(prod => new ProductPlanProductionReportViewModel()
|
||||||
.ThenInclude(x => x.Machine)
|
|
||||||
.Where(x => products.Any(y => x.ProductName == y.ProductName && x.ClientId == y.ClientId))
|
|
||||||
.Select(x => new ProductPlanProductionReportViewModel()
|
|
||||||
{
|
{
|
||||||
ProductName = x.ProductName,
|
ProductName = prod.ProductName,
|
||||||
PlanProductions = context.PlanProductions
|
PlanProductions = context.PlanProductionWorkpieces
|
||||||
.Include(y => y.Workpieces).
|
.Include(x => x.PlanProduction)
|
||||||
ThenInclude(y => y.Workpiece)
|
.Where(plan => prod.Id == plan.PlanProduction.Id)
|
||||||
.ThenInclude(y => y.Products)
|
.Select(x => x.PlanProduction.GetViewModel)
|
||||||
.ThenInclude(y => y.Product)
|
.ToList(),
|
||||||
.Where(y => y.Workpieces.Any(z => z.Workpiece.Products.Any(v => v.Product.ProductName == x.ProductName)))
|
|
||||||
.Select(y => y.GetViewModel)
|
|
||||||
.ToList()
|
|
||||||
|
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace FactoryDatabaseImplement.Migrations
|
namespace FactoryDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(FactoryDatabase))]
|
[DbContext(typeof(FactoryDatabase))]
|
||||||
[Migration("20240528135247_InitCreate")]
|
[Migration("20240528144223_InitCreate")]
|
||||||
partial class InitCreate
|
partial class InitCreate
|
||||||
{
|
{
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@ -81,7 +81,8 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("ClientId");
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
b.HasIndex("PlanProductionId");
|
b.HasIndex("PlanProductionId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
b.ToTable("ExecutionPhases");
|
b.ToTable("ExecutionPhases");
|
||||||
});
|
});
|
||||||
@ -157,9 +158,6 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
b.Property<DateTime>("Deadline")
|
b.Property<DateTime>("Deadline")
|
||||||
.HasColumnType("timestamp without time zone");
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
b.Property<int?>("ExecutionPhaseId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("ProductionName")
|
b.Property<string>("ProductionName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@ -168,8 +166,6 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("ClientId");
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
b.HasIndex("ExecutionPhaseId");
|
|
||||||
|
|
||||||
b.ToTable("PlanProductions");
|
b.ToTable("PlanProductions");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -349,8 +345,8 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("FactoryDatabaseImplement.Models.PlanProduction", "PlanProduction")
|
b.HasOne("FactoryDatabaseImplement.Models.PlanProduction", "PlanProduction")
|
||||||
.WithMany()
|
.WithOne("ExecutionPhase")
|
||||||
.HasForeignKey("PlanProductionId")
|
.HasForeignKey("FactoryDatabaseImplement.Models.ExecutionPhase", "PlanProductionId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
@ -397,10 +393,6 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("FactoryDatabaseImplement.Models.ExecutionPhase", null)
|
|
||||||
.WithMany("PlanProductions")
|
|
||||||
.HasForeignKey("ExecutionPhaseId");
|
|
||||||
|
|
||||||
b.Navigation("Client");
|
b.Navigation("Client");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -517,11 +509,6 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
b.Navigation("Workpieces");
|
b.Navigation("Workpieces");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("FactoryDatabaseImplement.Models.ExecutionPhase", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("PlanProductions");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FactoryDatabaseImplement.Models.Machine", b =>
|
modelBuilder.Entity("FactoryDatabaseImplement.Models.Machine", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("PlanProductions");
|
b.Navigation("PlanProductions");
|
||||||
@ -531,6 +518,9 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("FactoryDatabaseImplement.Models.PlanProduction", b =>
|
modelBuilder.Entity("FactoryDatabaseImplement.Models.PlanProduction", b =>
|
||||||
{
|
{
|
||||||
|
b.Navigation("ExecutionPhase")
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Machines");
|
b.Navigation("Machines");
|
||||||
|
|
||||||
b.Navigation("Workpieces");
|
b.Navigation("Workpieces");
|
@ -48,6 +48,28 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PlanProductions",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
ClientId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
ProductionName = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Count = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
Deadline = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PlanProductions", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlanProductions_Clients_ClientId",
|
||||||
|
column: x => x.ClientId,
|
||||||
|
principalTable: "Clients",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Products",
|
name: "Products",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@ -92,6 +114,62 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ExecutionPhases",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
ClientId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
PlanProductionId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
ExecutionPhaseName = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ImplementerFIO = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Status = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ExecutionPhases", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ExecutionPhases_Clients_ClientId",
|
||||||
|
column: x => x.ClientId,
|
||||||
|
principalTable: "Clients",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ExecutionPhases_PlanProductions_PlanProductionId",
|
||||||
|
column: x => x.PlanProductionId,
|
||||||
|
principalTable: "PlanProductions",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "MachinePlanProductions",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
MachineId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
PlanProductionId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
Count = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_MachinePlanProductions", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_MachinePlanProductions_Machines_MachineId",
|
||||||
|
column: x => x.MachineId,
|
||||||
|
principalTable: "Machines",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_MachinePlanProductions_PlanProductions_PlanProductionId",
|
||||||
|
column: x => x.PlanProductionId,
|
||||||
|
principalTable: "PlanProductions",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "ProductMachines",
|
name: "ProductMachines",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@ -147,111 +225,6 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "WorkpieceProducts",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
WorkpieceId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
ProductId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
Count = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_WorkpieceProducts", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_WorkpieceProducts_Products_ProductId",
|
|
||||||
column: x => x.ProductId,
|
|
||||||
principalTable: "Products",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_WorkpieceProducts_Workpieces_WorkpieceId",
|
|
||||||
column: x => x.WorkpieceId,
|
|
||||||
principalTable: "Workpieces",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "ExecutionPhases",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
ClientId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
PlanProductionId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
ExecutionPhaseName = table.Column<string>(type: "text", nullable: false),
|
|
||||||
ImplementerFIO = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Status = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_ExecutionPhases", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ExecutionPhases_Clients_ClientId",
|
|
||||||
column: x => x.ClientId,
|
|
||||||
principalTable: "Clients",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "PlanProductions",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
ClientId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
ProductionName = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Count = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
Deadline = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
|
||||||
ExecutionPhaseId = table.Column<int>(type: "integer", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_PlanProductions", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_PlanProductions_Clients_ClientId",
|
|
||||||
column: x => x.ClientId,
|
|
||||||
principalTable: "Clients",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_PlanProductions_ExecutionPhases_ExecutionPhaseId",
|
|
||||||
column: x => x.ExecutionPhaseId,
|
|
||||||
principalTable: "ExecutionPhases",
|
|
||||||
principalColumn: "Id");
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "MachinePlanProductions",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
MachineId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
PlanProductionId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
Count = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_MachinePlanProductions", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_MachinePlanProductions_Machines_MachineId",
|
|
||||||
column: x => x.MachineId,
|
|
||||||
principalTable: "Machines",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_MachinePlanProductions_PlanProductions_PlanProductionId",
|
|
||||||
column: x => x.PlanProductionId,
|
|
||||||
principalTable: "PlanProductions",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "PlanProductionWorkpieces",
|
name: "PlanProductionWorkpieces",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@ -279,6 +252,33 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "WorkpieceProducts",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
WorkpieceId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
ProductId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
Count = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_WorkpieceProducts", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_WorkpieceProducts_Products_ProductId",
|
||||||
|
column: x => x.ProductId,
|
||||||
|
principalTable: "Products",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_WorkpieceProducts_Workpieces_WorkpieceId",
|
||||||
|
column: x => x.WorkpieceId,
|
||||||
|
principalTable: "Workpieces",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_ExecutionPhases_ClientId",
|
name: "IX_ExecutionPhases_ClientId",
|
||||||
table: "ExecutionPhases",
|
table: "ExecutionPhases",
|
||||||
@ -287,7 +287,8 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_ExecutionPhases_PlanProductionId",
|
name: "IX_ExecutionPhases_PlanProductionId",
|
||||||
table: "ExecutionPhases",
|
table: "ExecutionPhases",
|
||||||
column: "PlanProductionId");
|
column: "PlanProductionId",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_MachinePlanProductions_MachineId",
|
name: "IX_MachinePlanProductions_MachineId",
|
||||||
@ -309,11 +310,6 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
table: "PlanProductions",
|
table: "PlanProductions",
|
||||||
column: "ClientId");
|
column: "ClientId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_PlanProductions_ExecutionPhaseId",
|
|
||||||
table: "PlanProductions",
|
|
||||||
column: "ExecutionPhaseId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_PlanProductionWorkpieces_PlanProductionId",
|
name: "IX_PlanProductionWorkpieces_PlanProductionId",
|
||||||
table: "PlanProductionWorkpieces",
|
table: "PlanProductionWorkpieces",
|
||||||
@ -364,29 +360,12 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
name: "IX_Workpieces_ClientId",
|
name: "IX_Workpieces_ClientId",
|
||||||
table: "Workpieces",
|
table: "Workpieces",
|
||||||
column: "ClientId");
|
column: "ClientId");
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_ExecutionPhases_PlanProductions_PlanProductionId",
|
|
||||||
table: "ExecutionPhases",
|
|
||||||
column: "PlanProductionId",
|
|
||||||
principalTable: "PlanProductions",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.DropForeignKey(
|
migrationBuilder.DropTable(
|
||||||
name: "FK_ExecutionPhases_Clients_ClientId",
|
name: "ExecutionPhases");
|
||||||
table: "ExecutionPhases");
|
|
||||||
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_PlanProductions_Clients_ClientId",
|
|
||||||
table: "PlanProductions");
|
|
||||||
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_ExecutionPhases_PlanProductions_PlanProductionId",
|
|
||||||
table: "ExecutionPhases");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "MachinePlanProductions");
|
name: "MachinePlanProductions");
|
||||||
@ -403,6 +382,9 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "WorkpieceProducts");
|
name: "WorkpieceProducts");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "PlanProductions");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Machines");
|
name: "Machines");
|
||||||
|
|
||||||
@ -414,12 +396,6 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Clients");
|
name: "Clients");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "PlanProductions");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ExecutionPhases");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -79,7 +79,8 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("ClientId");
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
b.HasIndex("PlanProductionId");
|
b.HasIndex("PlanProductionId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
b.ToTable("ExecutionPhases");
|
b.ToTable("ExecutionPhases");
|
||||||
});
|
});
|
||||||
@ -155,9 +156,6 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
b.Property<DateTime>("Deadline")
|
b.Property<DateTime>("Deadline")
|
||||||
.HasColumnType("timestamp without time zone");
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
b.Property<int?>("ExecutionPhaseId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("ProductionName")
|
b.Property<string>("ProductionName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@ -166,8 +164,6 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("ClientId");
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
b.HasIndex("ExecutionPhaseId");
|
|
||||||
|
|
||||||
b.ToTable("PlanProductions");
|
b.ToTable("PlanProductions");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -347,8 +343,8 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("FactoryDatabaseImplement.Models.PlanProduction", "PlanProduction")
|
b.HasOne("FactoryDatabaseImplement.Models.PlanProduction", "PlanProduction")
|
||||||
.WithMany()
|
.WithOne("ExecutionPhase")
|
||||||
.HasForeignKey("PlanProductionId")
|
.HasForeignKey("FactoryDatabaseImplement.Models.ExecutionPhase", "PlanProductionId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
@ -395,10 +391,6 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("FactoryDatabaseImplement.Models.ExecutionPhase", null)
|
|
||||||
.WithMany("PlanProductions")
|
|
||||||
.HasForeignKey("ExecutionPhaseId");
|
|
||||||
|
|
||||||
b.Navigation("Client");
|
b.Navigation("Client");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -515,11 +507,6 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
b.Navigation("Workpieces");
|
b.Navigation("Workpieces");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("FactoryDatabaseImplement.Models.ExecutionPhase", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("PlanProductions");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FactoryDatabaseImplement.Models.Machine", b =>
|
modelBuilder.Entity("FactoryDatabaseImplement.Models.Machine", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("PlanProductions");
|
b.Navigation("PlanProductions");
|
||||||
@ -529,6 +516,9 @@ namespace FactoryDatabaseImplement.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("FactoryDatabaseImplement.Models.PlanProduction", b =>
|
modelBuilder.Entity("FactoryDatabaseImplement.Models.PlanProduction", b =>
|
||||||
{
|
{
|
||||||
|
b.Navigation("ExecutionPhase")
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Machines");
|
b.Navigation("Machines");
|
||||||
|
|
||||||
b.Navigation("Workpieces");
|
b.Navigation("Workpieces");
|
||||||
|
@ -16,7 +16,7 @@ namespace FactoryDatabaseImplement.Models
|
|||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int PlanProductionId { get; private set; }
|
public int PlanProductionId { get; private set; }
|
||||||
public virtual PlanProduction PlanProduction { get; private set; }
|
public virtual PlanProduction PlanProduction { get; private set; } = null!;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string ExecutionPhaseName { get; private set; } = string.Empty;
|
public string ExecutionPhaseName { get; private set; } = string.Empty;
|
||||||
@ -25,9 +25,6 @@ namespace FactoryDatabaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public ExecutionPhaseStatus Status { get; private set; } = ExecutionPhaseStatus.Неизвестен;
|
public ExecutionPhaseStatus Status { get; private set; } = ExecutionPhaseStatus.Неизвестен;
|
||||||
|
|
||||||
[ForeignKey("ExecutionPhaseId")]
|
|
||||||
public virtual List<PlanProduction> PlanProductions { get; set; } = new();
|
|
||||||
|
|
||||||
public static ExecutionPhase? Create(ExecutionPhaseBindingModel model)
|
public static ExecutionPhase? Create(ExecutionPhaseBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -57,7 +57,7 @@ namespace FactoryStorekeeperApp.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult Enter(string login, string password)
|
public IActionResult Enter(string login, string password)
|
||||||
{
|
{
|
||||||
var existsClient = clientLogic.ReadElement(new ClientSearchModel { Login = login, Password = password });
|
var existsClient = clientLogic.ReadElement(new ClientSearchModel { Login = login, Password = password, Role = ClientRole.Кладовщик });
|
||||||
|
|
||||||
if (existsClient != null)
|
if (existsClient != null)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user