fix: 슬랫 작업일지 데이터 파이프라인 구축
- OrderService.createFromQuote: BOM 결과에서 slat_info(조인트바/방화유리 수량) 추출하여 OrderNode.options에 저장 - OrderService.createWorkOrders: nodeOptions에 slat_info 없을 때 bom_result에서 fallback 추출 - OrderService.syncFromQuote: 동일하게 slat_info 추출 추가 - WorkOrderService: salesOrder eager loading에 client_contact, options 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -668,6 +668,7 @@ public function createFromQuote(int $quoteId, array $data = [])
|
||||
'wing_size' => $locItem['wingSize'] ?? null,
|
||||
'inspection_fee' => $locItem['inspectionFee'] ?? null,
|
||||
'bom_result' => $bomResult,
|
||||
'slat_info' => $this->extractSlatInfoFromBom($bomResult, $locItem),
|
||||
],
|
||||
'depth' => 0,
|
||||
'sort_order' => $idx,
|
||||
@@ -850,6 +851,7 @@ public function syncFromQuote(Quote $quote, int $revision): ?Order
|
||||
'wing_size' => $locItem['wingSize'] ?? null,
|
||||
'inspection_fee' => $locItem['inspectionFee'] ?? null,
|
||||
'bom_result' => $bomResult,
|
||||
'slat_info' => $this->extractSlatInfoFromBom($bomResult, $locItem),
|
||||
],
|
||||
'depth' => 0,
|
||||
'sort_order' => $idx,
|
||||
@@ -1154,13 +1156,19 @@ public function createProductionOrder(int $orderId, array $data)
|
||||
$node = $order->rootNodes->firstWhere('id', $orderItem->order_node_id);
|
||||
$nodeOptions = $node ? ($node->options ?? []) : [];
|
||||
}
|
||||
// slat_info: nodeOptions에 있으면 사용, 없으면 bom_result에서 추출 (하위 호환)
|
||||
$slatInfo = $nodeOptions['slat_info'] ?? null;
|
||||
if (! $slatInfo && isset($nodeOptions['bom_result'])) {
|
||||
$slatInfo = $this->extractSlatInfoFromBom($nodeOptions['bom_result']);
|
||||
}
|
||||
|
||||
$woItemOptions = array_filter([
|
||||
'floor' => $orderItem->floor_code,
|
||||
'code' => $orderItem->symbol_code,
|
||||
'width' => $nodeOptions['width'] ?? $nodeOptions['open_width'] ?? null,
|
||||
'height' => $nodeOptions['height'] ?? $nodeOptions['open_height'] ?? null,
|
||||
'cutting_info' => $nodeOptions['cutting_info'] ?? null,
|
||||
'slat_info' => $nodeOptions['slat_info'] ?? null,
|
||||
'slat_info' => $slatInfo,
|
||||
'bending_info' => $nodeOptions['bending_info'] ?? null,
|
||||
'wip_info' => $nodeOptions['wip_info'] ?? null,
|
||||
], fn ($v) => $v !== null);
|
||||
@@ -1198,6 +1206,47 @@ public function createProductionOrder(int $orderId, array $data)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* BOM 결과에서 슬랫 공정 정보 추출
|
||||
*
|
||||
* 조인트바 수량: BOM items에서 '조인트바' 항목의 quantity, 없으면 inputVariables의 joint_bar_qty
|
||||
* 방화유리 수량: 프론트 입력값(glass_qty) 우선, 없으면 QTY(개소당 수량) 사용
|
||||
*/
|
||||
private function extractSlatInfoFromBom(?array $bomResult, array $locItem = []): ?array
|
||||
{
|
||||
if (! $bomResult) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$bomVars = $bomResult['variables'] ?? [];
|
||||
$bomItems = $bomResult['items'] ?? [];
|
||||
$productType = $bomVars['product_type'] ?? 'screen';
|
||||
|
||||
// 스크린 전용 제품은 슬랫 정보 불필요
|
||||
if ($productType === 'screen') {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 조인트바 수량: BOM items에서 추출, 없으면 입력 변수에서
|
||||
$jointBarQty = (int) ($bomVars['joint_bar_qty'] ?? 0);
|
||||
if ($jointBarQty === 0) {
|
||||
foreach ($bomItems as $item) {
|
||||
if (str_contains($item['item_name'] ?? '', '조인트바')) {
|
||||
$jointBarQty = (int) ($item['quantity'] ?? 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 방화유리 수량: 프론트 입력값 우선, 없으면 개소 수량(QTY)
|
||||
$glassQty = (int) ($locItem['glass_qty'] ?? $bomVars['glass_qty'] ?? $locItem['quantity'] ?? 0);
|
||||
|
||||
return [
|
||||
'joint_bar' => $jointBarQty,
|
||||
'glass_qty' => $glassQty,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 작업지시번호 자동 생성
|
||||
*/
|
||||
|
||||
@@ -53,7 +53,7 @@ public function index(array $params)
|
||||
'assignee:id,name',
|
||||
'assignees.user:id,name',
|
||||
'team:id,name',
|
||||
'salesOrder' => fn ($q) => $q->select('id', 'order_no', 'client_id', 'client_name', 'site_name', 'quantity', 'received_at', 'delivery_date')->withCount('rootNodes'),
|
||||
'salesOrder' => fn ($q) => $q->select('id', 'order_no', 'client_id', 'client_name', 'client_contact', 'site_name', 'quantity', 'received_at', 'delivery_date', 'options')->withCount('rootNodes'),
|
||||
'salesOrder.client:id,name',
|
||||
'process:id,process_name,process_code,department,options',
|
||||
'items:id,work_order_id,item_id,item_name,specification,quantity,unit,status,options,sort_order,source_order_item_id',
|
||||
|
||||
Reference in New Issue
Block a user