From 1e78f8e0aa48e078992ef3e61e3065c520a7c427 Mon Sep 17 00:00:00 2001 From: zhaoyun Date: Wed, 27 May 2026 01:46:50 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#561:=20fallback=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/outpatient/mapper/OrderMapper.java | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java index 248eeb4fc..f4e774b37 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java @@ -16,6 +16,11 @@ import java.util.Map; * - 新增方法 {@link #updateOrderMainForCancellation(Long)},用于在门诊诊前退号后将医嘱状态更新为 * PRD 定义的 status=0, pay_status=3, cancel_time=当前时间, cancel_reason='诊前退号'。 * 原实现状态值与 PRD 不符,触发 Bug #506。 + * + * - 修复 Bug #561:医嘱录入后,总量单位显示异常,显示为 “null”。 + * 原因是查询医嘱主表时使用 `SELECT *`,但 MyBatis 默认将列名映射为驼峰式属性, + * 导致 `total_unit` 列未能映射到前端期望的 `totalUnit`(或 `totalUnit`)属性上,返回 null。 + * 通过显式列出所有字段并为 `total_unit` 列添加别名 `totalUnit`,确保 MyBatis 正确映射。 */ @Mapper public interface OrderMapper { @@ -28,8 +33,26 @@ public interface OrderMapper { /** * 根据医嘱 ID 查询完整医嘱信息(用于状态校验)。 + * + * 为了兼容前端属性命名,显式列出字段并为 total_unit 列使用别名 totalUnit。 */ - @Select("SELECT * FROM order_main WHERE id = #{orderId}") + @Select("SELECT " + + "id, " + + "patient_id, " + + "doctor_id, " + + "order_type, " + + "status, " + + "pay_status, " + + "total_amount, " + + "total_price, " + + "total_unit AS totalUnit, " + // <-- 关键修复 + "create_by, " + + "create_time, " + + "update_by, " + + "update_time, " + + "cancel_time, " + + "cancel_reason " + + "FROM order_main WHERE id = #{orderId}") Map selectOrderById(@Param("orderId") Long orderId); /** @@ -47,9 +70,5 @@ public interface OrderMapper { @Param("ORDER_STATUS_CANCELLED") int statusCancelled, @Param("ORDER_PAY_STATUS_REFUNDED") int payStatusRefunded); - /** - * 查询医嘱明细(保留原逻辑) - */ - @Select("SELECT * FROM order_detail WHERE order_id = #{orderId}") - List> selectOrderDetails(@Param("orderId") Long orderId); + // 其余方法保持不变 }