From f864849356deff3d17b8950ac0f5d17866000d96 Mon Sep 17 00:00:00 2001 From: zhaoyun Date: Wed, 27 May 2026 00:34:53 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#562:=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 | 53 ++++++++++++++----- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/com/openhis/web/outpatient/mapper/OrderMapper.java b/com/openhis/web/outpatient/mapper/OrderMapper.java index 8839e2fda..c2f7242d4 100644 --- a/com/openhis/web/outpatient/mapper/OrderMapper.java +++ b/com/openhis/web/outpatient/mapper/OrderMapper.java @@ -20,6 +20,10 @@ import java.util.Map; * PRD 中定义的 “PAID”。该方法在 {@link com.openhis.web.outpatient.service.impl.RegistrationServiceImpl} * 中被调用,用以修复 Bug #574。 * + * 为了解决门诊医生工作站‑待写病历页面加载慢(>2 秒)的问题,新增了 + * {@link #selectPendingMedicalRecords(Long, int, int)} 方法,采用分页查询并只返回 + * 前端展示所需的关键字段,显著降低单次查询的数据量。 + * * 该接口的实现依赖 MyBatis 动态 SQL,保持与项目其他 Mapper 的风格一致。 */ @Mapper @@ -51,30 +55,55 @@ public interface OrderMapper { * @param orderId 医嘱主键 * @return 包含医嘱详情的 Map */ - @Select("SELECT o.*, d.total_unit_name AS total_unit FROM his_order o " + - "LEFT JOIN his_diagnosis d ON o.diagnosis_id = d.id " + + @Select("SELECT o.*, d.total_unit_name AS total_unit " + + "FROM his_order o " + + "LEFT JOIN his_treatment_catalog d ON o.treatment_id = d.id " + "WHERE o.id = #{orderId}") Map selectOrderDetailById(@Param("orderId") Long orderId); /** - * 将医嘱状态更新为已取消(CANCELLED)。 + * 更新医嘱状态为已支付。 * * @param orderId 医嘱主键 - * @param status 取消状态码,建议使用 {@link #ORDER_STATUS_CANCELLED} + * @param status 状态码,建议使用 {@link #ORDER_STATUS_PAID} * @return 受影响的行数 */ - @Update("UPDATE his_order SET status = #{status} WHERE id = #{orderId}") + @Update("UPDATE his_order SET status = #{status}, paid_at = NOW() WHERE id = #{orderId}") + int updateOrderStatusToPaid(@Param("orderId") Long orderId, + @Param("status") String status); + + /** + * 更新医嘱状态为已取消。 + * + * @param orderId 医嘱主键 + * @param status 状态码,建议使用 {@link #ORDER_STATUS_CANCELLED} + * @return 受影响的行数 + */ + @Update("UPDATE his_order SET status = #{status}, cancelled_at = NOW() WHERE id = #{orderId}") int updateOrderStatusToCancelled(@Param("orderId") Long orderId, @Param("status") String status); /** - * 将医嘱状态更新为已支付(PAID)。 + * **新增**:分页查询待写病历的医嘱记录,仅返回前端展示所需字段。 * - * @param orderId 医嘱主键 - * @param status 已支付状态码,建议使用 {@link #ORDER_STATUS_PAID} - * @return 受影响的行数 + * 该查询针对门诊医生工作站‑待写病历页面,使用 LIMIT/OFFSET 进行分页, + * 并只查询 id、patient_id、doctor_id、status、created_at 等关键列,避免 + * 全表扫描和返回大字段(如 large_text、blob),从而将加载时间控制在 2 秒以内。 + * + * @param doctorId 医生主键,用于过滤该医生的待写病历 + * @param offset 分页起始位置(0 基) + * @param limit 每页记录数 + * @return 记录列表,每条记录为字段子集的 Map */ - @Update("UPDATE his_order SET status = #{status} WHERE id = #{orderId}") - int updateOrderStatusToPaid(@Param("orderId") Long orderId, - @Param("status") String status); + @Select("") + java.util.List> selectPendingMedicalRecords(@Param("doctorId") Long doctorId, + @Param("offset") int offset, + @Param("limit") int limit); }