|
@@ -4510,52 +4510,60 @@ class ExamPdfExportService
|
|
|
'student_id' => $studentId,
|
|
'student_id' => $studentId,
|
|
|
'url' => $url,
|
|
'url' => $url,
|
|
|
]);
|
|
]);
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- // 【修复】同时更新 exam_analysis_results 表和分析报告表
|
|
|
|
|
- $updated = \DB::connection('mysql')->table('exam_analysis_results')
|
|
|
|
|
- ->where('student_id', $studentId)
|
|
|
|
|
- ->where('paper_id', $paperId)
|
|
|
|
|
- ->update([
|
|
|
|
|
- 'analysis_pdf_url' => $url,
|
|
|
|
|
- 'updated_at' => now(),
|
|
|
|
|
- ]);
|
|
|
|
|
|
|
|
|
|
- if ($updated) {
|
|
|
|
|
- Log::info('ExamPdfExportService: 学情分析PDF URL已写入exam_analysis_results表', [
|
|
|
|
|
- 'student_id' => $studentId,
|
|
|
|
|
- 'paper_id' => $paperId,
|
|
|
|
|
- 'url' => $url,
|
|
|
|
|
- 'updated_rows' => $updated,
|
|
|
|
|
- ]);
|
|
|
|
|
- } else {
|
|
|
|
|
- Log::warning('ExamPdfExportService: 未找到要更新的学情分析记录', [
|
|
|
|
|
- 'student_id' => $studentId,
|
|
|
|
|
- 'paper_id' => $paperId,
|
|
|
|
|
- ]);
|
|
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 学生记录 - 使用新的 student_reports 表(备用)
|
|
|
|
|
- \App\Models\StudentReport::updateOrCreate(
|
|
|
|
|
- [
|
|
|
|
|
- 'student_id' => $studentId,
|
|
|
|
|
- 'report_type' => 'exam_analysis',
|
|
|
|
|
- 'paper_id' => $paperId,
|
|
|
|
|
- ],
|
|
|
|
|
- [
|
|
|
|
|
- 'pdf_url' => $url,
|
|
|
|
|
- 'generation_status' => 'completed',
|
|
|
|
|
- 'generated_at' => now(),
|
|
|
|
|
- 'updated_at' => now(),
|
|
|
|
|
- ]
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ Log::warning('ExamPdfExportService: recordId未匹配OCR记录,回退写入学情分析PDF URL', [
|
|
|
|
|
+ 'record_id' => $recordId,
|
|
|
|
|
+ 'student_id' => $studentId,
|
|
|
|
|
+ 'paper_id' => $paperId,
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 【修复】同时更新 exam_analysis_results 表和分析报告表
|
|
|
|
|
+ $updated = \DB::connection('mysql')->table('exam_analysis_results')
|
|
|
|
|
+ ->where('student_id', $studentId)
|
|
|
|
|
+ ->where('paper_id', $paperId)
|
|
|
|
|
+ ->update([
|
|
|
|
|
+ 'analysis_pdf_url' => $url,
|
|
|
|
|
+ 'updated_at' => now(),
|
|
|
|
|
+ ]);
|
|
|
|
|
|
|
|
- Log::info('ExamPdfExportService: 学生学情报告PDF URL已保存到student_reports表(备用)', [
|
|
|
|
|
|
|
+ if ($updated) {
|
|
|
|
|
+ Log::info('ExamPdfExportService: 学情分析PDF URL已写入exam_analysis_results表', [
|
|
|
'student_id' => $studentId,
|
|
'student_id' => $studentId,
|
|
|
'paper_id' => $paperId,
|
|
'paper_id' => $paperId,
|
|
|
'url' => $url,
|
|
'url' => $url,
|
|
|
|
|
+ 'updated_rows' => $updated,
|
|
|
|
|
+ ]);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Log::warning('ExamPdfExportService: 未找到要更新的学情分析记录', [
|
|
|
|
|
+ 'student_id' => $studentId,
|
|
|
|
|
+ 'paper_id' => $paperId,
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 学生记录 - 使用新的 student_reports 表(备用)
|
|
|
|
|
+ \App\Models\StudentReport::updateOrCreate(
|
|
|
|
|
+ [
|
|
|
|
|
+ 'student_id' => $studentId,
|
|
|
|
|
+ 'report_type' => 'exam_analysis',
|
|
|
|
|
+ 'paper_id' => $paperId,
|
|
|
|
|
+ ],
|
|
|
|
|
+ [
|
|
|
|
|
+ 'pdf_url' => $url,
|
|
|
|
|
+ 'generation_status' => 'completed',
|
|
|
|
|
+ 'generated_at' => now(),
|
|
|
|
|
+ 'updated_at' => now(),
|
|
|
|
|
+ ]
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ Log::info('ExamPdfExportService: 学生学情报告PDF URL已保存到student_reports表(备用)', [
|
|
|
|
|
+ 'student_id' => $studentId,
|
|
|
|
|
+ 'paper_id' => $paperId,
|
|
|
|
|
+ 'url' => $url,
|
|
|
|
|
+ ]);
|
|
|
} catch (\Throwable $e) {
|
|
} catch (\Throwable $e) {
|
|
|
Log::error('ExamPdfExportService: 写入学情分析PDF URL失败', [
|
|
Log::error('ExamPdfExportService: 写入学情分析PDF URL失败', [
|
|
|
'paper_id' => $paperId,
|
|
'paper_id' => $paperId,
|