- linked_item_ids + template_links + link_values 3곳 동시 설정 - MNG UI 파란 태그 표시를 위한 template_links 구조 반영 - 기존 old ID 삭제 → 신규 매핑 스크립트 완성
280 lines
11 KiB
Markdown
280 lines
11 KiB
Markdown
# 수입검사 템플릿 ↔ 원자재 품목 매핑표
|
|
|
|
> **작성일**: 2026-03-17
|
|
> **상태**: 초안 (R&D실 검토 필요)
|
|
> **목적**: MNG 문서양식관리의 수입검사 템플릿에 품목을 연결하여 입고 시 수입검사 자동 매칭
|
|
|
|
---
|
|
|
|
## 1. 현황
|
|
|
|
| 항목 | 수량 |
|
|
|------|:----:|
|
|
| 수입검사 템플릿 (활성) | 16종 |
|
|
| 원자재/부자재/소모품 (활성) | 93개 |
|
|
| 현재 매핑 완료 | 2개 (실리카원단만) |
|
|
| **기존 linked_item_ids 대부분 무효** | old item ID (삭제됨) |
|
|
|
|
> **주의**: 기존 `linked_item_ids`에 저장된 ID(14xxx)는 5130 마이그레이션 이전 데이터로, 현재 items 테이블에 존재하지 않는다. 전체 재매핑 필요.
|
|
|
|
---
|
|
|
|
## 2. 매핑표
|
|
|
|
### 2.1 SUS 계열 (원자재)
|
|
|
|
| 템플릿 | 템플릿ID | 품목 | 품목ID | item_type |
|
|
|--------|:-------:|------|:------:|:---------:|
|
|
| SUS 절곡판 수입검사 | 19 | sus1.2\*1219\*2438 | 14953 | RM |
|
|
| | | sus1.2\*1219\*3000 | 14954 | RM |
|
|
| | | sus1.2t\*1219\*4000 | 14955 | RM |
|
|
| | | sus1.5\*1219\*2438 | 14956 | RM |
|
|
| | | sus1.5\*1219\*3000 | 14957 | RM |
|
|
| | | sus1.5\*1219\*4000 | 14958 | RM |
|
|
| | | sus1.2\*1219\*c | 14959 | RM |
|
|
| | | sus1.5\*1219\*2500 | 14960 | RM |
|
|
| | | sus1.2\*1219\*4230 | 14961 | RM |
|
|
| | | sus1.2\*1219\*3000 P/L | 14962 | RM |
|
|
| | | sus1.2\*1219\*2500 | 14963 | RM |
|
|
| | | SUS 316 slat | 15226 | SM |
|
|
| | | 철재용하장바(SUS1.2T) | 14940 | SM |
|
|
|
|
### 2.2 EGI 계열 (원자재)
|
|
|
|
| 템플릿 | 템플릿ID | 품목 | 품목ID | item_type |
|
|
|--------|:-------:|------|:------:|:---------:|
|
|
| EGI 수입검사 (두께별 자동매칭) | 18 | egi1.2\*1219\*2438 | 14964 | RM |
|
|
| | | egi1.2\*1219\*3000 | 14965 | RM |
|
|
| | | egi1.2\*1219\*4000 | 14966 | RM |
|
|
| | | egi1.6\*1219\*2438 | 14967 | RM |
|
|
| | | egi1.6\*1219\*3000 | 14968 | RM |
|
|
| | | egi1.6\*1219\*4000 | 14969 | RM |
|
|
| | | egi1.6t | 15017 | RM |
|
|
| | | egi1.55 | 15018 | RM |
|
|
| | | egi1.17 | 15019 | RM |
|
|
| | | egi 1.17 | 15020 | RM |
|
|
|
|
### 2.3 앵글 계열
|
|
|
|
| 템플릿 | 템플릿ID | 품목 | 품목ID | item_type |
|
|
|--------|:-------:|------|:------:|:---------:|
|
|
| 앵글 수입검사 | 20 | 앵글40x40x3T | 15265 | SM |
|
|
| | | 앵글50x50x4T | 15266 | SM |
|
|
| | | 앵글가공 40\*3T | 15276 | SM |
|
|
| | | 앵글가공 50\*4T (H0016) | 15277 | SM |
|
|
| | | 앵글가공 50\*4T (H0017) | 15278 | SM |
|
|
| | | 앵글가공 50\*4T (H0018) | 15279 | SM |
|
|
|
|
### 2.4 내화/방화 원단 계열
|
|
|
|
| 템플릿 | 템플릿ID | 품목 | 품목ID | item_type |
|
|
|--------|:-------:|------|:------:|:---------:|
|
|
| 실리카 수입검사 | 26 | 실리카원단(슬리팅) | 15491 | RM |
|
|
| | | 실리카원단(1270) | 15493 | RM |
|
|
| 화이바글라스 수입검사 | 25 | 화이바원단 | 15563 | RM |
|
|
| 와이어글라스 수입검사 | 27 | 와이어원단 | 15564 | RM |
|
|
| 내화실 수입검사 | 30 | 내화실 | 15027 | SM |
|
|
|
|
### 2.5 전동/제어기 계열
|
|
|
|
| 템플릿 | 템플릿ID | 품목 | 품목ID | item_type |
|
|
|--------|:-------:|------|:------:|:---------:|
|
|
| 전동개폐기 수입검사 | 29 | 제어기 노출형 | 15548 | SM |
|
|
| | | 제어기 매립형 | 15549 | SM |
|
|
| | | 방화 콘트롤박스(단상) | 15550 | SM |
|
|
| | | 방화 콘트롤박스(삼상) | 15551 | SM |
|
|
| | | 방화 콘트롤박스(1500K) | 15552 | SM |
|
|
| | | 방화 방화스위치 | 15553 | SM |
|
|
| | | 방범 콘트롤박스(단상) | 15554 | SM |
|
|
| | | 방범 콘트롤박스(삼상) | 15555 | SM |
|
|
| | | 방범 스위치커버 | 15556 | SM |
|
|
| | | 방범 안전리미트 | 15557 | SM |
|
|
| | | 방범 리모콘+스위치(최초) | 15558 | SM |
|
|
| | | 방범 리모콘4구 | 15559 | SM |
|
|
| | | 방범 스위치(무선+수신기) | 15560 | SM |
|
|
| | | IS-리미트 | 15152 | SM |
|
|
| | | IS-제어기기판 | 15153 | SM |
|
|
| | | KD뒷박스 | 15149 | SM |
|
|
| | | KD리미트잭 | 15174 | SM |
|
|
| | | KD방범스위치카바 | 15151 | SM |
|
|
| | | KD컨트롤박스 CASE (80136) | 15145 | SM |
|
|
| | | KD컨트롤박스 CASE (80137) | 15146 | SM |
|
|
| | | KST-제어기뒷박스 | 15172 | SM |
|
|
| | | 주문형 매립박스 | 15071 | SM |
|
|
|
|
### 2.6 샤프트/파이프 계열
|
|
|
|
| 템플릿 | 템플릿ID | 품목 | 품목ID | item_type |
|
|
|--------|:-------:|------|:------:|:---------:|
|
|
| 샤프트 수입검사 | 24 | 웨이브(201) | 15098 | SM |
|
|
| 각파이프 수입검사 | 23 | 백관 100*50 | 15105 | SM |
|
|
|
|
### 2.7 기타 부자재
|
|
|
|
| 템플릿 | 템플릿ID | 품목 | 품목ID | item_type |
|
|
|--------|:-------:|------|:------:|:---------:|
|
|
| 마환봉 수입검사 | 22 | 8인치후렌지 | 15072 | SM |
|
|
| | | 짜부가스켓 | 15073 | SM |
|
|
| | | 가스켓쫄대(삼각) | 15080 | SM |
|
|
|
|
---
|
|
|
|
## 3. 검토 필요 (R&D실 판단 요청)
|
|
|
|
### 3.1 매핑 불확실 품목
|
|
|
|
아래 품목은 적합한 수입검사 템플릿이 불명확하다. R&D실에서 결정 필요.
|
|
|
|
| 품목ID | 품목명 | item_type | 후보 템플릿 | 비고 |
|
|
|:------:|--------|:---------:|------------|------|
|
|
| 15561 | 신설비상문 | RM | ? | 비상문 전용 검사서 필요? |
|
|
| 15511 | 제연원단 | RM | 실리카? 화이바? | 원단 재질 확인 필요 |
|
|
| 15562 | 제연커튼 | RM | 실리카? | 완제품에 가까움? |
|
|
| 15040 | BS 샤우드 2인치 | SM | 샤프트? | 샤우드 전용 검사서? |
|
|
| 15474~15481 | BS/KS 샤우드 3~10인치 (7개) | SM | 샤프트? | 동일 그룹 |
|
|
| 14933, 15081~15083 | 알카바(R-case) (4개) | SM | ? | 알루미늄 케이스 |
|
|
| 15038 | 알카바몰딩 | SM | ? | 알루미늄 몰딩 |
|
|
| 15114 | AL단열1.6T | SM | ? | 알루미늄 단열 |
|
|
| 15046, 15087 | 덧대기원단 (2개) | SM | 화이바? 실리카? | 원단 재질 확인 |
|
|
| 14947 | 불연지퍼 | SM | ? | 소모성 부자재 |
|
|
| 14948 | 지퍼슬라이더 | SM | ? | 소모성 부자재 |
|
|
| 15041, 15514 | 조인트/조인트바 | SM | ? | |
|
|
| 15065 | 비상문평철세트 | SM | SUS? | 재질 확인 |
|
|
| 15134, 15135 | KD포장박스 (2개) | SM | ? | 포장재는 검사 불필요? |
|
|
| 15251 | 쪽잠 | SM | ? | |
|
|
| 15480 | 샤우드3인치 | SM | 샤프트? | BS와 다른 규격? |
|
|
| 15226 | SUS 316 slat | SM | SUS 절곡판? | SUS 재질 |
|
|
|
|
### 3.2 수입검사 제외 대상
|
|
|
|
아래 품목은 수입검사가 불필요한 것으로 판단된다 (비물리적 항목).
|
|
|
|
| 품목ID | 품목명 | item_type | 사유 |
|
|
|:------:|--------|:---------:|------|
|
|
| 15228 | 출장비 | CS | 비용 항목 |
|
|
| 15229 | 노무비 | CS | 비용 항목 |
|
|
| 15230 | 금액조정 | CS | 비용 항목 |
|
|
| 15250 | 모터A/S | CS | A/S 항목 |
|
|
| 15134 | KD포장박스 | SM | 포장재 (검사 불필요?) |
|
|
| 15135 | KD포장박스 | SM | 포장재 (검사 불필요?) |
|
|
|
|
---
|
|
|
|
## 4. 실행 방법
|
|
|
|
### 4.1 데이터 구조
|
|
|
|
MNG UI "연결 설정"에 표시되려면 **3곳에 데이터를 넣어야** 한다:
|
|
|
|
```
|
|
document_templates.linked_item_ids ← API 내부 매칭용 (JSON 배열)
|
|
document_template_links ← MNG UI "연결 설정" 소스 테이블 정의
|
|
document_template_link_values ← MNG UI 파란 태그 (개별 품목)
|
|
```
|
|
|
|
> `linked_item_ids`만 설정하면 API 매칭은 되지만 MNG UI에 표시되지 않는다.
|
|
> `template_links` + `link_values`도 함께 설정해야 MNG에서 파란 태그로 보이고 관리 가능.
|
|
|
|
### 4.2 매핑표 확정 후 tinker 실행
|
|
|
|
```bash
|
|
docker exec sam-mng-1 php artisan tinker --execute="
|
|
\$mapping = [
|
|
19 => [14953,14954,14955,14956,14957,14958,14959,14960,14961,14962,14963,15226,14940],
|
|
18 => [14964,14965,14966,14967,14968,14969,15017,15018,15019,15020],
|
|
20 => [15265,15266,15276,15277,15278,15279],
|
|
26 => [15491,15493],
|
|
25 => [15563],
|
|
27 => [15564],
|
|
30 => [15027],
|
|
29 => [15548,15549,15550,15551,15552,15553,15554,15555,15556,15557,15558,15559,15560,15152,15153,15149,15174,15151,15145,15146,15172,15071],
|
|
24 => [15098],
|
|
23 => [15105],
|
|
22 => [15072,15073,15080],
|
|
];
|
|
|
|
foreach (\$mapping as \$templateId => \$itemIds) {
|
|
// 1. linked_item_ids 업데이트
|
|
DB::table('document_templates')
|
|
->where('id', \$templateId)
|
|
->update(['linked_item_ids' => json_encode(\$itemIds)]);
|
|
|
|
// 2. 기존 template_links/link_values 삭제
|
|
\$oldLinks = DB::table('document_template_links')
|
|
->where('template_id', \$templateId)
|
|
->pluck('id');
|
|
if (\$oldLinks->isNotEmpty()) {
|
|
DB::table('document_template_link_values')
|
|
->whereIn('link_id', \$oldLinks)
|
|
->delete();
|
|
DB::table('document_template_links')
|
|
->where('template_id', \$templateId)
|
|
->delete();
|
|
}
|
|
|
|
// 3. template_links 생성
|
|
\$linkId = DB::table('document_template_links')->insertGetId([
|
|
'template_id' => \$templateId,
|
|
'link_key' => 'items',
|
|
'label' => '연결 품목 (RM)',
|
|
'link_type' => 'multiple',
|
|
'source_table' => 'items',
|
|
'search_params' => null,
|
|
'display_fields' => null,
|
|
'is_required' => false,
|
|
'sort_order' => 0,
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]);
|
|
|
|
// 4. link_values 생성
|
|
foreach (\$itemIds as \$idx => \$itemId) {
|
|
DB::table('document_template_link_values')->insert([
|
|
'template_id' => \$templateId,
|
|
'link_id' => \$linkId,
|
|
'linkable_id' => \$itemId,
|
|
'sort_order' => \$idx,
|
|
'created_at' => now(),
|
|
]);
|
|
}
|
|
|
|
print('템플릿 ' . \$templateId . ': ' . count(\$itemIds) . '개 품목 연결 완료' . PHP_EOL);
|
|
}
|
|
"
|
|
```
|
|
|
|
### 4.3 검증
|
|
|
|
```bash
|
|
# MNG에서 확인: 문서양식관리 → 각 수입검사 템플릿 편집 → "연결 설정"에 파란 태그 표시 확인
|
|
# API에서 확인:
|
|
docker exec sam-api-1 php artisan tinker --execute="
|
|
\$items = DB::table('items')->where('tenant_id', 287)->whereIn('item_type', ['RM','SM'])->whereNull('deleted_at')->where('is_active', true)->pluck('id')->toArray();
|
|
\$templates = DB::table('document_templates')->where('tenant_id', 287)->where('category', '수입검사')->whereNotNull('linked_item_ids')->get(['id','name','linked_item_ids']);
|
|
\$mapped = [];
|
|
foreach (\$templates as \$t) {
|
|
\$ids = json_decode(\$t->linked_item_ids, true) ?? [];
|
|
foreach (\$ids as \$id) { \$mapped[] = (int)\$id; }
|
|
}
|
|
\$mapped = array_unique(\$mapped);
|
|
\$unmapped = array_diff(\$items, \$mapped);
|
|
print('매핑 완료: ' . count(\$mapped) . '개' . PHP_EOL);
|
|
print('미매핑: ' . count(\$unmapped) . '개' . PHP_EOL);
|
|
foreach (\$unmapped as \$id) {
|
|
\$item = DB::table('items')->find(\$id, ['code','name']);
|
|
print(' ❌ ' . \$id . ' | ' . \$item->code . ' | ' . \$item->name . PHP_EOL);
|
|
}
|
|
"
|
|
```
|
|
|
|
---
|
|
|
|
## 관련 문서
|
|
|
|
- [입고×수입검사 연동 계획](receiving-inspection-integration-plan.md) — 전체 구현 계획
|
|
- [수입검사 성적서 연동](incoming-inspection-document-integration-plan.md) — 기존 상세 설계
|
|
|
|
---
|
|
|
|
**최종 업데이트**: 2026-03-17
|