fix: [작업일지] STOCK 작업지시 bending_info API fallback 추가

WorkOrderService::show()에서 STOCK 작업지시의 options에
bending_info가 없을 때 수주의 bending_lot에서 동적 생성.
React 작업일지 모달에서도 정상 표시되도록 수정.
This commit is contained in:
김보곤
2026-03-21 17:20:38 +09:00
parent 760efe656f
commit a24de6c35e
2 changed files with 33 additions and 2 deletions

View File

@@ -2208,7 +2208,20 @@ public function checkBendingStockForOrder(int $orderId): array
* order.options.bending_lot 코드를 work_order.options.bending_info 구조로 매핑하여
* 절곡 작업일지에서 데이터를 정상 표시할 수 있도록 한다.
*/
/**
* 외부에서 호출 가능한 static wrapper (WorkOrderService에서 사용)
*/
public function buildStockBendingInfoStatic(array $bendingLot, int $quantity): ?array
{
return self::buildStockBendingInfoFromLot($bendingLot, $quantity);
}
private function buildStockBendingInfo(array $bendingLot, int $quantity): ?array
{
return self::buildStockBendingInfoFromLot($bendingLot, $quantity);
}
private static function buildStockBendingInfoFromLot(array $bendingLot, int $quantity): ?array
{
$prodCode = $bendingLot['prod_code'] ?? '';
$specCode = $bendingLot['spec_code'] ?? '';
@@ -2219,7 +2232,7 @@ private function buildStockBendingInfo(array $bendingLot, int $quantity): ?array
}
// length_code → mm 변환
$lengthMm = $this->stockLengthCodeToMm($prodCode, $lengthCode);
$lengthMm = self::stockLengthCodeToMmStatic($prodCode, $lengthCode);
if ($lengthMm <= 0) {
return null;
}
@@ -2287,7 +2300,7 @@ private function buildStockBendingInfo(array $bendingLot, int $quantity): ?array
/**
* STOCK 재고생산 length_code → mm 변환
*/
private function stockLengthCodeToMm(string $prodCode, string $lengthCode): int
private static function stockLengthCodeToMmStatic(string $prodCode, string $lengthCode): int
{
// 연기차단재 전용 길이
if ($prodCode === 'G') {

View File

@@ -273,6 +273,24 @@ public function show(int $id)
throw new NotFoundHttpException(__('error.not_found'));
}
// STOCK(재고생산) 작업지시: bending_info 없으면 수주의 bending_lot에서 동적 생성
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;
}
}
}
return $workOrder;
}