From c2403b8a672b2553e8f791a4dd79847d74d4e37e 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 16:23:59 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20[=EC=9E=91=EC=97=85=EC=A7=80=EC=8B=9C]?= =?UTF-8?q?=20=EC=9E=90=EC=8B=9D=20=EA=B3=B5=EC=A0=95=20=EC=9E=90=EB=8F=99?= =?UTF-8?q?=20=EC=97=B0=EA=B2=B0=20=EB=B3=80=EA=B2=BD=EC=9D=B4=EB=A0=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changes/20260321_process_parent_id_tree.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/changes/20260321_process_parent_id_tree.md b/changes/20260321_process_parent_id_tree.md index d0eb680..fdfd82a 100644 --- a/changes/20260321_process_parent_id_tree.md +++ b/changes/20260321_process_parent_id_tree.md @@ -52,6 +52,28 @@ |------|----------| | `app/Models/Process.php` | `fillable`에 `parent_id` 추가 | +## 작업지시 자식 공정 자동 연결 + +### 배경 + +재공품(WIP) 작업지시의 `process_id`가 부모 공정(P-003)을 참조하여 중간검사 시 자식 공정별 개별 양식이 아닌 절곡 전체 양식이 로드되는 문제가 있었다. + +### 수정 내용 + +| 파일 | 변경 내용 | +|------|----------| +| `api/app/Services/WorkOrderService.php` | `store()`: 부모 공정 → 아이템 기반 자식 공정 자동 감지 | +| `api/app/Services/WorkOrderService.php` | `index()`: 부모 공정 필터 시 자식 공정 WO도 포함 | + +### 동작 원리 + +1. 작업지시 생성 시 `process_id`가 자식이 있는 부모 공정이면 +2. 아이템의 `item_id`를 `process_items` 테이블과 대조 +3. 가장 많이 매칭되는 자식 공정의 `process_id`로 자동 교체 +4. 매칭 실패 시 원래 부모 `process_id` 유지 (하위 호환) + +--- + ## 검증 규칙 - **2depth 제한**: 부모의 `parent_id`가 null인지 확인 (손자 공정 생성 불가)