fix: [bending] STOCK 작업지시 bending_info DB 영구 저장

- show() 동적 생성 후 saveQuietly()로 DB 영구 저장
- index() worker_screen 모드에서도 누락된 bending_info 자동 보충
- fillStockBendingInfo() 공통 메서드로 추출
- 기존 작업지시 194~196 bending_info 백필 완료
This commit is contained in:
김보곤
2026-03-21 17:34:41 +09:00
parent a24de6c35e
commit 89dd347ff4

View File

@@ -169,6 +169,7 @@ public function index(array $params)
// 작업자 화면: BENDING 카테고리 품목에 전개도 폭(bending_width) 추가
if ($workerScreen) {
$this->appendBendingWidths($result);
$this->fillMissingStockBendingInfo($result);
}
return $result;
@@ -197,6 +198,44 @@ private function appendBendingWidths($paginator): void
}
}
/**
* STOCK 작업지시에 bending_info가 없으면 수주의 bending_lot에서 생성 후 DB 영구 저장
*/
private function fillStockBendingInfo(WorkOrder $workOrder): void
{
$orderOptions = $workOrder->salesOrder->options ?? [];
$bendingLot = $orderOptions['bending_lot'] ?? null;
if (! $bendingLot || ($workOrder->salesOrder->order_type_code ?? '') !== 'STOCK') {
return;
}
$stockBendingInfo = app(\App\Services\OrderService::class)
->buildStockBendingInfoStatic(
$bendingLot,
(int) ($orderOptions['target_stock_qty'] ?? $workOrder->salesOrder->quantity ?? 1)
);
if ($stockBendingInfo) {
$opts = $workOrder->options ?? [];
$opts['bending_info'] = $stockBendingInfo;
$workOrder->options = $opts;
$workOrder->saveQuietly();
}
}
/**
* 목록 결과에서 STOCK 작업지시의 누락된 bending_info를 보충 후 DB 영구 저장
*/
private function fillMissingStockBendingInfo($paginator): void
{
foreach ($paginator->items() as $workOrder) {
if (! empty($workOrder->options['bending_info']) || ! $workOrder->salesOrder) {
continue;
}
$this->fillStockBendingInfo($workOrder);
}
}
/**
* 통계 조회
*/
@@ -273,22 +312,9 @@ public function show(int $id)
throw new NotFoundHttpException(__('error.not_found'));
}
// STOCK(재고생산) 작업지시: bending_info 없으면 수주의 bending_lot에서 동적 생성
// STOCK(재고생산) 작업지시: bending_info 없으면 수주의 bending_lot에서 생성 후 DB 영구 저장
if (empty($workOrder->options['bending_info']) && $workOrder->salesOrder) {
$orderOptions = $workOrder->salesOrder->options ?? [];
$bendingLot = $orderOptions['bending_lot'] ?? null;
if ($bendingLot && ($workOrder->salesOrder->order_type_code ?? '') === 'STOCK') {
$stockBendingInfo = app(\App\Services\OrderService::class)
->buildStockBendingInfoStatic(
$bendingLot,
(int) ($orderOptions['target_stock_qty'] ?? $workOrder->salesOrder->quantity ?? 1)
);
if ($stockBendingInfo) {
$opts = $workOrder->options ?? [];
$opts['bending_info'] = $stockBendingInfo;
$workOrder->options = $opts;
}
}
$this->fillStockBendingInfo($workOrder);
}
return $workOrder;