From 84fafb0bc5bf3d742f4136c78288a3d06678fc4d Mon Sep 17 00:00:00 2001 From: iven Date: Thu, 30 Apr 2026 12:27:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(web+health):=20=E4=BF=AE=E5=A4=8D=E5=92=A8?= =?UTF-8?q?=E8=AF=A2=E8=BD=AE=E8=AF=A2=20temp=20ID=20400=20+=20=E5=81=A5?= =?UTF-8?q?=E5=BA=B7=E6=95=B0=E6=8D=AE=E7=BB=9F=E8=AE=A1=20500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ConsultationDetail: 轮询取 lastId 时过滤 temp_ 前缀的乐观消息 ID, 避免将非法 UUID 传给 after_id 参数导致后端 400 - stats_service: count_abnormal_lab_items 和 compute_daily_report_rate 中 SQL 字面量 0 类型为 INT4,与 Rust i64 (INT8) 不匹配, 改为 0::bigint 确保类型兼容 --- apps/web/src/pages/health/ConsultationDetail.tsx | 3 ++- crates/erp-health/src/service/stats_service.rs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/web/src/pages/health/ConsultationDetail.tsx b/apps/web/src/pages/health/ConsultationDetail.tsx index 4cdb680..2bb73a4 100644 --- a/apps/web/src/pages/health/ConsultationDetail.tsx +++ b/apps/web/src/pages/health/ConsultationDetail.tsx @@ -120,7 +120,8 @@ export default function ConsultationDetail() { pollRef.current = setInterval(async () => { if (!sessionId) return; try { - const lastId = messages.length > 0 ? messages[messages.length - 1].id : undefined; + const realMsgs = messages.filter((m) => !m.id.startsWith('temp_')); + const lastId = realMsgs.length > 0 ? realMsgs[realMsgs.length - 1].id : undefined; const result = await consultationApi.listMessages(sessionId, { page: 1, page_size: 50, diff --git a/crates/erp-health/src/service/stats_service.rs b/crates/erp-health/src/service/stats_service.rs index c0cfc18..f97de36 100644 --- a/crates/erp-health/src/service/stats_service.rs +++ b/crates/erp-health/src/service/stats_service.rs @@ -386,7 +386,7 @@ async fn count_abnormal_lab_items( (SELECT jsonb_agg(elem) FROM jsonb_array_elements(items) elem WHERE elem->>'is_abnormal' = 'true'), '[]'::jsonb ) - )), 0) AS total + )), 0::bigint) AS total FROM lab_report WHERE tenant_id = $1 AND deleted_at IS NULL AND items IS NOT NULL AND created_at >= date_trunc('month', NOW()) @@ -446,7 +446,7 @@ async fn compute_daily_report_rate( let sql = r#" SELECT d::date::text AS date, COUNT(DISTINCT vs.patient_id) AS reported, - 0 AS total + 0::bigint AS total FROM generate_series( CURRENT_DATE - INTERVAL '6 days', CURRENT_DATE,