This commit is contained in:
Your Name
2026-10-09 09:36:17 +08:00
parent 88b94c2fc6
commit 51d8fd409e
727 changed files with 3753398 additions and 102 deletions
@@ -12,6 +12,7 @@ use app\common\model\dept\Dept;
use app\common\model\tcm\PatientAiReport;
use app\common\service\DifyChatService;
use app\common\service\NihaixiaClinicalSkill;
use app\common\service\TcmAncientBooksReference;
use app\common\service\FileService;
use think\facade\Db;
use think\facade\Log;
@@ -247,8 +248,8 @@ class PatientAiReportLogic extends BaseLogic
'source_snapshot' => $sourceJson,
'source_summary_json' => self::encodeJson($sourceSummary),
'source_diagnosis_ids_json' => self::encodeJson($diagnosisIds),
'ancient_book_sources_json' => self::encodeJson(is_array($upstream['ancient_book_sources'] ?? null)
? $upstream['ancient_book_sources'] : []),
'ancient_book_sources_json' => self::encodeJson(TcmAncientBooksReference::localizeSources(
is_array($upstream['ancient_book_sources'] ?? null) ? $upstream['ancient_book_sources'] : [])),
'source_hash' => $sourceHash,
'prompt_version' => self::PROMPT_VERSION,
'message_id' => self::cleanText($upstream['message_id'] ?? '', 191),
@@ -1110,19 +1111,29 @@ class PatientAiReportLogic extends BaseLogic
}
$seen = [];
foreach ($accumulated as $source) {
$seen[(string) ($source['url'] ?? '')] = true;
$seen[self::ancientBookSourceKey($source)] = true;
}
foreach ($sources as $source) {
if (!is_array($source) || !is_string($source['url'] ?? null) || isset($seen[$source['url']])) {
if (!is_array($source)) {
continue;
}
$seen[$source['url']] = true;
$key = self::ancientBookSourceKey($source);
if (isset($seen[$key])) {
continue;
}
$seen[$key] = true;
$accumulated[] = $source;
if (count($accumulated) >= 12) {
break;
}
}
return $accumulated;
return TcmAncientBooksReference::localizeSources($accumulated);
}
private static function ancientBookSourceKey(array $source): string
{
return (string) ($source['commit'] ?? '') . "\0" . (string) ($source['path'] ?? '')
. "\0" . (string) ($source['line'] ?? '');
}
/** @param array<string,mixed> $snapshot */
@@ -1505,7 +1516,8 @@ class PatientAiReportLogic extends BaseLogic
'source_summary' => $sourceSummary !== [] ? $sourceSummary : self::emptySourceSummary(),
'source_diagnosis_ids' => self::decodeJsonArray($row['source_diagnosis_ids_json'] ?? ''),
'knowledge_source' => NihaixiaClinicalSkill::knowledgeSourceForPromptVersion((string) ($row['prompt_version'] ?? '')),
'ancient_book_sources' => self::decodeJsonArray($row['ancient_book_sources_json'] ?? ''),
'ancient_book_sources' => TcmAncientBooksReference::localizeSources(
self::decodeJsonArray($row['ancient_book_sources_json'] ?? '')),
'prompt_version' => (string) ($row['prompt_version'] ?? ''),
'version' => max((int) ($row['version'] ?? 1), 1),
'generated_time' => $generatedTime,