2.8 KiB
2.8 KiB
공정관리 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 매핑, getRootProcessOptions 추가 |
src/components/process-management/ProcessListClient.tsx |
트리 형태 목록 (접기/펼치기, 자식 들여쓰기, 자식 수 배지) |
src/components/process-management/ProcessForm.tsx |
"부모 공정" Select 필드 (루트 공정 드롭다운) |
src/components/process-management/ProcessDetail.tsx |
부모 공정 링크 표시 + 하위 공정 섹션 |
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 — 재공품 공정 구조
- mng-document-template.md — 공정별 문서양식