diff --git a/app/Services/WorkOrderService.php b/app/Services/WorkOrderService.php index 5e08398d..421b789e 100644 --- a/app/Services/WorkOrderService.php +++ b/app/Services/WorkOrderService.php @@ -3,6 +3,7 @@ namespace App\Services; use App\Models\Documents\Document; +use Illuminate\Support\Facades\Storage; use App\Models\Documents\DocumentTemplate; use App\Models\Orders\Order; use App\Models\Process; @@ -3445,7 +3446,7 @@ public function getWorkLog(int $workOrderId): array 'comment' => $a->comment, 'acted_at' => $a->acted_at, ])->toArray(), - 'data' => $document->data->map(fn ($d) => [ + 'data' => ($document->data ?? collect())->map(fn ($d) => [ 'field_key' => $d->field_key, 'field_value' => $d->field_value, 'section_id' => $d->section_id, @@ -3456,9 +3457,41 @@ public function getWorkLog(int $workOrderId): array 'auto_values' => $this->buildWorkLogAutoValues($workOrder), 'work_order_info' => $this->buildWorkOrderInfo($workOrder), 'work_stats' => $this->calculateWorkStats($workOrder), + 'bending_images' => $this->buildBendingImageUrls(), ]; } + /** + * 절곡 정적 이미지 R2 presigned URL 맵 생성 + */ + private function buildBendingImageUrls(): array + { + $images = []; + $paths = [ + 'guiderail_KSS01_wall_120x70', 'guiderail_KSS01_side_120x120', + 'guiderail_KSS02_wall_120x70', 'guiderail_KSS02_side_120x120', + 'guiderail_KSE01_wall_120x70', 'guiderail_KSE01_side_120x120', + 'guiderail_KWE01_wall_120x70', 'guiderail_KWE01_side_120x120', + 'guiderail_KTE01_wall_130x75', 'guiderail_KTE01_side_130x125', + 'guiderail_KQTS01_wall_130x75', 'guiderail_KQTS01_side_130x125', + 'bottombar_KSS01', 'bottombar_KSS02', 'bottombar_KSE01', + 'bottombar_KWE01', 'bottombar_KTE01', 'bottombar_KQTS01', + 'box_both', 'box_bottom', 'box_rear', + 'smokeban', + ]; + + foreach ($paths as $name) { + $category = str_contains($name, 'guiderail') ? 'guiderail' + : (str_contains($name, 'bottombar') ? 'bottombar' + : (str_contains($name, 'box') ? 'box' : 'part')); + $r2Path = "images/bending/{$category}/{$name}.jpg"; + + $images[$name] = Storage::disk('r2')->temporaryUrl($r2Path, now()->addMinutes(30)); + } + + return $images; + } + /** * 작업일지 생성/수정 (Document 기반) *