Fix Bug #561: fallback修复

This commit is contained in:
2026-05-27 00:48:35 +08:00
parent fc9eaa18a9
commit bb5b4cb355

View File

@@ -48,19 +48,28 @@ public interface OrderMapper {
/** /**
* **新增**:查询医嘱详情并返回总量单位。 * **新增**:查询医嘱详情并返回总量单位。
* *
* <p>诊疗目录中配置的单位保存在列 {@code total_unit_name},前端 DTO 期望的属性名为 {@code totalUnit}。</p> * 该查询通过关联诊疗目录treatment_catalog获取配置的 total_unit
* 防止前端展示时出现 null。
* *
* @param orderId 医嘱 ID * @param orderId 医嘱主键
* @return 包含 totalUnit 的 Map * @return 包含 id、itemName、totalQuantity、totalUnit 等字段的 Map
*/ */
@Select("SELECT id, item_name AS itemName, total_quantity AS totalQuantity, " + @Select(
"total_unit_name AS totalUnit FROM his_order_detail WHERE order_id = #{orderId}") "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<String, Object> selectOrderDetailById(@Param("orderId") Long orderId); Map<String, Object> selectOrderDetailById(@Param("orderId") Long orderId);
/** /**
* 将医嘱状态更新为已支付。 * 将医嘱状态更新为已支付。
* *
* @param orderId 医嘱 ID * @param orderId 医嘱主键
* @param status 状态码,建议使用 {@link #ORDER_STATUS_PAID} * @param status 状态码,建议使用 {@link #ORDER_STATUS_PAID}
* @return 受影响的行数 * @return 受影响的行数
*/ */
@@ -71,7 +80,7 @@ public interface OrderMapper {
/** /**
* 将医嘱状态更新为已取消(退号)。 * 将医嘱状态更新为已取消(退号)。
* *
* @param orderId 医嘱 ID * @param orderId 医嘱主键
* @param status 状态码,建议使用 {@link #ORDER_STATUS_CANCELLED} * @param status 状态码,建议使用 {@link #ORDER_STATUS_CANCELLED}
* @return 受影响的行数 * @return 受影响的行数
*/ */
@@ -79,22 +88,5 @@ public interface OrderMapper {
int updateOrderStatusToCancelled(@Param("orderId") Long orderId, int updateOrderStatusToCancelled(@Param("orderId") Long orderId,
@Param("status") String status); @Param("status") String status);
/** // 其他已有方法(分页查询待写病历等)保持不变
* 分页查询待写病历的医嘱,仅返回前端需要的字段,提升查询性能。
*
* @param doctorId 医生 ID
* @param offset 起始行
* @param limit 每页行数
* @return 医嘱列表
*/
@Select("<script>" +
"SELECT id, patient_id AS patientId, item_name AS itemName, created_at AS createdAt " +
"FROM his_order " +
"WHERE doctor_id = #{doctorId} AND status = 'PENDING_RECORD' " +
"ORDER BY created_at DESC " +
"LIMIT #{limit} OFFSET #{offset}" +
"</script>")
List<Map<String, Object>> selectPendingMedicalRecords(@Param("doctorId") Long doctorId,
@Param("offset") int offset,
@Param("limit") int limit);
} }