diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Maintenance.cs b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Maintenance.cs index bc97150f..54c4a60a 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Maintenance.cs +++ b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Maintenance.cs @@ -705,7 +705,7 @@ public class ListFormSeeder_Maintenance : IDataSeedContributor, ITransientDepend Order=1, ColCount=2, ColSpan=1, Caption="General", ItemType="group", Items= [ new() { Order = 1, DataField = "Code", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxTextBox }, - new() { Order = 2, DataField = "WorkCenterId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, + new() { Order = 2, DataField = "WorkcenterId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, new() { Order = 3, DataField = "PlanType", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, new() { Order = 4, DataField = "Priority", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, new() { Order = 5, DataField = "Description", ColSpan = 2, EditorType2 = EditorTypes.dxTextArea }, @@ -791,7 +791,7 @@ public class ListFormSeeder_Maintenance : IDataSeedContributor, ITransientDepend ListFormCode = listForm.ListFormCode, CultureName = LanguageCodes.En, SourceDbType = DbType.Guid, - FieldName = "WorkCenterId", + FieldName = "WorkcenterId", Width = 150, ListOrderNo = 3, Visible = true, @@ -1329,7 +1329,7 @@ public class ListFormSeeder_Maintenance : IDataSeedContributor, ITransientDepend new EditingFormItemDto { Order = 1, DataField = "Code", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, new EditingFormItemDto { Order = 2, DataField = "Title", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, new EditingFormItemDto { Order = 3, DataField = "Description", ColSpan = 1, EditorType2=EditorTypes.dxTextArea }, - new EditingFormItemDto { Order = 4, DataField = "WorkCenterId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 4, DataField = "WorkcenterId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, new EditingFormItemDto { Order = 5, DataField = "Location", ColSpan = 1, EditorType2=EditorTypes.dxTextBox }, new EditingFormItemDto { Order = 6, DataField = "FaultTypeId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, new EditingFormItemDto { Order = 7, DataField = "Priority", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, @@ -1419,7 +1419,7 @@ public class ListFormSeeder_Maintenance : IDataSeedContributor, ITransientDepend ListFormCode = listForm.ListFormCode, CultureName = LanguageCodes.En, SourceDbType = DbType.Guid, - FieldName = "WorkCenterId", + FieldName = "WorkcenterId", Width = 150, ListOrderNo = 5, Visible = true, diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Mrp.cs b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Mrp.cs index 8e6aed3d..861f6fce 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Mrp.cs +++ b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Mrp.cs @@ -442,7 +442,7 @@ public class ListFormSeeder_Mrp : IDataSeedContributor, ITransientDependency new EditingFormItemDto { Order = 2, DataField = "Name", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, new EditingFormItemDto { Order = 3, DataField = "Description", ColSpan = 2, EditorType2=EditorTypes.dxTextArea }, new EditingFormItemDto { Order = 4, DataField = "OperationTypeId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, - new EditingFormItemDto { Order = 5, DataField = "WorkCenterId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 5, DataField = "WorkcenterId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, new EditingFormItemDto { Order = 6, DataField = "StandardTime", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxNumberBox }, new EditingFormItemDto { Order = 7, DataField = "SetupTime", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxNumberBox }, new EditingFormItemDto { Order = 8, DataField = "LaborCost", ColSpan = 1, EditorType2=EditorTypes.dxNumberBox, EditorOptions=EditorOptionValues.NumberStandartFormat }, @@ -554,7 +554,7 @@ public class ListFormSeeder_Mrp : IDataSeedContributor, ITransientDependency ListFormCode = listForm.ListFormCode, CultureName = LanguageCodes.En, SourceDbType = DbType.Guid, - FieldName = "WorkCenterId", + FieldName = "WorkcenterId", Width = 150, ListOrderNo = 6, Visible = true, diff --git a/api/src/Erp.Platform.Domain.Shared/Enums/TableNameEnum.cs b/api/src/Erp.Platform.Domain.Shared/Enums/TableNameEnum.cs index 4c75023d..dd72d298 100644 --- a/api/src/Erp.Platform.Domain.Shared/Enums/TableNameEnum.cs +++ b/api/src/Erp.Platform.Domain.Shared/Enums/TableNameEnum.cs @@ -183,5 +183,9 @@ public enum TableNameEnum PutawayCondition, OperationCategory, OperationType, - Operation + Operation, + BomType, + Bom, + BomOperation, + BomComponent } diff --git a/api/src/Erp.Platform.Domain.Shared/TableNameResolver.cs b/api/src/Erp.Platform.Domain.Shared/TableNameResolver.cs index 32434d12..e82964a9 100644 --- a/api/src/Erp.Platform.Domain.Shared/TableNameResolver.cs +++ b/api/src/Erp.Platform.Domain.Shared/TableNameResolver.cs @@ -221,6 +221,10 @@ public static class TableNameResolver { nameof(TableNameEnum.OperationCategory), (TablePrefix.TenantByName, MenuPrefix.Mrp) }, { nameof(TableNameEnum.OperationType), (TablePrefix.TenantByName, MenuPrefix.Mrp) }, { nameof(TableNameEnum.Operation), (TablePrefix.TenantByName, MenuPrefix.Mrp) }, + { nameof(TableNameEnum.BomType), (TablePrefix.TenantByName, MenuPrefix.Mrp) }, + { nameof(TableNameEnum.Bom), (TablePrefix.TenantByName, MenuPrefix.Mrp) }, + { nameof(TableNameEnum.BomOperation), (TablePrefix.TenantByName, MenuPrefix.Mrp) }, + { nameof(TableNameEnum.BomComponent), (TablePrefix.TenantByName, MenuPrefix.Mrp) }, }; public static string GetFullTableName(string tableName) diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/Fault.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/Fault.cs index 9e249b56..4f5aa6cf 100644 --- a/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/Fault.cs +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/Fault.cs @@ -11,7 +11,7 @@ public class Fault : FullAuditedEntity, IMultiTenant public string Code { get; set; } public string Title { get; set; } public string Description { get; set; } - public Guid? WorkCenterId { get; set; } + public Guid? WorkcenterId { get; set; } public Workcenter? WorkCenter { get; set; } public string Location { get; set; } public Guid? FaultTypeId { get; set; } diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/MaintenancePlan.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/MaintenancePlan.cs index 17ab2635..efadda58 100644 --- a/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/MaintenancePlan.cs +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/MaintenancePlan.cs @@ -10,8 +10,8 @@ public class MaintenancePlan : FullAuditedEntity, IMultiTenant public Guid? TenantId { get; set; } public string Code { get; set; } - public Guid? WorkCenterId { get; set; } - public Workcenter WorkCenter { get; set; } + public Guid? WorkcenterId { get; set; } + public Workcenter Workcenter { get; set; } public string PlanType { get; set; } public string Priority { get; set; } public string Description { get; set; } diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/Mrp/Bom.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/Mrp/Bom.cs new file mode 100644 index 00000000..f463856b --- /dev/null +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/Mrp/Bom.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; + +namespace Erp.Platform.Entities; + +public class Bom : FullAuditedEntity, IMultiTenant +{ + public Guid? TenantId { get; set; } + + public Guid? MaterialId { get; set; } + public Material? Material { get; set; } + + public Guid? BomTypeId { get; set; } + public BomType? BomType { get; set; } // Production, Engineering, Planning, Costing + + public string Code { get; set; } + public string Version { get; set; } + public DateTime ValidFrom { get; set; } + public DateTime? ValidTo { get; set; } + public decimal BaseQuantity { get; set; } + public bool IsActive { get; set; } + + public ICollection Components { get; set; } + public ICollection Operations { get; set; } +} diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/Mrp/BomComponent.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/Mrp/BomComponent.cs new file mode 100644 index 00000000..0c8d85d4 --- /dev/null +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/Mrp/BomComponent.cs @@ -0,0 +1,31 @@ +using System; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; + +namespace Erp.Platform.Entities; + +public class BomComponent : FullAuditedEntity, IMultiTenant +{ + public Guid? TenantId { get; set; } + + public Guid? BomId { get; set; } + public Bom? Bom { get; set; } + + public Guid? MaterialId { get; set; } + public Material? Material { get; set; } + + public Guid? OperationId { get; set; } + public Operation? Operation { get; set; } + + public decimal Quantity { get; set; } + public Guid? UomId { get; set; } + public Uom? Uom { get; set; } + + public decimal ScrapPercentage { get; set; } + public bool IsPhantom { get; set; } + public int Position { get; set; } + public DateTime ValidFrom { get; set; } + public DateTime? ValidTo { get; set; } + + public bool IsActive { get; set; } +} diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/Mrp/BomOperation.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/Mrp/BomOperation.cs new file mode 100644 index 00000000..11845e30 --- /dev/null +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/Mrp/BomOperation.cs @@ -0,0 +1,33 @@ +using System; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; + +namespace Erp.Platform.Entities; + +public class BomOperation : FullAuditedEntity, IMultiTenant +{ + public Guid? TenantId { get; set; } + + public Guid? BomId { get; set; } + public Bom? Bom { get; set; } + + public Guid? OperationId { get; set; } + public Operation? Operation { get; set; } + + public Guid? WorkcenterId { get; set; } + public Workcenter? Workcenter { get; set; } + + public int Sequence { get; set; } + public int SetupTime { get; set; } + public int RunTime { get; set; } + public int WaitTime { get; set; } + public int QueueTime { get; set; } + public int MoveTime { get; set; } + public bool IsActive { get; set; } + public bool IsParallel { get; set; } + + public string PrerequisitesJson { get; set; } + public string QualityChecksJson { get; set; } + public string ToolsJson { get; set; } + public string SkillsJson { get; set; } +} diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/Mrp/BomType.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/Mrp/BomType.cs new file mode 100644 index 00000000..8f3623d8 --- /dev/null +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/Mrp/BomType.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; + +namespace Erp.Platform.Entities; + +public class BomType : FullAuditedEntity, IMultiTenant +{ + public Guid? TenantId { get; set; } + + public string Name { get; set; } + public string Description { get; set; } + public bool IsActive { get; set; } + + public ICollection Boms { get; set; } +} diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/Mrp/Operation.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/Mrp/Operation.cs index 82b35c16..40060f6b 100644 --- a/api/src/Erp.Platform.Domain/Entities/Tenant/Mrp/Operation.cs +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/Mrp/Operation.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.MultiTenancy; @@ -15,8 +16,8 @@ public class Operation : FullAuditedEntity, IMultiTenant public Guid? OperationTypeId { get; set; } public OperationType? OperationType { get; set; } - public Guid? WorkCenterId { get; set; } - public Workcenter? WorkCenter { get; set; } + public Guid? WorkcenterId { get; set; } + public Workcenter? Workcenter { get; set; } public int StandardTime { get; set; } public int SetupTime { get; set; } @@ -27,4 +28,6 @@ public class Operation : FullAuditedEntity, IMultiTenant public bool QualityCheckRequired { get; set; } public bool IsActive { get; set; } + + public ICollection BomOperations { get; set; } } diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/Material.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/Material.cs index 4a016c70..3ce2c129 100644 --- a/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/Material.cs +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/Material.cs @@ -30,6 +30,7 @@ public class Material : FullAuditedEntity, IMultiTenant public List AlternativeUoms { get; set; } public List Specifications { get; set; } public List Suppliers { get; set; } - // public List StockLevels { get; set; } + public List Boms { get; set; } + public List BomComponents { get; set; } } diff --git a/api/src/Erp.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs b/api/src/Erp.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs index e863333f..4510fcfa 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs @@ -261,6 +261,10 @@ public class PlatformDbContext : public DbSet OperationCategories { get; set; } public DbSet OperationTypes { get; set; } public DbSet Operations { get; set; } + public DbSet BomTypes { get; set; } + public DbSet Boms { get; set; } + public DbSet BomOperations { get; set; } + public DbSet BomComponents { get; set; } #endregion public PlatformDbContext(DbContextOptions options) @@ -2811,7 +2815,7 @@ public class PlatformDbContext : b.ConfigureByConvention(); b.Property(x => x.Code).IsRequired().HasMaxLength(100); - b.Property(x => x.WorkCenterId).IsRequired(); + b.Property(x => x.WorkcenterId).IsRequired(); b.Property(x => x.PlanType).IsRequired().HasMaxLength(50); b.Property(x => x.Priority).HasMaxLength(50); b.Property(x => x.Description).HasMaxLength(1000); @@ -2860,7 +2864,7 @@ public class PlatformDbContext : b.ConfigureByConvention(); b.Property(x => x.Code).IsRequired().HasMaxLength(100); - b.Property(x => x.WorkCenterId).IsRequired().HasMaxLength(50); + b.Property(x => x.WorkcenterId).IsRequired().HasMaxLength(50); b.Property(x => x.Location).HasMaxLength(250); b.Property(x => x.FaultTypeId).IsRequired(); b.Property(x => x.Priority).HasMaxLength(50); @@ -3107,7 +3111,7 @@ public class PlatformDbContext : b.Property(x => x.Name).IsRequired().HasMaxLength(200); b.Property(x => x.Description).HasMaxLength(500); b.Property(x => x.OperationTypeId).IsRequired(); - b.Property(x => x.WorkCenterId).IsRequired(); + b.Property(x => x.WorkcenterId).IsRequired(); b.Property(x => x.StandardTime).HasDefaultValue(0); b.Property(x => x.SetupTime).HasDefaultValue(0); b.Property(x => x.LaborCost).HasPrecision(18, 2).HasDefaultValue(0); @@ -3122,5 +3126,82 @@ public class PlatformDbContext : .HasForeignKey(x => x.OperationTypeId) .OnDelete(DeleteBehavior.Restrict); }); + + builder.Entity(b => + { + b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.Bom)), Prefix.DbSchema); + b.ConfigureByConvention(); + + b.Property(x => x.MaterialId).IsRequired(); + b.Property(x => x.BomTypeId).IsRequired(); + b.Property(x => x.Code).IsRequired().HasMaxLength(100); + b.Property(x => x.Version).IsRequired().HasMaxLength(50); + b.Property(x => x.BaseQuantity).HasPrecision(18, 2).HasDefaultValue(1); + b.Property(x => x.IsActive).HasDefaultValue(true); + + b.HasOne(x => x.Material) + .WithMany(x => x.Boms) + .HasForeignKey(x => x.MaterialId) + .OnDelete(DeleteBehavior.Restrict); + }); + + builder.Entity(b => + { + b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.BomComponent)), Prefix.DbSchema); + b.ConfigureByConvention(); + + b.Property(x => x.BomId).IsRequired(); + b.Property(x => x.MaterialId).IsRequired(); + b.Property(x => x.Quantity).HasPrecision(18, 2).HasDefaultValue(0); + b.Property(x => x.UomId).IsRequired(); + b.Property(x => x.ScrapPercentage).HasPrecision(18, 2).HasDefaultValue(0); + b.Property(x => x.IsPhantom).HasDefaultValue(false); + b.Property(x => x.Position).HasDefaultValue(0); + b.Property(x => x.ValidFrom).IsRequired(); + b.Property(x => x.IsActive).HasDefaultValue(true); + + b.HasOne(x => x.Bom) + .WithMany(x => x.Components) + .HasForeignKey(x => x.BomId) + .OnDelete(DeleteBehavior.Restrict); + }); + + builder.Entity(b => + { + b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.BomOperation)), Prefix.DbSchema); + b.ConfigureByConvention(); + + b.Property(x => x.BomId).IsRequired(); + b.Property(x => x.OperationId).IsRequired(); + b.Property(x => x.WorkcenterId).IsRequired(false); + b.Property(x => x.Sequence).IsRequired(); + b.Property(x => x.SetupTime).HasDefaultValue(0); + b.Property(x => x.RunTime).HasDefaultValue(0); + b.Property(x => x.WaitTime).HasDefaultValue(0); + b.Property(x => x.QueueTime).HasDefaultValue(0); + b.Property(x => x.MoveTime).HasDefaultValue(0); + b.Property(x => x.IsActive).HasDefaultValue(true); + b.Property(x => x.IsParallel).HasDefaultValue(false); + + b.HasOne(x => x.Bom) + .WithMany(x => x.Operations) + .HasForeignKey(x => x.BomId) + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne(x => x.Operation) + .WithMany(x => x.BomOperations) + .HasForeignKey(x => x.OperationId) + .OnDelete(DeleteBehavior.Restrict); + }); + + builder.Entity(b => + { + b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.BomType)), Prefix.DbSchema); + b.ConfigureByConvention(); + + b.Property(x => x.Name).IsRequired().HasMaxLength(50); + b.Property(x => x.Description).HasMaxLength(500); + b.Property(x => x.IsActive).HasDefaultValue(true); + }); } } \ No newline at end of file diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251126071128_Initial.Designer.cs b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251126135352_Initial.Designer.cs similarity index 97% rename from api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251126071128_Initial.Designer.cs rename to api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251126135352_Initial.Designer.cs index c60e9c10..457e3408 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251126071128_Initial.Designer.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251126135352_Initial.Designer.cs @@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore; namespace Erp.Platform.Migrations { [DbContext(typeof(PlatformDbContext))] - [Migration("20251126071128_Initial")] + [Migration("20251126135352_Initial")] partial class Initial { /// @@ -1510,6 +1510,351 @@ namespace Erp.Platform.Migrations b.ToTable("Adm_T_BlogPost", (string)null); }); + modelBuilder.Entity("Erp.Platform.Entities.Bom", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("BaseQuantity") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(1m); + + b.Property("BomTypeId") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("MaterialId") + .HasColumnType("uniqueidentifier"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidTo") + .HasColumnType("datetime2"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("BomTypeId"); + + b.HasIndex("MaterialId"); + + b.ToTable("Mrp_T_Bom", (string)null); + }); + + modelBuilder.Entity("Erp.Platform.Entities.BomComponent", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("BomId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsPhantom") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("MaterialId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperationId") + .HasColumnType("uniqueidentifier"); + + b.Property("Position") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Quantity") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("ScrapPercentage") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("UomId") + .HasColumnType("uniqueidentifier"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidTo") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("BomId"); + + b.HasIndex("MaterialId"); + + b.HasIndex("OperationId"); + + b.HasIndex("UomId"); + + b.ToTable("Mrp_T_BomComponent", (string)null); + }); + + modelBuilder.Entity("Erp.Platform.Entities.BomOperation", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("BomId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsParallel") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("MoveTime") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("OperationId") + .HasColumnType("uniqueidentifier"); + + b.Property("PrerequisitesJson") + .HasColumnType("nvarchar(max)"); + + b.Property("QualityChecksJson") + .HasColumnType("nvarchar(max)"); + + b.Property("QueueTime") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("RunTime") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Sequence") + .HasColumnType("int"); + + b.Property("SetupTime") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("SkillsJson") + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("ToolsJson") + .HasColumnType("nvarchar(max)"); + + b.Property("WaitTime") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("WorkcenterId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("BomId"); + + b.HasIndex("OperationId"); + + b.HasIndex("WorkcenterId"); + + b.ToTable("Mrp_T_BomOperation", (string)null); + }); + + modelBuilder.Entity("Erp.Platform.Entities.BomType", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("Mrp_T_BomType", (string)null); + }); + modelBuilder.Entity("Erp.Platform.Entities.Branch", b => { b.Property("Id") @@ -4830,21 +5175,21 @@ namespace Erp.Platform.Migrations .HasMaxLength(200) .HasColumnType("nvarchar(200)"); - b.Property("WorkCenterId") - .HasMaxLength(50) - .HasColumnType("uniqueidentifier"); - b.Property("WorkOrderId") .HasMaxLength(100) .HasColumnType("uniqueidentifier"); + b.Property("WorkcenterId") + .HasMaxLength(50) + .HasColumnType("uniqueidentifier"); + b.HasKey("Id"); b.HasIndex("FaultStatusId"); b.HasIndex("FaultTypeId"); - b.HasIndex("WorkCenterId"); + b.HasIndex("WorkcenterId"); b.ToTable("Mnt_T_Fault", (string)null); }); @@ -6595,12 +6940,12 @@ namespace Erp.Platform.Migrations .HasColumnType("uniqueidentifier") .HasColumnName("TenantId"); - b.Property("WorkCenterId") + b.Property("WorkcenterId") .HasColumnType("uniqueidentifier"); b.HasKey("Id"); - b.HasIndex("WorkCenterId"); + b.HasIndex("WorkcenterId"); b.ToTable("Mnt_T_Plan", (string)null); }); @@ -7828,10 +8173,11 @@ namespace Erp.Platform.Migrations .HasDefaultValue(false) .HasColumnName("IsDeleted"); - b.Property("LaborCost") + b.Property("LaborCost") .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); b.Property("LastModificationTime") .HasColumnType("datetime2") @@ -7841,10 +8187,11 @@ namespace Erp.Platform.Migrations .HasColumnType("uniqueidentifier") .HasColumnName("LastModifierId"); - b.Property("MachineCost") + b.Property("MachineCost") .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); b.Property("Name") .IsRequired() @@ -7854,10 +8201,11 @@ namespace Erp.Platform.Migrations b.Property("OperationTypeId") .HasColumnType("uniqueidentifier"); - b.Property("OverheadCost") + b.Property("OverheadCost") .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); b.Property("QualityCheckRequired") .ValueGeneratedOnAdd() @@ -7878,14 +8226,14 @@ namespace Erp.Platform.Migrations .HasColumnType("uniqueidentifier") .HasColumnName("TenantId"); - b.Property("WorkCenterId") + b.Property("WorkcenterId") .HasColumnType("uniqueidentifier"); b.HasKey("Id"); b.HasIndex("OperationTypeId"); - b.HasIndex("WorkCenterId"); + b.HasIndex("WorkcenterId"); b.ToTable("Mrp_T_Operation", (string)null); }); @@ -15637,6 +15985,83 @@ namespace Erp.Platform.Migrations b.Navigation("Employee"); }); + modelBuilder.Entity("Erp.Platform.Entities.Bom", b => + { + b.HasOne("Erp.Platform.Entities.BomType", "BomType") + .WithMany("Boms") + .HasForeignKey("BomTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.Material", "Material") + .WithMany("Boms") + .HasForeignKey("MaterialId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("BomType"); + + b.Navigation("Material"); + }); + + modelBuilder.Entity("Erp.Platform.Entities.BomComponent", b => + { + b.HasOne("Erp.Platform.Entities.Bom", "Bom") + .WithMany("Components") + .HasForeignKey("BomId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.Material", "Material") + .WithMany("BomComponents") + .HasForeignKey("MaterialId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.Operation", "Operation") + .WithMany() + .HasForeignKey("OperationId"); + + b.HasOne("Erp.Platform.Entities.Uom", "Uom") + .WithMany() + .HasForeignKey("UomId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Bom"); + + b.Navigation("Material"); + + b.Navigation("Operation"); + + b.Navigation("Uom"); + }); + + modelBuilder.Entity("Erp.Platform.Entities.BomOperation", b => + { + b.HasOne("Erp.Platform.Entities.Bom", "Bom") + .WithMany("Operations") + .HasForeignKey("BomId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.Operation", "Operation") + .WithMany("BomOperations") + .HasForeignKey("OperationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.Workcenter", "Workcenter") + .WithMany() + .HasForeignKey("WorkcenterId"); + + b.Navigation("Bom"); + + b.Navigation("Operation"); + + b.Navigation("Workcenter"); + }); + modelBuilder.Entity("Erp.Platform.Entities.BranchUsers", b => { b.HasOne("Erp.Platform.Entities.Branch", "Branch") @@ -15982,7 +16407,7 @@ namespace Erp.Platform.Migrations b.HasOne("Erp.Platform.Entities.Workcenter", "WorkCenter") .WithMany() - .HasForeignKey("WorkCenterId") + .HasForeignKey("WorkcenterId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -16113,13 +16538,13 @@ namespace Erp.Platform.Migrations modelBuilder.Entity("Erp.Platform.Entities.MaintenancePlan", b => { - b.HasOne("Erp.Platform.Entities.Workcenter", "WorkCenter") + b.HasOne("Erp.Platform.Entities.Workcenter", "Workcenter") .WithMany() - .HasForeignKey("WorkCenterId") + .HasForeignKey("WorkcenterId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.Navigation("WorkCenter"); + b.Navigation("Workcenter"); }); modelBuilder.Entity("Erp.Platform.Entities.MaintenancePlanEmployee", b => @@ -16274,15 +16699,15 @@ namespace Erp.Platform.Migrations .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.HasOne("Erp.Platform.Entities.Workcenter", "WorkCenter") + b.HasOne("Erp.Platform.Entities.Workcenter", "Workcenter") .WithMany("Operations") - .HasForeignKey("WorkCenterId") + .HasForeignKey("WorkcenterId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("OperationType"); - b.Navigation("WorkCenter"); + b.Navigation("Workcenter"); }); modelBuilder.Entity("Erp.Platform.Entities.OperationType", b => @@ -17102,6 +17527,18 @@ namespace Erp.Platform.Migrations b.Navigation("Posts"); }); + modelBuilder.Entity("Erp.Platform.Entities.Bom", b => + { + b.Navigation("Components"); + + b.Navigation("Operations"); + }); + + modelBuilder.Entity("Erp.Platform.Entities.BomType", b => + { + b.Navigation("Boms"); + }); + modelBuilder.Entity("Erp.Platform.Entities.Branch", b => { b.Navigation("ClassTypes"); @@ -17268,6 +17705,10 @@ namespace Erp.Platform.Migrations { b.Navigation("AlternativeUoms"); + b.Navigation("BomComponents"); + + b.Navigation("Boms"); + b.Navigation("Specifications"); b.Navigation("Suppliers"); @@ -17287,6 +17728,11 @@ namespace Erp.Platform.Migrations b.Navigation("Materials"); }); + modelBuilder.Entity("Erp.Platform.Entities.Operation", b => + { + b.Navigation("BomOperations"); + }); + modelBuilder.Entity("Erp.Platform.Entities.OperationCategory", b => { b.Navigation("OperationTypes"); diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251126071128_Initial.cs b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251126135352_Initial.cs similarity index 97% rename from api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251126071128_Initial.cs rename to api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251126135352_Initial.cs index ee68fd66..81d4e9c6 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251126071128_Initial.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251126135352_Initial.cs @@ -1435,6 +1435,28 @@ namespace Erp.Platform.Migrations table.PrimaryKey("PK_Mnt_T_WorkorderType", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Mrp_T_BomType", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Description = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Mrp_T_BomType", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Mrp_T_OperationCategory", columns: table => new @@ -4787,6 +4809,45 @@ namespace Erp.Platform.Migrations onDelete: ReferentialAction.Restrict); }); + migrationBuilder.CreateTable( + name: "Mrp_T_Bom", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + MaterialId = table.Column(type: "uniqueidentifier", nullable: false), + BomTypeId = table.Column(type: "uniqueidentifier", nullable: false), + Code = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + Version = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + ValidFrom = table.Column(type: "datetime2", nullable: false), + ValidTo = table.Column(type: "datetime2", nullable: true), + BaseQuantity = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 1m), + IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Mrp_T_Bom", x => x.Id); + table.ForeignKey( + name: "FK_Mrp_T_Bom_Mrp_T_BomType_BomTypeId", + column: x => x.BomTypeId, + principalTable: "Mrp_T_BomType", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Mrp_T_Bom_Scp_T_Material_MaterialId", + column: x => x.MaterialId, + principalTable: "Scp_T_Material", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + migrationBuilder.CreateTable( name: "Scp_T_MaterialSpecification", columns: table => new @@ -5258,7 +5319,7 @@ namespace Erp.Platform.Migrations Code = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), Title = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), Description = table.Column(type: "nvarchar(max)", nullable: true), - WorkCenterId = table.Column(type: "uniqueidentifier", maxLength: 50, nullable: false), + WorkcenterId = table.Column(type: "uniqueidentifier", maxLength: 50, nullable: false), Location = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: true), FaultTypeId = table.Column(type: "uniqueidentifier", nullable: false), Priority = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), @@ -5297,8 +5358,8 @@ namespace Erp.Platform.Migrations principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_Mnt_T_Fault_Mnt_T_Workcenter_WorkCenterId", - column: x => x.WorkCenterId, + name: "FK_Mnt_T_Fault_Mnt_T_Workcenter_WorkcenterId", + column: x => x.WorkcenterId, principalTable: "Mnt_T_Workcenter", principalColumn: "Id", onDelete: ReferentialAction.Cascade); @@ -5311,7 +5372,7 @@ namespace Erp.Platform.Migrations Id = table.Column(type: "uniqueidentifier", nullable: false), TenantId = table.Column(type: "uniqueidentifier", nullable: true), Code = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), - WorkCenterId = table.Column(type: "uniqueidentifier", nullable: false), + WorkcenterId = table.Column(type: "uniqueidentifier", nullable: false), PlanType = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), Priority = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), @@ -5335,8 +5396,8 @@ namespace Erp.Platform.Migrations { table.PrimaryKey("PK_Mnt_T_Plan", x => x.Id); table.ForeignKey( - name: "FK_Mnt_T_Plan_Mnt_T_Workcenter_WorkCenterId", - column: x => x.WorkCenterId, + name: "FK_Mnt_T_Plan_Mnt_T_Workcenter_WorkcenterId", + column: x => x.WorkcenterId, principalTable: "Mnt_T_Workcenter", principalColumn: "Id", onDelete: ReferentialAction.Cascade); @@ -5388,12 +5449,12 @@ namespace Erp.Platform.Migrations Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), Description = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), OperationTypeId = table.Column(type: "uniqueidentifier", nullable: false), - WorkCenterId = table.Column(type: "uniqueidentifier", nullable: false), + WorkcenterId = table.Column(type: "uniqueidentifier", nullable: false), StandardTime = table.Column(type: "int", nullable: false, defaultValue: 0), SetupTime = table.Column(type: "int", nullable: false, defaultValue: 0), - LaborCost = table.Column(type: "int", nullable: false, defaultValue: 0), - MachineCost = table.Column(type: "int", nullable: false, defaultValue: 0), - OverheadCost = table.Column(type: "int", nullable: false, defaultValue: 0), + LaborCost = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + MachineCost = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + OverheadCost = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), Instructions = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), QualityCheckRequired = table.Column(type: "bit", nullable: false, defaultValue: false), IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), @@ -5409,8 +5470,8 @@ namespace Erp.Platform.Migrations { table.PrimaryKey("PK_Mrp_T_Operation", x => x.Id); table.ForeignKey( - name: "FK_Mrp_T_Operation_Mnt_T_Workcenter_WorkCenterId", - column: x => x.WorkCenterId, + name: "FK_Mrp_T_Operation_Mnt_T_Workcenter_WorkcenterId", + column: x => x.WorkcenterId, principalTable: "Mnt_T_Workcenter", principalColumn: "Id", onDelete: ReferentialAction.Cascade); @@ -6035,6 +6096,110 @@ namespace Erp.Platform.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "Mrp_T_BomComponent", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + BomId = table.Column(type: "uniqueidentifier", nullable: false), + MaterialId = table.Column(type: "uniqueidentifier", nullable: false), + OperationId = table.Column(type: "uniqueidentifier", nullable: true), + Quantity = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + UomId = table.Column(type: "uniqueidentifier", nullable: false), + ScrapPercentage = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + IsPhantom = table.Column(type: "bit", nullable: false, defaultValue: false), + Position = table.Column(type: "int", nullable: false, defaultValue: 0), + ValidFrom = table.Column(type: "datetime2", nullable: false), + ValidTo = table.Column(type: "datetime2", nullable: true), + IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Mrp_T_BomComponent", x => x.Id); + table.ForeignKey( + name: "FK_Mrp_T_BomComponent_Adm_T_Uom_UomId", + column: x => x.UomId, + principalTable: "Adm_T_Uom", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Mrp_T_BomComponent_Mrp_T_Bom_BomId", + column: x => x.BomId, + principalTable: "Mrp_T_Bom", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Mrp_T_BomComponent_Mrp_T_Operation_OperationId", + column: x => x.OperationId, + principalTable: "Mrp_T_Operation", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Mrp_T_BomComponent_Scp_T_Material_MaterialId", + column: x => x.MaterialId, + principalTable: "Scp_T_Material", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Mrp_T_BomOperation", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + BomId = table.Column(type: "uniqueidentifier", nullable: false), + OperationId = table.Column(type: "uniqueidentifier", nullable: false), + WorkcenterId = table.Column(type: "uniqueidentifier", nullable: true), + Sequence = table.Column(type: "int", nullable: false), + SetupTime = table.Column(type: "int", nullable: false, defaultValue: 0), + RunTime = table.Column(type: "int", nullable: false, defaultValue: 0), + WaitTime = table.Column(type: "int", nullable: false, defaultValue: 0), + QueueTime = table.Column(type: "int", nullable: false, defaultValue: 0), + MoveTime = table.Column(type: "int", nullable: false, defaultValue: 0), + IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), + IsParallel = table.Column(type: "bit", nullable: false, defaultValue: false), + PrerequisitesJson = table.Column(type: "nvarchar(max)", nullable: true), + QualityChecksJson = table.Column(type: "nvarchar(max)", nullable: true), + ToolsJson = table.Column(type: "nvarchar(max)", nullable: true), + SkillsJson = table.Column(type: "nvarchar(max)", nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Mrp_T_BomOperation", x => x.Id); + table.ForeignKey( + name: "FK_Mrp_T_BomOperation_Mnt_T_Workcenter_WorkcenterId", + column: x => x.WorkcenterId, + principalTable: "Mnt_T_Workcenter", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Mrp_T_BomOperation_Mrp_T_Bom_BomId", + column: x => x.BomId, + principalTable: "Mrp_T_Bom", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Mrp_T_BomOperation_Mrp_T_Operation_OperationId", + column: x => x.OperationId, + principalTable: "Mrp_T_Operation", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + migrationBuilder.CreateTable( name: "Hr_T_SurveyAnswer", columns: table => new @@ -7139,14 +7304,14 @@ namespace Erp.Platform.Migrations column: "FaultTypeId"); migrationBuilder.CreateIndex( - name: "IX_Mnt_T_Fault_WorkCenterId", + name: "IX_Mnt_T_Fault_WorkcenterId", table: "Mnt_T_Fault", - column: "WorkCenterId"); + column: "WorkcenterId"); migrationBuilder.CreateIndex( - name: "IX_Mnt_T_Plan_WorkCenterId", + name: "IX_Mnt_T_Plan_WorkcenterId", table: "Mnt_T_Plan", - column: "WorkCenterId"); + column: "WorkcenterId"); migrationBuilder.CreateIndex( name: "IX_Mnt_T_PlanEmployee_MaintenancePlanId", @@ -7183,15 +7348,60 @@ namespace Erp.Platform.Migrations table: "Mnt_T_WorkcenterSpecification", column: "WorkcenterId"); + migrationBuilder.CreateIndex( + name: "IX_Mrp_T_Bom_BomTypeId", + table: "Mrp_T_Bom", + column: "BomTypeId"); + + migrationBuilder.CreateIndex( + name: "IX_Mrp_T_Bom_MaterialId", + table: "Mrp_T_Bom", + column: "MaterialId"); + + migrationBuilder.CreateIndex( + name: "IX_Mrp_T_BomComponent_BomId", + table: "Mrp_T_BomComponent", + column: "BomId"); + + migrationBuilder.CreateIndex( + name: "IX_Mrp_T_BomComponent_MaterialId", + table: "Mrp_T_BomComponent", + column: "MaterialId"); + + migrationBuilder.CreateIndex( + name: "IX_Mrp_T_BomComponent_OperationId", + table: "Mrp_T_BomComponent", + column: "OperationId"); + + migrationBuilder.CreateIndex( + name: "IX_Mrp_T_BomComponent_UomId", + table: "Mrp_T_BomComponent", + column: "UomId"); + + migrationBuilder.CreateIndex( + name: "IX_Mrp_T_BomOperation_BomId", + table: "Mrp_T_BomOperation", + column: "BomId"); + + migrationBuilder.CreateIndex( + name: "IX_Mrp_T_BomOperation_OperationId", + table: "Mrp_T_BomOperation", + column: "OperationId"); + + migrationBuilder.CreateIndex( + name: "IX_Mrp_T_BomOperation_WorkcenterId", + table: "Mrp_T_BomOperation", + column: "WorkcenterId"); + migrationBuilder.CreateIndex( name: "IX_Mrp_T_Operation_OperationTypeId", table: "Mrp_T_Operation", column: "OperationTypeId"); migrationBuilder.CreateIndex( - name: "IX_Mrp_T_Operation_WorkCenterId", + name: "IX_Mrp_T_Operation_WorkcenterId", table: "Mrp_T_Operation", - column: "WorkCenterId"); + column: "WorkcenterId"); migrationBuilder.CreateIndex( name: "IX_Mrp_T_OperationType_CategoryId", @@ -7969,7 +8179,10 @@ namespace Erp.Platform.Migrations name: "Mnt_T_WorkcenterSpecification"); migrationBuilder.DropTable( - name: "Mrp_T_Operation"); + name: "Mrp_T_BomComponent"); + + migrationBuilder.DropTable( + name: "Mrp_T_BomOperation"); migrationBuilder.DropTable( name: "Net_B_Meal"); @@ -8197,7 +8410,10 @@ namespace Erp.Platform.Migrations name: "Mnt_T_FaultType"); migrationBuilder.DropTable( - name: "Mrp_T_OperationType"); + name: "Mrp_T_Bom"); + + migrationBuilder.DropTable( + name: "Mrp_T_Operation"); migrationBuilder.DropTable( name: "Net_T_Training"); @@ -8299,7 +8515,10 @@ namespace Erp.Platform.Migrations name: "Mnt_T_WorkorderType"); migrationBuilder.DropTable( - name: "Mrp_T_OperationCategory"); + name: "Mrp_T_BomType"); + + migrationBuilder.DropTable( + name: "Mrp_T_OperationType"); migrationBuilder.DropTable( name: "Net_T_EventCategory"); @@ -8343,6 +8562,9 @@ namespace Erp.Platform.Migrations migrationBuilder.DropTable( name: "Mnt_T_Workcenter"); + migrationBuilder.DropTable( + name: "Mrp_T_OperationCategory"); + migrationBuilder.DropTable( name: "Sas_H_CountryGroup"); diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs index 7df7bced..631501c5 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs @@ -1507,6 +1507,351 @@ namespace Erp.Platform.Migrations b.ToTable("Adm_T_BlogPost", (string)null); }); + modelBuilder.Entity("Erp.Platform.Entities.Bom", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("BaseQuantity") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(1m); + + b.Property("BomTypeId") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("MaterialId") + .HasColumnType("uniqueidentifier"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidTo") + .HasColumnType("datetime2"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("BomTypeId"); + + b.HasIndex("MaterialId"); + + b.ToTable("Mrp_T_Bom", (string)null); + }); + + modelBuilder.Entity("Erp.Platform.Entities.BomComponent", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("BomId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsPhantom") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("MaterialId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperationId") + .HasColumnType("uniqueidentifier"); + + b.Property("Position") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Quantity") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("ScrapPercentage") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("UomId") + .HasColumnType("uniqueidentifier"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidTo") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("BomId"); + + b.HasIndex("MaterialId"); + + b.HasIndex("OperationId"); + + b.HasIndex("UomId"); + + b.ToTable("Mrp_T_BomComponent", (string)null); + }); + + modelBuilder.Entity("Erp.Platform.Entities.BomOperation", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("BomId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsParallel") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("MoveTime") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("OperationId") + .HasColumnType("uniqueidentifier"); + + b.Property("PrerequisitesJson") + .HasColumnType("nvarchar(max)"); + + b.Property("QualityChecksJson") + .HasColumnType("nvarchar(max)"); + + b.Property("QueueTime") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("RunTime") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Sequence") + .HasColumnType("int"); + + b.Property("SetupTime") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("SkillsJson") + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("ToolsJson") + .HasColumnType("nvarchar(max)"); + + b.Property("WaitTime") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("WorkcenterId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("BomId"); + + b.HasIndex("OperationId"); + + b.HasIndex("WorkcenterId"); + + b.ToTable("Mrp_T_BomOperation", (string)null); + }); + + modelBuilder.Entity("Erp.Platform.Entities.BomType", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("Mrp_T_BomType", (string)null); + }); + modelBuilder.Entity("Erp.Platform.Entities.Branch", b => { b.Property("Id") @@ -4827,21 +5172,21 @@ namespace Erp.Platform.Migrations .HasMaxLength(200) .HasColumnType("nvarchar(200)"); - b.Property("WorkCenterId") - .HasMaxLength(50) - .HasColumnType("uniqueidentifier"); - b.Property("WorkOrderId") .HasMaxLength(100) .HasColumnType("uniqueidentifier"); + b.Property("WorkcenterId") + .HasMaxLength(50) + .HasColumnType("uniqueidentifier"); + b.HasKey("Id"); b.HasIndex("FaultStatusId"); b.HasIndex("FaultTypeId"); - b.HasIndex("WorkCenterId"); + b.HasIndex("WorkcenterId"); b.ToTable("Mnt_T_Fault", (string)null); }); @@ -6592,12 +6937,12 @@ namespace Erp.Platform.Migrations .HasColumnType("uniqueidentifier") .HasColumnName("TenantId"); - b.Property("WorkCenterId") + b.Property("WorkcenterId") .HasColumnType("uniqueidentifier"); b.HasKey("Id"); - b.HasIndex("WorkCenterId"); + b.HasIndex("WorkcenterId"); b.ToTable("Mnt_T_Plan", (string)null); }); @@ -7825,10 +8170,11 @@ namespace Erp.Platform.Migrations .HasDefaultValue(false) .HasColumnName("IsDeleted"); - b.Property("LaborCost") + b.Property("LaborCost") .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); b.Property("LastModificationTime") .HasColumnType("datetime2") @@ -7838,10 +8184,11 @@ namespace Erp.Platform.Migrations .HasColumnType("uniqueidentifier") .HasColumnName("LastModifierId"); - b.Property("MachineCost") + b.Property("MachineCost") .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); b.Property("Name") .IsRequired() @@ -7851,10 +8198,11 @@ namespace Erp.Platform.Migrations b.Property("OperationTypeId") .HasColumnType("uniqueidentifier"); - b.Property("OverheadCost") + b.Property("OverheadCost") .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); b.Property("QualityCheckRequired") .ValueGeneratedOnAdd() @@ -7875,14 +8223,14 @@ namespace Erp.Platform.Migrations .HasColumnType("uniqueidentifier") .HasColumnName("TenantId"); - b.Property("WorkCenterId") + b.Property("WorkcenterId") .HasColumnType("uniqueidentifier"); b.HasKey("Id"); b.HasIndex("OperationTypeId"); - b.HasIndex("WorkCenterId"); + b.HasIndex("WorkcenterId"); b.ToTable("Mrp_T_Operation", (string)null); }); @@ -15634,6 +15982,83 @@ namespace Erp.Platform.Migrations b.Navigation("Employee"); }); + modelBuilder.Entity("Erp.Platform.Entities.Bom", b => + { + b.HasOne("Erp.Platform.Entities.BomType", "BomType") + .WithMany("Boms") + .HasForeignKey("BomTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.Material", "Material") + .WithMany("Boms") + .HasForeignKey("MaterialId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("BomType"); + + b.Navigation("Material"); + }); + + modelBuilder.Entity("Erp.Platform.Entities.BomComponent", b => + { + b.HasOne("Erp.Platform.Entities.Bom", "Bom") + .WithMany("Components") + .HasForeignKey("BomId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.Material", "Material") + .WithMany("BomComponents") + .HasForeignKey("MaterialId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.Operation", "Operation") + .WithMany() + .HasForeignKey("OperationId"); + + b.HasOne("Erp.Platform.Entities.Uom", "Uom") + .WithMany() + .HasForeignKey("UomId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Bom"); + + b.Navigation("Material"); + + b.Navigation("Operation"); + + b.Navigation("Uom"); + }); + + modelBuilder.Entity("Erp.Platform.Entities.BomOperation", b => + { + b.HasOne("Erp.Platform.Entities.Bom", "Bom") + .WithMany("Operations") + .HasForeignKey("BomId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.Operation", "Operation") + .WithMany("BomOperations") + .HasForeignKey("OperationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.Workcenter", "Workcenter") + .WithMany() + .HasForeignKey("WorkcenterId"); + + b.Navigation("Bom"); + + b.Navigation("Operation"); + + b.Navigation("Workcenter"); + }); + modelBuilder.Entity("Erp.Platform.Entities.BranchUsers", b => { b.HasOne("Erp.Platform.Entities.Branch", "Branch") @@ -15979,7 +16404,7 @@ namespace Erp.Platform.Migrations b.HasOne("Erp.Platform.Entities.Workcenter", "WorkCenter") .WithMany() - .HasForeignKey("WorkCenterId") + .HasForeignKey("WorkcenterId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -16110,13 +16535,13 @@ namespace Erp.Platform.Migrations modelBuilder.Entity("Erp.Platform.Entities.MaintenancePlan", b => { - b.HasOne("Erp.Platform.Entities.Workcenter", "WorkCenter") + b.HasOne("Erp.Platform.Entities.Workcenter", "Workcenter") .WithMany() - .HasForeignKey("WorkCenterId") + .HasForeignKey("WorkcenterId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.Navigation("WorkCenter"); + b.Navigation("Workcenter"); }); modelBuilder.Entity("Erp.Platform.Entities.MaintenancePlanEmployee", b => @@ -16271,15 +16696,15 @@ namespace Erp.Platform.Migrations .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.HasOne("Erp.Platform.Entities.Workcenter", "WorkCenter") + b.HasOne("Erp.Platform.Entities.Workcenter", "Workcenter") .WithMany("Operations") - .HasForeignKey("WorkCenterId") + .HasForeignKey("WorkcenterId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("OperationType"); - b.Navigation("WorkCenter"); + b.Navigation("Workcenter"); }); modelBuilder.Entity("Erp.Platform.Entities.OperationType", b => @@ -17099,6 +17524,18 @@ namespace Erp.Platform.Migrations b.Navigation("Posts"); }); + modelBuilder.Entity("Erp.Platform.Entities.Bom", b => + { + b.Navigation("Components"); + + b.Navigation("Operations"); + }); + + modelBuilder.Entity("Erp.Platform.Entities.BomType", b => + { + b.Navigation("Boms"); + }); + modelBuilder.Entity("Erp.Platform.Entities.Branch", b => { b.Navigation("ClassTypes"); @@ -17265,6 +17702,10 @@ namespace Erp.Platform.Migrations { b.Navigation("AlternativeUoms"); + b.Navigation("BomComponents"); + + b.Navigation("Boms"); + b.Navigation("Specifications"); b.Navigation("Suppliers"); @@ -17284,6 +17725,11 @@ namespace Erp.Platform.Migrations b.Navigation("Materials"); }); + modelBuilder.Entity("Erp.Platform.Entities.Operation", b => + { + b.Navigation("BomOperations"); + }); + modelBuilder.Entity("Erp.Platform.Entities.OperationCategory", b => { b.Navigation("OperationTypes"); diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json index a35c0c13..c3017e9d 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json +++ b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json @@ -5636,5 +5636,175 @@ "instructions": "Teknik çizimlere göre boyutsal kontrol yapılacak", "qualityCheckRequired": false } + ], + "BomTypes": [ + { + "name": "Production", + "description": "Üretim için kullanılan malzeme listesi tipi", + "isActive": true + }, + { + "name": "Engineering", + "description": "Mühendislik değişiklikleri için kullanılan malzeme listesi tipi", + "isActive": true + }, + { + "name": "Planning", + "description": "Planlama amaçlı kullanılan malzeme listesi tipi", + "isActive": true + }, + { + "name": "Costing", + "description": "Maliyet hesaplamaları için kullanılan malzeme listesi tipi", + "isActive": true + } + ], + "Boms": [ + { + "materialCode": "MT001", + "bomTypeName": "Production", + "code": "BOM-MOT-001", + "version": "1.0", + "validFrom": "2024-01-01T00:00:00.000Z", + "validTo": "2024-12-31T00:00:00.000Z", + "baseQuantity": 1, + "isActive": true + }, + { + "materialCode": "MT002", + "bomTypeName": "Production", + "code": "BOM-GEAR-001", + "version": "2.1", + "validFrom": "2024-02-01T00:00:00.000Z", + "validTo": "2024-12-31T00:00:00.000Z", + "baseQuantity": 1, + "isActive": true + }, + { + "materialCode": "PR001", + "bomTypeName": "Engineering", + "code": "BOM-PCB-001", + "version": "1.0", + "validFrom": "2024-03-01T00:00:00.000Z", + "baseQuantity": 1, + "isActive": true + } + ], + "BomComponents": [ + { + "bomCode": "BOM-MOT-001", + "materialCode": "MT001", + "operationCode": "OP001", + "quantity": 2, + "uomName": "Adet", + "scrapPercentage": 0.05, + "isPhantom": false, + "validFrom": "2024-01-01T00:00:00.000Z", + "position": 10, + "isActive": true + }, + { + "bomCode": "BOM-MOT-001", + "materialCode": "MT002", + "operationCode": "OP001", + "quantity": 4, + "uomName": "Adet", + "scrapPercentage": 0.01, + "validFrom": "2024-01-01T00:00:00.000Z", + "isPhantom": false, + "position": 20, + "isActive": true + }, + { + "bomCode": "BOM-GEAR-001", + "materialCode": "PR001", + "operationCode": "OP001", + "quantity": 1, + "uomName": "Adet", + "scrapPercentage": 0.01, + "isPhantom": false, + "validFrom": "2024-01-01T00:00:00.000Z", + "position": 30, + "isActive": true + }, + { + "bomCode": "BOM-PCB-001", + "materialCode": "MT002", + "operationCode": "OP001", + "quantity": 1, + "uomName": "Adet", + "scrapPercentage": 0.01, + "isPhantom": false, + "validFrom": "2024-01-01T00:00:00.000Z", + "position": 40, + "isActive": true + } + ], + "BomOperations": [ + { + "bomCode": "BOM-MOT-001", + "operationCode": "OP001", + "workcenterCode": null, + "sequence": 10, + "setupTime": 30, + "runTime": 45, + "waitTime": 0, + "queueTime": 15, + "moveTime": 5, + "isActive": true, + "isParallel": false + }, + { + "bomCode": "BOM-MOT-001", + "operationCode": "OP002", + "workcenterCode": null, + "sequence": 20, + "setupTime": 15, + "runTime": 60, + "waitTime": 0, + "queueTime": 10, + "moveTime": 5, + "isActive": true, + "isParallel": false + }, + { + "bomCode": "BOM-MOT-001", + "operationCode": "OP002", + "workcenterCode": null, + "sequence": 30, + "setupTime": 5, + "runTime": 20, + "waitTime": 0, + "queueTime": 5, + "moveTime": 3, + "isActive": true, + "isParallel": false + }, + { + "bomCode": "BOM-GEAR-001", + "operationCode": "OP003", + "workcenterCode": null, + "sequence": 30, + "setupTime": 5, + "runTime": 20, + "waitTime": 0, + "queueTime": 5, + "moveTime": 3, + "isActive": true, + "isParallel": false + }, + { + "bomCode": "BOM-PCB-001", + "operationCode": "OP004", + "workcenterCode": null, + "sequence": 10, + "setupTime": 15, + "runTime": 30, + "waitTime": 0, + "queueTime": 20, + "moveTime": 3, + "isActive": true, + "isParallel": false + } ] } diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDataSeeder.cs b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDataSeeder.cs index 4af1ce82..0cff857b 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDataSeeder.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDataSeeder.cs @@ -125,6 +125,10 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency private readonly IRepository _operationCategoryRepository; private readonly IRepository _operationTypeRepository; private readonly IRepository _operationRepository; + private readonly IRepository _bomTypeRepository; + private readonly IRepository _bomRepository; + private readonly IRepository _bomComponentRepository; + private readonly IRepository _bomOperationRepository; public TenantDataSeeder( IClock clock, @@ -232,7 +236,11 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency IRepository putawayRepository, IRepository operationCategoryRepository, IRepository operationTypeRepository, - IRepository operationRepository + IRepository operationRepository, + IRepository bomTypeRepository, + IRepository bomRepository, + IRepository bomComponentRepository, + IRepository bomOperationRepository ) { _clock = clock; @@ -342,6 +350,10 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency _operationCategoryRepository = operationCategoryRepository; _operationTypeRepository = operationTypeRepository; _operationRepository = operationRepository; + _bomTypeRepository = bomTypeRepository; + _bomRepository = bomRepository; + _bomComponentRepository = bomComponentRepository; + _bomOperationRepository = bomOperationRepository; } private static IConfigurationRoot BuildConfiguration() @@ -2033,7 +2045,7 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency await _maintenancePlanRepository.InsertAsync(new MaintenancePlan { Code = item.Code, - WorkCenterId = workcenter?.Id, + WorkcenterId = workcenter?.Id, PlanType = item.PlanType, Priority = item.Priority, Description = item.Description, @@ -2089,7 +2101,7 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency await _faultRepository.InsertAsync(new Fault { Code = item.Code, - WorkCenterId = workcenter?.Id, + WorkcenterId = workcenter?.Id, Location = item.Location, FaultTypeId = faultType?.Id, Priority = item.Priority, @@ -2336,7 +2348,7 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency Name = item.Name, Description = item.Description, OperationTypeId = operationType?.Id, - WorkCenterId = workcenter?.Id, + WorkcenterId = workcenter?.Id, StandardTime = item.StandardTime, SetupTime = item.SetupTime, LaborCost = item.LaborCost, @@ -2347,6 +2359,96 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency IsActive = item.IsActive }, autoSave: true); } + + foreach (var item in items.BomTypes) + { + var exists = await _bomTypeRepository.AnyAsync(x => x.Name == item.Name); + if (exists) + continue; + + await _bomTypeRepository.InsertAsync(new BomType + { + Name = item.Name, + Description = item.Description, + IsActive = item.IsActive + }, autoSave: true); + } + + foreach (var item in items.Boms) + { + var exists = await _bomRepository.AnyAsync(x => x.Code == item.Code); + if (exists) + continue; + + var material = await _materialRepository.FirstOrDefaultAsync(x => x.Code == item.MaterialCode); + var bomType = await _bomTypeRepository.FirstOrDefaultAsync(x => x.Name == item.BomTypeName); + + await _bomRepository.InsertAsync(new Bom + { + BomTypeId = bomType?.Id, + MaterialId = material?.Id, + Code = item.Code, + Version = item.Version, + ValidFrom = item.ValidFrom, + ValidTo = item.ValidTo, + BaseQuantity = item.BaseQuantity, + IsActive = item.IsActive, + }, autoSave: true); + } + + foreach (var item in items.BomComponents) + { + var bom = await _bomRepository.FirstOrDefaultAsync(x => x.Code == item.BomCode); + var material = await _materialRepository.FirstOrDefaultAsync(x => x.Code == item.MaterialCode); + var uom = await _uomRepository.FirstOrDefaultAsync(x => x.Name == item.UomName); + var operation = await _operationRepository.FirstOrDefaultAsync(x => x.Code == item.OperationCode); + + var exists = await _bomComponentRepository.AnyAsync(x => x.BomId == bom.Id && x.MaterialId == material.Id); + if (exists) + continue; + + await _bomComponentRepository.InsertAsync(new BomComponent + { + BomId = bom?.Id, + MaterialId = material?.Id, + OperationId = operation?.Id, + Quantity = item.Quantity, + UomId = uom?.Id, + ScrapPercentage = item.ScrapPercentage, + IsPhantom = item.IsPhantom, + Position = item.Position, + ValidFrom = item.ValidFrom, + ValidTo = item.ValidTo, + IsActive = item.IsActive + }, autoSave: true); + } + + foreach (var item in items.BomOperations) + { + var bom = await _bomRepository.FirstOrDefaultAsync(x => x.Code == item.BomCode); + var operation = await _operationRepository.FirstOrDefaultAsync(x => x.Code == item.OperationCode); + + var exists = await _bomOperationRepository.AnyAsync(x => x.BomId == bom.Id && x.OperationId == operation.Id); + if (exists) + continue; + + var workcenter = await _workcenterRepository.FirstOrDefaultAsync(x => x.Code == item.WorkcenterCode); + + await _bomOperationRepository.InsertAsync(new BomOperation + { + BomId = bom?.Id, + OperationId = operation?.Id, + WorkcenterId = workcenter?.Id, + Sequence = item.Sequence, + SetupTime = item.SetupTime, + RunTime = item.RunTime, + WaitTime = item.WaitTime, + QueueTime = item.QueueTime, + MoveTime = item.MoveTime, + IsActive = item.IsActive, + IsParallel = item.IsParallel + }, autoSave: true); + } } } diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantSeederDto.cs b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantSeederDto.cs index 134a3e3a..2eff6c25 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantSeederDto.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantSeederDto.cs @@ -7,6 +7,7 @@ namespace Erp.Platform.Seeds; public class TenantSeederDto { + //Saas public List GlobalSearch { get; set; } public List ForumCategories { get; set; } public List CustomEndpoints { get; set; } @@ -119,6 +120,66 @@ public class TenantSeederDto public List OperationCategories { get; set; } public List OperationTypes { get; set; } public List Operations { get; set; } + + //Mrp + public List BomTypes { get; set; } + public List Boms { get; set; } + public List BomComponents { get; set; } + public List BomOperations { get; set; } +} + +public class BomOperationSeedDto +{ + public string BomCode { get; set; } + public string OperationCode { get; set; } + public string? WorkcenterCode { get; set; } + public int Sequence { get; set; } + public int SetupTime { get; set; } + public int RunTime { get; set; } + public int WaitTime { get; set; } + public int QueueTime { get; set; } + public int MoveTime { get; set; } + public bool IsActive { get; set; } + public bool IsParallel { get; set; } +} + +public class BomComponentSeedDto +{ + public string BomCode { get; set; } + public string MaterialCode { get; set; } + public string OperationCode { get; set; } + + public decimal Quantity { get; set; } + public string UomName { get; set; } + + public decimal ScrapPercentage { get; set; } + public bool IsPhantom { get; set; } + public int Position { get; set; } + public DateTime ValidFrom { get; set; } + public DateTime? ValidTo { get; set; } + + public bool IsActive { get; set; } +} + +public class BomSeedDto +{ + public string MaterialCode { get; set; } + public string BomTypeName { get; set; } + + public string Code { get; set; } + public string Version { get; set; } + public DateTime ValidFrom { get; set; } + public DateTime? ValidTo { get; set; } + public decimal BaseQuantity { get; set; } + + public bool IsActive { get; set; } +} + +public class BomTypeSeedDto +{ + public string Name { get; set; } + public string Description { get; set; } + public bool IsActive { get; set; } } public class OperationSeedDto