From 10c09b9feaabae761aa57ea26633757d31493242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Wed, 25 Feb 2026 19:39:52 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[equipment]=20=EC=84=A4=EB=B9=84?= =?UTF-8?q?=EA=B4=80=EB=A6=AC=20=ED=85=8C=EC=9D=B4=EB=B8=94=20=EB=A7=88?= =?UTF-8?q?=EC=9D=B4=EA=B7=B8=EB=A0=88=EC=9D=B4=EC=85=98=206=EA=B0=9C=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - equipments (설비 마스터) - equipment_inspection_templates (점검항목 템플릿) - equipment_inspections (월간 점검 헤더) - equipment_inspection_details (일자별 점검 결과) - equipment_repairs (수리이력) - equipment_process (설비-공정 피봇) --- ...6_02_25_100000_create_equipments_table.php | 51 +++++++++++++++++++ ...e_equipment_inspection_templates_table.php | 39 ++++++++++++++ ...200_create_equipment_inspections_table.php | 38 ++++++++++++++ ...ate_equipment_inspection_details_table.php | 38 ++++++++++++++ ..._100400_create_equipment_repairs_table.php | 42 +++++++++++++++ ..._100500_create_equipment_process_table.php | 36 +++++++++++++ 6 files changed, 244 insertions(+) create mode 100644 database/migrations/2026_02_25_100000_create_equipments_table.php create mode 100644 database/migrations/2026_02_25_100100_create_equipment_inspection_templates_table.php create mode 100644 database/migrations/2026_02_25_100200_create_equipment_inspections_table.php create mode 100644 database/migrations/2026_02_25_100300_create_equipment_inspection_details_table.php create mode 100644 database/migrations/2026_02_25_100400_create_equipment_repairs_table.php create mode 100644 database/migrations/2026_02_25_100500_create_equipment_process_table.php diff --git a/database/migrations/2026_02_25_100000_create_equipments_table.php b/database/migrations/2026_02_25_100000_create_equipments_table.php new file mode 100644 index 0000000..512bb9b --- /dev/null +++ b/database/migrations/2026_02_25_100000_create_equipments_table.php @@ -0,0 +1,51 @@ +id(); + $table->unsignedBigInteger('tenant_id')->comment('테넌트 ID'); + $table->string('equipment_code', 20)->comment('설비코드 (KD-M-001 형식)'); + $table->string('name', 100)->comment('설비명'); + $table->string('equipment_type', 50)->nullable()->comment('설비유형 (포밍기/미싱기/샤링기/V컷팅기/절곡기/프레스/드릴)'); + $table->string('specification', 255)->nullable()->comment('규격'); + $table->string('manufacturer', 100)->nullable()->comment('제조사'); + $table->string('model_name', 100)->nullable()->comment('모델명'); + $table->string('serial_no', 100)->nullable()->comment('제조번호'); + $table->string('location', 100)->nullable()->comment('위치 (1공장-1F, 2공장-절곡 등)'); + $table->string('production_line', 50)->nullable()->comment('생산라인 (스라트/스크린/절곡)'); + $table->date('purchase_date')->nullable()->comment('구입일'); + $table->date('install_date')->nullable()->comment('설치일'); + $table->decimal('purchase_price', 15, 2)->nullable()->comment('구입가격'); + $table->integer('useful_life')->nullable()->comment('내용연수'); + $table->string('status', 20)->default('active')->comment('상태: active/idle/disposed'); + $table->date('disposed_date')->nullable()->comment('폐기일'); + $table->foreignId('manager_id')->nullable()->comment('담당자 ID (users.id)'); + $table->string('photo_path', 500)->nullable()->comment('설비사진 경로'); + $table->text('memo')->nullable()->comment('비고'); + $table->tinyInteger('is_active')->default(1)->comment('사용여부'); + $table->integer('sort_order')->default(0)->comment('정렬순서'); + $table->foreignId('created_by')->nullable()->comment('생성자 ID'); + $table->foreignId('updated_by')->nullable()->comment('수정자 ID'); + $table->foreignId('deleted_by')->nullable()->comment('삭제자 ID'); + $table->timestamps(); + $table->softDeletes(); + + $table->unique(['tenant_id', 'equipment_code'], 'uq_equipment_code'); + $table->index(['tenant_id', 'status'], 'idx_equipment_status'); + $table->index(['tenant_id', 'production_line'], 'idx_equipment_line'); + $table->index(['tenant_id', 'equipment_type'], 'idx_equipment_type'); + }); + } + + public function down(): void + { + Schema::dropIfExists('equipments'); + } +}; diff --git a/database/migrations/2026_02_25_100100_create_equipment_inspection_templates_table.php b/database/migrations/2026_02_25_100100_create_equipment_inspection_templates_table.php new file mode 100644 index 0000000..c2ba3b5 --- /dev/null +++ b/database/migrations/2026_02_25_100100_create_equipment_inspection_templates_table.php @@ -0,0 +1,39 @@ +id(); + $table->unsignedBigInteger('tenant_id')->comment('테넌트 ID'); + $table->unsignedBigInteger('equipment_id')->comment('설비 ID'); + $table->integer('item_no')->comment('항목번호 (1,2,3,4)'); + $table->string('check_point', 50)->comment('점검개소 (겉모양, 스위치, 롤러 등)'); + $table->string('check_item', 100)->comment('점검항목 (청결상태, 작동상태 등)'); + $table->string('check_timing', 20)->nullable()->comment('시기: operating/stopped'); + $table->string('check_frequency', 50)->nullable()->comment('주기 (1회/일)'); + $table->text('check_method')->nullable()->comment('점검방법 및 기준'); + $table->integer('sort_order')->default(0)->comment('정렬순서'); + $table->tinyInteger('is_active')->default(1)->comment('사용여부'); + $table->timestamps(); + + $table->unique(['equipment_id', 'item_no'], 'uq_equipment_item_no'); + $table->index('tenant_id', 'idx_insp_tmpl_tenant'); + + $table->foreign('equipment_id') + ->references('id') + ->on('equipments') + ->onDelete('cascade'); + }); + } + + public function down(): void + { + Schema::dropIfExists('equipment_inspection_templates'); + } +}; diff --git a/database/migrations/2026_02_25_100200_create_equipment_inspections_table.php b/database/migrations/2026_02_25_100200_create_equipment_inspections_table.php new file mode 100644 index 0000000..f8637b8 --- /dev/null +++ b/database/migrations/2026_02_25_100200_create_equipment_inspections_table.php @@ -0,0 +1,38 @@ +id(); + $table->unsignedBigInteger('tenant_id')->comment('테넌트 ID'); + $table->unsignedBigInteger('equipment_id')->comment('설비 ID'); + $table->string('year_month', 7)->comment('점검년월 (2026-02)'); + $table->string('overall_judgment', 10)->nullable()->comment('종합판정: OK/NG'); + $table->foreignId('inspector_id')->nullable()->comment('점검자 ID (users.id)'); + $table->text('repair_note')->nullable()->comment('수리내역'); + $table->text('issue_note')->nullable()->comment('이상내용'); + $table->foreignId('created_by')->nullable()->comment('생성자 ID'); + $table->foreignId('updated_by')->nullable()->comment('수정자 ID'); + $table->timestamps(); + + $table->unique(['tenant_id', 'equipment_id', 'year_month'], 'uq_inspection_month'); + $table->index(['tenant_id', 'year_month'], 'idx_inspection_ym'); + + $table->foreign('equipment_id') + ->references('id') + ->on('equipments') + ->onDelete('cascade'); + }); + } + + public function down(): void + { + Schema::dropIfExists('equipment_inspections'); + } +}; diff --git a/database/migrations/2026_02_25_100300_create_equipment_inspection_details_table.php b/database/migrations/2026_02_25_100300_create_equipment_inspection_details_table.php new file mode 100644 index 0000000..f92f40d --- /dev/null +++ b/database/migrations/2026_02_25_100300_create_equipment_inspection_details_table.php @@ -0,0 +1,38 @@ +id(); + $table->unsignedBigInteger('inspection_id')->comment('점검 헤더 ID'); + $table->unsignedBigInteger('template_item_id')->comment('점검항목 템플릿 ID'); + $table->date('check_date')->comment('점검일'); + $table->string('result', 10)->nullable()->comment('결과: good/bad/repaired'); + $table->string('note', 500)->nullable()->comment('비고'); + $table->timestamps(); + + $table->unique(['inspection_id', 'template_item_id', 'check_date'], 'uq_inspection_detail'); + + $table->foreign('inspection_id') + ->references('id') + ->on('equipment_inspections') + ->onDelete('cascade'); + + $table->foreign('template_item_id') + ->references('id') + ->on('equipment_inspection_templates') + ->onDelete('cascade'); + }); + } + + public function down(): void + { + Schema::dropIfExists('equipment_inspection_details'); + } +}; diff --git a/database/migrations/2026_02_25_100400_create_equipment_repairs_table.php b/database/migrations/2026_02_25_100400_create_equipment_repairs_table.php new file mode 100644 index 0000000..5fac7d5 --- /dev/null +++ b/database/migrations/2026_02_25_100400_create_equipment_repairs_table.php @@ -0,0 +1,42 @@ +id(); + $table->unsignedBigInteger('tenant_id')->comment('테넌트 ID'); + $table->unsignedBigInteger('equipment_id')->comment('설비 ID'); + $table->date('repair_date')->comment('수리일'); + $table->string('repair_type', 20)->comment('보전구분: internal/external'); + $table->decimal('repair_hours', 5, 1)->nullable()->comment('수리시간'); + $table->text('description')->nullable()->comment('수리내용'); + $table->decimal('cost', 15, 2)->nullable()->comment('수리비용'); + $table->string('vendor', 100)->nullable()->comment('외주업체'); + $table->foreignId('repaired_by')->nullable()->comment('수리자 ID (users.id)'); + $table->text('memo')->nullable()->comment('비고'); + $table->foreignId('created_by')->nullable()->comment('생성자 ID'); + $table->foreignId('updated_by')->nullable()->comment('수정자 ID'); + $table->timestamps(); + $table->softDeletes(); + + $table->index(['tenant_id', 'repair_date'], 'idx_repair_date'); + $table->index(['tenant_id', 'equipment_id'], 'idx_repair_equipment'); + + $table->foreign('equipment_id') + ->references('id') + ->on('equipments') + ->onDelete('cascade'); + }); + } + + public function down(): void + { + Schema::dropIfExists('equipment_repairs'); + } +}; diff --git a/database/migrations/2026_02_25_100500_create_equipment_process_table.php b/database/migrations/2026_02_25_100500_create_equipment_process_table.php new file mode 100644 index 0000000..2f78ccb --- /dev/null +++ b/database/migrations/2026_02_25_100500_create_equipment_process_table.php @@ -0,0 +1,36 @@ +id(); + $table->unsignedBigInteger('equipment_id')->comment('설비 ID'); + $table->unsignedBigInteger('process_id')->comment('공정 ID'); + $table->tinyInteger('is_primary')->default(0)->comment('주 설비 여부'); + $table->timestamps(); + + $table->unique(['equipment_id', 'process_id'], 'uq_equipment_process'); + + $table->foreign('equipment_id') + ->references('id') + ->on('equipments') + ->onDelete('cascade'); + + $table->foreign('process_id') + ->references('id') + ->on('processes') + ->onDelete('cascade'); + }); + } + + public function down(): void + { + Schema::dropIfExists('equipment_process'); + } +};