Explorar o código

fix: align knowledge callback paper_id and center stem images

Fill paper_id for assemble_type=22 callbacks using knowledge_id fallback to keep callback contract consistent, and center case stem images with scoped styles to avoid impacting other PDF templates.

Co-authored-by: Cursor <cursoragent@cursor.com>
yemeishu hai 5 días
pai
achega
270e2d3637

+ 1 - 0
app/Jobs/GenerateKnowledgeExplanationPdfJob.php

@@ -58,6 +58,7 @@ class GenerateKnowledgeExplanationPdfJob implements ShouldQueue
             ]);
 
             $taskManager->markTaskCompleted($this->taskId, [
+                'paper_id' => $this->knowledgeId,
                 'knowledge_id' => $this->knowledgeId,
                 'pdfs' => [
                     'all_pdf' => $pdfUrl,

+ 1 - 0
app/Jobs/GenerateKnowledgeExplanationTaskJob.php

@@ -45,6 +45,7 @@ class GenerateKnowledgeExplanationTaskJob implements ShouldQueue
             $knowledgePoints = (array) $prepared['knowledge_points'];
 
             $taskManager->updateTaskStatus($this->taskId, [
+                'paper_id' => $knowledgeId,
                 'knowledge_id' => $knowledgeId,
                 'kp_codes' => array_map(static fn (array $kp) => $kp['kp_code'] ?? '', $knowledgePoints),
             ]);

+ 5 - 1
app/Services/TaskManager.php

@@ -288,7 +288,11 @@ class TaskManager
         // 根据任务类型添加特定数据
         if ($task['type'] === self::TASK_TYPE_EXAM) {
             $basePayload['callback_type'] = 'exam_pdf_generated';
-            $basePayload['paper_id'] = $task['data']['paper_id'] ?? null;
+            $basePayload['paper_id'] = $task['data']['paper_id']
+                ?? ($task['paper_id'] ?? null)
+                ?? ($task['data']['knowledge_id'] ?? null)
+                ?? ($task['knowledge_id'] ?? null);
+            // 兼容历史调用方(新调用方统一读取 paper_id)
             $basePayload['knowledge_id'] = $task['data']['knowledge_id'] ?? ($task['knowledge_id'] ?? null);
             $basePayload['pdfs'] = $task['pdfs'] ?? null;
             $basePayload['exam_content'] = $task['exam_content'] ?? null;

+ 6 - 0
resources/views/pdf/knowledge-explanation-standalone.blade.php

@@ -125,6 +125,12 @@
             orphans: 2;
             widows: 2;
         }
+        /* 题干插图:局部居中,避免影响其它 PDF 模板 */
+        .case-list .kp-case-stem img,
+        .case-list .kp-case-stem svg {
+            display: block;
+            margin: 6px auto;
+        }
 
         /* ========== 解析区 ========== */
         .case-list .kp-case-meta-block { margin-top: 3px; line-height: 1.85; }