diff --git a/com/openhis/web/outpatient/mapper/OrderMapper.java b/com/openhis/web/outpatient/mapper/OrderMapper.java index f6db07fea..c8db21112 100644 --- a/com/openhis/web/outpatient/mapper/OrderMapper.java +++ b/com/openhis/web/outpatient/mapper/OrderMapper.java @@ -48,19 +48,28 @@ public interface OrderMapper { /** * **新增**:查询医嘱详情并返回总量单位。 * - *
诊疗目录中配置的单位保存在列 {@code total_unit_name},前端 DTO 期望的属性名为 {@code totalUnit}。
+ * 该查询通过关联诊疗目录(treatment_catalog)获取配置的 total_unit, + * 防止前端展示时出现 null。 * - * @param orderId 医嘱 ID - * @return 包含 totalUnit 的 Map + * @param orderId 医嘱主键 + * @return 包含 id、itemName、totalQuantity、totalUnit 等字段的 Map */ - @Select("SELECT id, item_name AS itemName, total_quantity AS totalQuantity, " + - "total_unit_name AS totalUnit FROM his_order_detail WHERE order_id = #{orderId}") + @Select( + "SELECT " + + " o.id AS id, " + + " o.item_name AS itemName, " + + " o.total_quantity AS totalQuantity, " + + " COALESCE(c.total_unit, o.total_unit) AS totalUnit " + // 若目录无对应记录,回退到订单表字段 + "FROM his_order o " + + "LEFT JOIN treatment_catalog c ON o.catalog_id = c.id " + + "WHERE o.id = #{orderId}" + ) Map