From 396144f63b9ff9a3c3a93b5368e814800b897638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Sat, 21 Mar 2026 15:27:36 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20[changes]=20=EA=B3=B5=EC=A0=95=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20parent=5Fid=20=ED=8A=B8=EB=A6=AC=20=EA=B5=AC?= =?UTF-8?q?=EC=A1=B0=20=EB=8F=84=EC=9E=85=20=EC=9D=B4=EB=A0=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- INDEX.md | 1 + changes/20260321_process_parent_id_tree.md | 61 ++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 changes/20260321_process_parent_id_tree.md diff --git a/INDEX.md b/INDEX.md index 04f7784..520dcfc 100644 --- a/INDEX.md +++ b/INDEX.md @@ -311,6 +311,7 @@ DB 도메인별: | [20260320_daily_work_logs_codebridge_migration_fix.md](changes/20260320_daily_work_logs_codebridge_migration_fix.md) | 일일업무일지 codebridge DB 이관 누락 수정 (sam→codebridge 데이터 복구) | | [20260321_process_duplicate_feature.md](changes/20260321_process_duplicate_feature.md) | 공정관리 공정 복제(복사) 기능 추가 (API+React) | | [20260321_bending_api_internal_url_fix.md](changes/20260321_bending_api_internal_url_fix.md) | Docker 환경 MNG→API 호출 internal_url 미적용 500 에러 수정 | +| [20260321_process_parent_id_tree.md](changes/20260321_process_parent_id_tree.md) | 공정관리 parent_id 트리 구조 도입 (2depth, 작업자 화면 그룹 탭) | --- diff --git a/changes/20260321_process_parent_id_tree.md b/changes/20260321_process_parent_id_tree.md new file mode 100644 index 0000000..1d05057 --- /dev/null +++ b/changes/20260321_process_parent_id_tree.md @@ -0,0 +1,61 @@ +# 공정관리 parent_id 트리 구조 도입 + +**날짜:** 2026-03-21 +**작업자:** Claude Code (R&D실) + +## 변경 개요 + +공정관리에 `parent_id` 기반 2depth 트리 구조를 도입했다. 기존 `options.process_group` 임시 방식을 제거하고, 부모-자식 관계로 공정을 계층 구조화했다. + +## 배경 + +절곡 관련 공정이 5개(P-003~P-007)로 분리되면서 작업자 화면에 탭이 5개로 나뉘어 혼란이 발생했다. 공정관리 자체에서 그룹-하위 구조를 설계하는 것이 올바른 접근이다. + +## 목표 구조 + +``` +슬랫 (P-001) ← 단독 루트 +스크린 (P-002) ← 단독 루트 +절곡 (P-003) ← 부모 (자체 작업도 가능) +├── 재공품-가이드레일 (P-004) ← 자식 +├── 재공품-케이스 (P-005) +├── 재공품-하단마감재 (P-006) +└── 재공품-기타 (P-007) +``` + +## 수정된 파일 + +### API + +| 파일 | 변경 내용 | +|------|----------| +| `database/migrations/2026_03_21_152057_*.php` | `parent_id` 컬럼 + FK(onDelete: set null) + 인덱스 | +| `app/Models/Process.php` | `parent()`, `children()`, `scopeRoots()` 관계 추가 | +| `app/Services/ProcessService.php` | eager load에 parent/children 추가, store/update에 2depth 검증 | +| `app/Http/Requests/V1/Process/StoreProcessRequest.php` | `parent_id` 검증 규칙 | +| `app/Http/Requests/V1/Process/UpdateProcessRequest.php` | `parent_id` 검증 + 순환 참조 방지 | + +### React + +| 파일 | 변경 내용 | +|------|----------| +| `src/types/process.ts` | `parentId`, `children` 타입 추가, `processGroup` 제거 | +| `src/components/process-management/actions.ts` | API 변환에 parent_id/children 매핑 | +| `src/components/production/WorkerScreen/index.tsx` | `groupedTabs`를 parent_id 기반으로 전환 | + +### MNG + +| 파일 | 변경 내용 | +|------|----------| +| `app/Models/Process.php` | `fillable`에 `parent_id` 추가 | + +## 검증 규칙 + +- **2depth 제한**: 부모의 `parent_id`가 null인지 확인 (손자 공정 생성 불가) +- **순환 참조 방지**: 자기 자신 또는 자기 자식을 부모로 설정 불가 +- **FK onDelete: set null**: 부모 삭제 시 자식이 루트로 승격 (작업지시 참조 보호) + +## 관련 문서 + +- [bending/README.md](../features/bending/README.md) — 재공품 공정 구조 +- [mng-document-template.md](../features/documents/mng-document-template.md) — 공정별 문서양식