From 5e69e0e601c3474db2ac357a087eaa4fd62aef11 Mon Sep 17 00:00:00 2001 From: msmsrep <113223770+msmsrep@users.noreply.github.com> Date: Wed, 23 Sep 2026 17:11:19 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E5=B7=A5=E7=A8=8B=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=A0=85=E7=9B=AE=E3=81=AE=E8=87=AA=E7=94=B1=E8=A8=98=E8=BF=B0?= =?UTF-8?q?=E3=81=AE=E9=95=B7=E3=81=95=E3=82=92=E5=B7=A5=E9=A0=86=E3=81=A8?= =?UTF-8?q?=E4=BD=9C=E6=A5=AD=E6=8C=87=E7=A4=BA=E3=81=A71000=E6=96=87?= =?UTF-8?q?=E5=AD=97=E3=81=AB=E6=8F=83=E3=81=88=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 工順は1000文字、展開先の作業指示は500文字だったため、501文字以上を書いた 工順は PostgreSQL / SQL Server で指図の展開に失敗していた。 API入力とマスタCSVの上限も1000文字に揃え、超える記述は工順の登録で拒否する。 Co-Authored-By: Claude Opus 5.5 --- Spec.md | 1 + .../Services/MasterCsvService.Import.cs | 2 +- .../Contracts/Masters/MasterContracts.cs | 2 +- .../ProductionConfigurations.cs | 2 +- ...825_WidenWorkOrderControlItems.Designer.cs | 4753 ++++++++++++++++ ...260923080825_WidenWorkOrderControlItems.cs | 22 + .../MesAppDbContextModelSnapshot.cs | 2 +- ...828_WidenWorkOrderControlItems.Designer.cs | 4950 +++++++++++++++++ ...260923080828_WidenWorkOrderControlItems.cs | 40 + .../MesAppDbContextModelSnapshot.cs | 4 +- ...830_WidenWorkOrderControlItems.Designer.cs | 4929 ++++++++++++++++ ...260923080830_WidenWorkOrderControlItems.cs | 40 + .../MesAppDbContextModelSnapshot.cs | 4 +- tests/MesApp.Api.Tests/ExecutionTests.cs | 23 + 14 files changed, 14766 insertions(+), 8 deletions(-) create mode 100644 src/MesApp.Infrastructure/Migrations/20260923080825_WidenWorkOrderControlItems.Designer.cs create mode 100644 src/MesApp.Infrastructure/Migrations/20260923080825_WidenWorkOrderControlItems.cs create mode 100644 src/MesApp.Migrations.PostgreSql/Migrations/20260923080828_WidenWorkOrderControlItems.Designer.cs create mode 100644 src/MesApp.Migrations.PostgreSql/Migrations/20260923080828_WidenWorkOrderControlItems.cs create mode 100644 src/MesApp.Migrations.SqlServer/Migrations/20260923080830_WidenWorkOrderControlItems.Designer.cs create mode 100644 src/MesApp.Migrations.SqlServer/Migrations/20260923080830_WidenWorkOrderControlItems.cs diff --git a/Spec.md b/Spec.md index 5a9718e..4cf2126 100644 --- a/Spec.md +++ b/Spec.md @@ -121,6 +121,7 @@ 改訂120: 2026-09-23(5.1節:MBOMの代替部品グループの整合を登録時に確かめるようにした。グループの無い代替部品の行、主材料の無いグループ、主材料が2つ以上あるグループを登録できた。主材料が無いとバックフラッシュ(代替部品の行を消費しない。3.9節)がそのグループの部材を何も引かず、主材料が2つ以上だと代わりになるはずの部材を両方とも原単位ぶん引く。グループの無い代替部品はどの主材料の代わりかが決まらない。判定は `ProductStructurePolicy.CheckAlternativeGroups` に置き、単票APIとマスタCSV取込の両方から呼ぶ。グループ名は前後の空白を除いて比べ、その形で保存する(空白違いで別グループになるのを防ぐ)。既存のデータは直さない(次にそのMBOMを保存するときに判定される)) 改訂121: 2026-09-23(3.1節:MBOMの改訂(A-40-10-05 設計変更)の監査ログに変更前後の明細を残すようにした。これまでは `items=件数` だけで、一括置換のため何を変えたか追えなかった。明細は子品目をIDではなくコードで残す(品目を無効化・改名しても読めるように)。マスタCSV取込では種別ごとの取込ログに加えて親品目ごとに同じ形のログを書く(CSVが追跡の抜け道にならないように)。監査ログは書くたびに保存するため、取込の途中では書かず、全行の検証が通って保存した後にまとめて書く) 改訂122: 2026-09-23(5.7節「指図展開時のマスタ固定」に、予定材料の標準不良率による割り増しと消費工程の固定(改訂117・118)を追記した。あわせてマスタCSV・実績CSVの列の案内(`AlternativeGroup`・`IsAlternative`・`Backflush`)、サンプルの説明、利用者ガイド(帳票・用語・マスタのCSV・部材投入)を改訂117〜121に合わせた) +改訂123: 2026-09-23(工程管理項目の自由記述(`Routing.ControlItems`)の長さの上限を、工順・作業指示・API・マスタCSVで1000文字に揃えた。工順が1000文字、展開先の作業指示が500文字だったため、501文字以上を書いた工順は PostgreSQL / SQL Server で指図の展開に失敗していた(SQLiteは長さを守らせないため表に出なかった)。上限を超える記述は工順の登録で拒否する) 参考: みんなのMES(min-MES) https://min-mes.com/ / OSS: https://github.com/mihatama/open-mes-project --- diff --git a/src/MesApp.Api/Services/MasterCsvService.Import.cs b/src/MesApp.Api/Services/MasterCsvService.Import.cs index ef2b417..08ac12f 100644 --- a/src/MesApp.Api/Services/MasterCsvService.Import.cs +++ b/src/MesApp.Api/Services/MasterCsvService.Import.cs @@ -1120,7 +1120,7 @@ private async Task ImportRoutingAsync( var toolId = reader.Reference("ToolCode", null, toolIds, "治工具"); var checklistId = reader.Reference("ChecklistCode", null, checklistIds, "チェックリスト"); var workCenterId = reader.Reference("WorkCenterCode", null, workCenterIds, "作業区"); - var controlItems = reader.Text("ControlItems", null, 500); + var controlItems = reader.Text("ControlItems", null, 1000); var workProcedureId = reader.Reference("WorkProcedureNo", null, workProcedureIds, "作業手順書"); if (sequence is null && !reader.Failed) { diff --git a/src/MesApp.Core/Contracts/Masters/MasterContracts.cs b/src/MesApp.Core/Contracts/Masters/MasterContracts.cs index 5cb58bc..17ec383 100644 --- a/src/MesApp.Core/Contracts/Masters/MasterContracts.cs +++ b/src/MesApp.Core/Contracts/Masters/MasterContracts.cs @@ -57,7 +57,7 @@ public record RoutingStepRequest( int? RequiredSkillId, int? EquipmentId, int? ToolId, - string? ControlItems, + [MaxLength(1000)] string? ControlItems, int? ChecklistId, int? WorkCenterId = null, /// 候補設備(B-10-20-02)。空なら差立で設備を限定しない diff --git a/src/MesApp.Infrastructure/Configurations/ProductionConfigurations.cs b/src/MesApp.Infrastructure/Configurations/ProductionConfigurations.cs index 0b7450d..2274b96 100644 --- a/src/MesApp.Infrastructure/Configurations/ProductionConfigurations.cs +++ b/src/MesApp.Infrastructure/Configurations/ProductionConfigurations.cs @@ -101,7 +101,7 @@ public void Configure(EntityTypeBuilder e) .WithMany() .HasForeignKey(x => x.ProcessId) .OnDelete(DeleteBehavior.Restrict); - e.Property(x => x.ControlItems).HasMaxLength(500); + e.Property(x => x.ControlItems).HasMaxLength(1000); e.HasOne(x => x.RequiredSkill) .WithMany() .HasForeignKey(x => x.RequiredSkillId) diff --git a/src/MesApp.Infrastructure/Migrations/20260923080825_WidenWorkOrderControlItems.Designer.cs b/src/MesApp.Infrastructure/Migrations/20260923080825_WidenWorkOrderControlItems.Designer.cs new file mode 100644 index 0000000..e844591 --- /dev/null +++ b/src/MesApp.Infrastructure/Migrations/20260923080825_WidenWorkOrderControlItems.Designer.cs @@ -0,0 +1,4753 @@ +// +using System; +using MesApp.Infrastructure; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace MesApp.Infrastructure.Migrations +{ + [DbContext(typeof(MesAppDbContext))] + [Migration("20260923080825_WidenWorkOrderControlItems")] + partial class WidenWorkOrderControlItems + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "10.0.10"); + + modelBuilder.Entity("MesApp.Core.Entities.AppUser", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("AccessFailedCount") + .HasColumnType("INTEGER"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Department") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("EmailConfirmed") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnabled") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnd") + .HasColumnType("TEXT"); + + b.Property("MustChangePassword") + .HasColumnType("INTEGER"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("PasswordHash") + .HasColumnType("TEXT"); + + b.Property("PhoneNumber") + .HasColumnType("TEXT"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("INTEGER"); + + b.Property("SecurityStamp") + .HasColumnType("TEXT"); + + b.Property("ShiftId") + .HasColumnType("INTEGER"); + + b.Property("TwoFactorEnabled") + .HasColumnType("INTEGER"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("WorkCenterId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.HasIndex("ShiftId"); + + b.HasIndex("WorkCenterId"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Detail") + .HasColumnType("TEXT"); + + b.Property("IpAddress") + .HasColumnType("TEXT"); + + b.Property("RecordedOn") + .HasColumnType("TEXT"); + + b.Property("TargetId") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("TargetType") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Timestamp") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("UserName") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RecordedOn"); + + b.HasIndex("Timestamp"); + + b.HasIndex("UserId"); + + b.HasIndex("Category", "Action"); + + b.HasIndex("TargetType", "TargetId"); + + b.ToTable("AuditLogs"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.BomItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AlternativeGroup") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ChildProductId") + .HasColumnType("INTEGER"); + + b.Property("IsAlternative") + .HasColumnType("INTEGER"); + + b.Property("MakeOrBuy") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ParentProductId") + .HasColumnType("INTEGER"); + + b.Property("QuantityPer") + .HasColumnType("TEXT"); + + b.Property("RoutingSequence") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ChildProductId"); + + b.HasIndex("ParentProductId", "ChildProductId") + .IsUnique(); + + b.ToTable("BomItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Checklist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Checklists"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChecklistId") + .HasColumnType("INTEGER"); + + b.Property("IsRequired") + .HasColumnType("INTEGER"); + + b.Property("Sequence") + .HasColumnType("INTEGER"); + + b.Property("Text") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.ToTable("ChecklistItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChecklistId") + .HasColumnType("INTEGER"); + + b.Property("EquipmentId") + .HasColumnType("INTEGER"); + + b.Property("PerformedAt") + .HasColumnType("TEXT"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ChecklistRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistResultItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChecklistItemId") + .HasColumnType("INTEGER"); + + b.Property("ChecklistRecordId") + .HasColumnType("INTEGER"); + + b.Property("IsChecked") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistItemId"); + + b.HasIndex("ChecklistRecordId"); + + b.ToTable("ChecklistResultItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("LowerLimit") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("TargetProcessId") + .HasColumnType("INTEGER"); + + b.Property("TargetProductId") + .HasColumnType("INTEGER"); + + b.Property("TargetValue") + .HasColumnType("TEXT"); + + b.Property("Unit") + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("UpperLimit") + .HasColumnType("TEXT"); + + b.Property("Version") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("TargetProcessId"); + + b.HasIndex("TargetProductId"); + + b.ToTable("ControlItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.DefectReason", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("DefectReasons"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AssetNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("MaintenanceParts") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("MaintenanceThreshold") + .HasColumnType("TEXT"); + + b.Property("MaintenanceType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("Site") + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("WorkCenterId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AssetNo") + .IsUnique(); + + b.HasIndex("WorkCenterId"); + + b.ToTable("Equipments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("EndedAt") + .HasColumnType("TEXT"); + + b.Property("EquipmentId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("RecordedByUserId") + .HasColumnType("TEXT"); + + b.Property("StartedAt") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("StopCause") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("EquipmentLogs"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentPart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("EquipmentId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("QuantityPer") + .HasPrecision(18, 4) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("EquipmentId", "ProductId") + .IsUnique(); + + b.ToTable("EquipmentParts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDevice", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CalibratedOn") + .HasColumnType("TEXT"); + + b.Property("CalibrationCycleDays") + .HasColumnType("INTEGER"); + + b.Property("CalibrationDueOn") + .HasColumnType("TEXT"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Location") + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("SerialNo") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("InspectionDevices"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDeviceCalibration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CalibratedOn") + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("InspectionDeviceId") + .HasColumnType("INTEGER"); + + b.Property("NextDueOn") + .HasColumnType("TEXT"); + + b.Property("PerformedByUserId") + .HasColumnType("TEXT"); + + b.Property("Result") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("InspectionDeviceId", "CalibratedOn"); + + b.ToTable("InspectionDeviceCalibrations"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("LowerLimit") + .HasColumnType("TEXT"); + + b.Property("Method") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("SamplingCount") + .HasColumnType("INTEGER"); + + b.Property("StandardValue") + .HasColumnType("TEXT"); + + b.Property("TargetProcessId") + .HasColumnType("INTEGER"); + + b.Property("TargetProductId") + .HasColumnType("INTEGER"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("UpperLimit") + .HasColumnType("TEXT"); + + b.Property("Version") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("TargetProcessId"); + + b.HasIndex("TargetProductId"); + + b.ToTable("InspectionItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ApprovedAt") + .HasColumnType("TEXT"); + + b.Property("ApprovedByUserId") + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("JudgedAt") + .HasColumnType("TEXT"); + + b.Property("JudgedByUserId") + .HasColumnType("TEXT"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("OverallJudgment") + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("RequestedByUserId") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("TargetLotId") + .HasColumnType("INTEGER"); + + b.Property("TargetWorkOrderId") + .HasColumnType("INTEGER"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("RequestedByUserId"); + + b.HasIndex("Status"); + + b.HasIndex("TargetLotId"); + + b.HasIndex("TargetWorkOrderId"); + + b.ToTable("InspectionOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrderItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("InspectionItemId") + .HasColumnType("INTEGER"); + + b.Property("InspectionOrderId") + .HasColumnType("INTEGER"); + + b.Property("ItemCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ItemName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("ItemVersion") + .HasColumnType("INTEGER"); + + b.Property("LowerLimit") + .HasColumnType("TEXT"); + + b.Property("Method") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("SamplingCount") + .HasColumnType("INTEGER"); + + b.Property("StandardValue") + .HasColumnType("TEXT"); + + b.Property("UpperLimit") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("InspectionItemId"); + + b.HasIndex("InspectionOrderId", "InspectionItemId") + .IsUnique(); + + b.ToTable("InspectionOrderItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CorrectionNote") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("InspectedAt") + .HasColumnType("TEXT"); + + b.Property("InspectedByUserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("InspectionDeviceId") + .HasColumnType("INTEGER"); + + b.Property("InspectionItemId") + .HasColumnType("INTEGER"); + + b.Property("InspectionOrderId") + .HasColumnType("INTEGER"); + + b.Property("Judgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("MeasuredValue") + .HasColumnType("TEXT"); + + b.Property("SampleNo") + .HasColumnType("INTEGER"); + + b.Property("TextValue") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("InspectedByUserId"); + + b.HasIndex("InspectionDeviceId"); + + b.HasIndex("InspectionItemId"); + + b.HasIndex("InspectionOrderId"); + + b.ToTable("InspectionResults"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResultCorrection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AfterJudgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("AfterMeasuredValue") + .HasColumnType("TEXT"); + + b.Property("AfterTextValue") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("BeforeJudgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("BeforeMeasuredValue") + .HasColumnType("TEXT"); + + b.Property("BeforeTextValue") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("CorrectedAt") + .HasColumnType("TEXT"); + + b.Property("CorrectedByUserId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("InspectionOrderId") + .HasColumnType("INTEGER"); + + b.Property("InspectionResultId") + .HasColumnType("INTEGER"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CorrectedByUserId"); + + b.HasIndex("InspectionResultId"); + + b.HasIndex("InspectionOrderId", "Id"); + + b.ToTable("InspectionResultCorrections"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryStock", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("LocationId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId", "LocationId") + .IsUnique(); + + b.HasIndex("ProductId", "LocationId"); + + b.ToTable("InventoryStocks"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryTransaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("FromLocationId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("PerformedByUserId") + .HasColumnType("TEXT"); + + b.Property("PickingOrderId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("ShippingOrderId") + .HasColumnType("INTEGER"); + + b.Property("Timestamp") + .HasColumnType("TEXT"); + + b.Property("ToLocationId") + .HasColumnType("INTEGER"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("FromLocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("Timestamp"); + + b.HasIndex("ToLocationId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("InventoryTransactions"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AreaType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("ShelfNo") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("WorkCenterId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("WorkCenterId"); + + b.ToTable("Locations"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Lot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("ExpiresOn") + .HasColumnType("TEXT"); + + b.Property("Grade") + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("InitialQuantity") + .HasColumnType("TEXT"); + + b.Property("LotNumber") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("TEXT"); + + b.Property("ManufacturedOn") + .HasColumnType("TEXT"); + + b.Property("OriginType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ParentLotId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("SourceWorkOrderId") + .HasColumnType("INTEGER"); + + b.Property("StockStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("LotNumber") + .IsUnique(); + + b.HasIndex("ParentLotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SourceWorkOrderId"); + + b.ToTable("Lots"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotGenealogy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChildLotId") + .HasColumnType("INTEGER"); + + b.Property("OccurredAt") + .HasColumnType("TEXT"); + + b.Property("ParentLotId") + .HasColumnType("INTEGER"); + + b.Property("PerformedByUserId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("RelationType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ChildLotId"); + + b.HasIndex("ParentLotId"); + + b.ToTable("LotGenealogies"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotStatusHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChangedAt") + .HasColumnType("TEXT"); + + b.Property("ChangedByUserId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("FromStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("InspectionOrderId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("NonconformanceReportId") + .HasColumnType("INTEGER"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ToStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("LotId", "Id"); + + b.ToTable("LotStatusHistories"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CreatedByUserId") + .HasColumnType("TEXT"); + + b.Property("EquipmentId") + .HasColumnType("INTEGER"); + + b.Property("MaintenancePlanId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ProcedureId") + .HasColumnType("INTEGER"); + + b.Property("RequestType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ScheduledDate") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ToolId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("CreatedByUserId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("MaintenancePlanId"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("ProcedureId"); + + b.HasIndex("Status"); + + b.HasIndex("ToolId"); + + b.ToTable("MaintenanceOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenancePlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CreatedByUserId") + .HasColumnType("TEXT"); + + b.Property("CycleDays") + .HasColumnType("INTEGER"); + + b.Property("EquipmentId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("PlanYear") + .HasColumnType("INTEGER"); + + b.Property("ScheduledDate") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId", "PlanYear"); + + b.ToTable("MaintenancePlans"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("ProcedureNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Steps") + .IsRequired() + .HasMaxLength(4000) + .HasColumnType("TEXT"); + + b.Property("TargetEquipmentId") + .HasColumnType("INTEGER"); + + b.Property("TargetToolId") + .HasColumnType("INTEGER"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("Version") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ProcedureNo") + .IsUnique(); + + b.HasIndex("TargetEquipmentId"); + + b.HasIndex("TargetToolId"); + + b.ToTable("MaintenanceProcedures"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("EndedAt") + .HasColumnType("TEXT"); + + b.Property("MaintenanceOrderId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("PartsUsed") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Result") + .HasMaxLength(2000) + .HasColumnType("TEXT"); + + b.Property("StartedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("MaintenanceOrderId"); + + b.HasIndex("PerformedByUserId"); + + b.ToTable("MaintenanceRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecordPart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("LocationId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("MaintenanceRecordId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasPrecision(18, 4) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("MaintenanceRecordId"); + + b.HasIndex("ProductId"); + + b.ToTable("MaintenanceRecordParts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ApprovedAt") + .HasColumnType("TEXT"); + + b.Property("ApprovedByUserId") + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CreatedByUserId") + .HasColumnType("TEXT"); + + b.Property("DueDate") + .HasColumnType("TEXT"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("OrderType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("OutputLotId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("SourceOrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("OutputLotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SourceOrderId"); + + b.HasIndex("Status"); + + b.ToTable("ManufacturingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrderMaterial", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AlternativeGroup") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ChildProductId") + .HasColumnType("INTEGER"); + + b.Property("IsAlternative") + .HasColumnType("INTEGER"); + + b.Property("ManufacturingOrderId") + .HasColumnType("INTEGER"); + + b.Property("PlannedQuantity") + .HasColumnType("TEXT"); + + b.Property("QuantityPer") + .HasColumnType("TEXT"); + + b.Property("RoutingSequence") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ChildProductId"); + + b.HasIndex("ManufacturingOrderId", "ChildProductId") + .IsUnique(); + + b.ToTable("ManufacturingOrderMaterials"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaterialConsumption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ConsumedAt") + .HasColumnType("TEXT"); + + b.Property("IsSubstitute") + .HasColumnType("INTEGER"); + + b.Property("LocationId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("Method") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("RecordedByUserId") + .HasColumnType("TEXT"); + + b.Property("SubstituteReason") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("MaterialConsumptions"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NonconformanceReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ActionCompletedAt") + .HasColumnType("TEXT"); + + b.Property("ActionCompletedByUserId") + .HasColumnType("TEXT"); + + b.Property("ActionInstructedAt") + .HasColumnType("TEXT"); + + b.Property("ActionInstructedByUserId") + .HasColumnType("TEXT"); + + b.Property("ActionInstruction") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("ActionRecord") + .HasMaxLength(2000) + .HasColumnType("TEXT"); + + b.Property("ApprovedAt") + .HasColumnType("TEXT"); + + b.Property("ApprovedByUserId") + .HasColumnType("TEXT"); + + b.Property("CauseCategory") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("CauseDetail") + .HasMaxLength(2000) + .HasColumnType("TEXT"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("InspectionOrderId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("ReportNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ReportedByUserId") + .HasColumnType("TEXT"); + + b.Property("ReworkOrderId") + .HasColumnType("INTEGER"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("InspectionOrderId"); + + b.HasIndex("LotId"); + + b.HasIndex("ReportNo") + .IsUnique(); + + b.HasIndex("ReportedByUserId"); + + b.HasIndex("ReworkOrderId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("NonconformanceReports"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NumberSequence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("LastValue") + .HasColumnType("INTEGER"); + + b.Property("Prefix") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Prefix") + .IsUnique(); + + b.ToTable("NumberSequences"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("LocationId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("PickingOrderId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("PickingOrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("PickingLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CreatedByUserId") + .HasColumnType("TEXT"); + + b.Property("ExecutedAt") + .HasColumnType("TEXT"); + + b.Property("ExecutedByUserId") + .HasColumnType("TEXT"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ShippingOrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("ShippingOrderId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("PickingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProcessMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Processes", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("DefaultLocationId") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("Specification") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("StandardDefectRate") + .HasColumnType("TEXT"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Unit") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("DefaultLocationId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDataRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("IsDeviation") + .HasColumnType("INTEGER"); + + b.Property("Item") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("NumericValue") + .HasColumnType("TEXT"); + + b.Property("RecordedAt") + .HasColumnType("TEXT"); + + b.Property("RecordedByUserId") + .HasColumnType("TEXT"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("WorkOrderControlItemId") + .HasColumnType("INTEGER"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("WorkOrderControlItemId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ProductionDataRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDefect", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DefectReasonId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("ProductionRecordId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("DefectReasonId"); + + b.HasIndex("ProductionRecordId"); + + b.ToTable("ProductionDefects"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("BusinessDate") + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("PlannedQuantity") + .HasColumnType("TEXT"); + + b.Property("ProcessId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.Property("WorkCenterId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ProcessId"); + + b.HasIndex("ProductId"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("BusinessDate", "ProductId", "ProcessId", "WorkCenterId") + .IsUnique(); + + b.ToTable("ProductionPlans"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ApprovedAt") + .HasColumnType("TEXT"); + + b.Property("ApprovedByUserId") + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("DefectQuantity") + .HasColumnType("TEXT"); + + b.Property("EndedAt") + .HasColumnType("TEXT"); + + b.Property("GoodQuantity") + .HasColumnType("TEXT"); + + b.Property("OutputLocationId") + .HasColumnType("INTEGER"); + + b.Property("OutputLotId") + .HasColumnType("INTEGER"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ReworkQuantity") + .HasColumnType("TEXT"); + + b.Property("ScrapQuantity") + .HasColumnType("TEXT"); + + b.Property("ShiftId") + .HasColumnType("INTEGER"); + + b.Property("StartedAt") + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("OutputLotId"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("ShiftId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ProductionRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecordCorrection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AfterDefectQuantity") + .HasColumnType("TEXT"); + + b.Property("AfterGoodQuantity") + .HasColumnType("TEXT"); + + b.Property("AfterReworkQuantity") + .HasColumnType("TEXT"); + + b.Property("AfterScrapQuantity") + .HasColumnType("TEXT"); + + b.Property("BeforeDefectQuantity") + .HasColumnType("TEXT"); + + b.Property("BeforeGoodQuantity") + .HasColumnType("TEXT"); + + b.Property("BeforeReworkQuantity") + .HasColumnType("TEXT"); + + b.Property("BeforeScrapQuantity") + .HasColumnType("TEXT"); + + b.Property("CorrectedAt") + .HasColumnType("TEXT"); + + b.Property("CorrectedByUserId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("ProductionRecordId") + .HasColumnType("INTEGER"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("CorrectedByUserId"); + + b.HasIndex("ProductionRecordId"); + + b.HasIndex("WorkOrderId", "Id"); + + b.ToTable("ProductionRecordCorrections"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RefreshToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("ExpiresAt") + .HasColumnType("TEXT"); + + b.Property("RevokedAt") + .HasColumnType("TEXT"); + + b.Property("TokenHash") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("TokenHash") + .IsUnique(); + + b.HasIndex("UserId"); + + b.ToTable("RefreshTokens"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChecklistId") + .HasColumnType("INTEGER"); + + b.Property("ControlItems") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("EquipmentId") + .HasColumnType("INTEGER"); + + b.Property("ProcessId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("RequiredSkillId") + .HasColumnType("INTEGER"); + + b.Property("Sequence") + .HasColumnType("INTEGER"); + + b.Property("StandardSetupMinutes") + .HasColumnType("TEXT"); + + b.Property("StandardWorkMinutes") + .HasColumnType("TEXT"); + + b.Property("ToolId") + .HasColumnType("INTEGER"); + + b.Property("WorkCenterId") + .HasColumnType("INTEGER"); + + b.Property("WorkProcedureId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("ProcessId"); + + b.HasIndex("RequiredSkillId"); + + b.HasIndex("ToolId"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("WorkProcedureId"); + + b.HasIndex("ProductId", "Sequence") + .IsUnique(); + + b.ToTable("Routings"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("EquipmentId") + .HasColumnType("INTEGER"); + + b.Property("RoutingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("RoutingId", "EquipmentId") + .IsUnique(); + + b.ToTable("RoutingEquipments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SampleStorage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClosedByUserId") + .HasColumnType("TEXT"); + + b.Property("ClosedOn") + .HasColumnType("TEXT"); + + b.Property("CollectedByUserId") + .HasColumnType("TEXT"); + + b.Property("CollectedOn") + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("InspectionOrderId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasPrecision(18, 4) + .HasColumnType("TEXT"); + + b.Property("RetainUntil") + .HasColumnType("TEXT"); + + b.Property("SampleNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("INTEGER"); + + b.Property("StorageLocationId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("InspectionOrderId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SampleNo") + .IsUnique(); + + b.HasIndex("StorageLocationId"); + + b.HasIndex("Status", "RetainUntil"); + + b.ToTable("SampleStorages"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SetupRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AbnormalityNote") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("EndedAt") + .HasColumnType("TEXT"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("StartedAt") + .HasColumnType("TEXT"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("SetupRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Shift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("EndTime") + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("StartTime") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Shifts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShipmentJudgment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ApprovedAt") + .HasColumnType("TEXT"); + + b.Property("ApprovedByUserId") + .HasColumnType("TEXT"); + + b.Property("JudgedAt") + .HasColumnType("TEXT"); + + b.Property("JudgedByUserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("JudgmentNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("Result") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ShippingOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("JudgedByUserId"); + + b.HasIndex("JudgmentNo") + .IsUnique(); + + b.HasIndex("LotId"); + + b.HasIndex("ShippingOrderId"); + + b.ToTable("ShipmentJudgments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("ShippedQuantity") + .HasColumnType("TEXT"); + + b.Property("ShippingOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("ShippingOrderId"); + + b.ToTable("ShippingLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CreatedByUserId") + .HasColumnType("TEXT"); + + b.Property("Destination") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("PlannedDate") + .HasColumnType("TEXT"); + + b.Property("ShippedAt") + .HasColumnType("TEXT"); + + b.Property("ShippedByUserId") + .HasColumnType("TEXT"); + + b.Property("ShippingNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ShippingNo") + .IsUnique(); + + b.ToTable("ShippingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SkillMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("RequiresExpiry") + .HasColumnType("INTEGER"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Skills", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CreatedByUserId") + .HasColumnType("TEXT"); + + b.Property("FinalizedAt") + .HasColumnType("TEXT"); + + b.Property("FinalizedByUserId") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("StocktakeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("TargetLocationId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("StocktakeNo") + .IsUnique(); + + b.HasIndex("TargetLocationId"); + + b.ToTable("Stocktakes"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.StocktakeLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CountedQuantity") + .HasColumnType("TEXT"); + + b.Property("IsAdjusted") + .HasColumnType("INTEGER"); + + b.Property("LocationId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("StocktakeId") + .HasColumnType("INTEGER"); + + b.Property("TheoreticalQuantity") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("StocktakeId"); + + b.ToTable("StocktakeLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Tool", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("LifeResetAt") + .HasColumnType("TEXT"); + + b.Property("LifeThresholdCount") + .HasColumnType("INTEGER"); + + b.Property("LifeThresholdHours") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ToolType") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Tools"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolIssue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AllocatedAt") + .HasColumnType("TEXT"); + + b.Property("AllocatedByUserId") + .HasColumnType("TEXT"); + + b.Property("IssuedAt") + .HasColumnType("TEXT"); + + b.Property("IssuedToUserId") + .HasColumnType("TEXT"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("ReturnedAt") + .HasColumnType("TEXT"); + + b.Property("ReturnedByUserId") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("INTEGER"); + + b.Property("ToolId") + .HasColumnType("INTEGER"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("IssuedToUserId"); + + b.HasIndex("WorkOrderId"); + + b.HasIndex("ToolId", "Status"); + + b.ToTable("ToolIssues"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolUsage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("RecordedAt") + .HasColumnType("TEXT"); + + b.Property("RecordedByUserId") + .HasColumnType("TEXT"); + + b.Property("ToolId") + .HasColumnType("INTEGER"); + + b.Property("UsageCount") + .HasColumnType("INTEGER"); + + b.Property("UsageHours") + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ToolId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ToolUsages"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TransferOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CreatedByUserId") + .HasColumnType("TEXT"); + + b.Property("ExecutedAt") + .HasColumnType("TEXT"); + + b.Property("ExecutedByUserId") + .HasColumnType("TEXT"); + + b.Property("FromLocationId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ToLocationId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("FromLocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("Status"); + + b.HasIndex("ToLocationId"); + + b.ToTable("TransferOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TroubleReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("EquipmentId") + .HasColumnType("INTEGER"); + + b.Property("OccurredAt") + .HasColumnType("TEXT"); + + b.Property("ReportedByUserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ResponseHistory") + .HasMaxLength(4000) + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("ReportedByUserId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("TroubleReports"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.UserSkill", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AcquiredOn") + .HasColumnType("TEXT"); + + b.Property("ExpiresOn") + .HasColumnType("TEXT"); + + b.Property("SkillId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("SkillId"); + + b.HasIndex("UserId", "SkillId") + .IsUnique(); + + b.ToTable("UserSkills"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkCenter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Level") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("ParentId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("ParentId"); + + b.ToTable("WorkCenters"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AssignedEquipmentId") + .HasColumnType("INTEGER"); + + b.Property("AssignedUserId") + .HasColumnType("TEXT"); + + b.Property("ControlItems") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("DispatchOrder") + .HasColumnType("INTEGER"); + + b.Property("ManufacturingOrderId") + .HasColumnType("INTEGER"); + + b.Property("PlannedQuantity") + .HasColumnType("TEXT"); + + b.Property("ProcessId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("RequiredSkillId") + .HasColumnType("INTEGER"); + + b.Property("RoutingChecklistId") + .HasColumnType("INTEGER"); + + b.Property("RoutingSequence") + .HasColumnType("INTEGER"); + + b.Property("StandardSetupMinutes") + .HasColumnType("TEXT"); + + b.Property("StandardWorkMinutes") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("WorkCenterId") + .HasColumnType("INTEGER"); + + b.Property("WorkOrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("WorkProcedureId") + .HasColumnType("INTEGER"); + + b.Property("WorkProcedureVersion") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AssignedEquipmentId"); + + b.HasIndex("AssignedUserId"); + + b.HasIndex("ManufacturingOrderId"); + + b.HasIndex("ProcessId"); + + b.HasIndex("ProductId"); + + b.HasIndex("RequiredSkillId"); + + b.HasIndex("RoutingChecklistId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("WorkOrderNo") + .IsUnique(); + + b.HasIndex("WorkProcedureId"); + + b.ToTable("WorkOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ControlItemId") + .HasColumnType("INTEGER"); + + b.Property("ItemCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ItemName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("ItemVersion") + .HasColumnType("INTEGER"); + + b.Property("LowerLimit") + .HasColumnType("TEXT"); + + b.Property("TargetValue") + .HasColumnType("TEXT"); + + b.Property("Unit") + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("UpperLimit") + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ControlItemId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("WorkOrderControlItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderStatusHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChangedAt") + .HasColumnType("TEXT"); + + b.Property("ChangedByUserId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("FromStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ToStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ChangedByUserId"); + + b.HasIndex("WorkOrderId", "Id"); + + b.ToTable("WorkOrderStatusHistories"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("ProcedureNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Reference") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Steps") + .IsRequired() + .HasMaxLength(4000) + .HasColumnType("TEXT"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("Version") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ProcedureNo") + .IsUnique(); + + b.ToTable("WorkProcedures"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkTimeRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("EndedAt") + .HasColumnType("TEXT"); + + b.Property("IndirectCategory") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("StartedAt") + .HasColumnType("TEXT"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("WorkOrderId"); + + b.HasIndex("UserId", "StartedAt"); + + b.ToTable("WorkTimeRecords"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("ProviderKey") + .HasColumnType("TEXT"); + + b.Property("ProviderDisplayName") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.AppUser", b => + { + b.HasOne("MesApp.Core.Entities.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Shift"); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.BomItem", b => + { + b.HasOne("MesApp.Core.Entities.Product", "ChildProduct") + .WithMany() + .HasForeignKey("ChildProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "ParentProduct") + .WithMany() + .HasForeignKey("ParentProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChildProduct"); + + b.Navigation("ParentProduct"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistItem", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", null) + .WithMany("Items") + .HasForeignKey("ChecklistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", "Checklist") + .WithMany() + .HasForeignKey("ChecklistId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Checklist"); + + b.Navigation("Equipment"); + + b.Navigation("PerformedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistResultItem", b => + { + b.HasOne("MesApp.Core.Entities.ChecklistItem", "ChecklistItem") + .WithMany() + .HasForeignKey("ChecklistItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ChecklistRecord", null) + .WithMany("Results") + .HasForeignKey("ChecklistRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChecklistItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ControlItem", b => + { + b.HasOne("MesApp.Core.Entities.ProcessMaster", "TargetProcess") + .WithMany() + .HasForeignKey("TargetProcessId"); + + b.HasOne("MesApp.Core.Entities.Product", "TargetProduct") + .WithMany() + .HasForeignKey("TargetProductId"); + + b.Navigation("TargetProcess"); + + b.Navigation("TargetProduct"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentLog", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Equipment"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentPart", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany("Parts") + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Equipment"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDeviceCalibration", b => + { + b.HasOne("MesApp.Core.Entities.InspectionDevice", "InspectionDevice") + .WithMany() + .HasForeignKey("InspectionDeviceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("InspectionDevice"); + + b.Navigation("PerformedBy"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionItem", b => + { + b.HasOne("MesApp.Core.Entities.ProcessMaster", "TargetProcess") + .WithMany() + .HasForeignKey("TargetProcessId"); + + b.HasOne("MesApp.Core.Entities.Product", "TargetProduct") + .WithMany() + .HasForeignKey("TargetProductId"); + + b.Navigation("TargetProcess"); + + b.Navigation("TargetProduct"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "RequestedBy") + .WithMany() + .HasForeignKey("RequestedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Lot", "TargetLot") + .WithMany() + .HasForeignKey("TargetLotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "TargetWorkOrder") + .WithMany() + .HasForeignKey("TargetWorkOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("RequestedBy"); + + b.Navigation("TargetLot"); + + b.Navigation("TargetWorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrderItem", b => + { + b.HasOne("MesApp.Core.Entities.InspectionItem", "InspectionItem") + .WithMany() + .HasForeignKey("InspectionItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionOrder", null) + .WithMany("Items") + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectionItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResult", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "InspectedBy") + .WithMany() + .HasForeignKey("InspectedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionDevice", "InspectionDevice") + .WithMany() + .HasForeignKey("InspectionDeviceId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.InspectionItem", "InspectionItem") + .WithMany() + .HasForeignKey("InspectionItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionOrder", null) + .WithMany("Results") + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectedBy"); + + b.Navigation("InspectionDevice"); + + b.Navigation("InspectionItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResultCorrection", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CorrectedBy") + .WithMany() + .HasForeignKey("CorrectedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.InspectionResult", "InspectionResult") + .WithMany() + .HasForeignKey("InspectionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CorrectedBy"); + + b.Navigation("InspectionResult"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryStock", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryTransaction", b => + { + b.HasOne("MesApp.Core.Entities.Location", "FromLocation") + .WithMany() + .HasForeignKey("FromLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "ToLocation") + .WithMany() + .HasForeignKey("ToLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("FromLocation"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("ToLocation"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Location", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Lot", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "ParentLot") + .WithMany() + .HasForeignKey("ParentLotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "SourceWorkOrder") + .WithMany() + .HasForeignKey("SourceWorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("ParentLot"); + + b.Navigation("Product"); + + b.Navigation("SourceWorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotGenealogy", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "ChildLot") + .WithMany() + .HasForeignKey("ChildLotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "ParentLot") + .WithMany() + .HasForeignKey("ParentLotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ChildLot"); + + b.Navigation("ParentLot"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotStatusHistory", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lot"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.MaintenancePlan", "MaintenancePlan") + .WithMany() + .HasForeignKey("MaintenancePlanId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.MaintenanceProcedure", "Procedure") + .WithMany() + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CreatedBy"); + + b.Navigation("Equipment"); + + b.Navigation("MaintenancePlan"); + + b.Navigation("Procedure"); + + b.Navigation("Tool"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenancePlan", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Equipment"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceProcedure", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "TargetEquipment") + .WithMany() + .HasForeignKey("TargetEquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Tool", "TargetTool") + .WithMany() + .HasForeignKey("TargetToolId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("TargetEquipment"); + + b.Navigation("TargetTool"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.HasOne("MesApp.Core.Entities.MaintenanceOrder", null) + .WithMany("Records") + .HasForeignKey("MaintenanceOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("PerformedBy"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecordPart", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.MaintenanceRecord", null) + .WithMany("Parts") + .HasForeignKey("MaintenanceRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "OutputLot") + .WithMany() + .HasForeignKey("OutputLotId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "SourceOrder") + .WithMany() + .HasForeignKey("SourceOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("OutputLot"); + + b.Navigation("Product"); + + b.Navigation("SourceOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrderMaterial", b => + { + b.HasOne("MesApp.Core.Entities.Product", "ChildProduct") + .WithMany() + .HasForeignKey("ChildProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ManufacturingOrder") + .WithMany("Materials") + .HasForeignKey("ManufacturingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChildProduct"); + + b.Navigation("ManufacturingOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaterialConsumption", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NonconformanceReport", b => + { + b.HasOne("MesApp.Core.Entities.InspectionOrder", "InspectionOrder") + .WithMany() + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.AppUser", "ReportedBy") + .WithMany() + .HasForeignKey("ReportedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ReworkOrder") + .WithMany() + .HasForeignKey("ReworkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("InspectionOrder"); + + b.Navigation("Lot"); + + b.Navigation("ReportedBy"); + + b.Navigation("ReworkOrder"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingLine", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.PickingOrder", null) + .WithMany("Lines") + .HasForeignKey("PickingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.HasOne("MesApp.Core.Entities.ShippingOrder", "ShippingOrder") + .WithMany() + .HasForeignKey("ShippingOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("ShippingOrder"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Product", b => + { + b.HasOne("MesApp.Core.Entities.Location", "DefaultLocation") + .WithMany() + .HasForeignKey("DefaultLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("DefaultLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDataRecord", b => + { + b.HasOne("MesApp.Core.Entities.WorkOrderControlItem", "WorkOrderControlItem") + .WithMany() + .HasForeignKey("WorkOrderControlItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkOrder"); + + b.Navigation("WorkOrderControlItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDefect", b => + { + b.HasOne("MesApp.Core.Entities.DefectReason", "DefectReason") + .WithMany() + .HasForeignKey("DefectReasonId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ProductionRecord", "ProductionRecord") + .WithMany("Defects") + .HasForeignKey("ProductionRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DefectReason"); + + b.Navigation("ProductionRecord"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionPlan", b => + { + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "OutputLot") + .WithMany() + .HasForeignKey("OutputLotId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OutputLot"); + + b.Navigation("PerformedBy"); + + b.Navigation("Shift"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecordCorrection", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CorrectedBy") + .WithMany() + .HasForeignKey("CorrectedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.ProductionRecord", "ProductionRecord") + .WithMany() + .HasForeignKey("ProductionRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CorrectedBy"); + + b.Navigation("ProductionRecord"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RefreshToken", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", "Checklist") + .WithMany() + .HasForeignKey("ChecklistId"); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId"); + + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.SkillMaster", "RequiredSkill") + .WithMany() + .HasForeignKey("RequiredSkillId"); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId"); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkProcedure", "WorkProcedure") + .WithMany() + .HasForeignKey("WorkProcedureId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Checklist"); + + b.Navigation("Equipment"); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("RequiredSkill"); + + b.Navigation("Tool"); + + b.Navigation("WorkCenter"); + + b.Navigation("WorkProcedure"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Routing", "Routing") + .WithMany("EquipmentCandidates") + .HasForeignKey("RoutingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Equipment"); + + b.Navigation("Routing"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SampleStorage", b => + { + b.HasOne("MesApp.Core.Entities.InspectionOrder", "InspectionOrder") + .WithMany() + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "StorageLocation") + .WithMany() + .HasForeignKey("StorageLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("InspectionOrder"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("StorageLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SetupRecord", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PerformedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShipmentJudgment", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "JudgedBy") + .WithMany() + .HasForeignKey("JudgedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.ShippingOrder", "ShippingOrder") + .WithMany() + .HasForeignKey("ShippingOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("JudgedBy"); + + b.Navigation("Lot"); + + b.Navigation("ShippingOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingLine", b => + { + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ShippingOrder", null) + .WithMany("Lines") + .HasForeignKey("ShippingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.HasOne("MesApp.Core.Entities.Location", "TargetLocation") + .WithMany() + .HasForeignKey("TargetLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("TargetLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.StocktakeLine", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Stocktake", null) + .WithMany("Lines") + .HasForeignKey("StocktakeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolIssue", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "IssuedTo") + .WithMany() + .HasForeignKey("IssuedToUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IssuedTo"); + + b.Navigation("Tool"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolUsage", b => + { + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Tool"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TransferOrder", b => + { + b.HasOne("MesApp.Core.Entities.Location", "FromLocation") + .WithMany() + .HasForeignKey("FromLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "ToLocation") + .WithMany() + .HasForeignKey("ToLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("FromLocation"); + + b.Navigation("Lot"); + + b.Navigation("ToLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TroubleReport", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.AppUser", "ReportedBy") + .WithMany() + .HasForeignKey("ReportedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Equipment"); + + b.Navigation("ReportedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.UserSkill", b => + { + b.HasOne("MesApp.Core.Entities.SkillMaster", "Skill") + .WithMany() + .HasForeignKey("SkillId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Skill"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkCenter", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "Parent") + .WithMany() + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "AssignedEquipment") + .WithMany() + .HasForeignKey("AssignedEquipmentId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.AppUser", "AssignedUser") + .WithMany() + .HasForeignKey("AssignedUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ManufacturingOrder") + .WithMany("WorkOrders") + .HasForeignKey("ManufacturingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.SkillMaster", "RequiredSkill") + .WithMany() + .HasForeignKey("RequiredSkillId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Checklist", "RoutingChecklist") + .WithMany() + .HasForeignKey("RoutingChecklistId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkProcedure", "WorkProcedure") + .WithMany() + .HasForeignKey("WorkProcedureId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("AssignedEquipment"); + + b.Navigation("AssignedUser"); + + b.Navigation("ManufacturingOrder"); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("RequiredSkill"); + + b.Navigation("RoutingChecklist"); + + b.Navigation("WorkCenter"); + + b.Navigation("WorkProcedure"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderControlItem", b => + { + b.HasOne("MesApp.Core.Entities.ControlItem", "ControlItem") + .WithMany() + .HasForeignKey("ControlItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany("ControlItemSnapshots") + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ControlItem"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderStatusHistory", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "ChangedBy") + .WithMany() + .HasForeignKey("ChangedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChangedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkTimeRecord", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("User"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Checklist", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.Navigation("Results"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.Navigation("Parts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.Navigation("Items"); + + b.Navigation("Results"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.Navigation("Records"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.Navigation("Parts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.Navigation("Materials"); + + b.Navigation("WorkOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.Navigation("Defects"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.Navigation("EquipmentCandidates"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingOrder", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.Navigation("ControlItemSnapshots"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/MesApp.Infrastructure/Migrations/20260923080825_WidenWorkOrderControlItems.cs b/src/MesApp.Infrastructure/Migrations/20260923080825_WidenWorkOrderControlItems.cs new file mode 100644 index 0000000..2cf6257 --- /dev/null +++ b/src/MesApp.Infrastructure/Migrations/20260923080825_WidenWorkOrderControlItems.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MesApp.Infrastructure.Migrations +{ + /// + public partial class WidenWorkOrderControlItems : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/src/MesApp.Infrastructure/Migrations/MesAppDbContextModelSnapshot.cs b/src/MesApp.Infrastructure/Migrations/MesAppDbContextModelSnapshot.cs index 2b78802..340a655 100644 --- a/src/MesApp.Infrastructure/Migrations/MesAppDbContextModelSnapshot.cs +++ b/src/MesApp.Infrastructure/Migrations/MesAppDbContextModelSnapshot.cs @@ -2943,7 +2943,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("TEXT"); b.Property("ControlItems") - .HasMaxLength(500) + .HasMaxLength(1000) .HasColumnType("TEXT"); b.Property("CreatedAt") diff --git a/src/MesApp.Migrations.PostgreSql/Migrations/20260923080828_WidenWorkOrderControlItems.Designer.cs b/src/MesApp.Migrations.PostgreSql/Migrations/20260923080828_WidenWorkOrderControlItems.Designer.cs new file mode 100644 index 0000000..d4a2fa2 --- /dev/null +++ b/src/MesApp.Migrations.PostgreSql/Migrations/20260923080828_WidenWorkOrderControlItems.Designer.cs @@ -0,0 +1,4950 @@ +// +using System; +using MesApp.Infrastructure; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MesApp.Migrations.PostgreSql.Migrations +{ + [DbContext(typeof(MesAppDbContext))] + [Migration("20260923080828_WidenWorkOrderControlItems")] + partial class WidenWorkOrderControlItems + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MesApp.Core.Entities.AppUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Department") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("MustChangePassword") + .HasColumnType("boolean"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("ShiftId") + .HasColumnType("integer"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("WorkCenterId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.HasIndex("ShiftId"); + + b.HasIndex("WorkCenterId"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Detail") + .HasColumnType("text"); + + b.Property("IpAddress") + .HasColumnType("text"); + + b.Property("RecordedOn") + .HasColumnType("date"); + + b.Property("TargetId") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("TargetType") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("UserId") + .HasColumnType("text"); + + b.Property("UserName") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RecordedOn"); + + b.HasIndex("Timestamp"); + + b.HasIndex("UserId"); + + b.HasIndex("Category", "Action"); + + b.HasIndex("TargetType", "TargetId"); + + b.ToTable("AuditLogs"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.BomItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AlternativeGroup") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ChildProductId") + .HasColumnType("integer"); + + b.Property("IsAlternative") + .HasColumnType("boolean"); + + b.Property("MakeOrBuy") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ParentProductId") + .HasColumnType("integer"); + + b.Property("QuantityPer") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("RoutingSequence") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ChildProductId"); + + b.HasIndex("ParentProductId", "ChildProductId") + .IsUnique(); + + b.ToTable("BomItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Checklist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Checklists"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChecklistId") + .HasColumnType("integer"); + + b.Property("IsRequired") + .HasColumnType("boolean"); + + b.Property("Sequence") + .HasColumnType("integer"); + + b.Property("Text") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.ToTable("ChecklistItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChecklistId") + .HasColumnType("integer"); + + b.Property("EquipmentId") + .HasColumnType("integer"); + + b.Property("PerformedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ChecklistRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistResultItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChecklistItemId") + .HasColumnType("integer"); + + b.Property("ChecklistRecordId") + .HasColumnType("integer"); + + b.Property("IsChecked") + .HasColumnType("boolean"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistItemId"); + + b.HasIndex("ChecklistRecordId"); + + b.ToTable("ChecklistResultItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("LowerLimit") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("TargetProcessId") + .HasColumnType("integer"); + + b.Property("TargetProductId") + .HasColumnType("integer"); + + b.Property("TargetValue") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Unit") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("UpperLimit") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("TargetProcessId"); + + b.HasIndex("TargetProductId"); + + b.ToTable("ControlItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.DefectReason", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("DefectReasons"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssetNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("MaintenanceParts") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("MaintenanceThreshold") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("MaintenanceType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Site") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WorkCenterId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AssetNo") + .IsUnique(); + + b.HasIndex("WorkCenterId"); + + b.ToTable("Equipments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("EndedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("EquipmentId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("RecordedByUserId") + .HasColumnType("text"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("StopCause") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("EquipmentLogs"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentPart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("EquipmentId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("QuantityPer") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("EquipmentId", "ProductId") + .IsUnique(); + + b.ToTable("EquipmentParts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDevice", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CalibratedOn") + .HasColumnType("date"); + + b.Property("CalibrationCycleDays") + .HasColumnType("integer"); + + b.Property("CalibrationDueOn") + .HasColumnType("date"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Location") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("SerialNo") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("InspectionDevices"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDeviceCalibration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CalibratedOn") + .HasColumnType("date"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("InspectionDeviceId") + .HasColumnType("integer"); + + b.Property("NextDueOn") + .HasColumnType("date"); + + b.Property("PerformedByUserId") + .HasColumnType("text"); + + b.Property("Result") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.HasKey("Id"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("InspectionDeviceId", "CalibratedOn"); + + b.ToTable("InspectionDeviceCalibrations"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("LowerLimit") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Method") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("SamplingCount") + .HasColumnType("integer"); + + b.Property("StandardValue") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("TargetProcessId") + .HasColumnType("integer"); + + b.Property("TargetProductId") + .HasColumnType("integer"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("UpperLimit") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("TargetProcessId"); + + b.HasIndex("TargetProductId"); + + b.ToTable("InspectionItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ApprovedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovedByUserId") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("JudgedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("JudgedByUserId") + .HasColumnType("text"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OverallJudgment") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("RequestedByUserId") + .HasColumnType("text"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("TargetLotId") + .HasColumnType("integer"); + + b.Property("TargetWorkOrderId") + .HasColumnType("integer"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("RequestedByUserId"); + + b.HasIndex("Status"); + + b.HasIndex("TargetLotId"); + + b.HasIndex("TargetWorkOrderId"); + + b.ToTable("InspectionOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrderItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("InspectionItemId") + .HasColumnType("integer"); + + b.Property("InspectionOrderId") + .HasColumnType("integer"); + + b.Property("ItemCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ItemName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("ItemVersion") + .HasColumnType("integer"); + + b.Property("LowerLimit") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Method") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("SamplingCount") + .HasColumnType("integer"); + + b.Property("StandardValue") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("UpperLimit") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("InspectionItemId"); + + b.HasIndex("InspectionOrderId", "InspectionItemId") + .IsUnique(); + + b.ToTable("InspectionOrderItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CorrectionNote") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("InspectedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("InspectedByUserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("InspectionDeviceId") + .HasColumnType("integer"); + + b.Property("InspectionItemId") + .HasColumnType("integer"); + + b.Property("InspectionOrderId") + .HasColumnType("integer"); + + b.Property("Judgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("MeasuredValue") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("SampleNo") + .HasColumnType("integer"); + + b.Property("TextValue") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.HasKey("Id"); + + b.HasIndex("InspectedByUserId"); + + b.HasIndex("InspectionDeviceId"); + + b.HasIndex("InspectionItemId"); + + b.HasIndex("InspectionOrderId"); + + b.ToTable("InspectionResults"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResultCorrection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AfterJudgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("AfterMeasuredValue") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("AfterTextValue") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("BeforeJudgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("BeforeMeasuredValue") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("BeforeTextValue") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("CorrectedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CorrectedByUserId") + .HasMaxLength(450) + .HasColumnType("character varying(450)"); + + b.Property("InspectionOrderId") + .HasColumnType("integer"); + + b.Property("InspectionResultId") + .HasColumnType("integer"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.HasKey("Id"); + + b.HasIndex("CorrectedByUserId"); + + b.HasIndex("InspectionResultId"); + + b.HasIndex("InspectionOrderId", "Id"); + + b.ToTable("InspectionResultCorrections"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryStock", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("LocationId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId", "LocationId") + .IsUnique(); + + b.HasIndex("ProductId", "LocationId"); + + b.ToTable("InventoryStocks"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryTransaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FromLocationId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("PerformedByUserId") + .HasColumnType("text"); + + b.Property("PickingOrderId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("ShippingOrderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("ToLocationId") + .HasColumnType("integer"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FromLocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("Timestamp"); + + b.HasIndex("ToLocationId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("InventoryTransactions"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AreaType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("ShelfNo") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("WorkCenterId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("WorkCenterId"); + + b.ToTable("Locations"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Lot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ExpiresOn") + .HasColumnType("date"); + + b.Property("Grade") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("InitialQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("LotNumber") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("character varying(60)"); + + b.Property("ManufacturedOn") + .HasColumnType("date"); + + b.Property("OriginType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ParentLotId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("SourceWorkOrderId") + .HasColumnType("integer"); + + b.Property("StockStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("LotNumber") + .IsUnique(); + + b.HasIndex("ParentLotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SourceWorkOrderId"); + + b.ToTable("Lots"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotGenealogy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChildLotId") + .HasColumnType("integer"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ParentLotId") + .HasColumnType("integer"); + + b.Property("PerformedByUserId") + .HasMaxLength(450) + .HasColumnType("character varying(450)"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("RelationType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("ChildLotId"); + + b.HasIndex("ParentLotId"); + + b.ToTable("LotGenealogies"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotStatusHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChangedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ChangedByUserId") + .HasMaxLength(450) + .HasColumnType("character varying(450)"); + + b.Property("FromStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("InspectionOrderId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("NonconformanceReportId") + .HasColumnType("integer"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ToStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("LotId", "Id"); + + b.ToTable("LotStatusHistories"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByUserId") + .HasColumnType("text"); + + b.Property("EquipmentId") + .HasColumnType("integer"); + + b.Property("MaintenancePlanId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ProcedureId") + .HasColumnType("integer"); + + b.Property("RequestType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ScheduledDate") + .HasColumnType("date"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ToolId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CreatedByUserId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("MaintenancePlanId"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("ProcedureId"); + + b.HasIndex("Status"); + + b.HasIndex("ToolId"); + + b.ToTable("MaintenanceOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenancePlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByUserId") + .HasColumnType("text"); + + b.Property("CycleDays") + .HasColumnType("integer"); + + b.Property("EquipmentId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("PlanYear") + .HasColumnType("integer"); + + b.Property("ScheduledDate") + .HasColumnType("date"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId", "PlanYear"); + + b.ToTable("MaintenancePlans"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("ProcedureNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Steps") + .IsRequired() + .HasMaxLength(4000) + .HasColumnType("character varying(4000)"); + + b.Property("TargetEquipmentId") + .HasColumnType("integer"); + + b.Property("TargetToolId") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ProcedureNo") + .IsUnique(); + + b.HasIndex("TargetEquipmentId"); + + b.HasIndex("TargetToolId"); + + b.ToTable("MaintenanceProcedures"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("EndedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("MaintenanceOrderId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("PartsUsed") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Result") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("MaintenanceOrderId"); + + b.HasIndex("PerformedByUserId"); + + b.ToTable("MaintenanceRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecordPart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LocationId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("MaintenanceRecordId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("MaintenanceRecordId"); + + b.HasIndex("ProductId"); + + b.ToTable("MaintenanceRecordParts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ApprovedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovedByUserId") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByUserId") + .HasColumnType("text"); + + b.Property("DueDate") + .HasColumnType("date"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OrderType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("OutputLotId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("SourceOrderId") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("OutputLotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SourceOrderId"); + + b.HasIndex("Status"); + + b.ToTable("ManufacturingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrderMaterial", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AlternativeGroup") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ChildProductId") + .HasColumnType("integer"); + + b.Property("IsAlternative") + .HasColumnType("boolean"); + + b.Property("ManufacturingOrderId") + .HasColumnType("integer"); + + b.Property("PlannedQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("QuantityPer") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("RoutingSequence") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ChildProductId"); + + b.HasIndex("ManufacturingOrderId", "ChildProductId") + .IsUnique(); + + b.ToTable("ManufacturingOrderMaterials"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaterialConsumption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ConsumedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IsSubstitute") + .HasColumnType("boolean"); + + b.Property("LocationId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("Method") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("RecordedByUserId") + .HasColumnType("text"); + + b.Property("SubstituteReason") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("MaterialConsumptions"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NonconformanceReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ActionCompletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ActionCompletedByUserId") + .HasColumnType("text"); + + b.Property("ActionInstructedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ActionInstructedByUserId") + .HasColumnType("text"); + + b.Property("ActionInstruction") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("ActionRecord") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("ApprovedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovedByUserId") + .HasColumnType("text"); + + b.Property("CauseCategory") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("CauseDetail") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("InspectionOrderId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("ReportNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ReportedByUserId") + .HasColumnType("text"); + + b.Property("ReworkOrderId") + .HasColumnType("integer"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InspectionOrderId"); + + b.HasIndex("LotId"); + + b.HasIndex("ReportNo") + .IsUnique(); + + b.HasIndex("ReportedByUserId"); + + b.HasIndex("ReworkOrderId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("NonconformanceReports"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NumberSequence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LastValue") + .HasColumnType("integer"); + + b.Property("Prefix") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("character varying(60)"); + + b.HasKey("Id"); + + b.HasIndex("Prefix") + .IsUnique(); + + b.ToTable("NumberSequences"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LocationId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("PickingOrderId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("PickingOrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("PickingLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByUserId") + .HasColumnType("text"); + + b.Property("ExecutedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ExecutedByUserId") + .HasColumnType("text"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ShippingOrderId") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("ShippingOrderId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("PickingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProcessMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Processes", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DefaultLocationId") + .HasColumnType("integer"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Specification") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("StandardDefectRate") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Unit") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("DefaultLocationId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDataRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("IsDeviation") + .HasColumnType("boolean"); + + b.Property("Item") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("NumericValue") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("RecordedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("RecordedByUserId") + .HasColumnType("text"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("WorkOrderControlItemId") + .HasColumnType("integer"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("WorkOrderControlItemId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ProductionDataRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDefect", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DefectReasonId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("ProductionRecordId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("DefectReasonId"); + + b.HasIndex("ProductionRecordId"); + + b.ToTable("ProductionDefects"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BusinessDate") + .HasColumnType("date"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("PlannedQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("ProcessId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("WorkCenterId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ProcessId"); + + b.HasIndex("ProductId"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("BusinessDate", "ProductId", "ProcessId", "WorkCenterId") + .IsUnique(); + + b.ToTable("ProductionPlans"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ApprovedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovedByUserId") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DefectQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("EndedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("GoodQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("OutputLocationId") + .HasColumnType("integer"); + + b.Property("OutputLotId") + .HasColumnType("integer"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReworkQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("ScrapQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("ShiftId") + .HasColumnType("integer"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("OutputLotId"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("ShiftId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ProductionRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecordCorrection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AfterDefectQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("AfterGoodQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("AfterReworkQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("AfterScrapQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("BeforeDefectQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("BeforeGoodQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("BeforeReworkQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("BeforeScrapQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("CorrectedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CorrectedByUserId") + .HasMaxLength(450) + .HasColumnType("character varying(450)"); + + b.Property("ProductionRecordId") + .HasColumnType("integer"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CorrectedByUserId"); + + b.HasIndex("ProductionRecordId"); + + b.HasIndex("WorkOrderId", "Id"); + + b.ToTable("ProductionRecordCorrections"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RefreshToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.Property("RevokedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenHash") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("TokenHash") + .IsUnique(); + + b.HasIndex("UserId"); + + b.ToTable("RefreshTokens"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChecklistId") + .HasColumnType("integer"); + + b.Property("ControlItems") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("EquipmentId") + .HasColumnType("integer"); + + b.Property("ProcessId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("RequiredSkillId") + .HasColumnType("integer"); + + b.Property("Sequence") + .HasColumnType("integer"); + + b.Property("StandardSetupMinutes") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("StandardWorkMinutes") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("ToolId") + .HasColumnType("integer"); + + b.Property("WorkCenterId") + .HasColumnType("integer"); + + b.Property("WorkProcedureId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("ProcessId"); + + b.HasIndex("RequiredSkillId"); + + b.HasIndex("ToolId"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("WorkProcedureId"); + + b.HasIndex("ProductId", "Sequence") + .IsUnique(); + + b.ToTable("Routings"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EquipmentId") + .HasColumnType("integer"); + + b.Property("RoutingId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("RoutingId", "EquipmentId") + .IsUnique(); + + b.ToTable("RoutingEquipments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SampleStorage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClosedByUserId") + .HasColumnType("text"); + + b.Property("ClosedOn") + .HasColumnType("date"); + + b.Property("CollectedByUserId") + .HasColumnType("text"); + + b.Property("CollectedOn") + .HasColumnType("date"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("InspectionOrderId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("RetainUntil") + .HasColumnType("date"); + + b.Property("SampleNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StorageLocationId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InspectionOrderId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SampleNo") + .IsUnique(); + + b.HasIndex("StorageLocationId"); + + b.HasIndex("Status", "RetainUntil"); + + b.ToTable("SampleStorages"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SetupRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AbnormalityNote") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("EndedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("SetupRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Shift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("EndTime") + .HasColumnType("time without time zone"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("StartTime") + .HasColumnType("time without time zone"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Shifts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShipmentJudgment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ApprovedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovedByUserId") + .HasColumnType("text"); + + b.Property("JudgedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("JudgedByUserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("JudgmentNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("Result") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ShippingOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("JudgedByUserId"); + + b.HasIndex("JudgmentNo") + .IsUnique(); + + b.HasIndex("LotId"); + + b.HasIndex("ShippingOrderId"); + + b.ToTable("ShipmentJudgments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("ShippedQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("ShippingOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("ShippingOrderId"); + + b.ToTable("ShippingLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByUserId") + .HasColumnType("text"); + + b.Property("Destination") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("PlannedDate") + .HasColumnType("date"); + + b.Property("ShippedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ShippedByUserId") + .HasColumnType("text"); + + b.Property("ShippingNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("ShippingNo") + .IsUnique(); + + b.ToTable("ShippingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SkillMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("RequiresExpiry") + .HasColumnType("boolean"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Skills", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByUserId") + .HasColumnType("text"); + + b.Property("FinalizedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("FinalizedByUserId") + .HasColumnType("text"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("StocktakeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("TargetLocationId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("StocktakeNo") + .IsUnique(); + + b.HasIndex("TargetLocationId"); + + b.ToTable("Stocktakes"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.StocktakeLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CountedQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("IsAdjusted") + .HasColumnType("boolean"); + + b.Property("LocationId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("StocktakeId") + .HasColumnType("integer"); + + b.Property("TheoreticalQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("StocktakeId"); + + b.ToTable("StocktakeLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Tool", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("LifeResetAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LifeThresholdCount") + .HasColumnType("integer"); + + b.Property("LifeThresholdHours") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ToolType") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Tools"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolIssue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("AllocatedByUserId") + .HasColumnType("text"); + + b.Property("IssuedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IssuedToUserId") + .HasColumnType("text"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("ReturnedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ReturnedByUserId") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("ToolId") + .HasColumnType("integer"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("IssuedToUserId"); + + b.HasIndex("WorkOrderId"); + + b.HasIndex("ToolId", "Status"); + + b.ToTable("ToolIssues"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolUsage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("RecordedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("RecordedByUserId") + .HasColumnType("text"); + + b.Property("ToolId") + .HasColumnType("integer"); + + b.Property("UsageCount") + .HasColumnType("integer"); + + b.Property("UsageHours") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ToolId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ToolUsages"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TransferOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByUserId") + .HasColumnType("text"); + + b.Property("ExecutedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ExecutedByUserId") + .HasColumnType("text"); + + b.Property("FromLocationId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ToLocationId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FromLocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("Status"); + + b.HasIndex("ToLocationId"); + + b.ToTable("TransferOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TroubleReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("EquipmentId") + .HasColumnType("integer"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ReportedByUserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ResponseHistory") + .HasMaxLength(4000) + .HasColumnType("character varying(4000)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("ReportedByUserId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("TroubleReports"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.UserSkill", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AcquiredOn") + .HasColumnType("date"); + + b.Property("ExpiresOn") + .HasColumnType("date"); + + b.Property("SkillId") + .HasColumnType("integer"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("SkillId"); + + b.HasIndex("UserId", "SkillId") + .IsUnique(); + + b.ToTable("UserSkills"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkCenter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Level") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("ParentId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("ParentId"); + + b.ToTable("WorkCenters"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssignedEquipmentId") + .HasColumnType("integer"); + + b.Property("AssignedUserId") + .HasColumnType("text"); + + b.Property("ControlItems") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DispatchOrder") + .HasColumnType("integer"); + + b.Property("ManufacturingOrderId") + .HasColumnType("integer"); + + b.Property("PlannedQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("ProcessId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("RequiredSkillId") + .HasColumnType("integer"); + + b.Property("RoutingChecklistId") + .HasColumnType("integer"); + + b.Property("RoutingSequence") + .HasColumnType("integer"); + + b.Property("StandardSetupMinutes") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("StandardWorkMinutes") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WorkCenterId") + .HasColumnType("integer"); + + b.Property("WorkOrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("WorkProcedureId") + .HasColumnType("integer"); + + b.Property("WorkProcedureVersion") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AssignedEquipmentId"); + + b.HasIndex("AssignedUserId"); + + b.HasIndex("ManufacturingOrderId"); + + b.HasIndex("ProcessId"); + + b.HasIndex("ProductId"); + + b.HasIndex("RequiredSkillId"); + + b.HasIndex("RoutingChecklistId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("WorkOrderNo") + .IsUnique(); + + b.HasIndex("WorkProcedureId"); + + b.ToTable("WorkOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ControlItemId") + .HasColumnType("integer"); + + b.Property("ItemCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ItemName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("ItemVersion") + .HasColumnType("integer"); + + b.Property("LowerLimit") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("TargetValue") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Unit") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("UpperLimit") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ControlItemId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("WorkOrderControlItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderStatusHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChangedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ChangedByUserId") + .HasMaxLength(450) + .HasColumnType("character varying(450)"); + + b.Property("FromStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ToStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ChangedByUserId"); + + b.HasIndex("WorkOrderId", "Id"); + + b.ToTable("WorkOrderStatusHistories"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("ProcedureNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Reference") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Steps") + .IsRequired() + .HasMaxLength(4000) + .HasColumnType("character varying(4000)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ProcedureNo") + .IsUnique(); + + b.ToTable("WorkProcedures"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkTimeRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EndedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IndirectCategory") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("WorkOrderId"); + + b.HasIndex("UserId", "StartedAt"); + + b.ToTable("WorkTimeRecords"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.AppUser", b => + { + b.HasOne("MesApp.Core.Entities.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Shift"); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.BomItem", b => + { + b.HasOne("MesApp.Core.Entities.Product", "ChildProduct") + .WithMany() + .HasForeignKey("ChildProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "ParentProduct") + .WithMany() + .HasForeignKey("ParentProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChildProduct"); + + b.Navigation("ParentProduct"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistItem", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", null) + .WithMany("Items") + .HasForeignKey("ChecklistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", "Checklist") + .WithMany() + .HasForeignKey("ChecklistId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Checklist"); + + b.Navigation("Equipment"); + + b.Navigation("PerformedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistResultItem", b => + { + b.HasOne("MesApp.Core.Entities.ChecklistItem", "ChecklistItem") + .WithMany() + .HasForeignKey("ChecklistItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ChecklistRecord", null) + .WithMany("Results") + .HasForeignKey("ChecklistRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChecklistItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ControlItem", b => + { + b.HasOne("MesApp.Core.Entities.ProcessMaster", "TargetProcess") + .WithMany() + .HasForeignKey("TargetProcessId"); + + b.HasOne("MesApp.Core.Entities.Product", "TargetProduct") + .WithMany() + .HasForeignKey("TargetProductId"); + + b.Navigation("TargetProcess"); + + b.Navigation("TargetProduct"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentLog", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Equipment"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentPart", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany("Parts") + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Equipment"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDeviceCalibration", b => + { + b.HasOne("MesApp.Core.Entities.InspectionDevice", "InspectionDevice") + .WithMany() + .HasForeignKey("InspectionDeviceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("InspectionDevice"); + + b.Navigation("PerformedBy"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionItem", b => + { + b.HasOne("MesApp.Core.Entities.ProcessMaster", "TargetProcess") + .WithMany() + .HasForeignKey("TargetProcessId"); + + b.HasOne("MesApp.Core.Entities.Product", "TargetProduct") + .WithMany() + .HasForeignKey("TargetProductId"); + + b.Navigation("TargetProcess"); + + b.Navigation("TargetProduct"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "RequestedBy") + .WithMany() + .HasForeignKey("RequestedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Lot", "TargetLot") + .WithMany() + .HasForeignKey("TargetLotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "TargetWorkOrder") + .WithMany() + .HasForeignKey("TargetWorkOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("RequestedBy"); + + b.Navigation("TargetLot"); + + b.Navigation("TargetWorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrderItem", b => + { + b.HasOne("MesApp.Core.Entities.InspectionItem", "InspectionItem") + .WithMany() + .HasForeignKey("InspectionItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionOrder", null) + .WithMany("Items") + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectionItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResult", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "InspectedBy") + .WithMany() + .HasForeignKey("InspectedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionDevice", "InspectionDevice") + .WithMany() + .HasForeignKey("InspectionDeviceId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.InspectionItem", "InspectionItem") + .WithMany() + .HasForeignKey("InspectionItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionOrder", null) + .WithMany("Results") + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectedBy"); + + b.Navigation("InspectionDevice"); + + b.Navigation("InspectionItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResultCorrection", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CorrectedBy") + .WithMany() + .HasForeignKey("CorrectedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.InspectionResult", "InspectionResult") + .WithMany() + .HasForeignKey("InspectionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CorrectedBy"); + + b.Navigation("InspectionResult"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryStock", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryTransaction", b => + { + b.HasOne("MesApp.Core.Entities.Location", "FromLocation") + .WithMany() + .HasForeignKey("FromLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "ToLocation") + .WithMany() + .HasForeignKey("ToLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("FromLocation"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("ToLocation"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Location", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Lot", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "ParentLot") + .WithMany() + .HasForeignKey("ParentLotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "SourceWorkOrder") + .WithMany() + .HasForeignKey("SourceWorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("ParentLot"); + + b.Navigation("Product"); + + b.Navigation("SourceWorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotGenealogy", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "ChildLot") + .WithMany() + .HasForeignKey("ChildLotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "ParentLot") + .WithMany() + .HasForeignKey("ParentLotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ChildLot"); + + b.Navigation("ParentLot"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotStatusHistory", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lot"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.MaintenancePlan", "MaintenancePlan") + .WithMany() + .HasForeignKey("MaintenancePlanId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.MaintenanceProcedure", "Procedure") + .WithMany() + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CreatedBy"); + + b.Navigation("Equipment"); + + b.Navigation("MaintenancePlan"); + + b.Navigation("Procedure"); + + b.Navigation("Tool"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenancePlan", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Equipment"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceProcedure", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "TargetEquipment") + .WithMany() + .HasForeignKey("TargetEquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Tool", "TargetTool") + .WithMany() + .HasForeignKey("TargetToolId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("TargetEquipment"); + + b.Navigation("TargetTool"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.HasOne("MesApp.Core.Entities.MaintenanceOrder", null) + .WithMany("Records") + .HasForeignKey("MaintenanceOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("PerformedBy"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecordPart", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.MaintenanceRecord", null) + .WithMany("Parts") + .HasForeignKey("MaintenanceRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "OutputLot") + .WithMany() + .HasForeignKey("OutputLotId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "SourceOrder") + .WithMany() + .HasForeignKey("SourceOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("OutputLot"); + + b.Navigation("Product"); + + b.Navigation("SourceOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrderMaterial", b => + { + b.HasOne("MesApp.Core.Entities.Product", "ChildProduct") + .WithMany() + .HasForeignKey("ChildProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ManufacturingOrder") + .WithMany("Materials") + .HasForeignKey("ManufacturingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChildProduct"); + + b.Navigation("ManufacturingOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaterialConsumption", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NonconformanceReport", b => + { + b.HasOne("MesApp.Core.Entities.InspectionOrder", "InspectionOrder") + .WithMany() + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.AppUser", "ReportedBy") + .WithMany() + .HasForeignKey("ReportedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ReworkOrder") + .WithMany() + .HasForeignKey("ReworkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("InspectionOrder"); + + b.Navigation("Lot"); + + b.Navigation("ReportedBy"); + + b.Navigation("ReworkOrder"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingLine", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.PickingOrder", null) + .WithMany("Lines") + .HasForeignKey("PickingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.HasOne("MesApp.Core.Entities.ShippingOrder", "ShippingOrder") + .WithMany() + .HasForeignKey("ShippingOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("ShippingOrder"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Product", b => + { + b.HasOne("MesApp.Core.Entities.Location", "DefaultLocation") + .WithMany() + .HasForeignKey("DefaultLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("DefaultLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDataRecord", b => + { + b.HasOne("MesApp.Core.Entities.WorkOrderControlItem", "WorkOrderControlItem") + .WithMany() + .HasForeignKey("WorkOrderControlItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkOrder"); + + b.Navigation("WorkOrderControlItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDefect", b => + { + b.HasOne("MesApp.Core.Entities.DefectReason", "DefectReason") + .WithMany() + .HasForeignKey("DefectReasonId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ProductionRecord", "ProductionRecord") + .WithMany("Defects") + .HasForeignKey("ProductionRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DefectReason"); + + b.Navigation("ProductionRecord"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionPlan", b => + { + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "OutputLot") + .WithMany() + .HasForeignKey("OutputLotId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OutputLot"); + + b.Navigation("PerformedBy"); + + b.Navigation("Shift"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecordCorrection", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CorrectedBy") + .WithMany() + .HasForeignKey("CorrectedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.ProductionRecord", "ProductionRecord") + .WithMany() + .HasForeignKey("ProductionRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CorrectedBy"); + + b.Navigation("ProductionRecord"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RefreshToken", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", "Checklist") + .WithMany() + .HasForeignKey("ChecklistId"); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId"); + + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.SkillMaster", "RequiredSkill") + .WithMany() + .HasForeignKey("RequiredSkillId"); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId"); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkProcedure", "WorkProcedure") + .WithMany() + .HasForeignKey("WorkProcedureId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Checklist"); + + b.Navigation("Equipment"); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("RequiredSkill"); + + b.Navigation("Tool"); + + b.Navigation("WorkCenter"); + + b.Navigation("WorkProcedure"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Routing", "Routing") + .WithMany("EquipmentCandidates") + .HasForeignKey("RoutingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Equipment"); + + b.Navigation("Routing"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SampleStorage", b => + { + b.HasOne("MesApp.Core.Entities.InspectionOrder", "InspectionOrder") + .WithMany() + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "StorageLocation") + .WithMany() + .HasForeignKey("StorageLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("InspectionOrder"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("StorageLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SetupRecord", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PerformedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShipmentJudgment", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "JudgedBy") + .WithMany() + .HasForeignKey("JudgedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.ShippingOrder", "ShippingOrder") + .WithMany() + .HasForeignKey("ShippingOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("JudgedBy"); + + b.Navigation("Lot"); + + b.Navigation("ShippingOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingLine", b => + { + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ShippingOrder", null) + .WithMany("Lines") + .HasForeignKey("ShippingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.HasOne("MesApp.Core.Entities.Location", "TargetLocation") + .WithMany() + .HasForeignKey("TargetLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("TargetLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.StocktakeLine", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Stocktake", null) + .WithMany("Lines") + .HasForeignKey("StocktakeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolIssue", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "IssuedTo") + .WithMany() + .HasForeignKey("IssuedToUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IssuedTo"); + + b.Navigation("Tool"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolUsage", b => + { + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Tool"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TransferOrder", b => + { + b.HasOne("MesApp.Core.Entities.Location", "FromLocation") + .WithMany() + .HasForeignKey("FromLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "ToLocation") + .WithMany() + .HasForeignKey("ToLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("FromLocation"); + + b.Navigation("Lot"); + + b.Navigation("ToLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TroubleReport", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.AppUser", "ReportedBy") + .WithMany() + .HasForeignKey("ReportedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Equipment"); + + b.Navigation("ReportedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.UserSkill", b => + { + b.HasOne("MesApp.Core.Entities.SkillMaster", "Skill") + .WithMany() + .HasForeignKey("SkillId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Skill"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkCenter", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "Parent") + .WithMany() + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "AssignedEquipment") + .WithMany() + .HasForeignKey("AssignedEquipmentId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.AppUser", "AssignedUser") + .WithMany() + .HasForeignKey("AssignedUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ManufacturingOrder") + .WithMany("WorkOrders") + .HasForeignKey("ManufacturingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.SkillMaster", "RequiredSkill") + .WithMany() + .HasForeignKey("RequiredSkillId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Checklist", "RoutingChecklist") + .WithMany() + .HasForeignKey("RoutingChecklistId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkProcedure", "WorkProcedure") + .WithMany() + .HasForeignKey("WorkProcedureId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("AssignedEquipment"); + + b.Navigation("AssignedUser"); + + b.Navigation("ManufacturingOrder"); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("RequiredSkill"); + + b.Navigation("RoutingChecklist"); + + b.Navigation("WorkCenter"); + + b.Navigation("WorkProcedure"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderControlItem", b => + { + b.HasOne("MesApp.Core.Entities.ControlItem", "ControlItem") + .WithMany() + .HasForeignKey("ControlItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany("ControlItemSnapshots") + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ControlItem"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderStatusHistory", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "ChangedBy") + .WithMany() + .HasForeignKey("ChangedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChangedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkTimeRecord", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("User"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Checklist", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.Navigation("Results"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.Navigation("Parts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.Navigation("Items"); + + b.Navigation("Results"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.Navigation("Records"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.Navigation("Parts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.Navigation("Materials"); + + b.Navigation("WorkOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.Navigation("Defects"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.Navigation("EquipmentCandidates"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingOrder", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.Navigation("ControlItemSnapshots"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/MesApp.Migrations.PostgreSql/Migrations/20260923080828_WidenWorkOrderControlItems.cs b/src/MesApp.Migrations.PostgreSql/Migrations/20260923080828_WidenWorkOrderControlItems.cs new file mode 100644 index 0000000..2ec991b --- /dev/null +++ b/src/MesApp.Migrations.PostgreSql/Migrations/20260923080828_WidenWorkOrderControlItems.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MesApp.Migrations.PostgreSql.Migrations +{ + /// + public partial class WidenWorkOrderControlItems : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ControlItems", + table: "WorkOrders", + type: "character varying(1000)", + maxLength: 1000, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(500)", + oldMaxLength: 500, + oldNullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ControlItems", + table: "WorkOrders", + type: "character varying(500)", + maxLength: 500, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(1000)", + oldMaxLength: 1000, + oldNullable: true); + } + } +} diff --git a/src/MesApp.Migrations.PostgreSql/Migrations/MesAppDbContextModelSnapshot.cs b/src/MesApp.Migrations.PostgreSql/Migrations/MesAppDbContextModelSnapshot.cs index 6d6b506..b45ab8e 100644 --- a/src/MesApp.Migrations.PostgreSql/Migrations/MesAppDbContextModelSnapshot.cs +++ b/src/MesApp.Migrations.PostgreSql/Migrations/MesAppDbContextModelSnapshot.cs @@ -3122,8 +3122,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("text"); b.Property("ControlItems") - .HasMaxLength(500) - .HasColumnType("character varying(500)"); + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); b.Property("CreatedAt") .HasColumnType("timestamp with time zone"); diff --git a/src/MesApp.Migrations.SqlServer/Migrations/20260923080830_WidenWorkOrderControlItems.Designer.cs b/src/MesApp.Migrations.SqlServer/Migrations/20260923080830_WidenWorkOrderControlItems.Designer.cs new file mode 100644 index 0000000..2d43211 --- /dev/null +++ b/src/MesApp.Migrations.SqlServer/Migrations/20260923080830_WidenWorkOrderControlItems.Designer.cs @@ -0,0 +1,4929 @@ +// +using System; +using MesApp.Infrastructure; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace MesApp.Migrations.SqlServer.Migrations +{ + [DbContext(typeof(MesAppDbContext))] + [Migration("20260923080830_WidenWorkOrderControlItems")] + partial class WidenWorkOrderControlItems + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("MesApp.Core.Entities.AppUser", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("Department") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("MustChangePassword") + .HasColumnType("bit"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("ShiftId") + .HasColumnType("int"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("WorkCenterId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.HasIndex("ShiftId"); + + b.HasIndex("WorkCenterId"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Detail") + .HasColumnType("nvarchar(max)"); + + b.Property("IpAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("RecordedOn") + .HasColumnType("date"); + + b.Property("TargetId") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("TargetType") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Timestamp") + .HasColumnType("datetimeoffset"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("UserName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("RecordedOn"); + + b.HasIndex("Timestamp"); + + b.HasIndex("UserId"); + + b.HasIndex("Category", "Action"); + + b.HasIndex("TargetType", "TargetId"); + + b.ToTable("AuditLogs"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.BomItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AlternativeGroup") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ChildProductId") + .HasColumnType("int"); + + b.Property("IsAlternative") + .HasColumnType("bit"); + + b.Property("MakeOrBuy") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ParentProductId") + .HasColumnType("int"); + + b.Property("QuantityPer") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("RoutingSequence") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChildProductId"); + + b.HasIndex("ParentProductId", "ChildProductId") + .IsUnique(); + + b.ToTable("BomItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Checklist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Checklists"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChecklistId") + .HasColumnType("int"); + + b.Property("IsRequired") + .HasColumnType("bit"); + + b.Property("Sequence") + .HasColumnType("int"); + + b.Property("Text") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.ToTable("ChecklistItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChecklistId") + .HasColumnType("int"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("PerformedAt") + .HasColumnType("datetimeoffset"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ChecklistRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistResultItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChecklistItemId") + .HasColumnType("int"); + + b.Property("ChecklistRecordId") + .HasColumnType("int"); + + b.Property("IsChecked") + .HasColumnType("bit"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistItemId"); + + b.HasIndex("ChecklistRecordId"); + + b.ToTable("ChecklistResultItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("LowerLimit") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("TargetProcessId") + .HasColumnType("int"); + + b.Property("TargetProductId") + .HasColumnType("int"); + + b.Property("TargetValue") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Unit") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("UpperLimit") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("TargetProcessId"); + + b.HasIndex("TargetProductId"); + + b.ToTable("ControlItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.DefectReason", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("DefectReasons"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AssetNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("MaintenanceParts") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("MaintenanceThreshold") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("MaintenanceType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Site") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("WorkCenterId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AssetNo") + .IsUnique(); + + b.HasIndex("WorkCenterId"); + + b.ToTable("Equipments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("EndedAt") + .HasColumnType("datetimeoffset"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RecordedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("StartedAt") + .HasColumnType("datetimeoffset"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("StopCause") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("EquipmentLogs"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentPart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("QuantityPer") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("EquipmentId", "ProductId") + .IsUnique(); + + b.ToTable("EquipmentParts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDevice", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalibratedOn") + .HasColumnType("date"); + + b.Property("CalibrationCycleDays") + .HasColumnType("int"); + + b.Property("CalibrationDueOn") + .HasColumnType("date"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Location") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("SerialNo") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("InspectionDevices"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDeviceCalibration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalibratedOn") + .HasColumnType("date"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("InspectionDeviceId") + .HasColumnType("int"); + + b.Property("NextDueOn") + .HasColumnType("date"); + + b.Property("PerformedByUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("Result") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("InspectionDeviceId", "CalibratedOn"); + + b.ToTable("InspectionDeviceCalibrations"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("LowerLimit") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Method") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("SamplingCount") + .HasColumnType("int"); + + b.Property("StandardValue") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("TargetProcessId") + .HasColumnType("int"); + + b.Property("TargetProductId") + .HasColumnType("int"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("UpperLimit") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("TargetProcessId"); + + b.HasIndex("TargetProductId"); + + b.ToTable("InspectionItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ApprovedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ApprovedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("JudgedAt") + .HasColumnType("datetimeoffset"); + + b.Property("JudgedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("OverallJudgment") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("RequestedByUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("TargetLotId") + .HasColumnType("int"); + + b.Property("TargetWorkOrderId") + .HasColumnType("int"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("RequestedByUserId"); + + b.HasIndex("Status"); + + b.HasIndex("TargetLotId"); + + b.HasIndex("TargetWorkOrderId"); + + b.ToTable("InspectionOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrderItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("InspectionItemId") + .HasColumnType("int"); + + b.Property("InspectionOrderId") + .HasColumnType("int"); + + b.Property("ItemCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ItemName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("ItemVersion") + .HasColumnType("int"); + + b.Property("LowerLimit") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Method") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("SamplingCount") + .HasColumnType("int"); + + b.Property("StandardValue") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("UpperLimit") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("InspectionItemId"); + + b.HasIndex("InspectionOrderId", "InspectionItemId") + .IsUnique(); + + b.ToTable("InspectionOrderItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CorrectionNote") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("InspectedAt") + .HasColumnType("datetimeoffset"); + + b.Property("InspectedByUserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("InspectionDeviceId") + .HasColumnType("int"); + + b.Property("InspectionItemId") + .HasColumnType("int"); + + b.Property("InspectionOrderId") + .HasColumnType("int"); + + b.Property("Judgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("MeasuredValue") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("SampleNo") + .HasColumnType("int"); + + b.Property("TextValue") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("InspectedByUserId"); + + b.HasIndex("InspectionDeviceId"); + + b.HasIndex("InspectionItemId"); + + b.HasIndex("InspectionOrderId"); + + b.ToTable("InspectionResults"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResultCorrection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AfterJudgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("AfterMeasuredValue") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("AfterTextValue") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("BeforeJudgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("BeforeMeasuredValue") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("BeforeTextValue") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CorrectedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CorrectedByUserId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("InspectionOrderId") + .HasColumnType("int"); + + b.Property("InspectionResultId") + .HasColumnType("int"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("CorrectedByUserId"); + + b.HasIndex("InspectionResultId"); + + b.HasIndex("InspectionOrderId", "Id"); + + b.ToTable("InspectionResultCorrections"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryStock", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId", "LocationId") + .IsUnique(); + + b.HasIndex("ProductId", "LocationId"); + + b.ToTable("InventoryStocks"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryTransaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FromLocationId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("PerformedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("PickingOrderId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("ShippingOrderId") + .HasColumnType("int"); + + b.Property("Timestamp") + .HasColumnType("datetimeoffset"); + + b.Property("ToLocationId") + .HasColumnType("int"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("FromLocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("Timestamp"); + + b.HasIndex("ToLocationId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("InventoryTransactions"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AreaType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("ShelfNo") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("WorkCenterId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("WorkCenterId"); + + b.ToTable("Locations"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Lot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ExpiresOn") + .HasColumnType("date"); + + b.Property("Grade") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("InitialQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("LotNumber") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.Property("ManufacturedOn") + .HasColumnType("date"); + + b.Property("OriginType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ParentLotId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("SourceWorkOrderId") + .HasColumnType("int"); + + b.Property("StockStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("LotNumber") + .IsUnique(); + + b.HasIndex("ParentLotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SourceWorkOrderId"); + + b.ToTable("Lots"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotGenealogy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChildLotId") + .HasColumnType("int"); + + b.Property("OccurredAt") + .HasColumnType("datetimeoffset"); + + b.Property("ParentLotId") + .HasColumnType("int"); + + b.Property("PerformedByUserId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("RelationType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("ChildLotId"); + + b.HasIndex("ParentLotId"); + + b.ToTable("LotGenealogies"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotStatusHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChangedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ChangedByUserId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("FromStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("InspectionOrderId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("NonconformanceReportId") + .HasColumnType("int"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ToStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("LotId", "Id"); + + b.ToTable("LotStatusHistories"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CreatedByUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("MaintenancePlanId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ProcedureId") + .HasColumnType("int"); + + b.Property("RequestType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ScheduledDate") + .HasColumnType("date"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ToolId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedByUserId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("MaintenancePlanId"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("ProcedureId"); + + b.HasIndex("Status"); + + b.HasIndex("ToolId"); + + b.ToTable("MaintenanceOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenancePlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CreatedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("CycleDays") + .HasColumnType("int"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PlanYear") + .HasColumnType("int"); + + b.Property("ScheduledDate") + .HasColumnType("date"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId", "PlanYear"); + + b.ToTable("MaintenancePlans"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("ProcedureNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Steps") + .IsRequired() + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("TargetEquipmentId") + .HasColumnType("int"); + + b.Property("TargetToolId") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ProcedureNo") + .IsUnique(); + + b.HasIndex("TargetEquipmentId"); + + b.HasIndex("TargetToolId"); + + b.ToTable("MaintenanceProcedures"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("EndedAt") + .HasColumnType("datetimeoffset"); + + b.Property("MaintenanceOrderId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PartsUsed") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Result") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("StartedAt") + .HasColumnType("datetimeoffset"); + + b.HasKey("Id"); + + b.HasIndex("MaintenanceOrderId"); + + b.HasIndex("PerformedByUserId"); + + b.ToTable("MaintenanceRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecordPart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("MaintenanceRecordId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("MaintenanceRecordId"); + + b.HasIndex("ProductId"); + + b.ToTable("MaintenanceRecordParts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ApprovedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ApprovedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CreatedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("DueDate") + .HasColumnType("date"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("OrderType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("OutputLotId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("SourceOrderId") + .HasColumnType("int"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("UpdatedAt") + .HasColumnType("datetimeoffset"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("OutputLotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SourceOrderId"); + + b.HasIndex("Status"); + + b.ToTable("ManufacturingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrderMaterial", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AlternativeGroup") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ChildProductId") + .HasColumnType("int"); + + b.Property("IsAlternative") + .HasColumnType("bit"); + + b.Property("ManufacturingOrderId") + .HasColumnType("int"); + + b.Property("PlannedQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("QuantityPer") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("RoutingSequence") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChildProductId"); + + b.HasIndex("ManufacturingOrderId", "ChildProductId") + .IsUnique(); + + b.ToTable("ManufacturingOrderMaterials"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaterialConsumption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConsumedAt") + .HasColumnType("datetimeoffset"); + + b.Property("IsSubstitute") + .HasColumnType("bit"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("Method") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("RecordedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("SubstituteReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("MaterialConsumptions"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NonconformanceReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ActionCompletedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ActionCompletedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("ActionInstructedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ActionInstructedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("ActionInstruction") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("ActionRecord") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ApprovedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ApprovedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("CauseCategory") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CauseDetail") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("InspectionOrderId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("ReportNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ReportedByUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("ReworkOrderId") + .HasColumnType("int"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("InspectionOrderId"); + + b.HasIndex("LotId"); + + b.HasIndex("ReportNo") + .IsUnique(); + + b.HasIndex("ReportedByUserId"); + + b.HasIndex("ReworkOrderId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("NonconformanceReports"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NumberSequence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("LastValue") + .HasColumnType("int"); + + b.Property("Prefix") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.HasKey("Id"); + + b.HasIndex("Prefix") + .IsUnique(); + + b.ToTable("NumberSequences"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("PickingOrderId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("PickingOrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("PickingLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CreatedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ExecutedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ShippingOrderId") + .HasColumnType("int"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("ShippingOrderId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("PickingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProcessMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Processes", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("DefaultLocationId") + .HasColumnType("int"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Specification") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("StandardDefectRate") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Unit") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("UpdatedAt") + .HasColumnType("datetimeoffset"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("DefaultLocationId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDataRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsDeviation") + .HasColumnType("bit"); + + b.Property("Item") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("NumericValue") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("RecordedAt") + .HasColumnType("datetimeoffset"); + + b.Property("RecordedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("WorkOrderControlItemId") + .HasColumnType("int"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("WorkOrderControlItemId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ProductionDataRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDefect", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DefectReasonId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ProductionRecordId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("DefectReasonId"); + + b.HasIndex("ProductionRecordId"); + + b.ToTable("ProductionDefects"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BusinessDate") + .HasColumnType("date"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("PlannedQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("ProcessId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("WorkCenterId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ProcessId"); + + b.HasIndex("ProductId"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("BusinessDate", "ProductId", "ProcessId", "WorkCenterId") + .IsUnique() + .HasFilter("[WorkCenterId] IS NOT NULL"); + + b.ToTable("ProductionPlans"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ApprovedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ApprovedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("DefectQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("EndedAt") + .HasColumnType("datetimeoffset"); + + b.Property("GoodQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("OutputLocationId") + .HasColumnType("int"); + + b.Property("OutputLotId") + .HasColumnType("int"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ReworkQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("ScrapQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("ShiftId") + .HasColumnType("int"); + + b.Property("StartedAt") + .HasColumnType("datetimeoffset"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("OutputLotId"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("ShiftId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ProductionRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecordCorrection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AfterDefectQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("AfterGoodQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("AfterReworkQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("AfterScrapQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("BeforeDefectQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("BeforeGoodQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("BeforeReworkQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("BeforeScrapQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("CorrectedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CorrectedByUserId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("ProductionRecordId") + .HasColumnType("int"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CorrectedByUserId"); + + b.HasIndex("ProductionRecordId"); + + b.HasIndex("WorkOrderId", "Id"); + + b.ToTable("ProductionRecordCorrections"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RefreshToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ExpiresAt") + .HasColumnType("datetimeoffset"); + + b.Property("RevokedAt") + .HasColumnType("datetimeoffset"); + + b.Property("TokenHash") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("TokenHash") + .IsUnique(); + + b.HasIndex("UserId"); + + b.ToTable("RefreshTokens"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChecklistId") + .HasColumnType("int"); + + b.Property("ControlItems") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("ProcessId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("RequiredSkillId") + .HasColumnType("int"); + + b.Property("Sequence") + .HasColumnType("int"); + + b.Property("StandardSetupMinutes") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("StandardWorkMinutes") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("ToolId") + .HasColumnType("int"); + + b.Property("WorkCenterId") + .HasColumnType("int"); + + b.Property("WorkProcedureId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("ProcessId"); + + b.HasIndex("RequiredSkillId"); + + b.HasIndex("ToolId"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("WorkProcedureId"); + + b.HasIndex("ProductId", "Sequence") + .IsUnique(); + + b.ToTable("Routings"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("RoutingId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("RoutingId", "EquipmentId") + .IsUnique(); + + b.ToTable("RoutingEquipments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SampleStorage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClosedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("ClosedOn") + .HasColumnType("date"); + + b.Property("CollectedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("CollectedOn") + .HasColumnType("date"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("InspectionOrderId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("RetainUntil") + .HasColumnType("date"); + + b.Property("SampleNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StorageLocationId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("InspectionOrderId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SampleNo") + .IsUnique(); + + b.HasIndex("StorageLocationId"); + + b.HasIndex("Status", "RetainUntil"); + + b.ToTable("SampleStorages"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SetupRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AbnormalityNote") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("EndedAt") + .HasColumnType("datetimeoffset"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("StartedAt") + .HasColumnType("datetimeoffset"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("SetupRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Shift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("EndTime") + .HasColumnType("time"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("StartTime") + .HasColumnType("time"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Shifts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShipmentJudgment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ApprovedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ApprovedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("JudgedAt") + .HasColumnType("datetimeoffset"); + + b.Property("JudgedByUserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("JudgmentNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Result") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ShippingOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("JudgedByUserId"); + + b.HasIndex("JudgmentNo") + .IsUnique(); + + b.HasIndex("LotId"); + + b.HasIndex("ShippingOrderId"); + + b.ToTable("ShipmentJudgments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("ShippedQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("ShippingOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("ShippingOrderId"); + + b.ToTable("ShippingLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CreatedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("Destination") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("PlannedDate") + .HasColumnType("date"); + + b.Property("ShippedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ShippedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("ShippingNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("ShippingNo") + .IsUnique(); + + b.ToTable("ShippingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SkillMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("RequiresExpiry") + .HasColumnType("bit"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Skills", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CreatedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("FinalizedAt") + .HasColumnType("datetimeoffset"); + + b.Property("FinalizedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("StocktakeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TargetLocationId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("StocktakeNo") + .IsUnique(); + + b.HasIndex("TargetLocationId"); + + b.ToTable("Stocktakes"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.StocktakeLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CountedQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("IsAdjusted") + .HasColumnType("bit"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("StocktakeId") + .HasColumnType("int"); + + b.Property("TheoreticalQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("StocktakeId"); + + b.ToTable("StocktakeLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Tool", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("LifeResetAt") + .HasColumnType("datetimeoffset"); + + b.Property("LifeThresholdCount") + .HasColumnType("int"); + + b.Property("LifeThresholdHours") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ToolType") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Tools"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolIssue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AllocatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("AllocatedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("IssuedAt") + .HasColumnType("datetimeoffset"); + + b.Property("IssuedToUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ReturnedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ReturnedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("ToolId") + .HasColumnType("int"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IssuedToUserId"); + + b.HasIndex("WorkOrderId"); + + b.HasIndex("ToolId", "Status"); + + b.ToTable("ToolIssues"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolUsage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("RecordedAt") + .HasColumnType("datetimeoffset"); + + b.Property("RecordedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("ToolId") + .HasColumnType("int"); + + b.Property("UsageCount") + .HasColumnType("int"); + + b.Property("UsageHours") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ToolId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ToolUsages"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TransferOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CreatedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ExecutedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("FromLocationId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ToLocationId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("FromLocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("Status"); + + b.HasIndex("ToLocationId"); + + b.ToTable("TransferOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TroubleReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("OccurredAt") + .HasColumnType("datetimeoffset"); + + b.Property("ReportedByUserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ResponseHistory") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("ReportedByUserId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("TroubleReports"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.UserSkill", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AcquiredOn") + .HasColumnType("date"); + + b.Property("ExpiresOn") + .HasColumnType("date"); + + b.Property("SkillId") + .HasColumnType("int"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("SkillId"); + + b.HasIndex("UserId", "SkillId") + .IsUnique(); + + b.ToTable("UserSkills"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkCenter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Level") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("ParentId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("ParentId"); + + b.ToTable("WorkCenters"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AssignedEquipmentId") + .HasColumnType("int"); + + b.Property("AssignedUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("ControlItems") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("DispatchOrder") + .HasColumnType("int"); + + b.Property("ManufacturingOrderId") + .HasColumnType("int"); + + b.Property("PlannedQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("ProcessId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("RequiredSkillId") + .HasColumnType("int"); + + b.Property("RoutingChecklistId") + .HasColumnType("int"); + + b.Property("RoutingSequence") + .HasColumnType("int"); + + b.Property("StandardSetupMinutes") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("StandardWorkMinutes") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("WorkCenterId") + .HasColumnType("int"); + + b.Property("WorkOrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("WorkProcedureId") + .HasColumnType("int"); + + b.Property("WorkProcedureVersion") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AssignedEquipmentId"); + + b.HasIndex("AssignedUserId"); + + b.HasIndex("ManufacturingOrderId"); + + b.HasIndex("ProcessId"); + + b.HasIndex("ProductId"); + + b.HasIndex("RequiredSkillId"); + + b.HasIndex("RoutingChecklistId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("WorkOrderNo") + .IsUnique(); + + b.HasIndex("WorkProcedureId"); + + b.ToTable("WorkOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ControlItemId") + .HasColumnType("int"); + + b.Property("ItemCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ItemName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("ItemVersion") + .HasColumnType("int"); + + b.Property("LowerLimit") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("TargetValue") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Unit") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("UpperLimit") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ControlItemId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("WorkOrderControlItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderStatusHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChangedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ChangedByUserId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("FromStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ToStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChangedByUserId"); + + b.HasIndex("WorkOrderId", "Id"); + + b.ToTable("WorkOrderStatusHistories"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("ProcedureNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Reference") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Steps") + .IsRequired() + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ProcedureNo") + .IsUnique(); + + b.ToTable("WorkProcedures"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkTimeRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EndedAt") + .HasColumnType("datetimeoffset"); + + b.Property("IndirectCategory") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("StartedAt") + .HasColumnType("datetimeoffset"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("WorkOrderId"); + + b.HasIndex("UserId", "StartedAt"); + + b.ToTable("WorkTimeRecords"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.AppUser", b => + { + b.HasOne("MesApp.Core.Entities.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Shift"); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.BomItem", b => + { + b.HasOne("MesApp.Core.Entities.Product", "ChildProduct") + .WithMany() + .HasForeignKey("ChildProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "ParentProduct") + .WithMany() + .HasForeignKey("ParentProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChildProduct"); + + b.Navigation("ParentProduct"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistItem", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", null) + .WithMany("Items") + .HasForeignKey("ChecklistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", "Checklist") + .WithMany() + .HasForeignKey("ChecklistId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Checklist"); + + b.Navigation("Equipment"); + + b.Navigation("PerformedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistResultItem", b => + { + b.HasOne("MesApp.Core.Entities.ChecklistItem", "ChecklistItem") + .WithMany() + .HasForeignKey("ChecklistItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ChecklistRecord", null) + .WithMany("Results") + .HasForeignKey("ChecklistRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChecklistItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ControlItem", b => + { + b.HasOne("MesApp.Core.Entities.ProcessMaster", "TargetProcess") + .WithMany() + .HasForeignKey("TargetProcessId"); + + b.HasOne("MesApp.Core.Entities.Product", "TargetProduct") + .WithMany() + .HasForeignKey("TargetProductId"); + + b.Navigation("TargetProcess"); + + b.Navigation("TargetProduct"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentLog", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Equipment"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentPart", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany("Parts") + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Equipment"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDeviceCalibration", b => + { + b.HasOne("MesApp.Core.Entities.InspectionDevice", "InspectionDevice") + .WithMany() + .HasForeignKey("InspectionDeviceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("InspectionDevice"); + + b.Navigation("PerformedBy"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionItem", b => + { + b.HasOne("MesApp.Core.Entities.ProcessMaster", "TargetProcess") + .WithMany() + .HasForeignKey("TargetProcessId"); + + b.HasOne("MesApp.Core.Entities.Product", "TargetProduct") + .WithMany() + .HasForeignKey("TargetProductId"); + + b.Navigation("TargetProcess"); + + b.Navigation("TargetProduct"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "RequestedBy") + .WithMany() + .HasForeignKey("RequestedByUserId"); + + b.HasOne("MesApp.Core.Entities.Lot", "TargetLot") + .WithMany() + .HasForeignKey("TargetLotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "TargetWorkOrder") + .WithMany() + .HasForeignKey("TargetWorkOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("RequestedBy"); + + b.Navigation("TargetLot"); + + b.Navigation("TargetWorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrderItem", b => + { + b.HasOne("MesApp.Core.Entities.InspectionItem", "InspectionItem") + .WithMany() + .HasForeignKey("InspectionItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionOrder", null) + .WithMany("Items") + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectionItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResult", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "InspectedBy") + .WithMany() + .HasForeignKey("InspectedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionDevice", "InspectionDevice") + .WithMany() + .HasForeignKey("InspectionDeviceId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.InspectionItem", "InspectionItem") + .WithMany() + .HasForeignKey("InspectionItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionOrder", null) + .WithMany("Results") + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectedBy"); + + b.Navigation("InspectionDevice"); + + b.Navigation("InspectionItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResultCorrection", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CorrectedBy") + .WithMany() + .HasForeignKey("CorrectedByUserId"); + + b.HasOne("MesApp.Core.Entities.InspectionResult", "InspectionResult") + .WithMany() + .HasForeignKey("InspectionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CorrectedBy"); + + b.Navigation("InspectionResult"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryStock", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryTransaction", b => + { + b.HasOne("MesApp.Core.Entities.Location", "FromLocation") + .WithMany() + .HasForeignKey("FromLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "ToLocation") + .WithMany() + .HasForeignKey("ToLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId"); + + b.Navigation("FromLocation"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("ToLocation"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Location", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Lot", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "ParentLot") + .WithMany() + .HasForeignKey("ParentLotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "SourceWorkOrder") + .WithMany() + .HasForeignKey("SourceWorkOrderId"); + + b.Navigation("ParentLot"); + + b.Navigation("Product"); + + b.Navigation("SourceWorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotGenealogy", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "ChildLot") + .WithMany() + .HasForeignKey("ChildLotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "ParentLot") + .WithMany() + .HasForeignKey("ParentLotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ChildLot"); + + b.Navigation("ParentLot"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotStatusHistory", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lot"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedByUserId"); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.MaintenancePlan", "MaintenancePlan") + .WithMany() + .HasForeignKey("MaintenancePlanId"); + + b.HasOne("MesApp.Core.Entities.MaintenanceProcedure", "Procedure") + .WithMany() + .HasForeignKey("ProcedureId"); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CreatedBy"); + + b.Navigation("Equipment"); + + b.Navigation("MaintenancePlan"); + + b.Navigation("Procedure"); + + b.Navigation("Tool"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenancePlan", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Equipment"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceProcedure", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "TargetEquipment") + .WithMany() + .HasForeignKey("TargetEquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Tool", "TargetTool") + .WithMany() + .HasForeignKey("TargetToolId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("TargetEquipment"); + + b.Navigation("TargetTool"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.HasOne("MesApp.Core.Entities.MaintenanceOrder", null) + .WithMany("Records") + .HasForeignKey("MaintenanceOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("PerformedBy"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecordPart", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.MaintenanceRecord", null) + .WithMany("Parts") + .HasForeignKey("MaintenanceRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "OutputLot") + .WithMany() + .HasForeignKey("OutputLotId"); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "SourceOrder") + .WithMany() + .HasForeignKey("SourceOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("OutputLot"); + + b.Navigation("Product"); + + b.Navigation("SourceOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrderMaterial", b => + { + b.HasOne("MesApp.Core.Entities.Product", "ChildProduct") + .WithMany() + .HasForeignKey("ChildProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ManufacturingOrder") + .WithMany("Materials") + .HasForeignKey("ManufacturingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChildProduct"); + + b.Navigation("ManufacturingOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaterialConsumption", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NonconformanceReport", b => + { + b.HasOne("MesApp.Core.Entities.InspectionOrder", "InspectionOrder") + .WithMany() + .HasForeignKey("InspectionOrderId"); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.AppUser", "ReportedBy") + .WithMany() + .HasForeignKey("ReportedByUserId"); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ReworkOrder") + .WithMany() + .HasForeignKey("ReworkOrderId"); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId"); + + b.Navigation("InspectionOrder"); + + b.Navigation("Lot"); + + b.Navigation("ReportedBy"); + + b.Navigation("ReworkOrder"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingLine", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.PickingOrder", null) + .WithMany("Lines") + .HasForeignKey("PickingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.HasOne("MesApp.Core.Entities.ShippingOrder", "ShippingOrder") + .WithMany() + .HasForeignKey("ShippingOrderId"); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId"); + + b.Navigation("ShippingOrder"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Product", b => + { + b.HasOne("MesApp.Core.Entities.Location", "DefaultLocation") + .WithMany() + .HasForeignKey("DefaultLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("DefaultLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDataRecord", b => + { + b.HasOne("MesApp.Core.Entities.WorkOrderControlItem", "WorkOrderControlItem") + .WithMany() + .HasForeignKey("WorkOrderControlItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkOrder"); + + b.Navigation("WorkOrderControlItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDefect", b => + { + b.HasOne("MesApp.Core.Entities.DefectReason", "DefectReason") + .WithMany() + .HasForeignKey("DefectReasonId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ProductionRecord", "ProductionRecord") + .WithMany("Defects") + .HasForeignKey("ProductionRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DefectReason"); + + b.Navigation("ProductionRecord"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionPlan", b => + { + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "OutputLot") + .WithMany() + .HasForeignKey("OutputLotId"); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OutputLot"); + + b.Navigation("PerformedBy"); + + b.Navigation("Shift"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecordCorrection", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CorrectedBy") + .WithMany() + .HasForeignKey("CorrectedByUserId"); + + b.HasOne("MesApp.Core.Entities.ProductionRecord", "ProductionRecord") + .WithMany() + .HasForeignKey("ProductionRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CorrectedBy"); + + b.Navigation("ProductionRecord"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RefreshToken", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", "Checklist") + .WithMany() + .HasForeignKey("ChecklistId"); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId"); + + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.SkillMaster", "RequiredSkill") + .WithMany() + .HasForeignKey("RequiredSkillId"); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId"); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkProcedure", "WorkProcedure") + .WithMany() + .HasForeignKey("WorkProcedureId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Checklist"); + + b.Navigation("Equipment"); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("RequiredSkill"); + + b.Navigation("Tool"); + + b.Navigation("WorkCenter"); + + b.Navigation("WorkProcedure"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Routing", "Routing") + .WithMany("EquipmentCandidates") + .HasForeignKey("RoutingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Equipment"); + + b.Navigation("Routing"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SampleStorage", b => + { + b.HasOne("MesApp.Core.Entities.InspectionOrder", "InspectionOrder") + .WithMany() + .HasForeignKey("InspectionOrderId"); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "StorageLocation") + .WithMany() + .HasForeignKey("StorageLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("InspectionOrder"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("StorageLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SetupRecord", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PerformedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShipmentJudgment", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "JudgedBy") + .WithMany() + .HasForeignKey("JudgedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.ShippingOrder", "ShippingOrder") + .WithMany() + .HasForeignKey("ShippingOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("JudgedBy"); + + b.Navigation("Lot"); + + b.Navigation("ShippingOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingLine", b => + { + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ShippingOrder", null) + .WithMany("Lines") + .HasForeignKey("ShippingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.HasOne("MesApp.Core.Entities.Location", "TargetLocation") + .WithMany() + .HasForeignKey("TargetLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("TargetLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.StocktakeLine", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Stocktake", null) + .WithMany("Lines") + .HasForeignKey("StocktakeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolIssue", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "IssuedTo") + .WithMany() + .HasForeignKey("IssuedToUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IssuedTo"); + + b.Navigation("Tool"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolUsage", b => + { + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId"); + + b.Navigation("Tool"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TransferOrder", b => + { + b.HasOne("MesApp.Core.Entities.Location", "FromLocation") + .WithMany() + .HasForeignKey("FromLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "ToLocation") + .WithMany() + .HasForeignKey("ToLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("FromLocation"); + + b.Navigation("Lot"); + + b.Navigation("ToLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TroubleReport", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId"); + + b.HasOne("MesApp.Core.Entities.AppUser", "ReportedBy") + .WithMany() + .HasForeignKey("ReportedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId"); + + b.Navigation("Equipment"); + + b.Navigation("ReportedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.UserSkill", b => + { + b.HasOne("MesApp.Core.Entities.SkillMaster", "Skill") + .WithMany() + .HasForeignKey("SkillId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Skill"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkCenter", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "Parent") + .WithMany() + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "AssignedEquipment") + .WithMany() + .HasForeignKey("AssignedEquipmentId"); + + b.HasOne("MesApp.Core.Entities.AppUser", "AssignedUser") + .WithMany() + .HasForeignKey("AssignedUserId"); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ManufacturingOrder") + .WithMany("WorkOrders") + .HasForeignKey("ManufacturingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.SkillMaster", "RequiredSkill") + .WithMany() + .HasForeignKey("RequiredSkillId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Checklist", "RoutingChecklist") + .WithMany() + .HasForeignKey("RoutingChecklistId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkProcedure", "WorkProcedure") + .WithMany() + .HasForeignKey("WorkProcedureId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("AssignedEquipment"); + + b.Navigation("AssignedUser"); + + b.Navigation("ManufacturingOrder"); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("RequiredSkill"); + + b.Navigation("RoutingChecklist"); + + b.Navigation("WorkCenter"); + + b.Navigation("WorkProcedure"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderControlItem", b => + { + b.HasOne("MesApp.Core.Entities.ControlItem", "ControlItem") + .WithMany() + .HasForeignKey("ControlItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany("ControlItemSnapshots") + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ControlItem"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderStatusHistory", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "ChangedBy") + .WithMany() + .HasForeignKey("ChangedByUserId"); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChangedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkTimeRecord", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId"); + + b.Navigation("User"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Checklist", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.Navigation("Results"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.Navigation("Parts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.Navigation("Items"); + + b.Navigation("Results"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.Navigation("Records"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.Navigation("Parts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.Navigation("Materials"); + + b.Navigation("WorkOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.Navigation("Defects"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.Navigation("EquipmentCandidates"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingOrder", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.Navigation("ControlItemSnapshots"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/MesApp.Migrations.SqlServer/Migrations/20260923080830_WidenWorkOrderControlItems.cs b/src/MesApp.Migrations.SqlServer/Migrations/20260923080830_WidenWorkOrderControlItems.cs new file mode 100644 index 0000000..fceb2b9 --- /dev/null +++ b/src/MesApp.Migrations.SqlServer/Migrations/20260923080830_WidenWorkOrderControlItems.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MesApp.Migrations.SqlServer.Migrations +{ + /// + public partial class WidenWorkOrderControlItems : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ControlItems", + table: "WorkOrders", + type: "nvarchar(1000)", + maxLength: 1000, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(500)", + oldMaxLength: 500, + oldNullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ControlItems", + table: "WorkOrders", + type: "nvarchar(500)", + maxLength: 500, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(1000)", + oldMaxLength: 1000, + oldNullable: true); + } + } +} diff --git a/src/MesApp.Migrations.SqlServer/Migrations/MesAppDbContextModelSnapshot.cs b/src/MesApp.Migrations.SqlServer/Migrations/MesAppDbContextModelSnapshot.cs index d589440..157281c 100644 --- a/src/MesApp.Migrations.SqlServer/Migrations/MesAppDbContextModelSnapshot.cs +++ b/src/MesApp.Migrations.SqlServer/Migrations/MesAppDbContextModelSnapshot.cs @@ -3124,8 +3124,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("nvarchar(450)"); b.Property("ControlItems") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); b.Property("CreatedAt") .HasColumnType("datetimeoffset"); diff --git a/tests/MesApp.Api.Tests/ExecutionTests.cs b/tests/MesApp.Api.Tests/ExecutionTests.cs index c391e4d..a8a54af 100644 --- a/tests/MesApp.Api.Tests/ExecutionTests.cs +++ b/tests/MesApp.Api.Tests/ExecutionTests.cs @@ -728,6 +728,29 @@ public async Task 工順に候補設備があると差立はその中からし Assert.Equal(HttpStatusCode.OK, unrestricted.StatusCode); } + [Fact] + public async Task 工順に登録できる長さの工程管理項目はそのまま作業指示へ展開できる() + { + using var factory = new ApiFactory(); + using var admin = await TestAuth.CreateAdminClientAsync(factory); + + var product = await MasterTests.CreateProductAsync(admin, "FG-01", "完成品", ProductType.Product); + var process = await MasterTests.CreateProcessAsync(admin, "PR-01", "加工"); + + // 上限を超える記述は工順の登録で止める(展開まで持ち越すと実DBで保存に失敗する) + var tooLong = await admin.PutAsJsonAsync($"/api/products/{product.Id}/routing", + new List { new(1, process.Id, 30m, 10m, null, null, null, new string('あ', 1001), null) }); + Assert.Equal(HttpStatusCode.BadRequest, tooLong.StatusCode); + + // 上限いっぱいの記述は作業指示へ欠けずに写る(作業指示側の列が工順側より短いと展開に失敗していた) + var longest = new string('あ', 1000); + (await admin.PutAsJsonAsync($"/api/products/{product.Id}/routing", + new List { new(1, process.Id, 30m, 10m, null, null, null, longest, null) })) + .EnsureSuccessStatusCode(); + var order = await Phase3TestData.CreateReleasedOrderAsync(admin, product.Id, 10m); + Assert.Equal(longest, order.WorkOrders.Single().ControlItems); + } + private static async Task CreateEquipmentAsync( HttpClient admin, string assetNo, string name) { From f2e23106c8000668339339f6b4eca2e3c7d45bfd Mon Sep 17 00:00:00 2001 From: msmsrep <113223770+msmsrep@users.noreply.github.com> Date: Wed, 23 Sep 2026 17:28:49 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E5=B7=A5=E7=A8=8B=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=A0=85=E7=9B=AE=E3=82=92=E5=B7=A5=E9=A0=86=EF=BC=88BOP?= =?UTF-8?q?=EF=BC=89=E3=81=AE=E5=B7=A5=E7=A8=8B=E3=81=94=E3=81=A8=E3=81=AB?= =?UTF-8?q?=E7=B4=90=E4=BB=98=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 項目側の対象品目/対象工程に「または」で合致する項目を展開時に自動選択していたため、 品目を指定した項目がその品目の全工程の作業指示に載り、品目と工程の組合せや 同じ工程が2回ある工順の工程ごとの条件を表せなかった(I-30-20-10 とのずれ)。 - 工順の工程と工程管理項目の紐付け(RoutingControlItem)を追加し、展開はこの紐付けどおりに写す - ControlItem から対象品目・対象工程を削除(作業手順書と同じく紐付けは工順側だけに持つ) - 紐付けられるのは有効な項目だけ。紐付け中の項目は単票APIでもCSV取込でも無効化できない - CSV:工程管理項目から TargetProductCode・TargetProcessCode を外し、工順に ControlItemCodes を追加 - 工順画面に工程管理項目の複数選択を追加。自由記述は「補足」として残す - Spec.md 改訂124、サンプルCSV・利用者ガイド・CodeMap を更新 Co-Authored-By: Claude Opus 5.5 --- Spec.md | 13 +- docs-dev/CodeMap.md | 4 +- docs/masters.md | 3 +- samples/master-csv/13_control-items.csv | 10 +- samples/master-csv/17_routing.csv | 12 +- samples/master-csv/README.md | 6 +- .../Controllers/ControlItemsController.cs | 52 +- .../Controllers/ProductsController.cs | 7 +- src/MesApp.Api/Localization/ApiText.en.resx | 6 +- .../Policies/MasterDeactivationPolicy.cs | 11 + .../Policies/ProductStructurePolicy.cs | 7 + .../Services/ManufacturingOrderService.cs | 19 +- src/MesApp.Api/Services/MasterCsvKinds.cs | 7 +- .../Services/MasterCsvService.Import.cs | 53 +- src/MesApp.Api/Services/MasterCsvService.cs | 8 +- .../Services/ProductStructureService.cs | 6 + .../Pages/Masters/ControlItemsTab.razor | 40 +- .../Products/ProductRoutingEditor.razor | 57 +- src/MesApp.Client.Web/Shared/UiText.en.resx | 18 +- .../Contracts/Masters/MasterContracts.cs | 13 +- src/MesApp.Core/Entities/Masters.cs | 39 +- .../Configurations/MasterConfigurations.cs | 15 + src/MesApp.Infrastructure/MesAppDbContext.cs | 1 + ...1738_LinkControlItemsToRouting.Designer.cs | 4771 ++++++++++++++++ ...0260923081738_LinkControlItemsToRouting.cs | 118 + .../MesAppDbContextModelSnapshot.cs | 68 +- ...1741_LinkControlItemsToRouting.Designer.cs | 4970 +++++++++++++++++ ...0260923081741_LinkControlItemsToRouting.cs | 119 + .../MesAppDbContextModelSnapshot.cs | 70 +- ...1743_LinkControlItemsToRouting.Designer.cs | 4949 ++++++++++++++++ ...0260923081743_LinkControlItemsToRouting.cs | 118 + .../MesAppDbContextModelSnapshot.cs | 70 +- tests/MesApp.Api.Tests/ExecutionTests.cs | 30 +- tests/MesApp.Api.Tests/MasterCsvTests.cs | 32 +- tests/MesApp.Api.Tests/MasterTests.cs | 62 +- tests/MesApp.Api.Tests/ProductionTests.cs | 63 +- 36 files changed, 15551 insertions(+), 296 deletions(-) create mode 100644 src/MesApp.Infrastructure/Migrations/20260923081738_LinkControlItemsToRouting.Designer.cs create mode 100644 src/MesApp.Infrastructure/Migrations/20260923081738_LinkControlItemsToRouting.cs create mode 100644 src/MesApp.Migrations.PostgreSql/Migrations/20260923081741_LinkControlItemsToRouting.Designer.cs create mode 100644 src/MesApp.Migrations.PostgreSql/Migrations/20260923081741_LinkControlItemsToRouting.cs create mode 100644 src/MesApp.Migrations.SqlServer/Migrations/20260923081743_LinkControlItemsToRouting.Designer.cs create mode 100644 src/MesApp.Migrations.SqlServer/Migrations/20260923081743_LinkControlItemsToRouting.cs diff --git a/Spec.md b/Spec.md index 4cf2126..cd5262d 100644 --- a/Spec.md +++ b/Spec.md @@ -122,6 +122,7 @@ 改訂121: 2026-09-23(3.1節:MBOMの改訂(A-40-10-05 設計変更)の監査ログに変更前後の明細を残すようにした。これまでは `items=件数` だけで、一括置換のため何を変えたか追えなかった。明細は子品目をIDではなくコードで残す(品目を無効化・改名しても読めるように)。マスタCSV取込では種別ごとの取込ログに加えて親品目ごとに同じ形のログを書く(CSVが追跡の抜け道にならないように)。監査ログは書くたびに保存するため、取込の途中では書かず、全行の検証が通って保存した後にまとめて書く) 改訂122: 2026-09-23(5.7節「指図展開時のマスタ固定」に、予定材料の標準不良率による割り増しと消費工程の固定(改訂117・118)を追記した。あわせてマスタCSV・実績CSVの列の案内(`AlternativeGroup`・`IsAlternative`・`Backflush`)、サンプルの説明、利用者ガイド(帳票・用語・マスタのCSV・部材投入)を改訂117〜121に合わせた) 改訂123: 2026-09-23(工程管理項目の自由記述(`Routing.ControlItems`)の長さの上限を、工順・作業指示・API・マスタCSVで1000文字に揃えた。工順が1000文字、展開先の作業指示が500文字だったため、501文字以上を書いた工順は PostgreSQL / SQL Server で指図の展開に失敗していた(SQLiteは長さを守らせないため表に出なかった)。上限を超える記述は工順の登録で拒否する) +改訂124: 2026-09-23(工程管理項目を工順(BOP)の工程ごとに紐付けるようにした(`RoutingControlItem`。I-30-20-10)。これまでは項目側の対象品目/対象工程に「または」で合致する項目を展開時に自動選択していたため、品目を指定した項目がその品目の全工程の作業指示に載り、品目と工程の組合せや、同じ工程が2回ある工順の工程ごとの条件を表せなかった。改訂48の「工順に明示的な紐付けを持たせない」方針を改め、`ControlItem` から対象品目・対象工程を削除した(作業手順書と同じく紐付けは工順側だけに持つ)。紐付けられるのは有効な項目だけで、紐付け中の項目は単票APIでもCSV取込でも無効化できない(`MasterDeactivationPolicy`)。API は `RoutingStepRequest.ControlItemIds`、CSV は工程管理項目から `TargetProductCode`・`TargetProcessCode` を外し、工順に `ControlItemCodes`(セミコロン区切り)を追加。`Routing.ControlItems` の自由記述は補足として残す。5.1節・5.7節に反映) 参考: みんなのMES(min-MES) https://min-mes.com/ / OSS: https://github.com/mihatama/open-mes-project --- @@ -408,14 +409,15 @@ DBはバックエンド(MesApp.Api)のみが保持し、既定はSQLiteと | Product(品目マスタ) | 品目コード、品目名、単位、規格、品目区分(製品/半製品・中間品/部材)、標準不良率(0〜99.99%。指図の予定材料を割り増す。A-40-10-04)、**既定ロケーション**(推奨ロケーション指示の第一候補。D-10-30-03) | | BomItem(MBOM明細) | 親品目ID、子品目ID(部材)、必要数量(親1単位あたり)、内外製区分、代替部品グループ、**代替部品フラグ**(同一グループ内の主材料でない行。A-40-10)、**消費工程**(工順の工程順序。未指定なら最終工程。B-40-10-09)。品目自身を子品目にする行と、明細をたどって親品目へ戻る循環は登録できない(単票API・CSVで同じ判定。`ProductStructurePolicy.FindBomCycle`)。代替部品グループは主材料(代替部品フラグの無い行)をちょうど1つ持ち、代替部品フラグの行はグループを必須とする(`CheckAlternativeGroups`。グループ名は前後の空白を除いて保存・比較) | | Process(工程マスタ) | 工程コード、工程名、工程区分(内製/外注) | -| Routing(工順/BOP) | 品目ID、工程順序、工程ID、標準作業時間(**1個あたり**)、標準段取り時間(**1回あたり**)、必要スキルID、**候補設備**・治工具、**作業区**、工程管理項目、チェックリストID、**作業手順書ID**(A-40-20、I-30-20)
標準時間の予実(3.2節 B-60-10-05)は 段取り時間+作業時間×数量 で予定を出す | +| Routing(工順/BOP) | 品目ID、工程順序、工程ID、標準作業時間(**1個あたり**)、標準段取り時間(**1回あたり**)、必要スキルID、**候補設備**・治工具、**作業区**、**工程管理項目(紐付け)**と補足(自由記述)、チェックリストID、**作業手順書ID**(A-40-20、I-30-20)
標準時間の予実(3.2節 B-60-10-05)は 段取り時間+作業時間×数量 で予定を出す | | RoutingEquipment(工順の候補設備) | 工順ID、設備ID(同一工順で一意)。同じ工程を複数の装置で実行できる場合に列挙し、差立ではこの中から1台を選ぶ(B-10-20-02) | +| RoutingControlItem(工順の工程管理項目) | 工順ID、工程管理項目ID(同一工順で一意)。その工程で記録する製造条件を指す。指図展開時にこの紐付けどおり作業指示へ指示値を写す(I-30-20-10、B-30-30-04) | | WorkCenter(作業区/資源階層) | 作業区コード、名称、段(工場/ライン/エリア/作業区)、上位の資源、有効フラグ。工場・ライン・エリア・作業区を1つの自己参照ツリーで持ち、資源構成全体(BOR)を表す。最下段の作業区が作業の管理単位(I-10-20-02) | | Equipment(設備台帳/BOE) | 資産番号、設備名、**設置場所(作業区)**、状態(稼働可能/停止中/保全中/廃棄・除却。差立は稼働可能のみ)、保全タイプ(カレンダ/時間/回数ベース)、保全閾値、**保全部品(`EquipmentPart`)**(E-10-10、I-10-20)。`MaintenanceParts`(自由記述の保全部品)と`Site`(自由記述の設置場所)は作業区を整備するまでの旧項目として残すが、**設置場所の正は作業区参照**とする | | EquipmentPart(設備の保全部品) | 設備ID、部品の品目ID(同一設備で一意)、管理区分(資産管理部品/消耗品)、1回あたり数量、備考。自由記述では消耗材の使用状況(E-20-10-04)を集計できないため品目マスタを参照する(E-10-10-01) | | Tool(治工具マスタ) | 治工具コード、名称、種別(型/切削工具/検査工具等)、寿命閾値(使用回数/時間)、状態(使用可能/使用中/メンテナンス中/廃棄。**使用中は引当(`ToolIssue`)から決まり、マスタ編集・CSV取込では付けも外しもできない**。引当中の治工具は使用可能にできず、メンテナンス中・廃棄への変更はできる)(E-60) | | Location(ロケーション) | ロケーションコード、倉庫/エリア区分(部材倉庫/工程内/製品倉庫/出荷場)、**所属する作業区**、棚番(D-50-20-01) | -| ControlItem(工程管理項目) | 工程管理項目コード、名称、単位、対象品目/工程、**指示値**、許容下限/上限、版数、有効フラグ。温度・回転数など製造時に記録すべき条件の定義(B-30-30-04)。検査項目と同じ形にしているのは、「指示値と実績値」の関係が「検査パラメータと検査結果」と同じ構造で、判定の考え方も揃うため | +| ControlItem(工程管理項目) | 工程管理項目コード、名称、単位、**指示値**、許容下限/上限、版数、有効フラグ。対象品目・対象工程は持たず、工順(BOP)の工程から紐付ける(`RoutingControlItem`)。温度・回転数など製造時に記録すべき条件の定義(B-30-30-04)。検査項目と同じ形にしているのは、「指示値と実績値」の関係が「検査パラメータと検査結果」と同じ構造で、判定の考え方も揃うため | | InspectionItem(検査項目・基準) | 検査項目コード、対象品目/工程、検査種別(受入/工程内/完成品/サンプル)、規格値(上限/下限/基準値)、検査方法、サンプリング数、版数(C-10-10) | | InspectionDevice(検査機・測定器) | 検査機コード、名称、製造番号、設置場所、最終校正日、**次回校正期限**、校正周期(日)、備考、状態(C-20-50-03)。校正期限切れ・無効化された機器は検査実績に使えない | | InspectionDeviceCalibration(校正実施記録) | 検査機ID、校正日、次回期限、結果・所見、実施者(C-20-50-03)。現在値の上書きだけでは「いつ誰がどの結果で校正したか」が残らないため履歴に残す | @@ -512,12 +514,15 @@ DBはバックエンド(MesApp.Api)のみが保持し、既定はSQLiteと - **製造条件の指示値と実績値**:製造条件(温度・回転数など)は「こう作れ」という**指示値**と「実際はこうだった」という**実績値**の対になる。指示値と許容範囲を持たないと、実績を記録しても逸脱かどうかを判定できない - 条件の定義と指示値・許容範囲は`ControlItem`(工程管理項目)に持つ。**検査項目(`InspectionItem`)と同じ形**にする:指示値と実績値の関係は検査パラメータと検査結果と同じ構造であり、判定・版管理・スナップショットの考え方をそのまま適用できるため - **指示値は許容範囲の内側であることを登録時に確認する**。範囲外を許すと、指示どおりに作った実績が逸脱と判定されてしまう - - **工順に明示的な紐付けは持たせない**。検査基準と同じく**対象品目/工程に合致する有効な項目を指図展開時に自動選択**し、`WorkOrderControlItem`へ写す。工順側に選択リストを持たせると、品目にも工程にも当たる条件をどちらに登録するかで運用が割れるため + - **どの工程で記録するかは工順(BOP)の工程ごとに紐付ける**(`RoutingControlItem`。I-30-20-10「BOPに登録された作業に工程管理条件を定義する」)。指図展開時は紐付けどおりに`WorkOrderControlItem`へ写す + - 項目側に対象品目・対象工程を持たせて自動で選ぶ方式(改訂48)はやめた。品目を指定した項目がその品目の**全工程**の作業指示に載り、「品目Xの加熱工程だけ」を表せず、**同じ工程が2回ある工順**では工程ごとに条件を変えられなかったため + - 項目側には対象を持たせない(作業手順書と同じ。両側に持たせるとどちらで紐付けたかで運用が割れる)。品目ごとに指示値が違う条件は、品目ごとに別の項目として登録する + - 紐付けられるのは有効な項目だけで、**紐付け中の項目は無効化できない**(`MasterDeactivationPolicy`。単票APIとCSV取込の両方で同じ条件)。無効化を許すと、使わせないはずの条件が以降の作業指示へ写り続ける - スナップショットを取る理由は検査基準(下記)と同じ。**マスタを改訂しても展開済みの作業指示の指示値・許容範囲・版数は変わらない** - **実績は指示と照合して逸脱を判定する**。判定は1か所(`Api/Policies/ControlItemDeviationPolicy`)に集約し、基準はマスタの現在値ではなく作業指示のスナップショットを使う(現在値で判定すると同じ実績の合否が後から変わる) - **判定しない場合を「範囲内」と混同しない**。数値でない記録(定性的な記録)と、上下限をどちらも持たない項目(記録だけが目的の条件)は判定対象外とし、逸脱フラグはnullのままにする。falseにすると、条件を決めていない項目まで合格扱いになる - 逸脱は監査ログの`detail`にも内容を残し、ロットの履歴(H-30-10-04)では**逸脱した記録だけ**を出す(範囲内まで並べると見るべきものが埋もれる) - - `Routing.ControlItems`(自由記述)は**当面残す**。既存データの表示経路であり、工程管理項目マスタを整備していない運用では唯一の記録手段になる。マスタへ移行し終えた運用で不要になった時点で削除を判断する + - `Routing.ControlItems`(自由記述)は**工程管理項目の補足**として残す。指示値を持たない確認事項や外注の内容など、工程管理項目にもチェックリストにも当てはまらない記述の置き場になる。作業指示へはそのまま写す(上限1000文字) - **製造品軸と設備軸の紐付け(2軸データ)**:製造の実績は「どのロットをどう作ったか」(製造品軸)と「そのとき設備はどうだったか」(設備軸)の2つの軸で残り、**両者の交差点**が品質不良の原因究明に効く。交差点を作るのは`EquipmentLog.対象作業指示ID`だけなので、これを欠かすと設備の状態を時刻の重なりから推測するしかなくなる - 稼働報告(B-40-20-01)では作業指示を**任意**で指定する。段取り・保全・アイドルのように作業指示に紐づかない稼働区間もあるため必須にはしない - ロットの履歴(H-30-10-04)は、そのロットを産出した作業指示に紐づく稼働区間を**設備稼働履歴**として返す。紐付けのない稼働は履歴に出ない(出すと別のロットの設備状態を混ぜて見せることになる) diff --git a/docs-dev/CodeMap.md b/docs-dev/CodeMap.md index aeb6db1..e0a63eb 100644 --- a/docs-dev/CodeMap.md +++ b/docs-dev/CodeMap.md @@ -44,7 +44,7 @@ | 業務 | MES No | API | エンティティ | 画面 | テスト | |:--|:--|:--|:--|:--|:--| -| 工程管理項目マスタ(指示値・許容範囲。版数付き) | B-30-30-04 | `ControlItemsController.cs` `api/control-items`
展開時のスナップショット取得は `WorkOrdersController.ControlItems` `api/work-orders/{id}/control-items` | Masters.cs: ControlItem
Production.cs: **WorkOrderControlItem**(展開時点の指示値。判定・表示はこちらを使い、マスタ現在値を参照しない) | `/masters` `Masters/ControlItemsTab.razor` | `Tests/MasterTests.cs` / `MasterCsvTests.cs` | +| 工程管理項目マスタ(指示値・許容範囲。版数付き) | B-30-30-04 | `ControlItemsController.cs` `api/control-items`
展開時のスナップショット取得は `WorkOrdersController.ControlItems` `api/work-orders/{id}/control-items` | Masters.cs: ControlItem(対象品目・工程は持たない)/ **RoutingControlItem**(工順の工程への紐付け。展開はこの紐付けどおり。紐付け中は無効化できない:`MasterDeactivationPolicy`)
Production.cs: **WorkOrderControlItem**(展開時点の指示値。判定・表示はこちらを使い、マスタ現在値を参照しない) | `/masters` `Masters/ControlItemsTab.razor`
工順への紐付けは `Masters/Products/ProductRoutingEditor.razor` | `Tests/MasterTests.cs` / `MasterCsvTests.cs` / `ProductionTests.cs` | | 検査機・測定器マスタ/校正管理 | C-20-50-03 | `InspectionDevicesController.cs` `api/inspection-devices`
校正の記録は `POST {id}/calibrations`(次回期限は校正周期から自動)/期限接近は `GET expiring?withinDays=` | Masters.cs: InspectionDevice(現在の校正状態)/InspectionDeviceCalibration(実施履歴) | `/masters` `Masters/InspectionDevicesTab.razor` | `Tests/MasterTests.cs` / `MasterCsvTests.cs` | | 検査項目・基準マスタ | C-10-10 | `InspectionItemsController.cs` `api/inspection-items` | Masters.cs: InspectionItem | `/masters` `Masters/InspectionItemsTab.razor` | `Tests/MasterTests.cs` | | 検査指示・実績・判定・成績書 | C-20 | `InspectionOrdersController.cs` `api/inspection-orders`(発行・実績・判定の処理は `Api/Services/InspectionService.cs`。実績登録時に**検査機の校正期限を判定**:`InspectionDeviceCalibrationPolicy`) | `Core/Entities/Quality.cs`
InspectionOrder / InspectionOrderItem(**発行時点の基準スナップショット**。判定・成績書はこちらを使い、マスタ現在値を参照しない:Spec.md 5.7) / InspectionResult / **InspectionResultCorrection**(訂正前の記録。詳細画面・成績書に表示) | `/inspections` `Inspections.razor`
`/inspections/{id}` `InspectionDetail.razor`
`/print/inspection/{id}` `Print/InspectionCertificate.razor` | `Tests/QualityTests.cs` | @@ -119,7 +119,7 @@ | ロット使用可否(投入・引当・出荷の共通判定) | `Api/Policies/LotUsabilityPolicy.cs` | Spec.md 3.9。ステータス・有効期限の条件は**ここだけ**に置く。呼び先は `WorkOrderExecutionService.AddConsumptionAsync`(投入)/`InventoryService.AllocateFefoAsync`(FEFO)/`ShippingService.ShipAsync`(出荷) | | 製造条件の逸脱判定 | `Api/Policies/ControlItemDeviationPolicy.cs` | Spec.md 5.7。基準は**マスタ現在値ではなく作業指示のスナップショット**(`WorkOrderControlItem`)。数値なし・上下限なしは判定せず`null`のまま(`false`にしない)。呼び先は `WorkOrderExecutionService.AddDataRecordsAsync` | | 直(シフト)の時間帯判定 | `Api/Policies/ShiftSchedulePolicy.cs` | Spec.md 5.7。日跨ぎ(`EndTime <= StartTime`)・重なり判定・時刻→直の解決・**製造日の境界またぎの警告**(`CheckBusinessDateBoundary`。拒否ではなく `ShiftResponse.BoundaryWarning` で返す)。単票APIとCSV取込の両方から通す。重なり判定は**0時で切って区間に開いてから突き合わせる**(開始・終了の大小比較だと 22:00〜06:00 と 05:00〜09:00 の重なりを見落とす)。判定の単体テストは `Tests/ShiftSchedulePolicyTests.cs`(1440分の総当たりを期待値にした網羅テストで等価性を固定) | -| 工順・品目から参照できるマスタ | `Api/Policies/ProductStructurePolicy.cs` | Spec.md 5.7。工順の作業区(最下段かつ有効)・作業手順書(有効)・品目の既定ロケーション(有効)・候補設備(代表設備を含める)・**MBOMの循環(`FindBomCycle`)と代替部品グループの整合(`CheckAlternativeGroups`)**。呼び先は `ProductStructureService` / `ProductsController` と `MasterCsvService.Import` の `ImportProductsAsync`・`ImportRoutingAsync`・`ImportBomAsync`。`Tests/MasterTests.cs` / `MasterCsvTests.cs` | +| 工順・品目から参照できるマスタ | `Api/Policies/ProductStructurePolicy.cs` | Spec.md 5.7。工順の作業区(最下段かつ有効)・作業手順書(有効)・工程管理項目(有効)・品目の既定ロケーション(有効)・候補設備(代表設備を含める)・**MBOMの循環(`FindBomCycle`)と代替部品グループの整合(`CheckAlternativeGroups`)**。呼び先は `ProductStructureService` / `ProductsController` と `MasterCsvService.Import` の `ImportProductsAsync`・`ImportRoutingAsync`・`ImportBomAsync`。`Tests/MasterTests.cs` / `MasterCsvTests.cs` | | 部材投入の照合(予定材料) | `Api/Policies/MaterialIssuePolicy.cs` | Spec.md 3.9・5.7。基準はMBOMの現在値ではなく**指図の予定材料**。呼び先は `WorkOrderExecutionService.AddConsumptionAsync` | | 作業指示ステータス変更(+状態履歴) | `Api/Services/WorkOrderStatusService.cs`
`Core/Entities/Production.cs`: WorkOrderStatusHistory | Spec.md 5.2。`WorkOrder.Status` を**直接代入しない**。履歴は `GET api/work-orders/{id}/status-history` | | システム管理者を失わない | `Api/Policies/LastAdminPolicy.cs` | Spec.md 3.6。有効なシステム管理者が0人になる無効化・降格を拒否する。呼び先は `UsersController.Update`(1件ずつ判定)/`MasterCsvService.Import.ImportUsersAsync`(**全行の適用後**に判定。行順で引き継ぎを弾かないため)。`Tests/MasterTests.cs` / `MasterCsvTests.cs` | diff --git a/docs/masters.md b/docs/masters.md index 74aad8f..d8a0c88 100644 --- a/docs/masters.md +++ b/docs/masters.md @@ -112,7 +112,8 @@ MBOMは、実績入力の**バックフラッシュ**(部材の自動消費) | 必要スキル・資格 | 差立時に作業者の資格を照合します | | 使用設備 / 使用治工具 | 既定の設備・治工具 | | チェックリスト | この工程で実施するチェックリスト | -| 工程管理項目 | 温度、回転数など記録すべき条件のメモ | +| 工程管理項目 | この工程で記録する製造条件(温度・回転数など)を、工程管理項目マスタから複数選択します。展開した作業指示に指示値と許容範囲が写り、実績と照合されます | +| 工程管理項目の補足 | 指示値の無い確認事項などのメモ | **工程を追加** で行を積み上げ、**工順を保存(一括置換)** で確定します。MBOMと同様に一括置換です。 diff --git a/samples/master-csv/13_control-items.csv b/samples/master-csv/13_control-items.csv index c2bb651..a4f7475 100644 --- a/samples/master-csv/13_control-items.csv +++ b/samples/master-csv/13_control-items.csv @@ -1,5 +1,5 @@ -Code,Name,Unit,TargetProductCode,TargetProcessCode,TargetValue,LowerLimit,UpperLimit,IsActive -CI-01,主軸回転数,rpm,SF-2000,PR-10,8000,7600,8400,true -CI-02,送り速度,mm/min,SF-2000,PR-10,1200,1100,1300,true -CI-03,締付トルク,N・m,FG-1000,PR-30,10,9,11,true -CI-04,試験圧力,MPa,FG-1000,PR-40,0.5,0.48,0.52,true +Code,Name,Unit,TargetValue,LowerLimit,UpperLimit,IsActive +CI-01,主軸回転数,rpm,8000,7600,8400,true +CI-02,送り速度,mm/min,1200,1100,1300,true +CI-03,締付トルク,N・m,10,9,11,true +CI-04,試験圧力,MPa,0.5,0.48,0.52,true diff --git a/samples/master-csv/17_routing.csv b/samples/master-csv/17_routing.csv index 67d672e..6bec392 100644 --- a/samples/master-csv/17_routing.csv +++ b/samples/master-csv/17_routing.csv @@ -1,6 +1,6 @@ -ProductCode,Sequence,ProcessCode,StandardWorkMinutes,StandardSetupMinutes,RequiredSkillCode,EquipmentAssetNo,EquipmentAssetNos,ToolCode,WorkCenterCode,ChecklistCode,ControlItems,WorkProcedureNo -SF-2000,10,PR-10,25,15,SK-01,EQ-01,EQ-01;EQ-05,TL-01,WC-MC1,CL-01,"主軸回転数, 送り速度",SOP-MC-001 -SF-2000,20,PR-20,0,0,,,,,,,外注(アルマイト処理), -FG-1000,10,PR-30,30,10,SK-04,EQ-02,,TL-02,WC-AS1,CL-02,締付トルク,SOP-AS-001 -FG-1000,20,PR-40,15,5,SK-03,EQ-03,,TL-03,WC-QC1,,試験圧力, -FG-1000,30,PR-50,10,5,,EQ-04,,,WC-PK1,CL-03,, +ProductCode,Sequence,ProcessCode,StandardWorkMinutes,StandardSetupMinutes,RequiredSkillCode,EquipmentAssetNo,EquipmentAssetNos,ToolCode,WorkCenterCode,ChecklistCode,ControlItems,ControlItemCodes,WorkProcedureNo +SF-2000,10,PR-10,25,15,SK-01,EQ-01,EQ-01;EQ-05,TL-01,WC-MC1,CL-01,,CI-01;CI-02,SOP-MC-001 +SF-2000,20,PR-20,0,0,,,,,,,外注(アルマイト処理),, +FG-1000,10,PR-30,30,10,SK-04,EQ-02,,TL-02,WC-AS1,CL-02,,CI-03,SOP-AS-001 +FG-1000,20,PR-40,15,5,SK-03,EQ-03,,TL-03,WC-QC1,,吐出音に異音が無いこと,CI-04, +FG-1000,30,PR-50,10,5,,EQ-04,,,WC-PK1,CL-03,,, diff --git a/samples/master-csv/README.md b/samples/master-csv/README.md index d84b836..a4b2a4d 100644 --- a/samples/master-csv/README.md +++ b/samples/master-csv/README.md @@ -36,11 +36,11 @@ RM-3001 ハウジング鋳造品 | 10 | `10_checklists.csv` | チェックリスト | 同じコードの複数行が1つのチェックリストになる例 | | 11 | `11_defect-reasons.csv` | 不良理由 | 材質・加工・設備・人的要因・その他 | | 12 | `12_inspection-items.csv` | 検査項目・基準 | 規格値あり/なし、受入・工程内・完成品・サンプル検査 | -| 13 | `13_control-items.csv` | 工程管理項目 | 指示値と許容範囲(製造条件の逸脱判定に使う) | +| 13 | `13_control-items.csv` | 工程管理項目 | 指示値と許容範囲(製造条件の逸脱判定に使う)。どの工程で記録するかは `17_routing.csv` の `ControlItemCodes` で紐付ける | | 14 | `14_inspection-devices.csv` | 検査機・測定器 | 校正期限切れの機器を1台含む(システム管理者のみ取込可) | | 15 | `15_bom.csv` | 品目・MBOM・工順 | FG-1000 と SF-2000 のMBOM。Oリングに代替部品あり。部材はどれも最初の工程(工程10)で消費する | | 16 | `16_work-procedures.csv` | 作業手順書 | 手順を本文に書く例と、所在だけを書く例(システム管理者のみ取込可) | -| 17 | `17_routing.csv` | 品目・MBOM・工順 | 候補設備・作業区・治工具・スキル・チェックリスト・手順書を紐づけた工順 | +| 17 | `17_routing.csv` | 品目・MBOM・工順 | 候補設備・作業区・治工具・スキル・チェックリスト・工程管理項目・手順書を紐づけた工順 | | 18 | `18_users.csv` | ユーザー | 各ロールの担当者。作業場所・所属・直つき(システム管理者のみ取込可) | | 19 | `19_user-skills.csv` | ユーザー | ユーザーへのスキル・資格の割当(システム管理者のみ取込可) | @@ -59,7 +59,7 @@ RM-3001 ハウジング鋳造品 - **明細は同じキーの行をまとめる**(`08_equipment-parts.csv` は設備単位、`10_checklists.csv` はコード単位、 `15_bom.csv` は親品目単位、`17_routing.csv` は品目単位。取込時はその明細を丸ごと置き換えます) - **他のマスタはコードで参照する**(`17_routing.csv` の `ProcessCode` / `EquipmentAssetNo` など) -- **複数の値はセミコロンで区切る**(`17_routing.csv` の `EquipmentAssetNos`、`18_users.csv` の `Roles`) +- **複数の値はセミコロンで区切る**(`17_routing.csv` の `EquipmentAssetNos`・`ControlItemCodes`、`18_users.csv` の `Roles`) - **設備と工順の作業区は最下段(作業区)だけ**を指定できる。ロケーションとユーザーは工場・エリアなど、どの段でもよい - **工程順序は 10, 20, 30 のように間隔を空けておく**と、後から工程を差し込みやすくなります diff --git a/src/MesApp.Api/Controllers/ControlItemsController.cs b/src/MesApp.Api/Controllers/ControlItemsController.cs index 8cda990..2b00dad 100644 --- a/src/MesApp.Api/Controllers/ControlItemsController.cs +++ b/src/MesApp.Api/Controllers/ControlItemsController.cs @@ -1,4 +1,5 @@ using MesApp.Api.Localization; +using MesApp.Api.Policies; using MesApp.Core.Abstractions; using MesApp.Core.Contracts.Masters; using MesApp.Core.Entities; @@ -13,6 +14,7 @@ namespace MesApp.Api.Controllers; /// 工程管理項目マスタ(Spec.md 5.1 ControlItem。B-30-30-04)。 /// 温度・回転数など製造時に記録すべき条件の定義と指示値・上下限を持つ。 /// 条件の改訂では版数を自動インクリメントする(検査項目 C-10-10-03 と同じ扱い)。 +/// どの工程で記録するかは工順(BOP)側で紐付ける(I-30-20-10。)。 /// [ApiController] [Route("api/control-items")] @@ -22,8 +24,6 @@ public class ControlItemsController(MesAppDbContext db, IAuditLogger auditLogger [HttpGet] public async Task>> List( [FromQuery] bool includeInactive = false, - [FromQuery] int? targetProductId = null, - [FromQuery] int? targetProcessId = null, CancellationToken ct = default) { var query = BaseQuery(); @@ -31,14 +31,6 @@ public async Task>> List( { query = query.Where(i => i.IsActive); } - if (targetProductId is not null) - { - query = query.Where(i => i.TargetProductId == targetProductId); - } - if (targetProcessId is not null) - { - query = query.Where(i => i.TargetProcessId == targetProcessId); - } return await query.OrderBy(i => i.Code).Select(i => ToResponse(i)).ToListAsync(ct); } @@ -57,7 +49,7 @@ public async Task> Create(ControlItemRequest r { return this.ConflictProblem(ApiText.T("工程管理項目コード '{0}' は既に存在します。", request.Code)); } - if (await ValidateAsync(request, ct) is { } error) + if (Validate(request) is { } error) { return this.BadRequestProblem(error); } @@ -67,8 +59,6 @@ public async Task> Create(ControlItemRequest r Code = request.Code, Name = request.Name, Unit = request.Unit, - TargetProductId = request.TargetProductId, - TargetProcessId = request.TargetProcessId, TargetValue = request.TargetValue, LowerLimit = request.LowerLimit, UpperLimit = request.UpperLimit, @@ -94,7 +84,7 @@ public async Task> Update( { return this.ConflictProblem(ApiText.T("工程管理項目コード '{0}' は既に存在します。", request.Code)); } - if (await ValidateAsync(request, ct) is { } error) + if (Validate(request) is { } error) { return this.BadRequestProblem(error); } @@ -102,8 +92,6 @@ public async Task> Update( item.Code = request.Code; item.Name = request.Name; item.Unit = request.Unit; - item.TargetProductId = request.TargetProductId; - item.TargetProcessId = request.TargetProcessId; item.TargetValue = request.TargetValue; item.LowerLimit = request.LowerLimit; item.UpperLimit = request.UpperLimit; @@ -117,10 +105,19 @@ await auditLogger.LogAsync("Master", "Update", nameof(ControlItem), id.ToString( [HttpDelete("{id:int}")] [Authorize(Roles = MesRoleGroups.MasterWrite)] public Task Deactivate(int id, CancellationToken ct) => - this.DeactivateMasterAsync(db, auditLogger, id, item => $"code={item.Code}", ct); + this.DeactivateMasterAsync(db, auditLogger, id, item => $"code={item.Code}", ct, + // 工順から紐付けている項目を無効化すると、展開した作業指示に改訂されない指示値が載り続ける。 + // 判定は MasterDeactivationPolicy に置き、CSV取込と同じ条件・同じ文面で弾く + precheck: async item => MasterDeactivationPolicy.CheckControlItem( + item.Code, + await db.RoutingControlItems.AsNoTracking() + .Where(l => l.ControlItemId == id) + .Select(l => l.Routing!.Product!.Code) + .Distinct() + .ToListAsync(ct))); - /// 上下限の整合と参照先の存在を確認する。問題があれば日本語の理由を返す - private async Task ValidateAsync(ControlItemRequest request, CancellationToken ct) + /// 上下限と指示値の整合を確認する。問題があれば日本語の理由を返す + private static string? Validate(ControlItemRequest request) { if (request.LowerLimit is { } lower && request.UpperLimit is { } upper && lower > upper) { @@ -138,23 +135,10 @@ public Task Deactivate(int id, CancellationToken ct) => return ApiText.T("指示値が許容上限を超えています。"); } } - if (request.TargetProductId is { } productId - && !await db.Products.AnyAsync(p => p.Id == productId, ct)) - { - return ApiText.T("対象品目(ID {0})が見つかりません。", productId); - } - if (request.TargetProcessId is { } processId - && !await db.Processes.AnyAsync(p => p.Id == processId, ct)) - { - return ApiText.T("対象工程(ID {0})が見つかりません。", processId); - } return null; } - private IQueryable BaseQuery() => - db.ControlItems.AsNoTracking() - .Include(i => i.TargetProduct) - .Include(i => i.TargetProcess); + private IQueryable BaseQuery() => db.ControlItems.AsNoTracking(); private async Task GetResponseAsync(int id, CancellationToken ct) { @@ -164,7 +148,5 @@ private IQueryable BaseQuery() => private static ControlItemResponse ToResponse(ControlItem i) => new(i.Id, i.Code, i.Name, i.Unit, - i.TargetProductId, i.TargetProduct?.Code, - i.TargetProcessId, i.TargetProcess?.Code, i.TargetValue, i.LowerLimit, i.UpperLimit, i.Version, i.IsActive); } diff --git a/src/MesApp.Api/Controllers/ProductsController.cs b/src/MesApp.Api/Controllers/ProductsController.cs index fb708f5..bc4a704 100644 --- a/src/MesApp.Api/Controllers/ProductsController.cs +++ b/src/MesApp.Api/Controllers/ProductsController.cs @@ -180,6 +180,7 @@ public async Task>> GetRouting(int id, Ca return await db.Routings.AsNoTracking() .Include(r => r.EquipmentCandidates).ThenInclude(c => c.Equipment) .Include(r => r.WorkProcedure) + .Include(r => r.ControlItemLinks).ThenInclude(l => l.ControlItem) .Where(r => r.ProductId == id) .OrderBy(r => r.Sequence) .Select(r => new RoutingStepResponse( @@ -195,7 +196,11 @@ public async Task>> GetRouting(int id, Ca .Select(c => c.EquipmentId).ToList(), r.WorkProcedureId, r.WorkProcedure != null ? r.WorkProcedure.ProcedureNo : null, - r.WorkProcedure != null ? r.WorkProcedure.Title : null)) + r.WorkProcedure != null ? r.WorkProcedure.Title : null, + r.ControlItemLinks.OrderBy(l => l.ControlItem!.Code) + .Select(l => l.ControlItemId).ToList(), + r.ControlItemLinks.OrderBy(l => l.ControlItem!.Code) + .Select(l => l.ControlItem!.Code).ToList())) .ToListAsync(ct); } diff --git a/src/MesApp.Api/Localization/ApiText.en.resx b/src/MesApp.Api/Localization/ApiText.en.resx index 73ff611..aed7dcb 100644 --- a/src/MesApp.Api/Localization/ApiText.en.resx +++ b/src/MesApp.Api/Localization/ApiText.en.resx @@ -900,9 +900,6 @@ Process sequence {1} of item '{0}' is duplicated. - - Candidate equipment '{0}' is not registered (EquipmentAssetNos). - StartTime (start time) and EndTime (end time) must be in HH:mm format. @@ -2016,4 +2013,7 @@ Exactly one primary material (IsAlternative=false) per group + + Control item '{0}' cannot be deactivated because it is linked from the routing of item {1}. + diff --git a/src/MesApp.Api/Policies/MasterDeactivationPolicy.cs b/src/MesApp.Api/Policies/MasterDeactivationPolicy.cs index 161e9a1..ab6b08a 100644 --- a/src/MesApp.Api/Policies/MasterDeactivationPolicy.cs +++ b/src/MesApp.Api/Policies/MasterDeactivationPolicy.cs @@ -24,6 +24,17 @@ public static class MasterDeactivationPolicy ? null : ApiText.T("手順書 '{0}' は品目 {1} の工順から参照されているため無効化できません。", procedureNo, string.Join("、", referencingProductCodes)); + /// + /// 工程管理項目(B-30-30-04)。工順から紐付けている項目を無効化すると、 + /// 以降に展開する作業指示へ「使わせないはずの条件」が載り続ける(展開時は紐付けどおりに写すため)。 + /// + /// その項目を紐付けている工順の品目コード(重複なし) + public static string? CheckControlItem( + string code, IReadOnlyCollection referencingProductCodes) => + referencingProductCodes.Count == 0 + ? null + : ApiText.T("工程管理項目 '{0}' は品目 {1} の工順から紐付けられているため無効化できません。", code, string.Join("、", referencingProductCodes)); + /// /// 勤務シフト(F-10-10-01)。所属する直として使われている間に無効化すると、従業員の所属が宙に浮く。 /// diff --git a/src/MesApp.Api/Policies/ProductStructurePolicy.cs b/src/MesApp.Api/Policies/ProductStructurePolicy.cs index 9e5e843..1fe8327 100644 --- a/src/MesApp.Api/Policies/ProductStructurePolicy.cs +++ b/src/MesApp.Api/Policies/ProductStructurePolicy.cs @@ -24,6 +24,13 @@ public static IQueryable AssignableWorkCenters(IQueryable AssignableWorkProcedures(IQueryable source) => source.Where(p => p.IsActive); + /// + /// 工順に紐付けられる工程管理項目。無効な項目を紐付けると、使わせないはずの条件が作業指示に載る + /// (紐付け中の無効化は で止める) + /// + public static IQueryable AssignableControlItems(IQueryable source) => + source.Where(i => i.IsActive); + /// 品目の既定ロケーションに指定できるロケーション。無効なロケーションは推奨に出せないため弾く public static IQueryable AssignableDefaultLocations(IQueryable source) => source.Where(l => l.IsActive); diff --git a/src/MesApp.Api/Services/ManufacturingOrderService.cs b/src/MesApp.Api/Services/ManufacturingOrderService.cs index d0d07e6..7c9d10e 100644 --- a/src/MesApp.Api/Services/ManufacturingOrderService.cs +++ b/src/MesApp.Api/Services/ManufacturingOrderService.cs @@ -205,6 +205,7 @@ public async Task ExpandAsync(ManufacturingOrder order, string? lo var routing = await db.Routings .Include(r => r.WorkProcedure) + .Include(r => r.ControlItemLinks).ThenInclude(l => l.ControlItem) .Where(r => r.ProductId == order.ProductId) .OrderBy(r => r.Sequence) .ToListAsync(ct); @@ -251,14 +252,8 @@ public async Task ExpandAsync(ManufacturingOrder order, string? lo // 工順(BOP)は展開時点の値を作業指示へ写して固定する(Spec.md 5.7)。 // 以降に工順が改訂されても、この指図の標準時間・必要スキル・管理項目は変わらない - // 工程管理項目も同じ理由で展開時点の値を写す(B-30-30-04)。検査基準のスナップショットと同じ方針で、 - // 対象品目/工程に合致する有効な項目を自動選択する(工順に明示的な紐付けを持たせない) - var controlItems = await db.ControlItems.AsNoTracking() - .Where(i => i.IsActive && i.TargetProductId == order.ProductId) - .ToListAsync(ct); - var processControlItems = await db.ControlItems.AsNoTracking() - .Where(i => i.IsActive && i.TargetProcessId != null) - .ToListAsync(ct); + // 工程管理項目も同じ理由で展開時点の値を写す(B-30-30-04)。どの項目を載せるかは工順の工程ごとの紐付けに従う + // (I-30-20-10。紐付け中の項目は無効化できないため、ここで有効かを見直す必要はない) foreach (var step in routing) { @@ -281,13 +276,11 @@ public async Task ExpandAsync(ManufacturingOrder order, string? lo // 表示はマスタの現在値を使い、ここには「計画時の版数」だけを残す WorkProcedureVersion = step.WorkProcedure?.Version, }; - // 品目単位の項目と、この工程を対象にした項目を合わせる(同じ項目は1回だけ) workOrder.ControlItemSnapshots = [ - .. controlItems - .Concat(processControlItems.Where(i => i.TargetProcessId == step.ProcessId)) - .DistinctBy(i => i.Id) - .OrderBy(i => i.Code) + .. step.ControlItemLinks + .Select(l => l.ControlItem!) + .OrderBy(i => i.Code, StringComparer.Ordinal) .Select(i => new WorkOrderControlItem { ControlItemId = i.Id, diff --git a/src/MesApp.Api/Services/MasterCsvKinds.cs b/src/MesApp.Api/Services/MasterCsvKinds.cs index 2d7fe83..758e7b8 100644 --- a/src/MesApp.Api/Services/MasterCsvKinds.cs +++ b/src/MesApp.Api/Services/MasterCsvKinds.cs @@ -119,12 +119,10 @@ public static class MasterCsvKinds new("Code", "工程管理項目コード", true, null), new("Name", "名称", true, null), new("Unit", "単位", false, "℃ / rpm など"), - new("TargetProductCode", "対象品目コード", false, "登録済みの品目コード"), - new("TargetProcessCode", "対象工程コード", false, "登録済みの工程コード"), new("TargetValue", "指示値", false, "許容範囲の内側であること"), new("LowerLimit", "許容下限", false, null), new("UpperLimit", "許容上限", false, null), - new("IsActive", "有効", false, "true / false"), + new("IsActive", "有効", false, "true / false。工順から紐付けている項目は無効にできない"), ]), new(Checklists, "チェックリスト", false, [ @@ -178,7 +176,8 @@ public static class MasterCsvKinds new("ToolCode", "使用治工具コード", false, null), new("WorkCenterCode", "作業区コード", false, "登録済みの作業区コード(段が作業区のもの)"), new("ChecklistCode", "チェックリストコード", false, null), - new("ControlItems", "工程管理項目", false, "温度・回転数 など"), + new("ControlItems", "工程管理項目の補足", false, "自由記述。指示値を持つ条件は ControlItemCodes で紐付ける"), + new("ControlItemCodes", "工程管理項目コード", false, "セミコロン区切り。登録済みで有効な項目。作業指示に指示値を写す"), new("WorkProcedureNo", "作業手順書番号", false, "登録済みで有効な手順書の番号"), ]), new(WorkProcedures, "作業手順書(SOP)", true, diff --git a/src/MesApp.Api/Services/MasterCsvService.Import.cs b/src/MesApp.Api/Services/MasterCsvService.Import.cs index 08ac12f..76e7386 100644 --- a/src/MesApp.Api/Services/MasterCsvService.Import.cs +++ b/src/MesApp.Api/Services/MasterCsvService.Import.cs @@ -773,11 +773,17 @@ private async Task ImportControlItemsAsync( CsvTable table, List errors, ImportCounter counter, CancellationToken ct) { var byCode = await db.ControlItems.ToDictionaryAsync(i => i.Code, StringComparer.Ordinal, ct); - var productIds = await db.Products.AsNoTracking() - .ToDictionaryAsync(p => p.Code, p => p.Id, StringComparer.Ordinal, ct); - var processIds = await db.Processes.AsNoTracking() - .ToDictionaryAsync(p => p.Code, p => p.Id, StringComparer.Ordinal, ct); var seen = new HashSet(StringComparer.Ordinal); + // 工順から紐付けている項目を無効化できないのは単票APIと同じ。行ごとに引けるよう先にまとめて読む + // (工順は別種別のCSVなので、この取込の途中で紐付けが変わることはない) + var referencingProducts = (await db.RoutingControlItems.AsNoTracking() + .Select(l => new { l.ControlItemId, ProductCode = l.Routing!.Product!.Code }) + .Distinct() + .ToListAsync(ct)) + .GroupBy(x => x.ControlItemId) + .ToDictionary( + g => g.Key, + g => (IReadOnlyCollection)g.Select(x => x.ProductCode).ToList()); foreach (var row in table.Rows) { @@ -793,12 +799,16 @@ private async Task ImportControlItemsAsync( var name = reader.RequiredText("Name", 200); var unit = reader.Text("Unit", item.Unit, 30); - var productId = reader.Reference("TargetProductCode", item.TargetProductId, productIds, "対象品目"); - var processId = reader.Reference("TargetProcessCode", item.TargetProcessId, processIds, "対象工程"); var target = reader.NumberOrNull("TargetValue", item.TargetValue); var lower = reader.NumberOrNull("LowerLimit", item.LowerLimit); var upper = reader.NumberOrNull("UpperLimit", item.UpperLimit); var isActive = reader.Bool("IsActive", item.IsActive); + if (!isNew && item.IsActive && !isActive + && MasterDeactivationPolicy.CheckControlItem( + code, referencingProducts.GetValueOrDefault(item.Id, [])) is { } inUse) + { + reader.Fail(inUse); + } if (reader.Failed) { continue; @@ -817,8 +827,6 @@ private async Task ImportControlItemsAsync( item.Name = name; item.Unit = unit; - item.TargetProductId = productId; - item.TargetProcessId = processId; item.TargetValue = target; item.LowerLimit = lower; item.UpperLimit = upper; @@ -1092,6 +1100,9 @@ private async Task ImportRoutingAsync( // 候補をここで絞ることで、上位の段を書いた行は「登録されていません」として弾かれる var workCenterIds = await ProductStructurePolicy.AssignableWorkCenters(db.WorkCenters.AsNoTracking()) .ToDictionaryAsync(w => w.Code, w => w.Id, StringComparer.Ordinal, ct); + // 無効な工程管理項目は候補に入れない(単票APIと共通の条件) + var controlItemIds = await ProductStructurePolicy.AssignableControlItems(db.ControlItems.AsNoTracking()) + .ToDictionaryAsync(i => i.Code, i => i.Id, StringComparer.Ordinal, ct); var existing = await db.Routings.ToListAsync(ct); foreach (var group in GroupRows(table, "ProductCode", errors)) @@ -1116,7 +1127,9 @@ private async Task ImportRoutingAsync( var setup = reader.Number("StandardSetupMinutes", 0m, 0); var skillId = reader.Reference("RequiredSkillCode", null, skillIds, "スキル・資格"); var equipmentId = reader.Reference("EquipmentAssetNo", null, equipmentIds, "設備"); - var candidateIds = ParseCandidates(reader, table, row, equipmentIds); + var candidateIds = ParseCodeList(reader, table, row, "EquipmentAssetNos", equipmentIds, ApiText.T("候補設備")); + var linkedControlItemIds = ParseCodeList( + reader, table, row, "ControlItemCodes", controlItemIds, ApiText.T("工程管理項目")); var toolId = reader.Reference("ToolCode", null, toolIds, "治工具"); var checklistId = reader.Reference("ChecklistCode", null, checklistIds, "チェックリスト"); var workCenterId = reader.Reference("WorkCenterCode", null, workCenterIds, "作業区"); @@ -1157,6 +1170,10 @@ .. ProductStructurePolicy.CandidateEquipmentIds(candidateIds, equipmentId) WorkCenterId = workCenterId, ChecklistId = checklistId, ControlItems = controlItems, + ControlItemLinks = + [ + .. linkedControlItemIds.Distinct().Select(x => new RoutingControlItem { ControlItemId = x }), + ], WorkProcedureId = workProcedureId, }); } @@ -1181,15 +1198,19 @@ .. ProductStructurePolicy.CandidateEquipmentIds(candidateIds, equipmentId) // ---- ユーザー(システム管理者のみ)---- - /// 工順CSVの候補設備列(セミコロン区切りの資産番号)を解決する - private static List ParseCandidates( - CsvRowReader reader, CsvTable table, CsvRecord row, IReadOnlyDictionary equipmentIds) + /// + /// 工順CSVのセミコロン区切りのコード列(候補設備の資産番号・工程管理項目コード)を解決する。 + /// 候補に無いコード(未登録・無効)はその行の誤りにする + /// + private static List ParseCodeList( + CsvRowReader reader, CsvTable table, CsvRecord row, string column, + IReadOnlyDictionary idsByCode, string label) { - if (!table.HasColumn("EquipmentAssetNos")) + if (!table.HasColumn(column)) { return []; } - var raw = table.Value(row, "EquipmentAssetNos"); + var raw = table.Value(row, column); if (string.IsNullOrWhiteSpace(raw)) { return []; @@ -1197,13 +1218,13 @@ private static List ParseCandidates( var result = new List(); foreach (var code in raw.Split(';', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)) { - if (equipmentIds.TryGetValue(code, out var id)) + if (idsByCode.TryGetValue(code, out var id)) { result.Add(id); } else { - reader.Fail(ApiText.T("候補設備 '{0}' は登録されていません(EquipmentAssetNos)。", code)); + reader.Fail(ApiText.T("{0} '{1}' は登録されていません({2})。", label, code, column)); } } return result; diff --git a/src/MesApp.Api/Services/MasterCsvService.cs b/src/MesApp.Api/Services/MasterCsvService.cs index ba6ac34..3c24007 100644 --- a/src/MesApp.Api/Services/MasterCsvService.cs +++ b/src/MesApp.Api/Services/MasterCsvService.cs @@ -162,12 +162,11 @@ public async Task ExportAsync(CsvKindInfo kind, bool includeInactive, Ca private async Task> ExportControlItemsAsync(bool includeInactive, CancellationToken ct) { var items = await db.ControlItems.AsNoTracking() - .Include(i => i.TargetProduct).Include(i => i.TargetProcess) .Where(i => includeInactive || i.IsActive) .OrderBy(i => i.Code).ToListAsync(ct); return [.. items.Select(i => new string?[] { - i.Code, i.Name, i.Unit, i.TargetProduct?.Code, i.TargetProcess?.Code, + i.Code, i.Name, i.Unit, Num(i.TargetValue), Num(i.LowerLimit), Num(i.UpperLimit), Bool(i.IsActive), })]; } @@ -229,6 +228,7 @@ public async Task ExportAsync(CsvKindInfo kind, bool includeInactive, Ca .Include(r => r.Tool).Include(r => r.Checklist).Include(r => r.WorkCenter) .Include(r => r.WorkProcedure) .Include(r => r.EquipmentCandidates).ThenInclude(c => c.Equipment) + .Include(r => r.ControlItemLinks).ThenInclude(l => l.ControlItem) .OrderBy(r => r.Product!.Code).ThenBy(r => r.Sequence) .ToListAsync(ct); return [.. items.Select(r => new string?[] @@ -238,7 +238,9 @@ public async Task ExportAsync(CsvKindInfo kind, bool includeInactive, Ca r.RequiredSkill?.Code, r.Equipment?.AssetNo, string.Join(";", r.EquipmentCandidates.Select(c => c.Equipment!.AssetNo).Order(StringComparer.Ordinal)), r.Tool?.Code, r.WorkCenter?.Code, - r.Checklist?.Code, r.ControlItems, r.WorkProcedure?.ProcedureNo, + r.Checklist?.Code, r.ControlItems, + string.Join(";", r.ControlItemLinks.Select(l => l.ControlItem!.Code).Order(StringComparer.Ordinal)), + r.WorkProcedure?.ProcedureNo, })]; } diff --git a/src/MesApp.Api/Services/ProductStructureService.cs b/src/MesApp.Api/Services/ProductStructureService.cs index 63ba9e8..f972ec9 100644 --- a/src/MesApp.Api/Services/ProductStructureService.cs +++ b/src/MesApp.Api/Services/ProductStructureService.cs @@ -121,6 +121,8 @@ object[] Snapshot(IEnumerable lines) => (steps.Where(s => s.WorkProcedureId != null).Select(s => s.WorkProcedureId!.Value), ProductStructurePolicy.AssignableWorkProcedures(db.WorkProcedures).Select(x => x.Id), ApiText.T("作業手順書")), (steps.SelectMany(s => s.EquipmentIds ?? []), db.Equipments.Select(x => x.Id), ApiText.T("候補設備")), + (steps.SelectMany(s => s.ControlItemIds ?? []), + ProductStructurePolicy.AssignableControlItems(db.ControlItems).Select(x => x.Id), ApiText.T("工程管理項目")), (steps.Where(s => s.WorkCenterId != null).Select(s => s.WorkCenterId!.Value), ProductStructurePolicy.AssignableWorkCenters(db.WorkCenters).Select(x => x.Id), ApiText.T("作業区")), }) @@ -155,6 +157,10 @@ .. ProductStructurePolicy.CandidateEquipmentIds(s.EquipmentIds, s.EquipmentId) ToolId = s.ToolId, WorkCenterId = s.WorkCenterId, ControlItems = s.ControlItems, + ControlItemLinks = + [ + .. (s.ControlItemIds ?? []).Distinct().Select(x => new RoutingControlItem { ControlItemId = x }), + ], ChecklistId = s.ChecklistId, WorkProcedureId = s.WorkProcedureId, })); diff --git a/src/MesApp.Client.Web/Pages/Masters/ControlItemsTab.razor b/src/MesApp.Client.Web/Pages/Masters/ControlItemsTab.razor index e41eab1..55f10be 100644 --- a/src/MesApp.Client.Web/Pages/Masters/ControlItemsTab.razor +++ b/src/MesApp.Client.Web/Pages/Masters/ControlItemsTab.razor @@ -8,6 +8,7 @@

@(_editingId is null ? L["工程管理項目の登録"] : L["編集({0})", _code])

@L["温度・回転数など、製造時に記録すべき条件の定義と指示値・上下限。実績はこの範囲と照合する。"] + @L["どの工程で記録するかは品目タブの工順で紐付けます。品目ごとに指示値が違う条件は、品目ごとに別の項目として登録してください。"]

@@ -22,24 +23,6 @@
-
- - -
-
- - -
@@ -74,7 +57,7 @@ { - + @foreach (var item in _items) @@ -83,7 +66,6 @@ - @@ -107,14 +89,11 @@ @code { private List? _items; - private List _processes = []; private int? _editingId; private string _code = string.Empty; private string _name = string.Empty; private string? _unit; - private int _productId; - private int _processId; private decimal? _target; private decimal? _lower; private decimal? _upper; @@ -122,11 +101,7 @@ private string? _message; private bool _busy; - protected override async Task OnInitializedAsync() - { - _processes = await Http.GetFromJsonAsync>("api/processes") ?? []; - await LoadAsync(); - } + protected override Task OnInitializedAsync() => LoadAsync(); private async Task LoadAsync() => _items = await Http.GetFromJsonAsync>("api/control-items?includeInactive=true"); @@ -137,8 +112,6 @@ _code = item.Code; _name = item.Name; _unit = item.Unit; - _productId = item.TargetProductId ?? 0; - _processId = item.TargetProcessId ?? 0; _target = item.TargetValue; _lower = item.LowerLimit; _upper = item.UpperLimit; @@ -150,8 +123,6 @@ _code = string.Empty; _name = string.Empty; _unit = null; - _productId = 0; - _processId = 0; _target = null; _lower = null; _upper = null; @@ -169,10 +140,7 @@ _message = null; try { - var request = new ControlItemRequest(_code, _name, _unit, - _productId == 0 ? null : _productId, - _processId == 0 ? null : _processId, - _target, _lower, _upper); + var request = new ControlItemRequest(_code, _name, _unit, _target, _lower, _upper); var response = _editingId is null ? await Http.PostAsJsonAsync("api/control-items", request) : await Http.PutAsJsonAsync($"api/control-items/{_editingId}", request); diff --git a/src/MesApp.Client.Web/Pages/Masters/Products/ProductRoutingEditor.razor b/src/MesApp.Client.Web/Pages/Masters/Products/ProductRoutingEditor.razor index 0294b30..2497fd4 100644 --- a/src/MesApp.Client.Web/Pages/Masters/Products/ProductRoutingEditor.razor +++ b/src/MesApp.Client.Web/Pages/Masters/Products/ProductRoutingEditor.razor @@ -6,7 +6,7 @@
@L["コード"]@L["名称"]@L["単位"]@L["対象"]@L["指示値"]@L["許容範囲"]@L["版数"]@L["状態"]
@L["コード"]@L["名称"]@L["単位"]@L["指示値"]@L["許容範囲"]@L["版数"]@L["状態"]
@item.Code @item.Name @(item.Unit ?? "-")@(item.TargetProductCode ?? item.TargetProcessCode ?? "-") @(item.TargetValue?.ToString() ?? "-") @(item.LowerLimit?.ToString() ?? "-") 〜 @(item.UpperLimit?.ToString() ?? "-") v@(item.Version)
- + @foreach (var step in _steps.OrderBy(s => s.Sequence)) @@ -17,9 +17,10 @@ - + + @@ -104,8 +105,20 @@
- - + @* 工程管理項目の紐付け(I-30-20-10)。展開時にこの工程の作業指示へ指示値・許容範囲を写す *@ + + +
+
+ +
@* 作業手順書の紐付け(I-30-20-12)。作業者は作業指示からこれを辿る *@ @@ -139,6 +152,8 @@ private List _tools = []; private List _checklists = []; private List _workProcedures = []; + /// 紐付けられる工程管理項目(有効なものだけ) + private List _controlItemOptions = []; /// 工順の作業区は最下段のみ(Spec.md 5.7 資源階層への紐付け) private List _workCenters = []; @@ -157,6 +172,7 @@ private int _workProcedureId; private int _workCenterId; private string? _controlItems; + private readonly List _controlItemIds = []; private string? _error; private string? _message; @@ -170,6 +186,7 @@ _tools = await Http.GetFromJsonAsync>("api/tools") ?? []; _checklists = await Http.GetFromJsonAsync>("api/checklists") ?? []; _workProcedures = await Http.GetFromJsonAsync>("api/work-procedures") ?? []; + _controlItemOptions = await Http.GetFromJsonAsync>("api/control-items") ?? []; _workCenters = await Http.GetFromJsonAsync>( $"api/work-centers?level={WorkCenterLevel.WorkCenter}") ?? []; } @@ -192,7 +209,7 @@ _steps.AddRange(routing.Select(r => new RoutingStepRequest( r.Sequence, r.ProcessId, r.StandardWorkMinutes, r.StandardSetupMinutes, r.RequiredSkillId, r.EquipmentId, r.ToolId, r.ControlItems, r.ChecklistId, - r.WorkCenterId, r.EquipmentIds, r.WorkProcedureId))); + r.WorkCenterId, r.EquipmentIds, r.WorkProcedureId, r.ControlItemIds))); _sequence = _steps.Count == 0 ? 1 : _steps.Max(s => s.Sequence) + 1; // 親から呼ばれたときはパラメータが変わらないため、自分で再描画を要求する StateHasChanged(); @@ -219,37 +236,43 @@ _checklistId == 0 ? null : _checklistId, _workCenterId == 0 ? null : _workCenterId, _equipmentIds.Count == 0 ? null : [.. _equipmentIds], - _workProcedureId == 0 ? null : _workProcedureId)); + _workProcedureId == 0 ? null : _workProcedureId, + _controlItemIds.Count == 0 ? null : [.. _controlItemIds])); _sequence = _steps.Max(s => s.Sequence) + 1; _controlItems = null; _equipmentIds.Clear(); + _controlItemIds.Clear(); } /// 複数選択の設備一覧から候補を取り込む - private void OnCandidatesChanged(ChangeEventArgs e) + private void OnCandidatesChanged(ChangeEventArgs e) => ReadSelected(e, _equipmentIds); + + /// 複数選択の工程管理項目一覧から紐付けを取り込む + private void OnControlItemsChanged(ChangeEventArgs e) => ReadSelected(e, _controlItemIds); + + private static void ReadSelected(ChangeEventArgs e, List target) { - _equipmentIds.Clear(); + target.Clear(); foreach (var value in (string[])(e.Value ?? Array.Empty())) { if (int.TryParse(value, out var id)) { - _equipmentIds.Add(id); + target.Add(id); } } } - /// 一覧に出す候補設備の表示(多いときは件数で省略する) - private string CandidateLabel(RoutingStepRequest step) + /// 一覧に出す候補設備・工程管理項目の表示(多いときは件数で省略する) + private string ShortList(IEnumerable ids, Func codeOf) { - var ids = step.EquipmentIds ?? (step.EquipmentId is { } single ? [single] : []); - if (ids.Count == 0) - { - return "-"; - } var codes = ids - .Select(id => _equipments.FirstOrDefault(e => e.Id == id)?.AssetNo) + .Select(codeOf) .Where(code => code is not null) .ToList(); + if (codes.Count == 0) + { + return "-"; + } return codes.Count <= 3 ? string.Join(L["、"], codes) : L["{0} ほか{1}件", string.Join(L["、"], codes.Take(3)), codes.Count - 3]; } diff --git a/src/MesApp.Client.Web/Shared/UiText.en.resx b/src/MesApp.Client.Web/Shared/UiText.en.resx index 54ce73d..cea695f 100644 --- a/src/MesApp.Client.Web/Shared/UiText.en.resx +++ b/src/MesApp.Client.Web/Shared/UiText.en.resx @@ -1005,9 +1005,6 @@ Tools used - - e.g. temperature, speed - Work procedure (SOP) @@ -4167,4 +4164,19 @@ {0} (not in routing) + + Link items to process steps in the routing on the Items tab. If the target value differs by item, register a separate control item for each item. + + + Notes + + + Control items (Ctrl/Shift to select multiple) + + + Control item notes + + + Checks without target values, etc. + diff --git a/src/MesApp.Core/Contracts/Masters/MasterContracts.cs b/src/MesApp.Core/Contracts/Masters/MasterContracts.cs index 17ec383..a8d0ab2 100644 --- a/src/MesApp.Core/Contracts/Masters/MasterContracts.cs +++ b/src/MesApp.Core/Contracts/Masters/MasterContracts.cs @@ -63,7 +63,9 @@ public record RoutingStepRequest( /// 候補設備(B-10-20-02)。空なら差立で設備を限定しない List? EquipmentIds = null, /// 作業手順書(SOP。I-30-20-12) - int? WorkProcedureId = null); + int? WorkProcedureId = null, + /// この工程で記録する工程管理項目(I-30-20-10)。有効な項目だけを指定できる + List? ControlItemIds = null); public record RoutingStepResponse( int Id, int Sequence, int ProcessId, string ProcessCode, string ProcessName, @@ -74,7 +76,10 @@ public record RoutingStepResponse( /// 候補設備の資産番号(表示用) List? EquipmentAssetNos = null, List? EquipmentIds = null, - int? WorkProcedureId = null, string? WorkProcedureNo = null, string? WorkProcedureTitle = null); + int? WorkProcedureId = null, string? WorkProcedureNo = null, string? WorkProcedureTitle = null, + /// この工程で記録する工程管理項目(コード順) + List? ControlItemIds = null, + List? ControlItemCodes = null); // ---- 作業手順書(SOP。I-30-40、B-10-30-03)---- @@ -212,16 +217,12 @@ public record ControlItemRequest( [Required, MaxLength(50)] string Code, [Required, MaxLength(200)] string Name, [MaxLength(30)] string? Unit, - int? TargetProductId, - int? TargetProcessId, decimal? TargetValue, decimal? LowerLimit, decimal? UpperLimit); public record ControlItemResponse( int Id, string Code, string Name, string? Unit, - int? TargetProductId, string? TargetProductCode, - int? TargetProcessId, string? TargetProcessCode, decimal? TargetValue, decimal? LowerLimit, decimal? UpperLimit, int Version, bool IsActive); diff --git a/src/MesApp.Core/Entities/Masters.cs b/src/MesApp.Core/Entities/Masters.cs index a8ed796..85d982a 100644 --- a/src/MesApp.Core/Entities/Masters.cs +++ b/src/MesApp.Core/Entities/Masters.cs @@ -139,9 +139,18 @@ public class Routing public int? ToolId { get; set; } public Tool? Tool { get; set; } - /// 工程管理項目(温度・回転数など記録すべき製造条件の定義) + /// + /// 工程管理項目の補足(自由記述)。指示値・許容範囲を持つ条件は で紐付ける + /// public string? ControlItems { get; set; } + /// + /// この工程で記録する工程管理項目(I-30-20-10「BOPに登録された作業に工程管理条件を定義する」)。 + /// 指図展開時にこの紐付けどおり作業指示へ指示値を写す。項目側に対象品目・工程を持たせて自動で選ぶと、 + /// 品目を指定した項目がその品目の全工程に載り、同じ工程が2回ある工順を区別できないため + /// + public List ControlItemLinks { get; set; } = []; + /// 工程・段取りで実施するチェックリスト public int? ChecklistId { get; set; } public Checklist? Checklist { get; set; } @@ -205,6 +214,21 @@ public class RoutingEquipment public Equipment? Equipment { get; set; } } +/// +/// 工順の工程管理項目(Spec.md 5.1 RoutingControlItem。I-30-20-10、B-30-30-04)。 +/// 工順の1工程で記録する製造条件を指す。工順の一括置換で工程ごと作り直す +/// +public class RoutingControlItem +{ + public int Id { get; set; } + + public int RoutingId { get; set; } + public Routing? Routing { get; set; } + + public int ControlItemId { get; set; } + public ControlItem? ControlItem { get; set; } +} + /// 設備台帳/BOE(Spec.md 5.1 Equipment。E-10-10、I-10-20) public class Equipment : IDeactivatableMaster { @@ -498,6 +522,11 @@ public class InspectionItem : IDeactivatableMaster /// 関係は「検査パラメータと検査結果」と同じ構造であり、判定の考え方も揃うため。 /// 違いは、検査が結果を測るのに対し、こちらは作る前に与える条件だという点。 /// +/// +/// 対象品目・対象工程は持たない。どの工程で記録するかは工順(BOP)側から紐付ける()。 +/// 作業手順書()と同じ理由で、両側に対象を持たせると運用が割れる。 +/// 品目ごとに指示値が違う条件は、品目ごとに別の項目として登録する +/// /// public class ControlItem : IDeactivatableMaster { @@ -511,14 +540,6 @@ public class ControlItem : IDeactivatableMaster /// 単位(℃・rpm など) public string? Unit { get; set; } - /// 対象品目(品目単位の条件の場合) - public int? TargetProductId { get; set; } - public Product? TargetProduct { get; set; } - - /// 対象工程(工程単位の条件の場合) - public int? TargetProcessId { get; set; } - public ProcessMaster? TargetProcess { get; set; } - /// 指示値(レシピ上の狙い値。例「600W」) public decimal? TargetValue { get; set; } diff --git a/src/MesApp.Infrastructure/Configurations/MasterConfigurations.cs b/src/MesApp.Infrastructure/Configurations/MasterConfigurations.cs index b783e88..a4c085d 100644 --- a/src/MesApp.Infrastructure/Configurations/MasterConfigurations.cs +++ b/src/MesApp.Infrastructure/Configurations/MasterConfigurations.cs @@ -77,6 +77,21 @@ public void Configure(EntityTypeBuilder e) } } +internal sealed class RoutingControlItemConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder e) + { + // 同じ工程に同じ項目を二重に紐付けさせない(作業指示に同じ指示が2行出る) + e.HasIndex(x => new { x.RoutingId, x.ControlItemId }).IsUnique(); + // 候補設備と同じく、工順を置き換えると紐付けも消える。逆側のナビゲーションを明示する + e.HasOne(x => x.Routing).WithMany(r => r.ControlItemLinks) + .HasForeignKey(x => x.RoutingId) + .OnDelete(DeleteBehavior.Cascade); + e.HasOne(x => x.ControlItem).WithMany().HasForeignKey(x => x.ControlItemId) + .OnDelete(DeleteBehavior.Restrict); + } +} + internal sealed class WorkProcedureConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder e) diff --git a/src/MesApp.Infrastructure/MesAppDbContext.cs b/src/MesApp.Infrastructure/MesAppDbContext.cs index 049ddf8..a65823d 100644 --- a/src/MesApp.Infrastructure/MesAppDbContext.cs +++ b/src/MesApp.Infrastructure/MesAppDbContext.cs @@ -19,6 +19,7 @@ public class MesAppDbContext(DbContextOptions options) public DbSet Processes => Set(); public DbSet Routings => Set(); public DbSet RoutingEquipments => Set(); + public DbSet RoutingControlItems => Set(); public DbSet Equipments => Set(); public DbSet EquipmentParts => Set(); public DbSet Tools => Set(); diff --git a/src/MesApp.Infrastructure/Migrations/20260923081738_LinkControlItemsToRouting.Designer.cs b/src/MesApp.Infrastructure/Migrations/20260923081738_LinkControlItemsToRouting.Designer.cs new file mode 100644 index 0000000..28cc2f9 --- /dev/null +++ b/src/MesApp.Infrastructure/Migrations/20260923081738_LinkControlItemsToRouting.Designer.cs @@ -0,0 +1,4771 @@ +// +using System; +using MesApp.Infrastructure; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace MesApp.Infrastructure.Migrations +{ + [DbContext(typeof(MesAppDbContext))] + [Migration("20260923081738_LinkControlItemsToRouting")] + partial class LinkControlItemsToRouting + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "10.0.10"); + + modelBuilder.Entity("MesApp.Core.Entities.AppUser", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("AccessFailedCount") + .HasColumnType("INTEGER"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Department") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("EmailConfirmed") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnabled") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnd") + .HasColumnType("TEXT"); + + b.Property("MustChangePassword") + .HasColumnType("INTEGER"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("PasswordHash") + .HasColumnType("TEXT"); + + b.Property("PhoneNumber") + .HasColumnType("TEXT"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("INTEGER"); + + b.Property("SecurityStamp") + .HasColumnType("TEXT"); + + b.Property("ShiftId") + .HasColumnType("INTEGER"); + + b.Property("TwoFactorEnabled") + .HasColumnType("INTEGER"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("WorkCenterId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.HasIndex("ShiftId"); + + b.HasIndex("WorkCenterId"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Detail") + .HasColumnType("TEXT"); + + b.Property("IpAddress") + .HasColumnType("TEXT"); + + b.Property("RecordedOn") + .HasColumnType("TEXT"); + + b.Property("TargetId") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("TargetType") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Timestamp") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("UserName") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RecordedOn"); + + b.HasIndex("Timestamp"); + + b.HasIndex("UserId"); + + b.HasIndex("Category", "Action"); + + b.HasIndex("TargetType", "TargetId"); + + b.ToTable("AuditLogs"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.BomItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AlternativeGroup") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ChildProductId") + .HasColumnType("INTEGER"); + + b.Property("IsAlternative") + .HasColumnType("INTEGER"); + + b.Property("MakeOrBuy") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ParentProductId") + .HasColumnType("INTEGER"); + + b.Property("QuantityPer") + .HasColumnType("TEXT"); + + b.Property("RoutingSequence") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ChildProductId"); + + b.HasIndex("ParentProductId", "ChildProductId") + .IsUnique(); + + b.ToTable("BomItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Checklist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Checklists"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChecklistId") + .HasColumnType("INTEGER"); + + b.Property("IsRequired") + .HasColumnType("INTEGER"); + + b.Property("Sequence") + .HasColumnType("INTEGER"); + + b.Property("Text") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.ToTable("ChecklistItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChecklistId") + .HasColumnType("INTEGER"); + + b.Property("EquipmentId") + .HasColumnType("INTEGER"); + + b.Property("PerformedAt") + .HasColumnType("TEXT"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ChecklistRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistResultItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChecklistItemId") + .HasColumnType("INTEGER"); + + b.Property("ChecklistRecordId") + .HasColumnType("INTEGER"); + + b.Property("IsChecked") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistItemId"); + + b.HasIndex("ChecklistRecordId"); + + b.ToTable("ChecklistResultItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("LowerLimit") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("TargetValue") + .HasColumnType("TEXT"); + + b.Property("Unit") + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("UpperLimit") + .HasColumnType("TEXT"); + + b.Property("Version") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("ControlItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.DefectReason", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("DefectReasons"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AssetNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("MaintenanceParts") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("MaintenanceThreshold") + .HasColumnType("TEXT"); + + b.Property("MaintenanceType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("Site") + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("WorkCenterId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AssetNo") + .IsUnique(); + + b.HasIndex("WorkCenterId"); + + b.ToTable("Equipments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("EndedAt") + .HasColumnType("TEXT"); + + b.Property("EquipmentId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("RecordedByUserId") + .HasColumnType("TEXT"); + + b.Property("StartedAt") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("StopCause") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("EquipmentLogs"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentPart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("EquipmentId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("QuantityPer") + .HasPrecision(18, 4) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("EquipmentId", "ProductId") + .IsUnique(); + + b.ToTable("EquipmentParts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDevice", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CalibratedOn") + .HasColumnType("TEXT"); + + b.Property("CalibrationCycleDays") + .HasColumnType("INTEGER"); + + b.Property("CalibrationDueOn") + .HasColumnType("TEXT"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Location") + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("SerialNo") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("InspectionDevices"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDeviceCalibration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CalibratedOn") + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("InspectionDeviceId") + .HasColumnType("INTEGER"); + + b.Property("NextDueOn") + .HasColumnType("TEXT"); + + b.Property("PerformedByUserId") + .HasColumnType("TEXT"); + + b.Property("Result") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("InspectionDeviceId", "CalibratedOn"); + + b.ToTable("InspectionDeviceCalibrations"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("LowerLimit") + .HasColumnType("TEXT"); + + b.Property("Method") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("SamplingCount") + .HasColumnType("INTEGER"); + + b.Property("StandardValue") + .HasColumnType("TEXT"); + + b.Property("TargetProcessId") + .HasColumnType("INTEGER"); + + b.Property("TargetProductId") + .HasColumnType("INTEGER"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("UpperLimit") + .HasColumnType("TEXT"); + + b.Property("Version") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("TargetProcessId"); + + b.HasIndex("TargetProductId"); + + b.ToTable("InspectionItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ApprovedAt") + .HasColumnType("TEXT"); + + b.Property("ApprovedByUserId") + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("JudgedAt") + .HasColumnType("TEXT"); + + b.Property("JudgedByUserId") + .HasColumnType("TEXT"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("OverallJudgment") + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("RequestedByUserId") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("TargetLotId") + .HasColumnType("INTEGER"); + + b.Property("TargetWorkOrderId") + .HasColumnType("INTEGER"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("RequestedByUserId"); + + b.HasIndex("Status"); + + b.HasIndex("TargetLotId"); + + b.HasIndex("TargetWorkOrderId"); + + b.ToTable("InspectionOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrderItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("InspectionItemId") + .HasColumnType("INTEGER"); + + b.Property("InspectionOrderId") + .HasColumnType("INTEGER"); + + b.Property("ItemCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ItemName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("ItemVersion") + .HasColumnType("INTEGER"); + + b.Property("LowerLimit") + .HasColumnType("TEXT"); + + b.Property("Method") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("SamplingCount") + .HasColumnType("INTEGER"); + + b.Property("StandardValue") + .HasColumnType("TEXT"); + + b.Property("UpperLimit") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("InspectionItemId"); + + b.HasIndex("InspectionOrderId", "InspectionItemId") + .IsUnique(); + + b.ToTable("InspectionOrderItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CorrectionNote") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("InspectedAt") + .HasColumnType("TEXT"); + + b.Property("InspectedByUserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("InspectionDeviceId") + .HasColumnType("INTEGER"); + + b.Property("InspectionItemId") + .HasColumnType("INTEGER"); + + b.Property("InspectionOrderId") + .HasColumnType("INTEGER"); + + b.Property("Judgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("MeasuredValue") + .HasColumnType("TEXT"); + + b.Property("SampleNo") + .HasColumnType("INTEGER"); + + b.Property("TextValue") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("InspectedByUserId"); + + b.HasIndex("InspectionDeviceId"); + + b.HasIndex("InspectionItemId"); + + b.HasIndex("InspectionOrderId"); + + b.ToTable("InspectionResults"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResultCorrection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AfterJudgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("AfterMeasuredValue") + .HasColumnType("TEXT"); + + b.Property("AfterTextValue") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("BeforeJudgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("BeforeMeasuredValue") + .HasColumnType("TEXT"); + + b.Property("BeforeTextValue") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("CorrectedAt") + .HasColumnType("TEXT"); + + b.Property("CorrectedByUserId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("InspectionOrderId") + .HasColumnType("INTEGER"); + + b.Property("InspectionResultId") + .HasColumnType("INTEGER"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CorrectedByUserId"); + + b.HasIndex("InspectionResultId"); + + b.HasIndex("InspectionOrderId", "Id"); + + b.ToTable("InspectionResultCorrections"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryStock", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("LocationId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId", "LocationId") + .IsUnique(); + + b.HasIndex("ProductId", "LocationId"); + + b.ToTable("InventoryStocks"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryTransaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("FromLocationId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("PerformedByUserId") + .HasColumnType("TEXT"); + + b.Property("PickingOrderId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("ShippingOrderId") + .HasColumnType("INTEGER"); + + b.Property("Timestamp") + .HasColumnType("TEXT"); + + b.Property("ToLocationId") + .HasColumnType("INTEGER"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("FromLocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("Timestamp"); + + b.HasIndex("ToLocationId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("InventoryTransactions"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AreaType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("ShelfNo") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("WorkCenterId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("WorkCenterId"); + + b.ToTable("Locations"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Lot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("ExpiresOn") + .HasColumnType("TEXT"); + + b.Property("Grade") + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("InitialQuantity") + .HasColumnType("TEXT"); + + b.Property("LotNumber") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("TEXT"); + + b.Property("ManufacturedOn") + .HasColumnType("TEXT"); + + b.Property("OriginType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ParentLotId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("SourceWorkOrderId") + .HasColumnType("INTEGER"); + + b.Property("StockStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("LotNumber") + .IsUnique(); + + b.HasIndex("ParentLotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SourceWorkOrderId"); + + b.ToTable("Lots"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotGenealogy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChildLotId") + .HasColumnType("INTEGER"); + + b.Property("OccurredAt") + .HasColumnType("TEXT"); + + b.Property("ParentLotId") + .HasColumnType("INTEGER"); + + b.Property("PerformedByUserId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("RelationType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ChildLotId"); + + b.HasIndex("ParentLotId"); + + b.ToTable("LotGenealogies"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotStatusHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChangedAt") + .HasColumnType("TEXT"); + + b.Property("ChangedByUserId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("FromStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("InspectionOrderId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("NonconformanceReportId") + .HasColumnType("INTEGER"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ToStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("LotId", "Id"); + + b.ToTable("LotStatusHistories"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CreatedByUserId") + .HasColumnType("TEXT"); + + b.Property("EquipmentId") + .HasColumnType("INTEGER"); + + b.Property("MaintenancePlanId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ProcedureId") + .HasColumnType("INTEGER"); + + b.Property("RequestType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ScheduledDate") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ToolId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("CreatedByUserId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("MaintenancePlanId"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("ProcedureId"); + + b.HasIndex("Status"); + + b.HasIndex("ToolId"); + + b.ToTable("MaintenanceOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenancePlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CreatedByUserId") + .HasColumnType("TEXT"); + + b.Property("CycleDays") + .HasColumnType("INTEGER"); + + b.Property("EquipmentId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("PlanYear") + .HasColumnType("INTEGER"); + + b.Property("ScheduledDate") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId", "PlanYear"); + + b.ToTable("MaintenancePlans"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("ProcedureNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Steps") + .IsRequired() + .HasMaxLength(4000) + .HasColumnType("TEXT"); + + b.Property("TargetEquipmentId") + .HasColumnType("INTEGER"); + + b.Property("TargetToolId") + .HasColumnType("INTEGER"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("Version") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ProcedureNo") + .IsUnique(); + + b.HasIndex("TargetEquipmentId"); + + b.HasIndex("TargetToolId"); + + b.ToTable("MaintenanceProcedures"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("EndedAt") + .HasColumnType("TEXT"); + + b.Property("MaintenanceOrderId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("PartsUsed") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Result") + .HasMaxLength(2000) + .HasColumnType("TEXT"); + + b.Property("StartedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("MaintenanceOrderId"); + + b.HasIndex("PerformedByUserId"); + + b.ToTable("MaintenanceRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecordPart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("LocationId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("MaintenanceRecordId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasPrecision(18, 4) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("MaintenanceRecordId"); + + b.HasIndex("ProductId"); + + b.ToTable("MaintenanceRecordParts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ApprovedAt") + .HasColumnType("TEXT"); + + b.Property("ApprovedByUserId") + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CreatedByUserId") + .HasColumnType("TEXT"); + + b.Property("DueDate") + .HasColumnType("TEXT"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("OrderType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("OutputLotId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("SourceOrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("OutputLotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SourceOrderId"); + + b.HasIndex("Status"); + + b.ToTable("ManufacturingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrderMaterial", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AlternativeGroup") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ChildProductId") + .HasColumnType("INTEGER"); + + b.Property("IsAlternative") + .HasColumnType("INTEGER"); + + b.Property("ManufacturingOrderId") + .HasColumnType("INTEGER"); + + b.Property("PlannedQuantity") + .HasColumnType("TEXT"); + + b.Property("QuantityPer") + .HasColumnType("TEXT"); + + b.Property("RoutingSequence") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ChildProductId"); + + b.HasIndex("ManufacturingOrderId", "ChildProductId") + .IsUnique(); + + b.ToTable("ManufacturingOrderMaterials"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaterialConsumption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ConsumedAt") + .HasColumnType("TEXT"); + + b.Property("IsSubstitute") + .HasColumnType("INTEGER"); + + b.Property("LocationId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("Method") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("RecordedByUserId") + .HasColumnType("TEXT"); + + b.Property("SubstituteReason") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("MaterialConsumptions"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NonconformanceReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ActionCompletedAt") + .HasColumnType("TEXT"); + + b.Property("ActionCompletedByUserId") + .HasColumnType("TEXT"); + + b.Property("ActionInstructedAt") + .HasColumnType("TEXT"); + + b.Property("ActionInstructedByUserId") + .HasColumnType("TEXT"); + + b.Property("ActionInstruction") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("ActionRecord") + .HasMaxLength(2000) + .HasColumnType("TEXT"); + + b.Property("ApprovedAt") + .HasColumnType("TEXT"); + + b.Property("ApprovedByUserId") + .HasColumnType("TEXT"); + + b.Property("CauseCategory") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("CauseDetail") + .HasMaxLength(2000) + .HasColumnType("TEXT"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("InspectionOrderId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("ReportNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ReportedByUserId") + .HasColumnType("TEXT"); + + b.Property("ReworkOrderId") + .HasColumnType("INTEGER"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("InspectionOrderId"); + + b.HasIndex("LotId"); + + b.HasIndex("ReportNo") + .IsUnique(); + + b.HasIndex("ReportedByUserId"); + + b.HasIndex("ReworkOrderId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("NonconformanceReports"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NumberSequence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("LastValue") + .HasColumnType("INTEGER"); + + b.Property("Prefix") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Prefix") + .IsUnique(); + + b.ToTable("NumberSequences"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("LocationId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("PickingOrderId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("PickingOrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("PickingLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CreatedByUserId") + .HasColumnType("TEXT"); + + b.Property("ExecutedAt") + .HasColumnType("TEXT"); + + b.Property("ExecutedByUserId") + .HasColumnType("TEXT"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ShippingOrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("ShippingOrderId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("PickingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProcessMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Processes", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("DefaultLocationId") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("Specification") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("StandardDefectRate") + .HasColumnType("TEXT"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Unit") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("DefaultLocationId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDataRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("IsDeviation") + .HasColumnType("INTEGER"); + + b.Property("Item") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("NumericValue") + .HasColumnType("TEXT"); + + b.Property("RecordedAt") + .HasColumnType("TEXT"); + + b.Property("RecordedByUserId") + .HasColumnType("TEXT"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("WorkOrderControlItemId") + .HasColumnType("INTEGER"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("WorkOrderControlItemId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ProductionDataRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDefect", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DefectReasonId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("ProductionRecordId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("DefectReasonId"); + + b.HasIndex("ProductionRecordId"); + + b.ToTable("ProductionDefects"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("BusinessDate") + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("PlannedQuantity") + .HasColumnType("TEXT"); + + b.Property("ProcessId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.Property("WorkCenterId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ProcessId"); + + b.HasIndex("ProductId"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("BusinessDate", "ProductId", "ProcessId", "WorkCenterId") + .IsUnique(); + + b.ToTable("ProductionPlans"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ApprovedAt") + .HasColumnType("TEXT"); + + b.Property("ApprovedByUserId") + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("DefectQuantity") + .HasColumnType("TEXT"); + + b.Property("EndedAt") + .HasColumnType("TEXT"); + + b.Property("GoodQuantity") + .HasColumnType("TEXT"); + + b.Property("OutputLocationId") + .HasColumnType("INTEGER"); + + b.Property("OutputLotId") + .HasColumnType("INTEGER"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ReworkQuantity") + .HasColumnType("TEXT"); + + b.Property("ScrapQuantity") + .HasColumnType("TEXT"); + + b.Property("ShiftId") + .HasColumnType("INTEGER"); + + b.Property("StartedAt") + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("OutputLotId"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("ShiftId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ProductionRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecordCorrection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AfterDefectQuantity") + .HasColumnType("TEXT"); + + b.Property("AfterGoodQuantity") + .HasColumnType("TEXT"); + + b.Property("AfterReworkQuantity") + .HasColumnType("TEXT"); + + b.Property("AfterScrapQuantity") + .HasColumnType("TEXT"); + + b.Property("BeforeDefectQuantity") + .HasColumnType("TEXT"); + + b.Property("BeforeGoodQuantity") + .HasColumnType("TEXT"); + + b.Property("BeforeReworkQuantity") + .HasColumnType("TEXT"); + + b.Property("BeforeScrapQuantity") + .HasColumnType("TEXT"); + + b.Property("CorrectedAt") + .HasColumnType("TEXT"); + + b.Property("CorrectedByUserId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("ProductionRecordId") + .HasColumnType("INTEGER"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("CorrectedByUserId"); + + b.HasIndex("ProductionRecordId"); + + b.HasIndex("WorkOrderId", "Id"); + + b.ToTable("ProductionRecordCorrections"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RefreshToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("ExpiresAt") + .HasColumnType("TEXT"); + + b.Property("RevokedAt") + .HasColumnType("TEXT"); + + b.Property("TokenHash") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("TokenHash") + .IsUnique(); + + b.HasIndex("UserId"); + + b.ToTable("RefreshTokens"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChecklistId") + .HasColumnType("INTEGER"); + + b.Property("ControlItems") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("EquipmentId") + .HasColumnType("INTEGER"); + + b.Property("ProcessId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("RequiredSkillId") + .HasColumnType("INTEGER"); + + b.Property("Sequence") + .HasColumnType("INTEGER"); + + b.Property("StandardSetupMinutes") + .HasColumnType("TEXT"); + + b.Property("StandardWorkMinutes") + .HasColumnType("TEXT"); + + b.Property("ToolId") + .HasColumnType("INTEGER"); + + b.Property("WorkCenterId") + .HasColumnType("INTEGER"); + + b.Property("WorkProcedureId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("ProcessId"); + + b.HasIndex("RequiredSkillId"); + + b.HasIndex("ToolId"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("WorkProcedureId"); + + b.HasIndex("ProductId", "Sequence") + .IsUnique(); + + b.ToTable("Routings"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ControlItemId") + .HasColumnType("INTEGER"); + + b.Property("RoutingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ControlItemId"); + + b.HasIndex("RoutingId", "ControlItemId") + .IsUnique(); + + b.ToTable("RoutingControlItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("EquipmentId") + .HasColumnType("INTEGER"); + + b.Property("RoutingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("RoutingId", "EquipmentId") + .IsUnique(); + + b.ToTable("RoutingEquipments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SampleStorage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClosedByUserId") + .HasColumnType("TEXT"); + + b.Property("ClosedOn") + .HasColumnType("TEXT"); + + b.Property("CollectedByUserId") + .HasColumnType("TEXT"); + + b.Property("CollectedOn") + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("InspectionOrderId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasPrecision(18, 4) + .HasColumnType("TEXT"); + + b.Property("RetainUntil") + .HasColumnType("TEXT"); + + b.Property("SampleNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("INTEGER"); + + b.Property("StorageLocationId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("InspectionOrderId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SampleNo") + .IsUnique(); + + b.HasIndex("StorageLocationId"); + + b.HasIndex("Status", "RetainUntil"); + + b.ToTable("SampleStorages"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SetupRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AbnormalityNote") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("EndedAt") + .HasColumnType("TEXT"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("StartedAt") + .HasColumnType("TEXT"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("SetupRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Shift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("EndTime") + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("StartTime") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Shifts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShipmentJudgment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ApprovedAt") + .HasColumnType("TEXT"); + + b.Property("ApprovedByUserId") + .HasColumnType("TEXT"); + + b.Property("JudgedAt") + .HasColumnType("TEXT"); + + b.Property("JudgedByUserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("JudgmentNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("Result") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ShippingOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("JudgedByUserId"); + + b.HasIndex("JudgmentNo") + .IsUnique(); + + b.HasIndex("LotId"); + + b.HasIndex("ShippingOrderId"); + + b.ToTable("ShipmentJudgments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("ShippedQuantity") + .HasColumnType("TEXT"); + + b.Property("ShippingOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("ShippingOrderId"); + + b.ToTable("ShippingLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CreatedByUserId") + .HasColumnType("TEXT"); + + b.Property("Destination") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("PlannedDate") + .HasColumnType("TEXT"); + + b.Property("ShippedAt") + .HasColumnType("TEXT"); + + b.Property("ShippedByUserId") + .HasColumnType("TEXT"); + + b.Property("ShippingNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ShippingNo") + .IsUnique(); + + b.ToTable("ShippingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SkillMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("RequiresExpiry") + .HasColumnType("INTEGER"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Skills", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CreatedByUserId") + .HasColumnType("TEXT"); + + b.Property("FinalizedAt") + .HasColumnType("TEXT"); + + b.Property("FinalizedByUserId") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("StocktakeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("TargetLocationId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("StocktakeNo") + .IsUnique(); + + b.HasIndex("TargetLocationId"); + + b.ToTable("Stocktakes"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.StocktakeLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CountedQuantity") + .HasColumnType("TEXT"); + + b.Property("IsAdjusted") + .HasColumnType("INTEGER"); + + b.Property("LocationId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("StocktakeId") + .HasColumnType("INTEGER"); + + b.Property("TheoreticalQuantity") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("StocktakeId"); + + b.ToTable("StocktakeLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Tool", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("LifeResetAt") + .HasColumnType("TEXT"); + + b.Property("LifeThresholdCount") + .HasColumnType("INTEGER"); + + b.Property("LifeThresholdHours") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ToolType") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Tools"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolIssue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AllocatedAt") + .HasColumnType("TEXT"); + + b.Property("AllocatedByUserId") + .HasColumnType("TEXT"); + + b.Property("IssuedAt") + .HasColumnType("TEXT"); + + b.Property("IssuedToUserId") + .HasColumnType("TEXT"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("ReturnedAt") + .HasColumnType("TEXT"); + + b.Property("ReturnedByUserId") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("INTEGER"); + + b.Property("ToolId") + .HasColumnType("INTEGER"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("IssuedToUserId"); + + b.HasIndex("WorkOrderId"); + + b.HasIndex("ToolId", "Status"); + + b.ToTable("ToolIssues"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolUsage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("RecordedAt") + .HasColumnType("TEXT"); + + b.Property("RecordedByUserId") + .HasColumnType("TEXT"); + + b.Property("ToolId") + .HasColumnType("INTEGER"); + + b.Property("UsageCount") + .HasColumnType("INTEGER"); + + b.Property("UsageHours") + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ToolId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ToolUsages"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TransferOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CreatedByUserId") + .HasColumnType("TEXT"); + + b.Property("ExecutedAt") + .HasColumnType("TEXT"); + + b.Property("ExecutedByUserId") + .HasColumnType("TEXT"); + + b.Property("FromLocationId") + .HasColumnType("INTEGER"); + + b.Property("LotId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ToLocationId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("FromLocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("Status"); + + b.HasIndex("ToLocationId"); + + b.ToTable("TransferOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TroubleReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("EquipmentId") + .HasColumnType("INTEGER"); + + b.Property("OccurredAt") + .HasColumnType("TEXT"); + + b.Property("ReportedByUserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ResponseHistory") + .HasMaxLength(4000) + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("ReportedByUserId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("TroubleReports"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.UserSkill", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AcquiredOn") + .HasColumnType("TEXT"); + + b.Property("ExpiresOn") + .HasColumnType("TEXT"); + + b.Property("SkillId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("SkillId"); + + b.HasIndex("UserId", "SkillId") + .IsUnique(); + + b.ToTable("UserSkills"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkCenter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Level") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("ParentId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("ParentId"); + + b.ToTable("WorkCenters"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AssignedEquipmentId") + .HasColumnType("INTEGER"); + + b.Property("AssignedUserId") + .HasColumnType("TEXT"); + + b.Property("ControlItems") + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("DispatchOrder") + .HasColumnType("INTEGER"); + + b.Property("ManufacturingOrderId") + .HasColumnType("INTEGER"); + + b.Property("PlannedQuantity") + .HasColumnType("TEXT"); + + b.Property("ProcessId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("RequiredSkillId") + .HasColumnType("INTEGER"); + + b.Property("RoutingChecklistId") + .HasColumnType("INTEGER"); + + b.Property("RoutingSequence") + .HasColumnType("INTEGER"); + + b.Property("StandardSetupMinutes") + .HasColumnType("TEXT"); + + b.Property("StandardWorkMinutes") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("WorkCenterId") + .HasColumnType("INTEGER"); + + b.Property("WorkOrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("WorkProcedureId") + .HasColumnType("INTEGER"); + + b.Property("WorkProcedureVersion") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AssignedEquipmentId"); + + b.HasIndex("AssignedUserId"); + + b.HasIndex("ManufacturingOrderId"); + + b.HasIndex("ProcessId"); + + b.HasIndex("ProductId"); + + b.HasIndex("RequiredSkillId"); + + b.HasIndex("RoutingChecklistId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("WorkOrderNo") + .IsUnique(); + + b.HasIndex("WorkProcedureId"); + + b.ToTable("WorkOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ControlItemId") + .HasColumnType("INTEGER"); + + b.Property("ItemCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ItemName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("ItemVersion") + .HasColumnType("INTEGER"); + + b.Property("LowerLimit") + .HasColumnType("TEXT"); + + b.Property("TargetValue") + .HasColumnType("TEXT"); + + b.Property("Unit") + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("UpperLimit") + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ControlItemId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("WorkOrderControlItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderStatusHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChangedAt") + .HasColumnType("TEXT"); + + b.Property("ChangedByUserId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("FromStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ToStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ChangedByUserId"); + + b.HasIndex("WorkOrderId", "Id"); + + b.ToTable("WorkOrderStatusHistories"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("ProcedureNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Reference") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Steps") + .IsRequired() + .HasMaxLength(4000) + .HasColumnType("TEXT"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("Version") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ProcedureNo") + .IsUnique(); + + b.ToTable("WorkProcedures"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkTimeRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("EndedAt") + .HasColumnType("TEXT"); + + b.Property("IndirectCategory") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("StartedAt") + .HasColumnType("TEXT"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("WorkOrderId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("WorkOrderId"); + + b.HasIndex("UserId", "StartedAt"); + + b.ToTable("WorkTimeRecords"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("ProviderKey") + .HasColumnType("TEXT"); + + b.Property("ProviderDisplayName") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.AppUser", b => + { + b.HasOne("MesApp.Core.Entities.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Shift"); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.BomItem", b => + { + b.HasOne("MesApp.Core.Entities.Product", "ChildProduct") + .WithMany() + .HasForeignKey("ChildProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "ParentProduct") + .WithMany() + .HasForeignKey("ParentProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChildProduct"); + + b.Navigation("ParentProduct"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistItem", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", null) + .WithMany("Items") + .HasForeignKey("ChecklistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", "Checklist") + .WithMany() + .HasForeignKey("ChecklistId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Checklist"); + + b.Navigation("Equipment"); + + b.Navigation("PerformedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistResultItem", b => + { + b.HasOne("MesApp.Core.Entities.ChecklistItem", "ChecklistItem") + .WithMany() + .HasForeignKey("ChecklistItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ChecklistRecord", null) + .WithMany("Results") + .HasForeignKey("ChecklistRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChecklistItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentLog", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Equipment"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentPart", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany("Parts") + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Equipment"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDeviceCalibration", b => + { + b.HasOne("MesApp.Core.Entities.InspectionDevice", "InspectionDevice") + .WithMany() + .HasForeignKey("InspectionDeviceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("InspectionDevice"); + + b.Navigation("PerformedBy"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionItem", b => + { + b.HasOne("MesApp.Core.Entities.ProcessMaster", "TargetProcess") + .WithMany() + .HasForeignKey("TargetProcessId"); + + b.HasOne("MesApp.Core.Entities.Product", "TargetProduct") + .WithMany() + .HasForeignKey("TargetProductId"); + + b.Navigation("TargetProcess"); + + b.Navigation("TargetProduct"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "RequestedBy") + .WithMany() + .HasForeignKey("RequestedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Lot", "TargetLot") + .WithMany() + .HasForeignKey("TargetLotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "TargetWorkOrder") + .WithMany() + .HasForeignKey("TargetWorkOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("RequestedBy"); + + b.Navigation("TargetLot"); + + b.Navigation("TargetWorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrderItem", b => + { + b.HasOne("MesApp.Core.Entities.InspectionItem", "InspectionItem") + .WithMany() + .HasForeignKey("InspectionItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionOrder", null) + .WithMany("Items") + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectionItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResult", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "InspectedBy") + .WithMany() + .HasForeignKey("InspectedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionDevice", "InspectionDevice") + .WithMany() + .HasForeignKey("InspectionDeviceId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.InspectionItem", "InspectionItem") + .WithMany() + .HasForeignKey("InspectionItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionOrder", null) + .WithMany("Results") + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectedBy"); + + b.Navigation("InspectionDevice"); + + b.Navigation("InspectionItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResultCorrection", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CorrectedBy") + .WithMany() + .HasForeignKey("CorrectedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.InspectionResult", "InspectionResult") + .WithMany() + .HasForeignKey("InspectionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CorrectedBy"); + + b.Navigation("InspectionResult"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryStock", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryTransaction", b => + { + b.HasOne("MesApp.Core.Entities.Location", "FromLocation") + .WithMany() + .HasForeignKey("FromLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "ToLocation") + .WithMany() + .HasForeignKey("ToLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("FromLocation"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("ToLocation"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Location", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Lot", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "ParentLot") + .WithMany() + .HasForeignKey("ParentLotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "SourceWorkOrder") + .WithMany() + .HasForeignKey("SourceWorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("ParentLot"); + + b.Navigation("Product"); + + b.Navigation("SourceWorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotGenealogy", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "ChildLot") + .WithMany() + .HasForeignKey("ChildLotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "ParentLot") + .WithMany() + .HasForeignKey("ParentLotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ChildLot"); + + b.Navigation("ParentLot"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotStatusHistory", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lot"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.MaintenancePlan", "MaintenancePlan") + .WithMany() + .HasForeignKey("MaintenancePlanId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.MaintenanceProcedure", "Procedure") + .WithMany() + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CreatedBy"); + + b.Navigation("Equipment"); + + b.Navigation("MaintenancePlan"); + + b.Navigation("Procedure"); + + b.Navigation("Tool"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenancePlan", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Equipment"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceProcedure", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "TargetEquipment") + .WithMany() + .HasForeignKey("TargetEquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Tool", "TargetTool") + .WithMany() + .HasForeignKey("TargetToolId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("TargetEquipment"); + + b.Navigation("TargetTool"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.HasOne("MesApp.Core.Entities.MaintenanceOrder", null) + .WithMany("Records") + .HasForeignKey("MaintenanceOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("PerformedBy"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecordPart", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.MaintenanceRecord", null) + .WithMany("Parts") + .HasForeignKey("MaintenanceRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "OutputLot") + .WithMany() + .HasForeignKey("OutputLotId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "SourceOrder") + .WithMany() + .HasForeignKey("SourceOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("OutputLot"); + + b.Navigation("Product"); + + b.Navigation("SourceOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrderMaterial", b => + { + b.HasOne("MesApp.Core.Entities.Product", "ChildProduct") + .WithMany() + .HasForeignKey("ChildProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ManufacturingOrder") + .WithMany("Materials") + .HasForeignKey("ManufacturingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChildProduct"); + + b.Navigation("ManufacturingOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaterialConsumption", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NonconformanceReport", b => + { + b.HasOne("MesApp.Core.Entities.InspectionOrder", "InspectionOrder") + .WithMany() + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.AppUser", "ReportedBy") + .WithMany() + .HasForeignKey("ReportedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ReworkOrder") + .WithMany() + .HasForeignKey("ReworkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("InspectionOrder"); + + b.Navigation("Lot"); + + b.Navigation("ReportedBy"); + + b.Navigation("ReworkOrder"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingLine", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.PickingOrder", null) + .WithMany("Lines") + .HasForeignKey("PickingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.HasOne("MesApp.Core.Entities.ShippingOrder", "ShippingOrder") + .WithMany() + .HasForeignKey("ShippingOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("ShippingOrder"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Product", b => + { + b.HasOne("MesApp.Core.Entities.Location", "DefaultLocation") + .WithMany() + .HasForeignKey("DefaultLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("DefaultLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDataRecord", b => + { + b.HasOne("MesApp.Core.Entities.WorkOrderControlItem", "WorkOrderControlItem") + .WithMany() + .HasForeignKey("WorkOrderControlItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkOrder"); + + b.Navigation("WorkOrderControlItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDefect", b => + { + b.HasOne("MesApp.Core.Entities.DefectReason", "DefectReason") + .WithMany() + .HasForeignKey("DefectReasonId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ProductionRecord", "ProductionRecord") + .WithMany("Defects") + .HasForeignKey("ProductionRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DefectReason"); + + b.Navigation("ProductionRecord"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionPlan", b => + { + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "OutputLot") + .WithMany() + .HasForeignKey("OutputLotId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OutputLot"); + + b.Navigation("PerformedBy"); + + b.Navigation("Shift"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecordCorrection", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CorrectedBy") + .WithMany() + .HasForeignKey("CorrectedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.ProductionRecord", "ProductionRecord") + .WithMany() + .HasForeignKey("ProductionRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CorrectedBy"); + + b.Navigation("ProductionRecord"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RefreshToken", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", "Checklist") + .WithMany() + .HasForeignKey("ChecklistId"); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId"); + + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.SkillMaster", "RequiredSkill") + .WithMany() + .HasForeignKey("RequiredSkillId"); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId"); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkProcedure", "WorkProcedure") + .WithMany() + .HasForeignKey("WorkProcedureId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Checklist"); + + b.Navigation("Equipment"); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("RequiredSkill"); + + b.Navigation("Tool"); + + b.Navigation("WorkCenter"); + + b.Navigation("WorkProcedure"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingControlItem", b => + { + b.HasOne("MesApp.Core.Entities.ControlItem", "ControlItem") + .WithMany() + .HasForeignKey("ControlItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Routing", "Routing") + .WithMany("ControlItemLinks") + .HasForeignKey("RoutingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ControlItem"); + + b.Navigation("Routing"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Routing", "Routing") + .WithMany("EquipmentCandidates") + .HasForeignKey("RoutingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Equipment"); + + b.Navigation("Routing"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SampleStorage", b => + { + b.HasOne("MesApp.Core.Entities.InspectionOrder", "InspectionOrder") + .WithMany() + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "StorageLocation") + .WithMany() + .HasForeignKey("StorageLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("InspectionOrder"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("StorageLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SetupRecord", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PerformedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShipmentJudgment", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "JudgedBy") + .WithMany() + .HasForeignKey("JudgedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.ShippingOrder", "ShippingOrder") + .WithMany() + .HasForeignKey("ShippingOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("JudgedBy"); + + b.Navigation("Lot"); + + b.Navigation("ShippingOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingLine", b => + { + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ShippingOrder", null) + .WithMany("Lines") + .HasForeignKey("ShippingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.HasOne("MesApp.Core.Entities.Location", "TargetLocation") + .WithMany() + .HasForeignKey("TargetLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("TargetLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.StocktakeLine", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Stocktake", null) + .WithMany("Lines") + .HasForeignKey("StocktakeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolIssue", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "IssuedTo") + .WithMany() + .HasForeignKey("IssuedToUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IssuedTo"); + + b.Navigation("Tool"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolUsage", b => + { + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Tool"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TransferOrder", b => + { + b.HasOne("MesApp.Core.Entities.Location", "FromLocation") + .WithMany() + .HasForeignKey("FromLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "ToLocation") + .WithMany() + .HasForeignKey("ToLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("FromLocation"); + + b.Navigation("Lot"); + + b.Navigation("ToLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TroubleReport", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.AppUser", "ReportedBy") + .WithMany() + .HasForeignKey("ReportedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Equipment"); + + b.Navigation("ReportedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.UserSkill", b => + { + b.HasOne("MesApp.Core.Entities.SkillMaster", "Skill") + .WithMany() + .HasForeignKey("SkillId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Skill"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkCenter", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "Parent") + .WithMany() + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "AssignedEquipment") + .WithMany() + .HasForeignKey("AssignedEquipmentId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.AppUser", "AssignedUser") + .WithMany() + .HasForeignKey("AssignedUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ManufacturingOrder") + .WithMany("WorkOrders") + .HasForeignKey("ManufacturingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.SkillMaster", "RequiredSkill") + .WithMany() + .HasForeignKey("RequiredSkillId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Checklist", "RoutingChecklist") + .WithMany() + .HasForeignKey("RoutingChecklistId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkProcedure", "WorkProcedure") + .WithMany() + .HasForeignKey("WorkProcedureId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("AssignedEquipment"); + + b.Navigation("AssignedUser"); + + b.Navigation("ManufacturingOrder"); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("RequiredSkill"); + + b.Navigation("RoutingChecklist"); + + b.Navigation("WorkCenter"); + + b.Navigation("WorkProcedure"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderControlItem", b => + { + b.HasOne("MesApp.Core.Entities.ControlItem", "ControlItem") + .WithMany() + .HasForeignKey("ControlItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany("ControlItemSnapshots") + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ControlItem"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderStatusHistory", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "ChangedBy") + .WithMany() + .HasForeignKey("ChangedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChangedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkTimeRecord", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("User"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Checklist", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.Navigation("Results"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.Navigation("Parts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.Navigation("Items"); + + b.Navigation("Results"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.Navigation("Records"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.Navigation("Parts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.Navigation("Materials"); + + b.Navigation("WorkOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.Navigation("Defects"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.Navigation("ControlItemLinks"); + + b.Navigation("EquipmentCandidates"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingOrder", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.Navigation("ControlItemSnapshots"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/MesApp.Infrastructure/Migrations/20260923081738_LinkControlItemsToRouting.cs b/src/MesApp.Infrastructure/Migrations/20260923081738_LinkControlItemsToRouting.cs new file mode 100644 index 0000000..f24ff37 --- /dev/null +++ b/src/MesApp.Infrastructure/Migrations/20260923081738_LinkControlItemsToRouting.cs @@ -0,0 +1,118 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MesApp.Infrastructure.Migrations +{ + /// + public partial class LinkControlItemsToRouting : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ControlItems_Processes_TargetProcessId", + table: "ControlItems"); + + migrationBuilder.DropForeignKey( + name: "FK_ControlItems_Products_TargetProductId", + table: "ControlItems"); + + migrationBuilder.DropIndex( + name: "IX_ControlItems_TargetProcessId", + table: "ControlItems"); + + migrationBuilder.DropIndex( + name: "IX_ControlItems_TargetProductId", + table: "ControlItems"); + + migrationBuilder.DropColumn( + name: "TargetProcessId", + table: "ControlItems"); + + migrationBuilder.DropColumn( + name: "TargetProductId", + table: "ControlItems"); + + migrationBuilder.CreateTable( + name: "RoutingControlItems", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + RoutingId = table.Column(type: "INTEGER", nullable: false), + ControlItemId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RoutingControlItems", x => x.Id); + table.ForeignKey( + name: "FK_RoutingControlItems_ControlItems_ControlItemId", + column: x => x.ControlItemId, + principalTable: "ControlItems", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_RoutingControlItems_Routings_RoutingId", + column: x => x.RoutingId, + principalTable: "Routings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_RoutingControlItems_ControlItemId", + table: "RoutingControlItems", + column: "ControlItemId"); + + migrationBuilder.CreateIndex( + name: "IX_RoutingControlItems_RoutingId_ControlItemId", + table: "RoutingControlItems", + columns: new[] { "RoutingId", "ControlItemId" }, + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "RoutingControlItems"); + + migrationBuilder.AddColumn( + name: "TargetProcessId", + table: "ControlItems", + type: "INTEGER", + nullable: true); + + migrationBuilder.AddColumn( + name: "TargetProductId", + table: "ControlItems", + type: "INTEGER", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_ControlItems_TargetProcessId", + table: "ControlItems", + column: "TargetProcessId"); + + migrationBuilder.CreateIndex( + name: "IX_ControlItems_TargetProductId", + table: "ControlItems", + column: "TargetProductId"); + + migrationBuilder.AddForeignKey( + name: "FK_ControlItems_Processes_TargetProcessId", + table: "ControlItems", + column: "TargetProcessId", + principalTable: "Processes", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_ControlItems_Products_TargetProductId", + table: "ControlItems", + column: "TargetProductId", + principalTable: "Products", + principalColumn: "Id"); + } + } +} diff --git a/src/MesApp.Infrastructure/Migrations/MesAppDbContextModelSnapshot.cs b/src/MesApp.Infrastructure/Migrations/MesAppDbContextModelSnapshot.cs index 340a655..19d0494 100644 --- a/src/MesApp.Infrastructure/Migrations/MesAppDbContextModelSnapshot.cs +++ b/src/MesApp.Infrastructure/Migrations/MesAppDbContextModelSnapshot.cs @@ -349,12 +349,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(200) .HasColumnType("TEXT"); - b.Property("TargetProcessId") - .HasColumnType("INTEGER"); - - b.Property("TargetProductId") - .HasColumnType("INTEGER"); - b.Property("TargetValue") .HasColumnType("TEXT"); @@ -373,10 +367,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Code") .IsUnique(); - b.HasIndex("TargetProcessId"); - - b.HasIndex("TargetProductId"); - b.ToTable("ControlItems"); }); @@ -2231,6 +2221,28 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Routings"); }); + modelBuilder.Entity("MesApp.Core.Entities.RoutingControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ControlItemId") + .HasColumnType("INTEGER"); + + b.Property("RoutingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ControlItemId"); + + b.HasIndex("RoutingId", "ControlItemId") + .IsUnique(); + + b.ToTable("RoutingControlItems"); + }); + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => { b.Property("Id") @@ -3420,21 +3432,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("ChecklistItem"); }); - modelBuilder.Entity("MesApp.Core.Entities.ControlItem", b => - { - b.HasOne("MesApp.Core.Entities.ProcessMaster", "TargetProcess") - .WithMany() - .HasForeignKey("TargetProcessId"); - - b.HasOne("MesApp.Core.Entities.Product", "TargetProduct") - .WithMany() - .HasForeignKey("TargetProductId"); - - b.Navigation("TargetProcess"); - - b.Navigation("TargetProduct"); - }); - modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => { b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") @@ -4220,6 +4217,25 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("WorkProcedure"); }); + modelBuilder.Entity("MesApp.Core.Entities.RoutingControlItem", b => + { + b.HasOne("MesApp.Core.Entities.ControlItem", "ControlItem") + .WithMany() + .HasForeignKey("ControlItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Routing", "Routing") + .WithMany("ControlItemLinks") + .HasForeignKey("RoutingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ControlItem"); + + b.Navigation("Routing"); + }); + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => { b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") @@ -4727,6 +4743,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("MesApp.Core.Entities.Routing", b => { + b.Navigation("ControlItemLinks"); + b.Navigation("EquipmentCandidates"); }); diff --git a/src/MesApp.Migrations.PostgreSql/Migrations/20260923081741_LinkControlItemsToRouting.Designer.cs b/src/MesApp.Migrations.PostgreSql/Migrations/20260923081741_LinkControlItemsToRouting.Designer.cs new file mode 100644 index 0000000..59e50c9 --- /dev/null +++ b/src/MesApp.Migrations.PostgreSql/Migrations/20260923081741_LinkControlItemsToRouting.Designer.cs @@ -0,0 +1,4970 @@ +// +using System; +using MesApp.Infrastructure; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MesApp.Migrations.PostgreSql.Migrations +{ + [DbContext(typeof(MesAppDbContext))] + [Migration("20260923081741_LinkControlItemsToRouting")] + partial class LinkControlItemsToRouting + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MesApp.Core.Entities.AppUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Department") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("MustChangePassword") + .HasColumnType("boolean"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("ShiftId") + .HasColumnType("integer"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("WorkCenterId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.HasIndex("ShiftId"); + + b.HasIndex("WorkCenterId"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Detail") + .HasColumnType("text"); + + b.Property("IpAddress") + .HasColumnType("text"); + + b.Property("RecordedOn") + .HasColumnType("date"); + + b.Property("TargetId") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("TargetType") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("UserId") + .HasColumnType("text"); + + b.Property("UserName") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RecordedOn"); + + b.HasIndex("Timestamp"); + + b.HasIndex("UserId"); + + b.HasIndex("Category", "Action"); + + b.HasIndex("TargetType", "TargetId"); + + b.ToTable("AuditLogs"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.BomItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AlternativeGroup") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ChildProductId") + .HasColumnType("integer"); + + b.Property("IsAlternative") + .HasColumnType("boolean"); + + b.Property("MakeOrBuy") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ParentProductId") + .HasColumnType("integer"); + + b.Property("QuantityPer") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("RoutingSequence") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ChildProductId"); + + b.HasIndex("ParentProductId", "ChildProductId") + .IsUnique(); + + b.ToTable("BomItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Checklist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Checklists"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChecklistId") + .HasColumnType("integer"); + + b.Property("IsRequired") + .HasColumnType("boolean"); + + b.Property("Sequence") + .HasColumnType("integer"); + + b.Property("Text") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.ToTable("ChecklistItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChecklistId") + .HasColumnType("integer"); + + b.Property("EquipmentId") + .HasColumnType("integer"); + + b.Property("PerformedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ChecklistRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistResultItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChecklistItemId") + .HasColumnType("integer"); + + b.Property("ChecklistRecordId") + .HasColumnType("integer"); + + b.Property("IsChecked") + .HasColumnType("boolean"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistItemId"); + + b.HasIndex("ChecklistRecordId"); + + b.ToTable("ChecklistResultItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("LowerLimit") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("TargetValue") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Unit") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("UpperLimit") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("ControlItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.DefectReason", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("DefectReasons"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssetNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("MaintenanceParts") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("MaintenanceThreshold") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("MaintenanceType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Site") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WorkCenterId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AssetNo") + .IsUnique(); + + b.HasIndex("WorkCenterId"); + + b.ToTable("Equipments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("EndedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("EquipmentId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("RecordedByUserId") + .HasColumnType("text"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("StopCause") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("EquipmentLogs"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentPart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("EquipmentId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("QuantityPer") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("EquipmentId", "ProductId") + .IsUnique(); + + b.ToTable("EquipmentParts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDevice", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CalibratedOn") + .HasColumnType("date"); + + b.Property("CalibrationCycleDays") + .HasColumnType("integer"); + + b.Property("CalibrationDueOn") + .HasColumnType("date"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Location") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("SerialNo") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("InspectionDevices"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDeviceCalibration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CalibratedOn") + .HasColumnType("date"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("InspectionDeviceId") + .HasColumnType("integer"); + + b.Property("NextDueOn") + .HasColumnType("date"); + + b.Property("PerformedByUserId") + .HasColumnType("text"); + + b.Property("Result") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.HasKey("Id"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("InspectionDeviceId", "CalibratedOn"); + + b.ToTable("InspectionDeviceCalibrations"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("LowerLimit") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Method") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("SamplingCount") + .HasColumnType("integer"); + + b.Property("StandardValue") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("TargetProcessId") + .HasColumnType("integer"); + + b.Property("TargetProductId") + .HasColumnType("integer"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("UpperLimit") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("TargetProcessId"); + + b.HasIndex("TargetProductId"); + + b.ToTable("InspectionItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ApprovedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovedByUserId") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("JudgedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("JudgedByUserId") + .HasColumnType("text"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OverallJudgment") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("RequestedByUserId") + .HasColumnType("text"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("TargetLotId") + .HasColumnType("integer"); + + b.Property("TargetWorkOrderId") + .HasColumnType("integer"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("RequestedByUserId"); + + b.HasIndex("Status"); + + b.HasIndex("TargetLotId"); + + b.HasIndex("TargetWorkOrderId"); + + b.ToTable("InspectionOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrderItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("InspectionItemId") + .HasColumnType("integer"); + + b.Property("InspectionOrderId") + .HasColumnType("integer"); + + b.Property("ItemCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ItemName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("ItemVersion") + .HasColumnType("integer"); + + b.Property("LowerLimit") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Method") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("SamplingCount") + .HasColumnType("integer"); + + b.Property("StandardValue") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("UpperLimit") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("InspectionItemId"); + + b.HasIndex("InspectionOrderId", "InspectionItemId") + .IsUnique(); + + b.ToTable("InspectionOrderItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CorrectionNote") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("InspectedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("InspectedByUserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("InspectionDeviceId") + .HasColumnType("integer"); + + b.Property("InspectionItemId") + .HasColumnType("integer"); + + b.Property("InspectionOrderId") + .HasColumnType("integer"); + + b.Property("Judgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("MeasuredValue") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("SampleNo") + .HasColumnType("integer"); + + b.Property("TextValue") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.HasKey("Id"); + + b.HasIndex("InspectedByUserId"); + + b.HasIndex("InspectionDeviceId"); + + b.HasIndex("InspectionItemId"); + + b.HasIndex("InspectionOrderId"); + + b.ToTable("InspectionResults"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResultCorrection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AfterJudgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("AfterMeasuredValue") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("AfterTextValue") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("BeforeJudgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("BeforeMeasuredValue") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("BeforeTextValue") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("CorrectedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CorrectedByUserId") + .HasMaxLength(450) + .HasColumnType("character varying(450)"); + + b.Property("InspectionOrderId") + .HasColumnType("integer"); + + b.Property("InspectionResultId") + .HasColumnType("integer"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.HasKey("Id"); + + b.HasIndex("CorrectedByUserId"); + + b.HasIndex("InspectionResultId"); + + b.HasIndex("InspectionOrderId", "Id"); + + b.ToTable("InspectionResultCorrections"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryStock", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("LocationId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId", "LocationId") + .IsUnique(); + + b.HasIndex("ProductId", "LocationId"); + + b.ToTable("InventoryStocks"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryTransaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FromLocationId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("PerformedByUserId") + .HasColumnType("text"); + + b.Property("PickingOrderId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("ShippingOrderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("ToLocationId") + .HasColumnType("integer"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FromLocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("Timestamp"); + + b.HasIndex("ToLocationId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("InventoryTransactions"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AreaType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("ShelfNo") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("WorkCenterId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("WorkCenterId"); + + b.ToTable("Locations"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Lot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ExpiresOn") + .HasColumnType("date"); + + b.Property("Grade") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("InitialQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("LotNumber") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("character varying(60)"); + + b.Property("ManufacturedOn") + .HasColumnType("date"); + + b.Property("OriginType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ParentLotId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("SourceWorkOrderId") + .HasColumnType("integer"); + + b.Property("StockStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("LotNumber") + .IsUnique(); + + b.HasIndex("ParentLotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SourceWorkOrderId"); + + b.ToTable("Lots"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotGenealogy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChildLotId") + .HasColumnType("integer"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ParentLotId") + .HasColumnType("integer"); + + b.Property("PerformedByUserId") + .HasMaxLength(450) + .HasColumnType("character varying(450)"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("RelationType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("ChildLotId"); + + b.HasIndex("ParentLotId"); + + b.ToTable("LotGenealogies"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotStatusHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChangedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ChangedByUserId") + .HasMaxLength(450) + .HasColumnType("character varying(450)"); + + b.Property("FromStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("InspectionOrderId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("NonconformanceReportId") + .HasColumnType("integer"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ToStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("LotId", "Id"); + + b.ToTable("LotStatusHistories"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByUserId") + .HasColumnType("text"); + + b.Property("EquipmentId") + .HasColumnType("integer"); + + b.Property("MaintenancePlanId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ProcedureId") + .HasColumnType("integer"); + + b.Property("RequestType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ScheduledDate") + .HasColumnType("date"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ToolId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CreatedByUserId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("MaintenancePlanId"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("ProcedureId"); + + b.HasIndex("Status"); + + b.HasIndex("ToolId"); + + b.ToTable("MaintenanceOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenancePlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByUserId") + .HasColumnType("text"); + + b.Property("CycleDays") + .HasColumnType("integer"); + + b.Property("EquipmentId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("PlanYear") + .HasColumnType("integer"); + + b.Property("ScheduledDate") + .HasColumnType("date"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId", "PlanYear"); + + b.ToTable("MaintenancePlans"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("ProcedureNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Steps") + .IsRequired() + .HasMaxLength(4000) + .HasColumnType("character varying(4000)"); + + b.Property("TargetEquipmentId") + .HasColumnType("integer"); + + b.Property("TargetToolId") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ProcedureNo") + .IsUnique(); + + b.HasIndex("TargetEquipmentId"); + + b.HasIndex("TargetToolId"); + + b.ToTable("MaintenanceProcedures"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("EndedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("MaintenanceOrderId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("PartsUsed") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Result") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("MaintenanceOrderId"); + + b.HasIndex("PerformedByUserId"); + + b.ToTable("MaintenanceRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecordPart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LocationId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("MaintenanceRecordId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("MaintenanceRecordId"); + + b.HasIndex("ProductId"); + + b.ToTable("MaintenanceRecordParts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ApprovedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovedByUserId") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByUserId") + .HasColumnType("text"); + + b.Property("DueDate") + .HasColumnType("date"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OrderType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("OutputLotId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("SourceOrderId") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("OutputLotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SourceOrderId"); + + b.HasIndex("Status"); + + b.ToTable("ManufacturingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrderMaterial", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AlternativeGroup") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ChildProductId") + .HasColumnType("integer"); + + b.Property("IsAlternative") + .HasColumnType("boolean"); + + b.Property("ManufacturingOrderId") + .HasColumnType("integer"); + + b.Property("PlannedQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("QuantityPer") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("RoutingSequence") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ChildProductId"); + + b.HasIndex("ManufacturingOrderId", "ChildProductId") + .IsUnique(); + + b.ToTable("ManufacturingOrderMaterials"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaterialConsumption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ConsumedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IsSubstitute") + .HasColumnType("boolean"); + + b.Property("LocationId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("Method") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("RecordedByUserId") + .HasColumnType("text"); + + b.Property("SubstituteReason") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("MaterialConsumptions"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NonconformanceReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ActionCompletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ActionCompletedByUserId") + .HasColumnType("text"); + + b.Property("ActionInstructedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ActionInstructedByUserId") + .HasColumnType("text"); + + b.Property("ActionInstruction") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("ActionRecord") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("ApprovedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovedByUserId") + .HasColumnType("text"); + + b.Property("CauseCategory") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("CauseDetail") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("InspectionOrderId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("ReportNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ReportedByUserId") + .HasColumnType("text"); + + b.Property("ReworkOrderId") + .HasColumnType("integer"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InspectionOrderId"); + + b.HasIndex("LotId"); + + b.HasIndex("ReportNo") + .IsUnique(); + + b.HasIndex("ReportedByUserId"); + + b.HasIndex("ReworkOrderId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("NonconformanceReports"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NumberSequence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LastValue") + .HasColumnType("integer"); + + b.Property("Prefix") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("character varying(60)"); + + b.HasKey("Id"); + + b.HasIndex("Prefix") + .IsUnique(); + + b.ToTable("NumberSequences"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LocationId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("PickingOrderId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("PickingOrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("PickingLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByUserId") + .HasColumnType("text"); + + b.Property("ExecutedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ExecutedByUserId") + .HasColumnType("text"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ShippingOrderId") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("ShippingOrderId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("PickingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProcessMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Processes", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DefaultLocationId") + .HasColumnType("integer"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Specification") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("StandardDefectRate") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Unit") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("DefaultLocationId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDataRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("IsDeviation") + .HasColumnType("boolean"); + + b.Property("Item") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("NumericValue") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("RecordedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("RecordedByUserId") + .HasColumnType("text"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("WorkOrderControlItemId") + .HasColumnType("integer"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("WorkOrderControlItemId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ProductionDataRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDefect", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DefectReasonId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("ProductionRecordId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("DefectReasonId"); + + b.HasIndex("ProductionRecordId"); + + b.ToTable("ProductionDefects"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BusinessDate") + .HasColumnType("date"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("PlannedQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("ProcessId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("WorkCenterId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ProcessId"); + + b.HasIndex("ProductId"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("BusinessDate", "ProductId", "ProcessId", "WorkCenterId") + .IsUnique(); + + b.ToTable("ProductionPlans"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ApprovedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovedByUserId") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DefectQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("EndedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("GoodQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("OutputLocationId") + .HasColumnType("integer"); + + b.Property("OutputLotId") + .HasColumnType("integer"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReworkQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("ScrapQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("ShiftId") + .HasColumnType("integer"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("OutputLotId"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("ShiftId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ProductionRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecordCorrection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AfterDefectQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("AfterGoodQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("AfterReworkQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("AfterScrapQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("BeforeDefectQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("BeforeGoodQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("BeforeReworkQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("BeforeScrapQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("CorrectedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CorrectedByUserId") + .HasMaxLength(450) + .HasColumnType("character varying(450)"); + + b.Property("ProductionRecordId") + .HasColumnType("integer"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CorrectedByUserId"); + + b.HasIndex("ProductionRecordId"); + + b.HasIndex("WorkOrderId", "Id"); + + b.ToTable("ProductionRecordCorrections"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RefreshToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.Property("RevokedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenHash") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("TokenHash") + .IsUnique(); + + b.HasIndex("UserId"); + + b.ToTable("RefreshTokens"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChecklistId") + .HasColumnType("integer"); + + b.Property("ControlItems") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("EquipmentId") + .HasColumnType("integer"); + + b.Property("ProcessId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("RequiredSkillId") + .HasColumnType("integer"); + + b.Property("Sequence") + .HasColumnType("integer"); + + b.Property("StandardSetupMinutes") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("StandardWorkMinutes") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("ToolId") + .HasColumnType("integer"); + + b.Property("WorkCenterId") + .HasColumnType("integer"); + + b.Property("WorkProcedureId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("ProcessId"); + + b.HasIndex("RequiredSkillId"); + + b.HasIndex("ToolId"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("WorkProcedureId"); + + b.HasIndex("ProductId", "Sequence") + .IsUnique(); + + b.ToTable("Routings"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ControlItemId") + .HasColumnType("integer"); + + b.Property("RoutingId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ControlItemId"); + + b.HasIndex("RoutingId", "ControlItemId") + .IsUnique(); + + b.ToTable("RoutingControlItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EquipmentId") + .HasColumnType("integer"); + + b.Property("RoutingId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("RoutingId", "EquipmentId") + .IsUnique(); + + b.ToTable("RoutingEquipments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SampleStorage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClosedByUserId") + .HasColumnType("text"); + + b.Property("ClosedOn") + .HasColumnType("date"); + + b.Property("CollectedByUserId") + .HasColumnType("text"); + + b.Property("CollectedOn") + .HasColumnType("date"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("InspectionOrderId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("RetainUntil") + .HasColumnType("date"); + + b.Property("SampleNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StorageLocationId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InspectionOrderId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SampleNo") + .IsUnique(); + + b.HasIndex("StorageLocationId"); + + b.HasIndex("Status", "RetainUntil"); + + b.ToTable("SampleStorages"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SetupRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AbnormalityNote") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("EndedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("SetupRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Shift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("EndTime") + .HasColumnType("time without time zone"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("StartTime") + .HasColumnType("time without time zone"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Shifts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShipmentJudgment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ApprovedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovedByUserId") + .HasColumnType("text"); + + b.Property("JudgedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("JudgedByUserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("JudgmentNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("Result") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ShippingOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("JudgedByUserId"); + + b.HasIndex("JudgmentNo") + .IsUnique(); + + b.HasIndex("LotId"); + + b.HasIndex("ShippingOrderId"); + + b.ToTable("ShipmentJudgments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("ShippedQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("ShippingOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("ShippingOrderId"); + + b.ToTable("ShippingLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByUserId") + .HasColumnType("text"); + + b.Property("Destination") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("PlannedDate") + .HasColumnType("date"); + + b.Property("ShippedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ShippedByUserId") + .HasColumnType("text"); + + b.Property("ShippingNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("ShippingNo") + .IsUnique(); + + b.ToTable("ShippingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SkillMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("RequiresExpiry") + .HasColumnType("boolean"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Skills", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByUserId") + .HasColumnType("text"); + + b.Property("FinalizedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("FinalizedByUserId") + .HasColumnType("text"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("StocktakeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("TargetLocationId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("StocktakeNo") + .IsUnique(); + + b.HasIndex("TargetLocationId"); + + b.ToTable("Stocktakes"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.StocktakeLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CountedQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("IsAdjusted") + .HasColumnType("boolean"); + + b.Property("LocationId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("StocktakeId") + .HasColumnType("integer"); + + b.Property("TheoreticalQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("StocktakeId"); + + b.ToTable("StocktakeLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Tool", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("LifeResetAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LifeThresholdCount") + .HasColumnType("integer"); + + b.Property("LifeThresholdHours") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ToolType") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Tools"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolIssue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("AllocatedByUserId") + .HasColumnType("text"); + + b.Property("IssuedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IssuedToUserId") + .HasColumnType("text"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("ReturnedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ReturnedByUserId") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("ToolId") + .HasColumnType("integer"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("IssuedToUserId"); + + b.HasIndex("WorkOrderId"); + + b.HasIndex("ToolId", "Status"); + + b.ToTable("ToolIssues"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolUsage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("RecordedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("RecordedByUserId") + .HasColumnType("text"); + + b.Property("ToolId") + .HasColumnType("integer"); + + b.Property("UsageCount") + .HasColumnType("integer"); + + b.Property("UsageHours") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ToolId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ToolUsages"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TransferOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByUserId") + .HasColumnType("text"); + + b.Property("ExecutedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ExecutedByUserId") + .HasColumnType("text"); + + b.Property("FromLocationId") + .HasColumnType("integer"); + + b.Property("LotId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ToLocationId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FromLocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("Status"); + + b.HasIndex("ToLocationId"); + + b.ToTable("TransferOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TroubleReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("EquipmentId") + .HasColumnType("integer"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ReportedByUserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ResponseHistory") + .HasMaxLength(4000) + .HasColumnType("character varying(4000)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("ReportedByUserId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("TroubleReports"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.UserSkill", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AcquiredOn") + .HasColumnType("date"); + + b.Property("ExpiresOn") + .HasColumnType("date"); + + b.Property("SkillId") + .HasColumnType("integer"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("SkillId"); + + b.HasIndex("UserId", "SkillId") + .IsUnique(); + + b.ToTable("UserSkills"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkCenter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Level") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("ParentId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("ParentId"); + + b.ToTable("WorkCenters"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssignedEquipmentId") + .HasColumnType("integer"); + + b.Property("AssignedUserId") + .HasColumnType("text"); + + b.Property("ControlItems") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DispatchOrder") + .HasColumnType("integer"); + + b.Property("ManufacturingOrderId") + .HasColumnType("integer"); + + b.Property("PlannedQuantity") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("ProcessId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("RequiredSkillId") + .HasColumnType("integer"); + + b.Property("RoutingChecklistId") + .HasColumnType("integer"); + + b.Property("RoutingSequence") + .HasColumnType("integer"); + + b.Property("StandardSetupMinutes") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("StandardWorkMinutes") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WorkCenterId") + .HasColumnType("integer"); + + b.Property("WorkOrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("WorkProcedureId") + .HasColumnType("integer"); + + b.Property("WorkProcedureVersion") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AssignedEquipmentId"); + + b.HasIndex("AssignedUserId"); + + b.HasIndex("ManufacturingOrderId"); + + b.HasIndex("ProcessId"); + + b.HasIndex("ProductId"); + + b.HasIndex("RequiredSkillId"); + + b.HasIndex("RoutingChecklistId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("WorkOrderNo") + .IsUnique(); + + b.HasIndex("WorkProcedureId"); + + b.ToTable("WorkOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ControlItemId") + .HasColumnType("integer"); + + b.Property("ItemCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ItemName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("ItemVersion") + .HasColumnType("integer"); + + b.Property("LowerLimit") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("TargetValue") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("Unit") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("UpperLimit") + .HasPrecision(18, 6) + .HasColumnType("numeric(18,6)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ControlItemId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("WorkOrderControlItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderStatusHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChangedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ChangedByUserId") + .HasMaxLength(450) + .HasColumnType("character varying(450)"); + + b.Property("FromStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ToStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ChangedByUserId"); + + b.HasIndex("WorkOrderId", "Id"); + + b.ToTable("WorkOrderStatusHistories"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("ProcedureNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Reference") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Steps") + .IsRequired() + .HasMaxLength(4000) + .HasColumnType("character varying(4000)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ProcedureNo") + .IsUnique(); + + b.ToTable("WorkProcedures"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkTimeRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EndedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IndirectCategory") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkOrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("WorkOrderId"); + + b.HasIndex("UserId", "StartedAt"); + + b.ToTable("WorkTimeRecords"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.AppUser", b => + { + b.HasOne("MesApp.Core.Entities.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Shift"); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.BomItem", b => + { + b.HasOne("MesApp.Core.Entities.Product", "ChildProduct") + .WithMany() + .HasForeignKey("ChildProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "ParentProduct") + .WithMany() + .HasForeignKey("ParentProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChildProduct"); + + b.Navigation("ParentProduct"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistItem", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", null) + .WithMany("Items") + .HasForeignKey("ChecklistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", "Checklist") + .WithMany() + .HasForeignKey("ChecklistId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Checklist"); + + b.Navigation("Equipment"); + + b.Navigation("PerformedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistResultItem", b => + { + b.HasOne("MesApp.Core.Entities.ChecklistItem", "ChecklistItem") + .WithMany() + .HasForeignKey("ChecklistItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ChecklistRecord", null) + .WithMany("Results") + .HasForeignKey("ChecklistRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChecklistItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentLog", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Equipment"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentPart", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany("Parts") + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Equipment"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDeviceCalibration", b => + { + b.HasOne("MesApp.Core.Entities.InspectionDevice", "InspectionDevice") + .WithMany() + .HasForeignKey("InspectionDeviceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("InspectionDevice"); + + b.Navigation("PerformedBy"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionItem", b => + { + b.HasOne("MesApp.Core.Entities.ProcessMaster", "TargetProcess") + .WithMany() + .HasForeignKey("TargetProcessId"); + + b.HasOne("MesApp.Core.Entities.Product", "TargetProduct") + .WithMany() + .HasForeignKey("TargetProductId"); + + b.Navigation("TargetProcess"); + + b.Navigation("TargetProduct"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "RequestedBy") + .WithMany() + .HasForeignKey("RequestedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Lot", "TargetLot") + .WithMany() + .HasForeignKey("TargetLotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "TargetWorkOrder") + .WithMany() + .HasForeignKey("TargetWorkOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("RequestedBy"); + + b.Navigation("TargetLot"); + + b.Navigation("TargetWorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrderItem", b => + { + b.HasOne("MesApp.Core.Entities.InspectionItem", "InspectionItem") + .WithMany() + .HasForeignKey("InspectionItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionOrder", null) + .WithMany("Items") + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectionItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResult", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "InspectedBy") + .WithMany() + .HasForeignKey("InspectedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionDevice", "InspectionDevice") + .WithMany() + .HasForeignKey("InspectionDeviceId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.InspectionItem", "InspectionItem") + .WithMany() + .HasForeignKey("InspectionItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionOrder", null) + .WithMany("Results") + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectedBy"); + + b.Navigation("InspectionDevice"); + + b.Navigation("InspectionItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResultCorrection", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CorrectedBy") + .WithMany() + .HasForeignKey("CorrectedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.InspectionResult", "InspectionResult") + .WithMany() + .HasForeignKey("InspectionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CorrectedBy"); + + b.Navigation("InspectionResult"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryStock", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryTransaction", b => + { + b.HasOne("MesApp.Core.Entities.Location", "FromLocation") + .WithMany() + .HasForeignKey("FromLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "ToLocation") + .WithMany() + .HasForeignKey("ToLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("FromLocation"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("ToLocation"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Location", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Lot", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "ParentLot") + .WithMany() + .HasForeignKey("ParentLotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "SourceWorkOrder") + .WithMany() + .HasForeignKey("SourceWorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("ParentLot"); + + b.Navigation("Product"); + + b.Navigation("SourceWorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotGenealogy", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "ChildLot") + .WithMany() + .HasForeignKey("ChildLotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "ParentLot") + .WithMany() + .HasForeignKey("ParentLotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ChildLot"); + + b.Navigation("ParentLot"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotStatusHistory", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lot"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.MaintenancePlan", "MaintenancePlan") + .WithMany() + .HasForeignKey("MaintenancePlanId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.MaintenanceProcedure", "Procedure") + .WithMany() + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CreatedBy"); + + b.Navigation("Equipment"); + + b.Navigation("MaintenancePlan"); + + b.Navigation("Procedure"); + + b.Navigation("Tool"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenancePlan", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Equipment"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceProcedure", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "TargetEquipment") + .WithMany() + .HasForeignKey("TargetEquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Tool", "TargetTool") + .WithMany() + .HasForeignKey("TargetToolId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("TargetEquipment"); + + b.Navigation("TargetTool"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.HasOne("MesApp.Core.Entities.MaintenanceOrder", null) + .WithMany("Records") + .HasForeignKey("MaintenanceOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("PerformedBy"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecordPart", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.MaintenanceRecord", null) + .WithMany("Parts") + .HasForeignKey("MaintenanceRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "OutputLot") + .WithMany() + .HasForeignKey("OutputLotId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "SourceOrder") + .WithMany() + .HasForeignKey("SourceOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("OutputLot"); + + b.Navigation("Product"); + + b.Navigation("SourceOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrderMaterial", b => + { + b.HasOne("MesApp.Core.Entities.Product", "ChildProduct") + .WithMany() + .HasForeignKey("ChildProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ManufacturingOrder") + .WithMany("Materials") + .HasForeignKey("ManufacturingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChildProduct"); + + b.Navigation("ManufacturingOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaterialConsumption", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NonconformanceReport", b => + { + b.HasOne("MesApp.Core.Entities.InspectionOrder", "InspectionOrder") + .WithMany() + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.AppUser", "ReportedBy") + .WithMany() + .HasForeignKey("ReportedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ReworkOrder") + .WithMany() + .HasForeignKey("ReworkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("InspectionOrder"); + + b.Navigation("Lot"); + + b.Navigation("ReportedBy"); + + b.Navigation("ReworkOrder"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingLine", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.PickingOrder", null) + .WithMany("Lines") + .HasForeignKey("PickingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.HasOne("MesApp.Core.Entities.ShippingOrder", "ShippingOrder") + .WithMany() + .HasForeignKey("ShippingOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("ShippingOrder"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Product", b => + { + b.HasOne("MesApp.Core.Entities.Location", "DefaultLocation") + .WithMany() + .HasForeignKey("DefaultLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("DefaultLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDataRecord", b => + { + b.HasOne("MesApp.Core.Entities.WorkOrderControlItem", "WorkOrderControlItem") + .WithMany() + .HasForeignKey("WorkOrderControlItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkOrder"); + + b.Navigation("WorkOrderControlItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDefect", b => + { + b.HasOne("MesApp.Core.Entities.DefectReason", "DefectReason") + .WithMany() + .HasForeignKey("DefectReasonId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ProductionRecord", "ProductionRecord") + .WithMany("Defects") + .HasForeignKey("ProductionRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DefectReason"); + + b.Navigation("ProductionRecord"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionPlan", b => + { + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "OutputLot") + .WithMany() + .HasForeignKey("OutputLotId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OutputLot"); + + b.Navigation("PerformedBy"); + + b.Navigation("Shift"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecordCorrection", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CorrectedBy") + .WithMany() + .HasForeignKey("CorrectedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.ProductionRecord", "ProductionRecord") + .WithMany() + .HasForeignKey("ProductionRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CorrectedBy"); + + b.Navigation("ProductionRecord"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RefreshToken", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", "Checklist") + .WithMany() + .HasForeignKey("ChecklistId"); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId"); + + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.SkillMaster", "RequiredSkill") + .WithMany() + .HasForeignKey("RequiredSkillId"); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId"); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkProcedure", "WorkProcedure") + .WithMany() + .HasForeignKey("WorkProcedureId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Checklist"); + + b.Navigation("Equipment"); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("RequiredSkill"); + + b.Navigation("Tool"); + + b.Navigation("WorkCenter"); + + b.Navigation("WorkProcedure"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingControlItem", b => + { + b.HasOne("MesApp.Core.Entities.ControlItem", "ControlItem") + .WithMany() + .HasForeignKey("ControlItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Routing", "Routing") + .WithMany("ControlItemLinks") + .HasForeignKey("RoutingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ControlItem"); + + b.Navigation("Routing"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Routing", "Routing") + .WithMany("EquipmentCandidates") + .HasForeignKey("RoutingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Equipment"); + + b.Navigation("Routing"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SampleStorage", b => + { + b.HasOne("MesApp.Core.Entities.InspectionOrder", "InspectionOrder") + .WithMany() + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "StorageLocation") + .WithMany() + .HasForeignKey("StorageLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("InspectionOrder"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("StorageLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SetupRecord", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PerformedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShipmentJudgment", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "JudgedBy") + .WithMany() + .HasForeignKey("JudgedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.ShippingOrder", "ShippingOrder") + .WithMany() + .HasForeignKey("ShippingOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("JudgedBy"); + + b.Navigation("Lot"); + + b.Navigation("ShippingOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingLine", b => + { + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ShippingOrder", null) + .WithMany("Lines") + .HasForeignKey("ShippingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.HasOne("MesApp.Core.Entities.Location", "TargetLocation") + .WithMany() + .HasForeignKey("TargetLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("TargetLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.StocktakeLine", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Stocktake", null) + .WithMany("Lines") + .HasForeignKey("StocktakeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolIssue", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "IssuedTo") + .WithMany() + .HasForeignKey("IssuedToUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IssuedTo"); + + b.Navigation("Tool"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolUsage", b => + { + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Tool"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TransferOrder", b => + { + b.HasOne("MesApp.Core.Entities.Location", "FromLocation") + .WithMany() + .HasForeignKey("FromLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "ToLocation") + .WithMany() + .HasForeignKey("ToLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("FromLocation"); + + b.Navigation("Lot"); + + b.Navigation("ToLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TroubleReport", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.AppUser", "ReportedBy") + .WithMany() + .HasForeignKey("ReportedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Equipment"); + + b.Navigation("ReportedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.UserSkill", b => + { + b.HasOne("MesApp.Core.Entities.SkillMaster", "Skill") + .WithMany() + .HasForeignKey("SkillId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Skill"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkCenter", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "Parent") + .WithMany() + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "AssignedEquipment") + .WithMany() + .HasForeignKey("AssignedEquipmentId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.AppUser", "AssignedUser") + .WithMany() + .HasForeignKey("AssignedUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ManufacturingOrder") + .WithMany("WorkOrders") + .HasForeignKey("ManufacturingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.SkillMaster", "RequiredSkill") + .WithMany() + .HasForeignKey("RequiredSkillId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Checklist", "RoutingChecklist") + .WithMany() + .HasForeignKey("RoutingChecklistId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkProcedure", "WorkProcedure") + .WithMany() + .HasForeignKey("WorkProcedureId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("AssignedEquipment"); + + b.Navigation("AssignedUser"); + + b.Navigation("ManufacturingOrder"); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("RequiredSkill"); + + b.Navigation("RoutingChecklist"); + + b.Navigation("WorkCenter"); + + b.Navigation("WorkProcedure"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderControlItem", b => + { + b.HasOne("MesApp.Core.Entities.ControlItem", "ControlItem") + .WithMany() + .HasForeignKey("ControlItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany("ControlItemSnapshots") + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ControlItem"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderStatusHistory", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "ChangedBy") + .WithMany() + .HasForeignKey("ChangedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChangedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkTimeRecord", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("User"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Checklist", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.Navigation("Results"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.Navigation("Parts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.Navigation("Items"); + + b.Navigation("Results"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.Navigation("Records"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.Navigation("Parts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.Navigation("Materials"); + + b.Navigation("WorkOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.Navigation("Defects"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.Navigation("ControlItemLinks"); + + b.Navigation("EquipmentCandidates"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingOrder", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.Navigation("ControlItemSnapshots"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/MesApp.Migrations.PostgreSql/Migrations/20260923081741_LinkControlItemsToRouting.cs b/src/MesApp.Migrations.PostgreSql/Migrations/20260923081741_LinkControlItemsToRouting.cs new file mode 100644 index 0000000..bb7773e --- /dev/null +++ b/src/MesApp.Migrations.PostgreSql/Migrations/20260923081741_LinkControlItemsToRouting.cs @@ -0,0 +1,119 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MesApp.Migrations.PostgreSql.Migrations +{ + /// + public partial class LinkControlItemsToRouting : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ControlItems_Processes_TargetProcessId", + table: "ControlItems"); + + migrationBuilder.DropForeignKey( + name: "FK_ControlItems_Products_TargetProductId", + table: "ControlItems"); + + migrationBuilder.DropIndex( + name: "IX_ControlItems_TargetProcessId", + table: "ControlItems"); + + migrationBuilder.DropIndex( + name: "IX_ControlItems_TargetProductId", + table: "ControlItems"); + + migrationBuilder.DropColumn( + name: "TargetProcessId", + table: "ControlItems"); + + migrationBuilder.DropColumn( + name: "TargetProductId", + table: "ControlItems"); + + migrationBuilder.CreateTable( + name: "RoutingControlItems", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RoutingId = table.Column(type: "integer", nullable: false), + ControlItemId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RoutingControlItems", x => x.Id); + table.ForeignKey( + name: "FK_RoutingControlItems_ControlItems_ControlItemId", + column: x => x.ControlItemId, + principalTable: "ControlItems", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_RoutingControlItems_Routings_RoutingId", + column: x => x.RoutingId, + principalTable: "Routings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_RoutingControlItems_ControlItemId", + table: "RoutingControlItems", + column: "ControlItemId"); + + migrationBuilder.CreateIndex( + name: "IX_RoutingControlItems_RoutingId_ControlItemId", + table: "RoutingControlItems", + columns: new[] { "RoutingId", "ControlItemId" }, + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "RoutingControlItems"); + + migrationBuilder.AddColumn( + name: "TargetProcessId", + table: "ControlItems", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "TargetProductId", + table: "ControlItems", + type: "integer", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_ControlItems_TargetProcessId", + table: "ControlItems", + column: "TargetProcessId"); + + migrationBuilder.CreateIndex( + name: "IX_ControlItems_TargetProductId", + table: "ControlItems", + column: "TargetProductId"); + + migrationBuilder.AddForeignKey( + name: "FK_ControlItems_Processes_TargetProcessId", + table: "ControlItems", + column: "TargetProcessId", + principalTable: "Processes", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_ControlItems_Products_TargetProductId", + table: "ControlItems", + column: "TargetProductId", + principalTable: "Products", + principalColumn: "Id"); + } + } +} diff --git a/src/MesApp.Migrations.PostgreSql/Migrations/MesAppDbContextModelSnapshot.cs b/src/MesApp.Migrations.PostgreSql/Migrations/MesAppDbContextModelSnapshot.cs index b45ab8e..e6882d5 100644 --- a/src/MesApp.Migrations.PostgreSql/Migrations/MesAppDbContextModelSnapshot.cs +++ b/src/MesApp.Migrations.PostgreSql/Migrations/MesAppDbContextModelSnapshot.cs @@ -370,12 +370,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(200) .HasColumnType("character varying(200)"); - b.Property("TargetProcessId") - .HasColumnType("integer"); - - b.Property("TargetProductId") - .HasColumnType("integer"); - b.Property("TargetValue") .HasPrecision(18, 6) .HasColumnType("numeric(18,6)"); @@ -396,10 +390,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Code") .IsUnique(); - b.HasIndex("TargetProcessId"); - - b.HasIndex("TargetProductId"); - b.ToTable("ControlItems"); }); @@ -2367,6 +2357,30 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Routings"); }); + modelBuilder.Entity("MesApp.Core.Entities.RoutingControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ControlItemId") + .HasColumnType("integer"); + + b.Property("RoutingId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ControlItemId"); + + b.HasIndex("RoutingId", "ControlItemId") + .IsUnique(); + + b.ToTable("RoutingControlItems"); + }); + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => { b.Property("Id") @@ -3617,21 +3631,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("ChecklistItem"); }); - modelBuilder.Entity("MesApp.Core.Entities.ControlItem", b => - { - b.HasOne("MesApp.Core.Entities.ProcessMaster", "TargetProcess") - .WithMany() - .HasForeignKey("TargetProcessId"); - - b.HasOne("MesApp.Core.Entities.Product", "TargetProduct") - .WithMany() - .HasForeignKey("TargetProductId"); - - b.Navigation("TargetProcess"); - - b.Navigation("TargetProduct"); - }); - modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => { b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") @@ -4417,6 +4416,25 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("WorkProcedure"); }); + modelBuilder.Entity("MesApp.Core.Entities.RoutingControlItem", b => + { + b.HasOne("MesApp.Core.Entities.ControlItem", "ControlItem") + .WithMany() + .HasForeignKey("ControlItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Routing", "Routing") + .WithMany("ControlItemLinks") + .HasForeignKey("RoutingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ControlItem"); + + b.Navigation("Routing"); + }); + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => { b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") @@ -4924,6 +4942,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("MesApp.Core.Entities.Routing", b => { + b.Navigation("ControlItemLinks"); + b.Navigation("EquipmentCandidates"); }); diff --git a/src/MesApp.Migrations.SqlServer/Migrations/20260923081743_LinkControlItemsToRouting.Designer.cs b/src/MesApp.Migrations.SqlServer/Migrations/20260923081743_LinkControlItemsToRouting.Designer.cs new file mode 100644 index 0000000..8334649 --- /dev/null +++ b/src/MesApp.Migrations.SqlServer/Migrations/20260923081743_LinkControlItemsToRouting.Designer.cs @@ -0,0 +1,4949 @@ +// +using System; +using MesApp.Infrastructure; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace MesApp.Migrations.SqlServer.Migrations +{ + [DbContext(typeof(MesAppDbContext))] + [Migration("20260923081743_LinkControlItemsToRouting")] + partial class LinkControlItemsToRouting + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("MesApp.Core.Entities.AppUser", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("Department") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("MustChangePassword") + .HasColumnType("bit"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("ShiftId") + .HasColumnType("int"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("WorkCenterId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.HasIndex("ShiftId"); + + b.HasIndex("WorkCenterId"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Detail") + .HasColumnType("nvarchar(max)"); + + b.Property("IpAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("RecordedOn") + .HasColumnType("date"); + + b.Property("TargetId") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("TargetType") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Timestamp") + .HasColumnType("datetimeoffset"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("UserName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("RecordedOn"); + + b.HasIndex("Timestamp"); + + b.HasIndex("UserId"); + + b.HasIndex("Category", "Action"); + + b.HasIndex("TargetType", "TargetId"); + + b.ToTable("AuditLogs"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.BomItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AlternativeGroup") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ChildProductId") + .HasColumnType("int"); + + b.Property("IsAlternative") + .HasColumnType("bit"); + + b.Property("MakeOrBuy") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ParentProductId") + .HasColumnType("int"); + + b.Property("QuantityPer") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("RoutingSequence") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChildProductId"); + + b.HasIndex("ParentProductId", "ChildProductId") + .IsUnique(); + + b.ToTable("BomItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Checklist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Checklists"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChecklistId") + .HasColumnType("int"); + + b.Property("IsRequired") + .HasColumnType("bit"); + + b.Property("Sequence") + .HasColumnType("int"); + + b.Property("Text") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.ToTable("ChecklistItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChecklistId") + .HasColumnType("int"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("PerformedAt") + .HasColumnType("datetimeoffset"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ChecklistRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistResultItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChecklistItemId") + .HasColumnType("int"); + + b.Property("ChecklistRecordId") + .HasColumnType("int"); + + b.Property("IsChecked") + .HasColumnType("bit"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistItemId"); + + b.HasIndex("ChecklistRecordId"); + + b.ToTable("ChecklistResultItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("LowerLimit") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("TargetValue") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Unit") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("UpperLimit") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("ControlItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.DefectReason", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("DefectReasons"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AssetNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("MaintenanceParts") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("MaintenanceThreshold") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("MaintenanceType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Site") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("WorkCenterId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AssetNo") + .IsUnique(); + + b.HasIndex("WorkCenterId"); + + b.ToTable("Equipments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("EndedAt") + .HasColumnType("datetimeoffset"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RecordedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("StartedAt") + .HasColumnType("datetimeoffset"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("StopCause") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("EquipmentLogs"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentPart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("QuantityPer") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("EquipmentId", "ProductId") + .IsUnique(); + + b.ToTable("EquipmentParts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDevice", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalibratedOn") + .HasColumnType("date"); + + b.Property("CalibrationCycleDays") + .HasColumnType("int"); + + b.Property("CalibrationDueOn") + .HasColumnType("date"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Location") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("SerialNo") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("InspectionDevices"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDeviceCalibration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalibratedOn") + .HasColumnType("date"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("InspectionDeviceId") + .HasColumnType("int"); + + b.Property("NextDueOn") + .HasColumnType("date"); + + b.Property("PerformedByUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("Result") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("InspectionDeviceId", "CalibratedOn"); + + b.ToTable("InspectionDeviceCalibrations"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("LowerLimit") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Method") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("SamplingCount") + .HasColumnType("int"); + + b.Property("StandardValue") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("TargetProcessId") + .HasColumnType("int"); + + b.Property("TargetProductId") + .HasColumnType("int"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("UpperLimit") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("TargetProcessId"); + + b.HasIndex("TargetProductId"); + + b.ToTable("InspectionItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ApprovedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ApprovedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("JudgedAt") + .HasColumnType("datetimeoffset"); + + b.Property("JudgedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("OverallJudgment") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("RequestedByUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("TargetLotId") + .HasColumnType("int"); + + b.Property("TargetWorkOrderId") + .HasColumnType("int"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("RequestedByUserId"); + + b.HasIndex("Status"); + + b.HasIndex("TargetLotId"); + + b.HasIndex("TargetWorkOrderId"); + + b.ToTable("InspectionOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrderItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("InspectionItemId") + .HasColumnType("int"); + + b.Property("InspectionOrderId") + .HasColumnType("int"); + + b.Property("ItemCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ItemName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("ItemVersion") + .HasColumnType("int"); + + b.Property("LowerLimit") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Method") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("SamplingCount") + .HasColumnType("int"); + + b.Property("StandardValue") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("UpperLimit") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("InspectionItemId"); + + b.HasIndex("InspectionOrderId", "InspectionItemId") + .IsUnique(); + + b.ToTable("InspectionOrderItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CorrectionNote") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("InspectedAt") + .HasColumnType("datetimeoffset"); + + b.Property("InspectedByUserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("InspectionDeviceId") + .HasColumnType("int"); + + b.Property("InspectionItemId") + .HasColumnType("int"); + + b.Property("InspectionOrderId") + .HasColumnType("int"); + + b.Property("Judgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("MeasuredValue") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("SampleNo") + .HasColumnType("int"); + + b.Property("TextValue") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("InspectedByUserId"); + + b.HasIndex("InspectionDeviceId"); + + b.HasIndex("InspectionItemId"); + + b.HasIndex("InspectionOrderId"); + + b.ToTable("InspectionResults"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResultCorrection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AfterJudgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("AfterMeasuredValue") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("AfterTextValue") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("BeforeJudgment") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("BeforeMeasuredValue") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("BeforeTextValue") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CorrectedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CorrectedByUserId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("InspectionOrderId") + .HasColumnType("int"); + + b.Property("InspectionResultId") + .HasColumnType("int"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("CorrectedByUserId"); + + b.HasIndex("InspectionResultId"); + + b.HasIndex("InspectionOrderId", "Id"); + + b.ToTable("InspectionResultCorrections"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryStock", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId", "LocationId") + .IsUnique(); + + b.HasIndex("ProductId", "LocationId"); + + b.ToTable("InventoryStocks"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryTransaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FromLocationId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("PerformedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("PickingOrderId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("ShippingOrderId") + .HasColumnType("int"); + + b.Property("Timestamp") + .HasColumnType("datetimeoffset"); + + b.Property("ToLocationId") + .HasColumnType("int"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("FromLocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("Timestamp"); + + b.HasIndex("ToLocationId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("InventoryTransactions"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AreaType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("ShelfNo") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("WorkCenterId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("WorkCenterId"); + + b.ToTable("Locations"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Lot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ExpiresOn") + .HasColumnType("date"); + + b.Property("Grade") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("InitialQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("LotNumber") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.Property("ManufacturedOn") + .HasColumnType("date"); + + b.Property("OriginType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ParentLotId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("SourceWorkOrderId") + .HasColumnType("int"); + + b.Property("StockStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("LotNumber") + .IsUnique(); + + b.HasIndex("ParentLotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SourceWorkOrderId"); + + b.ToTable("Lots"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotGenealogy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChildLotId") + .HasColumnType("int"); + + b.Property("OccurredAt") + .HasColumnType("datetimeoffset"); + + b.Property("ParentLotId") + .HasColumnType("int"); + + b.Property("PerformedByUserId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("RelationType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("ChildLotId"); + + b.HasIndex("ParentLotId"); + + b.ToTable("LotGenealogies"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotStatusHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChangedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ChangedByUserId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("FromStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("InspectionOrderId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("NonconformanceReportId") + .HasColumnType("int"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ToStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("LotId", "Id"); + + b.ToTable("LotStatusHistories"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CreatedByUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("MaintenancePlanId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ProcedureId") + .HasColumnType("int"); + + b.Property("RequestType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ScheduledDate") + .HasColumnType("date"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ToolId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedByUserId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("MaintenancePlanId"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("ProcedureId"); + + b.HasIndex("Status"); + + b.HasIndex("ToolId"); + + b.ToTable("MaintenanceOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenancePlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CreatedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("CycleDays") + .HasColumnType("int"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PlanYear") + .HasColumnType("int"); + + b.Property("ScheduledDate") + .HasColumnType("date"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId", "PlanYear"); + + b.ToTable("MaintenancePlans"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("ProcedureNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Steps") + .IsRequired() + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("TargetEquipmentId") + .HasColumnType("int"); + + b.Property("TargetToolId") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ProcedureNo") + .IsUnique(); + + b.HasIndex("TargetEquipmentId"); + + b.HasIndex("TargetToolId"); + + b.ToTable("MaintenanceProcedures"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("EndedAt") + .HasColumnType("datetimeoffset"); + + b.Property("MaintenanceOrderId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PartsUsed") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Result") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("StartedAt") + .HasColumnType("datetimeoffset"); + + b.HasKey("Id"); + + b.HasIndex("MaintenanceOrderId"); + + b.HasIndex("PerformedByUserId"); + + b.ToTable("MaintenanceRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecordPart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("MaintenanceRecordId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("MaintenanceRecordId"); + + b.HasIndex("ProductId"); + + b.ToTable("MaintenanceRecordParts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ApprovedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ApprovedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CreatedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("DueDate") + .HasColumnType("date"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("OrderType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("OutputLotId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("SourceOrderId") + .HasColumnType("int"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("UpdatedAt") + .HasColumnType("datetimeoffset"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("OutputLotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SourceOrderId"); + + b.HasIndex("Status"); + + b.ToTable("ManufacturingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrderMaterial", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AlternativeGroup") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ChildProductId") + .HasColumnType("int"); + + b.Property("IsAlternative") + .HasColumnType("bit"); + + b.Property("ManufacturingOrderId") + .HasColumnType("int"); + + b.Property("PlannedQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("QuantityPer") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("RoutingSequence") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChildProductId"); + + b.HasIndex("ManufacturingOrderId", "ChildProductId") + .IsUnique(); + + b.ToTable("ManufacturingOrderMaterials"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaterialConsumption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConsumedAt") + .HasColumnType("datetimeoffset"); + + b.Property("IsSubstitute") + .HasColumnType("bit"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("Method") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("RecordedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("SubstituteReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("MaterialConsumptions"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NonconformanceReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ActionCompletedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ActionCompletedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("ActionInstructedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ActionInstructedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("ActionInstruction") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("ActionRecord") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ApprovedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ApprovedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("CauseCategory") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CauseDetail") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("InspectionOrderId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("ReportNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ReportedByUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("ReworkOrderId") + .HasColumnType("int"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("InspectionOrderId"); + + b.HasIndex("LotId"); + + b.HasIndex("ReportNo") + .IsUnique(); + + b.HasIndex("ReportedByUserId"); + + b.HasIndex("ReworkOrderId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("NonconformanceReports"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NumberSequence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("LastValue") + .HasColumnType("int"); + + b.Property("Prefix") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.HasKey("Id"); + + b.HasIndex("Prefix") + .IsUnique(); + + b.ToTable("NumberSequences"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("PickingOrderId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("PickingOrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("PickingLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CreatedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ExecutedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ShippingOrderId") + .HasColumnType("int"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("OrderNo") + .IsUnique(); + + b.HasIndex("ShippingOrderId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("PickingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProcessMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Processes", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("DefaultLocationId") + .HasColumnType("int"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Specification") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("StandardDefectRate") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Unit") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("UpdatedAt") + .HasColumnType("datetimeoffset"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("DefaultLocationId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDataRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsDeviation") + .HasColumnType("bit"); + + b.Property("Item") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("NumericValue") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("RecordedAt") + .HasColumnType("datetimeoffset"); + + b.Property("RecordedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("WorkOrderControlItemId") + .HasColumnType("int"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("WorkOrderControlItemId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ProductionDataRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDefect", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DefectReasonId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ProductionRecordId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("DefectReasonId"); + + b.HasIndex("ProductionRecordId"); + + b.ToTable("ProductionDefects"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BusinessDate") + .HasColumnType("date"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("PlannedQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("ProcessId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("WorkCenterId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ProcessId"); + + b.HasIndex("ProductId"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("BusinessDate", "ProductId", "ProcessId", "WorkCenterId") + .IsUnique() + .HasFilter("[WorkCenterId] IS NOT NULL"); + + b.ToTable("ProductionPlans"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ApprovedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ApprovedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("DefectQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("EndedAt") + .HasColumnType("datetimeoffset"); + + b.Property("GoodQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("OutputLocationId") + .HasColumnType("int"); + + b.Property("OutputLotId") + .HasColumnType("int"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ReworkQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("ScrapQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("ShiftId") + .HasColumnType("int"); + + b.Property("StartedAt") + .HasColumnType("datetimeoffset"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("OutputLotId"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("ShiftId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ProductionRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecordCorrection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AfterDefectQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("AfterGoodQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("AfterReworkQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("AfterScrapQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("BeforeDefectQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("BeforeGoodQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("BeforeReworkQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("BeforeScrapQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("CorrectedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CorrectedByUserId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("ProductionRecordId") + .HasColumnType("int"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CorrectedByUserId"); + + b.HasIndex("ProductionRecordId"); + + b.HasIndex("WorkOrderId", "Id"); + + b.ToTable("ProductionRecordCorrections"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RefreshToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ExpiresAt") + .HasColumnType("datetimeoffset"); + + b.Property("RevokedAt") + .HasColumnType("datetimeoffset"); + + b.Property("TokenHash") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("TokenHash") + .IsUnique(); + + b.HasIndex("UserId"); + + b.ToTable("RefreshTokens"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChecklistId") + .HasColumnType("int"); + + b.Property("ControlItems") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("ProcessId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("RequiredSkillId") + .HasColumnType("int"); + + b.Property("Sequence") + .HasColumnType("int"); + + b.Property("StandardSetupMinutes") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("StandardWorkMinutes") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("ToolId") + .HasColumnType("int"); + + b.Property("WorkCenterId") + .HasColumnType("int"); + + b.Property("WorkProcedureId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChecklistId"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("ProcessId"); + + b.HasIndex("RequiredSkillId"); + + b.HasIndex("ToolId"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("WorkProcedureId"); + + b.HasIndex("ProductId", "Sequence") + .IsUnique(); + + b.ToTable("Routings"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ControlItemId") + .HasColumnType("int"); + + b.Property("RoutingId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ControlItemId"); + + b.HasIndex("RoutingId", "ControlItemId") + .IsUnique(); + + b.ToTable("RoutingControlItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("RoutingId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("RoutingId", "EquipmentId") + .IsUnique(); + + b.ToTable("RoutingEquipments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SampleStorage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClosedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("ClosedOn") + .HasColumnType("date"); + + b.Property("CollectedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("CollectedOn") + .HasColumnType("date"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("InspectionOrderId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("RetainUntil") + .HasColumnType("date"); + + b.Property("SampleNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StorageLocationId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("InspectionOrderId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("SampleNo") + .IsUnique(); + + b.HasIndex("StorageLocationId"); + + b.HasIndex("Status", "RetainUntil"); + + b.ToTable("SampleStorages"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SetupRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AbnormalityNote") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("EndedAt") + .HasColumnType("datetimeoffset"); + + b.Property("PerformedByUserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("StartedAt") + .HasColumnType("datetimeoffset"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PerformedByUserId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("SetupRecords"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Shift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("EndTime") + .HasColumnType("time"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("StartTime") + .HasColumnType("time"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Shifts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShipmentJudgment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ApprovedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ApprovedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("JudgedAt") + .HasColumnType("datetimeoffset"); + + b.Property("JudgedByUserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("JudgmentNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Result") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ShippingOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("JudgedByUserId"); + + b.HasIndex("JudgmentNo") + .IsUnique(); + + b.HasIndex("LotId"); + + b.HasIndex("ShippingOrderId"); + + b.ToTable("ShipmentJudgments"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("ShippedQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("ShippingOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("ShippingOrderId"); + + b.ToTable("ShippingLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CreatedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("Destination") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("PlannedDate") + .HasColumnType("date"); + + b.Property("ShippedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ShippedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("ShippingNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("ShippingNo") + .IsUnique(); + + b.ToTable("ShippingOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SkillMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("RequiresExpiry") + .HasColumnType("bit"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Skills", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CreatedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("FinalizedAt") + .HasColumnType("datetimeoffset"); + + b.Property("FinalizedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("StocktakeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TargetLocationId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("StocktakeNo") + .IsUnique(); + + b.HasIndex("TargetLocationId"); + + b.ToTable("Stocktakes"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.StocktakeLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CountedQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("IsAdjusted") + .HasColumnType("bit"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("StocktakeId") + .HasColumnType("int"); + + b.Property("TheoreticalQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("ProductId"); + + b.HasIndex("StocktakeId"); + + b.ToTable("StocktakeLine"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Tool", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("LifeResetAt") + .HasColumnType("datetimeoffset"); + + b.Property("LifeThresholdCount") + .HasColumnType("int"); + + b.Property("LifeThresholdHours") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ToolType") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Tools"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolIssue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AllocatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("AllocatedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("IssuedAt") + .HasColumnType("datetimeoffset"); + + b.Property("IssuedToUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ReturnedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ReturnedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("ToolId") + .HasColumnType("int"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IssuedToUserId"); + + b.HasIndex("WorkOrderId"); + + b.HasIndex("ToolId", "Status"); + + b.ToTable("ToolIssues"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolUsage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("RecordedAt") + .HasColumnType("datetimeoffset"); + + b.Property("RecordedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("ToolId") + .HasColumnType("int"); + + b.Property("UsageCount") + .HasColumnType("int"); + + b.Property("UsageHours") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ToolId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("ToolUsages"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TransferOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("CreatedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ExecutedByUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("FromLocationId") + .HasColumnType("int"); + + b.Property("LotId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ToLocationId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("FromLocationId"); + + b.HasIndex("LotId"); + + b.HasIndex("Status"); + + b.HasIndex("ToLocationId"); + + b.ToTable("TransferOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TroubleReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("OccurredAt") + .HasColumnType("datetimeoffset"); + + b.Property("ReportedByUserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ResponseHistory") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EquipmentId"); + + b.HasIndex("ReportedByUserId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("TroubleReports"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.UserSkill", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AcquiredOn") + .HasColumnType("date"); + + b.Property("ExpiresOn") + .HasColumnType("date"); + + b.Property("SkillId") + .HasColumnType("int"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("SkillId"); + + b.HasIndex("UserId", "SkillId") + .IsUnique(); + + b.ToTable("UserSkills"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkCenter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Level") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("ParentId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("ParentId"); + + b.ToTable("WorkCenters"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AssignedEquipmentId") + .HasColumnType("int"); + + b.Property("AssignedUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("ControlItems") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedAt") + .HasColumnType("datetimeoffset"); + + b.Property("DispatchOrder") + .HasColumnType("int"); + + b.Property("ManufacturingOrderId") + .HasColumnType("int"); + + b.Property("PlannedQuantity") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("ProcessId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("RequiredSkillId") + .HasColumnType("int"); + + b.Property("RoutingChecklistId") + .HasColumnType("int"); + + b.Property("RoutingSequence") + .HasColumnType("int"); + + b.Property("StandardSetupMinutes") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("StandardWorkMinutes") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("WorkCenterId") + .HasColumnType("int"); + + b.Property("WorkOrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("WorkProcedureId") + .HasColumnType("int"); + + b.Property("WorkProcedureVersion") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AssignedEquipmentId"); + + b.HasIndex("AssignedUserId"); + + b.HasIndex("ManufacturingOrderId"); + + b.HasIndex("ProcessId"); + + b.HasIndex("ProductId"); + + b.HasIndex("RequiredSkillId"); + + b.HasIndex("RoutingChecklistId"); + + b.HasIndex("Status"); + + b.HasIndex("WorkCenterId"); + + b.HasIndex("WorkOrderNo") + .IsUnique(); + + b.HasIndex("WorkProcedureId"); + + b.ToTable("WorkOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ControlItemId") + .HasColumnType("int"); + + b.Property("ItemCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ItemName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("ItemVersion") + .HasColumnType("int"); + + b.Property("LowerLimit") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("TargetValue") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("Unit") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("UpperLimit") + .HasPrecision(18, 6) + .HasColumnType("decimal(18,6)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ControlItemId"); + + b.HasIndex("WorkOrderId"); + + b.ToTable("WorkOrderControlItems"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderStatusHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChangedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ChangedByUserId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("FromStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ToStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChangedByUserId"); + + b.HasIndex("WorkOrderId", "Id"); + + b.ToTable("WorkOrderStatusHistories"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("ProcedureNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Reference") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Steps") + .IsRequired() + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ProcedureNo") + .IsUnique(); + + b.ToTable("WorkProcedures"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkTimeRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EndedAt") + .HasColumnType("datetimeoffset"); + + b.Property("IndirectCategory") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("StartedAt") + .HasColumnType("datetimeoffset"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("WorkOrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("WorkOrderId"); + + b.HasIndex("UserId", "StartedAt"); + + b.ToTable("WorkTimeRecords"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("MesApp.Core.Entities.AppUser", b => + { + b.HasOne("MesApp.Core.Entities.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Shift"); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.BomItem", b => + { + b.HasOne("MesApp.Core.Entities.Product", "ChildProduct") + .WithMany() + .HasForeignKey("ChildProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "ParentProduct") + .WithMany() + .HasForeignKey("ParentProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChildProduct"); + + b.Navigation("ParentProduct"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistItem", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", null) + .WithMany("Items") + .HasForeignKey("ChecklistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", "Checklist") + .WithMany() + .HasForeignKey("ChecklistId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Checklist"); + + b.Navigation("Equipment"); + + b.Navigation("PerformedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistResultItem", b => + { + b.HasOne("MesApp.Core.Entities.ChecklistItem", "ChecklistItem") + .WithMany() + .HasForeignKey("ChecklistItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ChecklistRecord", null) + .WithMany("Results") + .HasForeignKey("ChecklistRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChecklistItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentLog", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Equipment"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.EquipmentPart", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany("Parts") + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Equipment"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionDeviceCalibration", b => + { + b.HasOne("MesApp.Core.Entities.InspectionDevice", "InspectionDevice") + .WithMany() + .HasForeignKey("InspectionDeviceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("InspectionDevice"); + + b.Navigation("PerformedBy"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionItem", b => + { + b.HasOne("MesApp.Core.Entities.ProcessMaster", "TargetProcess") + .WithMany() + .HasForeignKey("TargetProcessId"); + + b.HasOne("MesApp.Core.Entities.Product", "TargetProduct") + .WithMany() + .HasForeignKey("TargetProductId"); + + b.Navigation("TargetProcess"); + + b.Navigation("TargetProduct"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "RequestedBy") + .WithMany() + .HasForeignKey("RequestedByUserId"); + + b.HasOne("MesApp.Core.Entities.Lot", "TargetLot") + .WithMany() + .HasForeignKey("TargetLotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "TargetWorkOrder") + .WithMany() + .HasForeignKey("TargetWorkOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("RequestedBy"); + + b.Navigation("TargetLot"); + + b.Navigation("TargetWorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrderItem", b => + { + b.HasOne("MesApp.Core.Entities.InspectionItem", "InspectionItem") + .WithMany() + .HasForeignKey("InspectionItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionOrder", null) + .WithMany("Items") + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectionItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResult", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "InspectedBy") + .WithMany() + .HasForeignKey("InspectedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionDevice", "InspectionDevice") + .WithMany() + .HasForeignKey("InspectionDeviceId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.InspectionItem", "InspectionItem") + .WithMany() + .HasForeignKey("InspectionItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.InspectionOrder", null) + .WithMany("Results") + .HasForeignKey("InspectionOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectedBy"); + + b.Navigation("InspectionDevice"); + + b.Navigation("InspectionItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionResultCorrection", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CorrectedBy") + .WithMany() + .HasForeignKey("CorrectedByUserId"); + + b.HasOne("MesApp.Core.Entities.InspectionResult", "InspectionResult") + .WithMany() + .HasForeignKey("InspectionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CorrectedBy"); + + b.Navigation("InspectionResult"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryStock", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InventoryTransaction", b => + { + b.HasOne("MesApp.Core.Entities.Location", "FromLocation") + .WithMany() + .HasForeignKey("FromLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "ToLocation") + .WithMany() + .HasForeignKey("ToLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId"); + + b.Navigation("FromLocation"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("ToLocation"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Location", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Lot", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "ParentLot") + .WithMany() + .HasForeignKey("ParentLotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "SourceWorkOrder") + .WithMany() + .HasForeignKey("SourceWorkOrderId"); + + b.Navigation("ParentLot"); + + b.Navigation("Product"); + + b.Navigation("SourceWorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotGenealogy", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "ChildLot") + .WithMany() + .HasForeignKey("ChildLotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "ParentLot") + .WithMany() + .HasForeignKey("ParentLotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ChildLot"); + + b.Navigation("ParentLot"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.LotStatusHistory", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lot"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedByUserId"); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.MaintenancePlan", "MaintenancePlan") + .WithMany() + .HasForeignKey("MaintenancePlanId"); + + b.HasOne("MesApp.Core.Entities.MaintenanceProcedure", "Procedure") + .WithMany() + .HasForeignKey("ProcedureId"); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CreatedBy"); + + b.Navigation("Equipment"); + + b.Navigation("MaintenancePlan"); + + b.Navigation("Procedure"); + + b.Navigation("Tool"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenancePlan", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Equipment"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceProcedure", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "TargetEquipment") + .WithMany() + .HasForeignKey("TargetEquipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Tool", "TargetTool") + .WithMany() + .HasForeignKey("TargetToolId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("TargetEquipment"); + + b.Navigation("TargetTool"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.HasOne("MesApp.Core.Entities.MaintenanceOrder", null) + .WithMany("Records") + .HasForeignKey("MaintenanceOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("PerformedBy"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecordPart", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.MaintenanceRecord", null) + .WithMany("Parts") + .HasForeignKey("MaintenanceRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "OutputLot") + .WithMany() + .HasForeignKey("OutputLotId"); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "SourceOrder") + .WithMany() + .HasForeignKey("SourceOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("OutputLot"); + + b.Navigation("Product"); + + b.Navigation("SourceOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrderMaterial", b => + { + b.HasOne("MesApp.Core.Entities.Product", "ChildProduct") + .WithMany() + .HasForeignKey("ChildProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ManufacturingOrder") + .WithMany("Materials") + .HasForeignKey("ManufacturingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChildProduct"); + + b.Navigation("ManufacturingOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaterialConsumption", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.NonconformanceReport", b => + { + b.HasOne("MesApp.Core.Entities.InspectionOrder", "InspectionOrder") + .WithMany() + .HasForeignKey("InspectionOrderId"); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.AppUser", "ReportedBy") + .WithMany() + .HasForeignKey("ReportedByUserId"); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ReworkOrder") + .WithMany() + .HasForeignKey("ReworkOrderId"); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId"); + + b.Navigation("InspectionOrder"); + + b.Navigation("Lot"); + + b.Navigation("ReportedBy"); + + b.Navigation("ReworkOrder"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingLine", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.PickingOrder", null) + .WithMany("Lines") + .HasForeignKey("PickingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.HasOne("MesApp.Core.Entities.ShippingOrder", "ShippingOrder") + .WithMany() + .HasForeignKey("ShippingOrderId"); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId"); + + b.Navigation("ShippingOrder"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Product", b => + { + b.HasOne("MesApp.Core.Entities.Location", "DefaultLocation") + .WithMany() + .HasForeignKey("DefaultLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("DefaultLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDataRecord", b => + { + b.HasOne("MesApp.Core.Entities.WorkOrderControlItem", "WorkOrderControlItem") + .WithMany() + .HasForeignKey("WorkOrderControlItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkOrder"); + + b.Navigation("WorkOrderControlItem"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionDefect", b => + { + b.HasOne("MesApp.Core.Entities.DefectReason", "DefectReason") + .WithMany() + .HasForeignKey("DefectReasonId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ProductionRecord", "ProductionRecord") + .WithMany("Defects") + .HasForeignKey("ProductionRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DefectReason"); + + b.Navigation("ProductionRecord"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionPlan", b => + { + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("WorkCenter"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.HasOne("MesApp.Core.Entities.Lot", "OutputLot") + .WithMany() + .HasForeignKey("OutputLotId"); + + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OutputLot"); + + b.Navigation("PerformedBy"); + + b.Navigation("Shift"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecordCorrection", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "CorrectedBy") + .WithMany() + .HasForeignKey("CorrectedByUserId"); + + b.HasOne("MesApp.Core.Entities.ProductionRecord", "ProductionRecord") + .WithMany() + .HasForeignKey("ProductionRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CorrectedBy"); + + b.Navigation("ProductionRecord"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RefreshToken", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.HasOne("MesApp.Core.Entities.Checklist", "Checklist") + .WithMany() + .HasForeignKey("ChecklistId"); + + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId"); + + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.SkillMaster", "RequiredSkill") + .WithMany() + .HasForeignKey("RequiredSkillId"); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId"); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkProcedure", "WorkProcedure") + .WithMany() + .HasForeignKey("WorkProcedureId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Checklist"); + + b.Navigation("Equipment"); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("RequiredSkill"); + + b.Navigation("Tool"); + + b.Navigation("WorkCenter"); + + b.Navigation("WorkProcedure"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingControlItem", b => + { + b.HasOne("MesApp.Core.Entities.ControlItem", "ControlItem") + .WithMany() + .HasForeignKey("ControlItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Routing", "Routing") + .WithMany("ControlItemLinks") + .HasForeignKey("RoutingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ControlItem"); + + b.Navigation("Routing"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Routing", "Routing") + .WithMany("EquipmentCandidates") + .HasForeignKey("RoutingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Equipment"); + + b.Navigation("Routing"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SampleStorage", b => + { + b.HasOne("MesApp.Core.Entities.InspectionOrder", "InspectionOrder") + .WithMany() + .HasForeignKey("InspectionOrderId"); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "StorageLocation") + .WithMany() + .HasForeignKey("StorageLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("InspectionOrder"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + + b.Navigation("StorageLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.SetupRecord", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "PerformedBy") + .WithMany() + .HasForeignKey("PerformedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PerformedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShipmentJudgment", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "JudgedBy") + .WithMany() + .HasForeignKey("JudgedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.ShippingOrder", "ShippingOrder") + .WithMany() + .HasForeignKey("ShippingOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("JudgedBy"); + + b.Navigation("Lot"); + + b.Navigation("ShippingOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingLine", b => + { + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ShippingOrder", null) + .WithMany("Lines") + .HasForeignKey("ShippingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.HasOne("MesApp.Core.Entities.Location", "TargetLocation") + .WithMany() + .HasForeignKey("TargetLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("TargetLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.StocktakeLine", b => + { + b.HasOne("MesApp.Core.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Stocktake", null) + .WithMany("Lines") + .HasForeignKey("StocktakeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Lot"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolIssue", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "IssuedTo") + .WithMany() + .HasForeignKey("IssuedToUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IssuedTo"); + + b.Navigation("Tool"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ToolUsage", b => + { + b.HasOne("MesApp.Core.Entities.Tool", "Tool") + .WithMany() + .HasForeignKey("ToolId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId"); + + b.Navigation("Tool"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TransferOrder", b => + { + b.HasOne("MesApp.Core.Entities.Location", "FromLocation") + .WithMany() + .HasForeignKey("FromLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Lot", "Lot") + .WithMany() + .HasForeignKey("LotId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Location", "ToLocation") + .WithMany() + .HasForeignKey("ToLocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("FromLocation"); + + b.Navigation("Lot"); + + b.Navigation("ToLocation"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.TroubleReport", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId"); + + b.HasOne("MesApp.Core.Entities.AppUser", "ReportedBy") + .WithMany() + .HasForeignKey("ReportedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId"); + + b.Navigation("Equipment"); + + b.Navigation("ReportedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.UserSkill", b => + { + b.HasOne("MesApp.Core.Entities.SkillMaster", "Skill") + .WithMany() + .HasForeignKey("SkillId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Skill"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkCenter", b => + { + b.HasOne("MesApp.Core.Entities.WorkCenter", "Parent") + .WithMany() + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.HasOne("MesApp.Core.Entities.Equipment", "AssignedEquipment") + .WithMany() + .HasForeignKey("AssignedEquipmentId"); + + b.HasOne("MesApp.Core.Entities.AppUser", "AssignedUser") + .WithMany() + .HasForeignKey("AssignedUserId"); + + b.HasOne("MesApp.Core.Entities.ManufacturingOrder", "ManufacturingOrder") + .WithMany("WorkOrders") + .HasForeignKey("ManufacturingOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.ProcessMaster", "Process") + .WithMany() + .HasForeignKey("ProcessId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.SkillMaster", "RequiredSkill") + .WithMany() + .HasForeignKey("RequiredSkillId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.Checklist", "RoutingChecklist") + .WithMany() + .HasForeignKey("RoutingChecklistId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") + .WithMany() + .HasForeignKey("WorkCenterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkProcedure", "WorkProcedure") + .WithMany() + .HasForeignKey("WorkProcedureId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("AssignedEquipment"); + + b.Navigation("AssignedUser"); + + b.Navigation("ManufacturingOrder"); + + b.Navigation("Process"); + + b.Navigation("Product"); + + b.Navigation("RequiredSkill"); + + b.Navigation("RoutingChecklist"); + + b.Navigation("WorkCenter"); + + b.Navigation("WorkProcedure"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderControlItem", b => + { + b.HasOne("MesApp.Core.Entities.ControlItem", "ControlItem") + .WithMany() + .HasForeignKey("ControlItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany("ControlItemSnapshots") + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ControlItem"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrderStatusHistory", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "ChangedBy") + .WithMany() + .HasForeignKey("ChangedByUserId"); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChangedBy"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkTimeRecord", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.WorkOrder", "WorkOrder") + .WithMany() + .HasForeignKey("WorkOrderId"); + + b.Navigation("User"); + + b.Navigation("WorkOrder"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("MesApp.Core.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Checklist", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ChecklistRecord", b => + { + b.Navigation("Results"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => + { + b.Navigation("Parts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.InspectionOrder", b => + { + b.Navigation("Items"); + + b.Navigation("Results"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceOrder", b => + { + b.Navigation("Records"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.MaintenanceRecord", b => + { + b.Navigation("Parts"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ManufacturingOrder", b => + { + b.Navigation("Materials"); + + b.Navigation("WorkOrders"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.PickingOrder", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ProductionRecord", b => + { + b.Navigation("Defects"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Routing", b => + { + b.Navigation("ControlItemLinks"); + + b.Navigation("EquipmentCandidates"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.ShippingOrder", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.Stocktake", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("MesApp.Core.Entities.WorkOrder", b => + { + b.Navigation("ControlItemSnapshots"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/MesApp.Migrations.SqlServer/Migrations/20260923081743_LinkControlItemsToRouting.cs b/src/MesApp.Migrations.SqlServer/Migrations/20260923081743_LinkControlItemsToRouting.cs new file mode 100644 index 0000000..0e95149 --- /dev/null +++ b/src/MesApp.Migrations.SqlServer/Migrations/20260923081743_LinkControlItemsToRouting.cs @@ -0,0 +1,118 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MesApp.Migrations.SqlServer.Migrations +{ + /// + public partial class LinkControlItemsToRouting : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ControlItems_Processes_TargetProcessId", + table: "ControlItems"); + + migrationBuilder.DropForeignKey( + name: "FK_ControlItems_Products_TargetProductId", + table: "ControlItems"); + + migrationBuilder.DropIndex( + name: "IX_ControlItems_TargetProcessId", + table: "ControlItems"); + + migrationBuilder.DropIndex( + name: "IX_ControlItems_TargetProductId", + table: "ControlItems"); + + migrationBuilder.DropColumn( + name: "TargetProcessId", + table: "ControlItems"); + + migrationBuilder.DropColumn( + name: "TargetProductId", + table: "ControlItems"); + + migrationBuilder.CreateTable( + name: "RoutingControlItems", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RoutingId = table.Column(type: "int", nullable: false), + ControlItemId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RoutingControlItems", x => x.Id); + table.ForeignKey( + name: "FK_RoutingControlItems_ControlItems_ControlItemId", + column: x => x.ControlItemId, + principalTable: "ControlItems", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_RoutingControlItems_Routings_RoutingId", + column: x => x.RoutingId, + principalTable: "Routings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_RoutingControlItems_ControlItemId", + table: "RoutingControlItems", + column: "ControlItemId"); + + migrationBuilder.CreateIndex( + name: "IX_RoutingControlItems_RoutingId_ControlItemId", + table: "RoutingControlItems", + columns: new[] { "RoutingId", "ControlItemId" }, + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "RoutingControlItems"); + + migrationBuilder.AddColumn( + name: "TargetProcessId", + table: "ControlItems", + type: "int", + nullable: true); + + migrationBuilder.AddColumn( + name: "TargetProductId", + table: "ControlItems", + type: "int", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_ControlItems_TargetProcessId", + table: "ControlItems", + column: "TargetProcessId"); + + migrationBuilder.CreateIndex( + name: "IX_ControlItems_TargetProductId", + table: "ControlItems", + column: "TargetProductId"); + + migrationBuilder.AddForeignKey( + name: "FK_ControlItems_Processes_TargetProcessId", + table: "ControlItems", + column: "TargetProcessId", + principalTable: "Processes", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_ControlItems_Products_TargetProductId", + table: "ControlItems", + column: "TargetProductId", + principalTable: "Products", + principalColumn: "Id"); + } + } +} diff --git a/src/MesApp.Migrations.SqlServer/Migrations/MesAppDbContextModelSnapshot.cs b/src/MesApp.Migrations.SqlServer/Migrations/MesAppDbContextModelSnapshot.cs index 157281c..0bdd2e6 100644 --- a/src/MesApp.Migrations.SqlServer/Migrations/MesAppDbContextModelSnapshot.cs +++ b/src/MesApp.Migrations.SqlServer/Migrations/MesAppDbContextModelSnapshot.cs @@ -371,12 +371,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(200) .HasColumnType("nvarchar(200)"); - b.Property("TargetProcessId") - .HasColumnType("int"); - - b.Property("TargetProductId") - .HasColumnType("int"); - b.Property("TargetValue") .HasPrecision(18, 6) .HasColumnType("decimal(18,6)"); @@ -397,10 +391,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Code") .IsUnique(); - b.HasIndex("TargetProcessId"); - - b.HasIndex("TargetProductId"); - b.ToTable("ControlItems"); }); @@ -2369,6 +2359,30 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Routings"); }); + modelBuilder.Entity("MesApp.Core.Entities.RoutingControlItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ControlItemId") + .HasColumnType("int"); + + b.Property("RoutingId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ControlItemId"); + + b.HasIndex("RoutingId", "ControlItemId") + .IsUnique(); + + b.ToTable("RoutingControlItems"); + }); + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => { b.Property("Id") @@ -3620,21 +3634,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("ChecklistItem"); }); - modelBuilder.Entity("MesApp.Core.Entities.ControlItem", b => - { - b.HasOne("MesApp.Core.Entities.ProcessMaster", "TargetProcess") - .WithMany() - .HasForeignKey("TargetProcessId"); - - b.HasOne("MesApp.Core.Entities.Product", "TargetProduct") - .WithMany() - .HasForeignKey("TargetProductId"); - - b.Navigation("TargetProcess"); - - b.Navigation("TargetProduct"); - }); - modelBuilder.Entity("MesApp.Core.Entities.Equipment", b => { b.HasOne("MesApp.Core.Entities.WorkCenter", "WorkCenter") @@ -4404,6 +4403,25 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("WorkProcedure"); }); + modelBuilder.Entity("MesApp.Core.Entities.RoutingControlItem", b => + { + b.HasOne("MesApp.Core.Entities.ControlItem", "ControlItem") + .WithMany() + .HasForeignKey("ControlItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("MesApp.Core.Entities.Routing", "Routing") + .WithMany("ControlItemLinks") + .HasForeignKey("RoutingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ControlItem"); + + b.Navigation("Routing"); + }); + modelBuilder.Entity("MesApp.Core.Entities.RoutingEquipment", b => { b.HasOne("MesApp.Core.Entities.Equipment", "Equipment") @@ -4903,6 +4921,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("MesApp.Core.Entities.Routing", b => { + b.Navigation("ControlItemLinks"); + b.Navigation("EquipmentCandidates"); }); diff --git a/tests/MesApp.Api.Tests/ExecutionTests.cs b/tests/MesApp.Api.Tests/ExecutionTests.cs index a8a54af..55f14fa 100644 --- a/tests/MesApp.Api.Tests/ExecutionTests.cs +++ b/tests/MesApp.Api.Tests/ExecutionTests.cs @@ -103,7 +103,11 @@ await ImportAsync("masters/csv/checklists", "CL-T,段取り確認,Setup,true,1,治具の確認,true\nCL-T,段取り確認,Setup,true,2,清掃,false\n"); await ImportAsync("masters/csv/defect-reasons", "Code,Name,Category\nDR-01,寸法不良,Process\n"); await ImportAsync("masters/csv/control-items", - "Code,Name,Unit,TargetProductCode,TargetValue,LowerLimit,UpperLimit\nCI-T,温度,℃,FG-01,100,90,110\n"); + "Code,Name,Unit,TargetValue,LowerLimit,UpperLimit\nCI-T,温度,℃,100,90,110\n"); + // 工程管理項目は工順の工程に紐付けたものだけが作業指示へ写る(1工程目にだけ紐付ける) + await ImportAsync("masters/csv/routing", + "ProductCode,Sequence,ProcessCode,StandardWorkMinutes,StandardSetupMinutes,ControlItemCodes\n" + + "FG-01,1,PR-01,30,10,CI-T\nFG-01,2,PR-01,15,5,\n"); await ImportAsync("actuals/csv/receiving", "ProductCode,Quantity,LocationCode,LotNumber\nRM-01,100,LOC-M,RM-LOT-1\n"); await ImportAsync("actuals/csv/manufacturing-orders", "OrderNo,ProductCode,Quantity,Approve,Expand\nORD-1,FG-01,10,true,true\n"); @@ -768,16 +772,22 @@ public async Task 製造条件の実績を指示と照合して逸脱を判定 using var admin = await TestAuth.CreateAdminClientAsync(factory); var ctx = await Phase3TestData.SetupAsync(admin); - // 指示(工程単位)を用意してから展開する。展開時点の値が作業指示へ写る - (await admin.PostAsJsonAsync("/api/control-items", - new Core.Contracts.Masters.ControlItemRequest( - "CI-01", "加熱温度", "℃", null, ctx.ProcessId, 180m, 175m, 185m))) - .EnsureSuccessStatusCode(); + // 指示を用意して工順の1工程目に紐付けてから展開する。展開時点の値が作業指示へ写る + async Task CreateItemAsync(Core.Contracts.Masters.ControlItemRequest request) + { + var created = await admin.PostAsJsonAsync("/api/control-items", request); + created.EnsureSuccessStatusCode(); + return (await created.Content.ReadFromJsonAsync())!.Id; + } + var temperatureId = await CreateItemAsync(new("CI-01", "加熱温度", "℃", 180m, 175m, 185m)); // 上下限を持たない項目は判定しない(記録だけが目的の条件) - (await admin.PostAsJsonAsync("/api/control-items", - new Core.Contracts.Masters.ControlItemRequest( - "CI-02", "作業者メモ", null, null, ctx.ProcessId, null, null, null))) - .EnsureSuccessStatusCode(); + var memoId = await CreateItemAsync(new("CI-02", "作業者メモ", null, null, null, null)); + (await admin.PutAsJsonAsync($"/api/products/{ctx.ProductId}/routing", + new List + { + new(1, ctx.ProcessId, 30m, 10m, null, null, null, null, null, ControlItemIds: [temperatureId, memoId]), + new(2, ctx.ProcessId, 15m, 5m, null, null, null, null, null), + })).EnsureSuccessStatusCode(); var order = await Phase3TestData.CreateReleasedOrderAsync(admin, ctx.ProductId, 10m); var workOrderId = order.WorkOrders[0].Id; diff --git a/tests/MesApp.Api.Tests/MasterCsvTests.cs b/tests/MesApp.Api.Tests/MasterCsvTests.cs index cd60e40..9e1ce58 100644 --- a/tests/MesApp.Api.Tests/MasterCsvTests.cs +++ b/tests/MesApp.Api.Tests/MasterCsvTests.cs @@ -810,13 +810,12 @@ public async Task 工程管理項目をCSVで一括登録でき許容範囲の """)).Succeeded); var result = await ImportAsync(client, "control-items", """ - Code,Name,Unit,TargetProductCode,TargetProcessCode,TargetValue,LowerLimit,UpperLimit,IsActive - CI-01,加熱温度,℃,,PR-01,180,175,185,true + Code,Name,Unit,TargetValue,LowerLimit,UpperLimit,IsActive + CI-01,加熱温度,℃,180,175,185,true """); Assert.True(result.Succeeded, string.Join(" / ", result.Errors.Select(e => e.Message))); var items = await client.GetFromJsonAsync>("/api/control-items"); Assert.Equal(180m, items!.Single().TargetValue); - Assert.Equal("PR-01", items!.Single().TargetProcessCode); // 単票APIと同じ条件で弾かれる var invalid = await ImportAsync(client, "control-items", """ @@ -837,6 +836,33 @@ public async Task 工程管理項目をCSVで一括登録でき許容範囲の Assert.Equal(1, revised.Updated); var after = await client.GetFromJsonAsync>("/api/control-items"); Assert.Equal(2, after!.Single().Version); + + // 工順CSVで工程に紐付ける。未登録のコードはその行の誤り + Assert.True((await ImportAsync(client, "products", """ + Code,Name,Unit,Type + FG-01,完成品,個,Product + """)).Succeeded); + var unknown = await ImportAsync(client, "routing", """ + ProductCode,Sequence,ProcessCode,ControlItemCodes + FG-01,1,PR-01,CI-01;CI-99 + """); + Assert.False(unknown.Succeeded); + Assert.Contains(unknown.Errors, e => e.Line == 2 && e.Message.Contains("CI-99")); + var linked = await ImportAsync(client, "routing", """ + ProductCode,Sequence,ProcessCode,ControlItemCodes + FG-01,1,PR-01,CI-01 + """); + Assert.True(linked.Succeeded, string.Join(" / ", linked.Errors.Select(e => e.Message))); + var export = await (await client.GetAsync("/api/masters/csv/routing")).Content.ReadAsStringAsync(); + Assert.Contains("CI-01", export); + + // 紐付け中の項目はCSVからも無効化できない(単票APIと同じ条件) + var deactivate = await ImportAsync(client, "control-items", """ + Code,Name,IsActive + CI-01,加熱温度,false + """); + Assert.False(deactivate.Succeeded); + Assert.Contains(deactivate.Errors, e => e.Message.Contains("FG-01")); } [Fact] diff --git a/tests/MesApp.Api.Tests/MasterTests.cs b/tests/MesApp.Api.Tests/MasterTests.cs index 7000e30..449d40f 100644 --- a/tests/MesApp.Api.Tests/MasterTests.cs +++ b/tests/MesApp.Api.Tests/MasterTests.cs @@ -453,38 +453,31 @@ public async Task 工程管理項目のCRUDと版数管理ができ許容範囲 { using var factory = new ApiFactory(); using var client = await TestAuth.CreateAdminClientAsync(factory); - var process = await CreateProcessAsync(client, "PR-01", "加熱"); var created = await client.PostAsJsonAsync("/api/control-items", - new ControlItemRequest("CI-01", "加熱温度", "℃", null, process.Id, 180m, 175m, 185m)); + new ControlItemRequest("CI-01", "加熱温度", "℃", 180m, 175m, 185m)); Assert.Equal(HttpStatusCode.Created, created.StatusCode); var item = await created.Content.ReadFromJsonAsync(); Assert.Equal(1, item!.Version); - Assert.Equal("PR-01", item.TargetProcessCode); // コード重複は409 var duplicated = await client.PostAsJsonAsync("/api/control-items", - new ControlItemRequest("CI-01", "別項目", null, null, null, null, null, null)); + new ControlItemRequest("CI-01", "別項目", null, null, null, null)); Assert.Equal(HttpStatusCode.Conflict, duplicated.StatusCode); // 下限>上限は400 var reversed = await client.PostAsJsonAsync("/api/control-items", - new ControlItemRequest("CI-02", "逆転", null, null, null, null, 200m, 100m)); + new ControlItemRequest("CI-02", "逆転", null, null, 200m, 100m)); Assert.Equal(HttpStatusCode.BadRequest, reversed.StatusCode); // 指示値が許容範囲の外は400(指示どおり作っても逸脱になってしまうため) var outOfRange = await client.PostAsJsonAsync("/api/control-items", - new ControlItemRequest("CI-03", "範囲外", null, null, null, 300m, 175m, 185m)); + new ControlItemRequest("CI-03", "範囲外", null, 300m, 175m, 185m)); Assert.Equal(HttpStatusCode.BadRequest, outOfRange.StatusCode); - // 存在しない対象工程は400 - var missingProcess = await client.PostAsJsonAsync("/api/control-items", - new ControlItemRequest("CI-04", "工程なし", null, null, 9999, null, null, null)); - Assert.Equal(HttpStatusCode.BadRequest, missingProcess.StatusCode); - // 更新で版数が上がる var updated = await client.PutAsJsonAsync($"/api/control-items/{item.Id}", - new ControlItemRequest("CI-01", "加熱温度", "℃", null, process.Id, 182m, 178m, 186m)); + new ControlItemRequest("CI-01", "加熱温度", "℃", 182m, 178m, 186m)); var updatedBody = await updated.Content.ReadFromJsonAsync(); Assert.Equal(2, updatedBody!.Version); Assert.Equal(182m, updatedBody.TargetValue); @@ -496,6 +489,51 @@ public async Task 工程管理項目のCRUDと版数管理ができ許容範囲 Assert.Empty(active!); } + [Fact] + public async Task 工順に紐付けた工程管理項目は無効化できず無効な項目は紐付けられない() + { + using var factory = new ApiFactory(); + using var client = await TestAuth.CreateAdminClientAsync(factory); + var product = await CreateProductAsync(client, "FG-01", "完成品", ProductType.Product); + var process = await CreateProcessAsync(client, "PR-01", "加熱"); + async Task CreateItemAsync(string code) + { + var created = await client.PostAsJsonAsync("/api/control-items", + new ControlItemRequest(code, code, null, null, null, null)); + created.EnsureSuccessStatusCode(); + return (await created.Content.ReadFromJsonAsync())!.Id; + } + var linkedId = await CreateItemAsync("CI-02"); + var otherId = await CreateItemAsync("CI-01"); + + // 紐付けは工程ごとにコード順で返る(同じ項目の二重指定は1つにまとめる) + var saved = await client.PutAsJsonAsync($"/api/products/{product.Id}/routing", + new List + { + new(1, process.Id, 30m, 10m, null, null, null, null, null, ControlItemIds: [linkedId, otherId, linkedId]), + }); + Assert.Equal(HttpStatusCode.OK, saved.StatusCode); + var steps = await saved.Content.ReadFromJsonAsync>(); + Assert.Equal(["CI-01", "CI-02"], steps!.Single().ControlItemCodes!); + + // 紐付け中は無効化できない(展開する作業指示に使わせないはずの条件が載り続ける) + var inUse = await client.DeleteAsync($"/api/control-items/{linkedId}"); + Assert.Equal(HttpStatusCode.Conflict, inUse.StatusCode); + Assert.Contains("FG-01", await inUse.Content.ReadAsStringAsync()); + + // 紐付けを外せば無効化でき、無効な項目は紐付けられない + (await client.PutAsJsonAsync($"/api/products/{product.Id}/routing", + new List { new(1, process.Id, 30m, 10m, null, null, null, null, null) })) + .EnsureSuccessStatusCode(); + Assert.Equal(HttpStatusCode.NoContent, (await client.DeleteAsync($"/api/control-items/{linkedId}")).StatusCode); + var inactive = await client.PutAsJsonAsync($"/api/products/{product.Id}/routing", + new List + { + new(1, process.Id, 30m, 10m, null, null, null, null, null, ControlItemIds: [linkedId]), + }); + Assert.Equal(HttpStatusCode.BadRequest, inactive.StatusCode); + } + internal static async Task CreateWorkCenterAsync( HttpClient client, string code, string name, WorkCenterLevel level, int? parentId) { diff --git a/tests/MesApp.Api.Tests/ProductionTests.cs b/tests/MesApp.Api.Tests/ProductionTests.cs index b631df6..916fa50 100644 --- a/tests/MesApp.Api.Tests/ProductionTests.cs +++ b/tests/MesApp.Api.Tests/ProductionTests.cs @@ -105,29 +105,32 @@ private static async Task CreateOrderAsync( } [Fact] - public async Task 工程管理項目が展開時に固定され以降のマスタ改訂で指示が変わらない() + public async Task 工程管理項目は工順の工程ごとの紐付けどおりに展開され以降のマスタ改訂で指示が変わらない() { using var factory = new ApiFactory(); using var admin = await TestAuth.CreateAdminClientAsync(factory); var product = await MasterTests.CreateProductAsync(admin, "FG-01", "完成品", ProductType.Product); - var process = await MasterTests.CreateProcessAsync(admin, "PR-01", "加熱"); - (await admin.PutAsJsonAsync($"/api/products/{product.Id}/routing", - new List { new(1, process.Id, 30m, 10m, null, null, null, null, null) })) - .EnsureSuccessStatusCode(); + var heating = await MasterTests.CreateProcessAsync(admin, "PR-01", "加熱"); + var inspection = await MasterTests.CreateProcessAsync(admin, "PR-02", "検査"); + async Task CreateItemAsync(ControlItemRequest request) + { + var created = await admin.PostAsJsonAsync("/api/control-items", request); + created.EnsureSuccessStatusCode(); + return (await created.Content.ReadFromJsonAsync())!.Id; + } + var weightId = await CreateItemAsync(new("CI-01", "投入重量", "kg", 10m, 9.5m, 10.5m)); + var temperatureId = await CreateItemAsync(new("CI-02", "加熱温度", "℃", 180m, 175m, 185m)); + var reheatId = await CreateItemAsync(new("CI-03", "再加熱温度", "℃", 150m, 145m, 155m)); - // 品目単位の項目と工程単位の項目を用意する(両方が作業指示へ写る) - var byProduct = await admin.PostAsJsonAsync("/api/control-items", - new ControlItemRequest("CI-01", "投入重量", "kg", product.Id, null, 10m, 9.5m, 10.5m)); - byProduct.EnsureSuccessStatusCode(); - var byProcess = await admin.PostAsJsonAsync("/api/control-items", - new ControlItemRequest("CI-02", "加熱温度", "℃", null, process.Id, 180m, 175m, 185m)); - byProcess.EnsureSuccessStatusCode(); - // 別工程の項目は写らない - var other = await MasterTests.CreateProcessAsync(admin, "PR-02", "検査"); - (await admin.PostAsJsonAsync("/api/control-items", - new ControlItemRequest("CI-03", "別工程の項目", null, null, other.Id, null, null, null))) - .EnsureSuccessStatusCode(); + // 同じ加熱工程が2回ある工順。工程ごとに別の条件を持たせ、検査工程には何も紐付けない + (await admin.PutAsJsonAsync($"/api/products/{product.Id}/routing", + new List + { + new(1, heating.Id, 30m, 10m, null, null, null, null, null, ControlItemIds: [weightId, temperatureId]), + new(2, inspection.Id, 10m, 0m, null, null, null, null, null), + new(3, heating.Id, 20m, 0m, null, null, null, null, null, ControlItemIds: [reheatId]), + })).EnsureSuccessStatusCode(); var order = await CreateOrderAsync(admin, product.Id); await admin.PostAsync($"/api/manufacturing-orders/{order.Id}/approve", null); @@ -135,11 +138,15 @@ public async Task 工程管理項目が展開時に固定され以降のマス $"/api/manufacturing-orders/{order.Id}/expand", new ExpandRequest(null)); expanded.EnsureSuccessStatusCode(); var detail = await expanded.Content.ReadFromJsonAsync(); - var workOrder = detail!.WorkOrders.Single(); - - var items = await admin.GetFromJsonAsync>( - $"/api/work-orders/{workOrder.Id}/control-items"); - Assert.Equal(["CI-01", "CI-02"], items!.Select(i => i.ItemCode)); + async Task> ItemsOfAsync(ManufacturingOrderDetailResponse d, int sequence) => + (await admin.GetFromJsonAsync>( + $"/api/work-orders/{d.WorkOrders.Single(w => w.RoutingSequence == sequence).Id}/control-items"))!; + + var items = await ItemsOfAsync(detail!, 1); + Assert.Equal(["CI-01", "CI-02"], items.Select(i => i.ItemCode)); + Assert.Empty(await ItemsOfAsync(detail!, 2)); + Assert.Equal(["CI-03"], (await ItemsOfAsync(detail!, 3)).Select(i => i.ItemCode)); + var workOrder = detail!.WorkOrders.Single(w => w.RoutingSequence == 1); var temperature = items!.Single(i => i.ItemCode == "CI-02"); Assert.Equal(180m, temperature.TargetValue); Assert.Equal(175m, temperature.LowerLimit); @@ -147,9 +154,8 @@ public async Task 工程管理項目が展開時に固定され以降のマス Assert.Equal("℃", temperature.Unit); // マスタを改訂しても展開済みの指示は変わらない(Spec.md 5.7) - var itemId = (await byProcess.Content.ReadFromJsonAsync())!.Id; - (await admin.PutAsJsonAsync($"/api/control-items/{itemId}", - new ControlItemRequest("CI-02", "加熱温度", "℃", null, process.Id, 200m, 195m, 205m))) + (await admin.PutAsJsonAsync($"/api/control-items/{temperatureId}", + new ControlItemRequest("CI-02", "加熱温度", "℃", 200m, 195m, 205m))) .EnsureSuccessStatusCode(); var afterRevision = await admin.GetFromJsonAsync>( $"/api/work-orders/{workOrder.Id}/control-items"); @@ -163,10 +169,9 @@ public async Task 工程管理項目が展開時に固定され以降のマス var nextExpanded = await admin.PostAsJsonAsync( $"/api/manufacturing-orders/{next.Id}/expand", new ExpandRequest(null)); var nextDetail = await nextExpanded.Content.ReadFromJsonAsync(); - var nextItems = await admin.GetFromJsonAsync>( - $"/api/work-orders/{nextDetail!.WorkOrders.Single().Id}/control-items"); - Assert.Equal(200m, nextItems!.Single(i => i.ItemCode == "CI-02").TargetValue); - Assert.Equal(2, nextItems!.Single(i => i.ItemCode == "CI-02").ItemVersion); + var nextItems = await ItemsOfAsync(nextDetail!, 1); + Assert.Equal(200m, nextItems.Single(i => i.ItemCode == "CI-02").TargetValue); + Assert.Equal(2, nextItems.Single(i => i.ItemCode == "CI-02").ItemVersion); } [Fact] From 8c25433c2184ff66c3e7ae3243d4f5af30257e94 Mon Sep 17 00:00:00 2001 From: msmsrep <113223770+msmsrep@users.noreply.github.com> Date: Wed, 23 Sep 2026 17:51:59 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E5=B7=A5=E9=A0=86=E3=81=AE=E5=B7=A5?= =?UTF-8?q?=E7=A8=8B=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=9F=E5=BE=8C?= =?UTF-8?q?=E3=80=81=E8=A4=87=E6=95=B0=E9=81=B8=E6=8A=9E=E3=81=AE=E4=B8=80?= =?UTF-8?q?=E8=A6=A7=E3=81=AB=E5=89=8D=E3=81=AE=E5=B7=A5=E7=A8=8B=E3=81=AE?= =?UTF-8?q?=E9=81=B8=E6=8A=9E=E3=81=8C=E6=AE=8B=E3=82=89=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 工程を追加すると選んだ候補設備・工程管理項目は内部で空にしていたが、 利用者が選んだ選択状態は selected 属性を外しても画面に残るため、 表示だけが前の工程のままになり、選んだつもりで何も紐付かない工程ができた。 工程を追加するたびに一覧を作り直す。 Co-Authored-By: Claude Opus 5.5 --- .../Pages/Masters/Products/ProductRoutingEditor.razor | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/MesApp.Client.Web/Pages/Masters/Products/ProductRoutingEditor.razor b/src/MesApp.Client.Web/Pages/Masters/Products/ProductRoutingEditor.razor index 2497fd4..aa9818b 100644 --- a/src/MesApp.Client.Web/Pages/Masters/Products/ProductRoutingEditor.razor +++ b/src/MesApp.Client.Web/Pages/Masters/Products/ProductRoutingEditor.razor @@ -65,7 +65,7 @@
@* 候補設備(B-10-20-02)。複数選ぶと差立でその中から選ばせる。空なら限定しない *@ - @foreach (var equipment in _equipments) {
@L["順序"]@L["工程"]@L["標準作業(分)"]@L["標準段取(分)"]@L["必要スキル"]@L["候補設備"]@L["治工具"]@L["チェックリスト"]@L["管理項目"]@L["作業手順書"]
@L["順序"]@L["工程"]@L["標準作業(分)"]@L["標準段取(分)"]@L["必要スキル"]@L["候補設備"]@L["治工具"]@L["チェックリスト"]@L["管理項目"]@L["補足"]@L["作業手順書"]
@step.StandardWorkMinutes @step.StandardSetupMinutes @(_skills.FirstOrDefault(s => s.Id == step.RequiredSkillId)?.Name ?? "-")@CandidateLabel(step)@ShortList(step.EquipmentIds ?? (step.EquipmentId is { } single ? [single] : []), id => _equipments.FirstOrDefault(e => e.Id == id)?.AssetNo) @(_tools.FirstOrDefault(t => t.Id == step.ToolId)?.Code ?? "-") @(_checklists.FirstOrDefault(c => c.Id == step.ChecklistId)?.Code ?? "-")@ShortList(step.ControlItemIds ?? [], id => _controlItemOptions.FirstOrDefault(i => i.Id == id)?.Code) @(step.ControlItems ?? "-") @(_workProcedures.FirstOrDefault(w => w.Id == step.WorkProcedureId)?.ProcedureNo ?? "-")