diff --git a/src/main/java/com/openhis/web/outpatient/dto/OrderDTO.java b/src/main/java/com/openhis/web/outpatient/dto/OrderDTO.java new file mode 100644 index 000000000..a05083172 --- /dev/null +++ b/src/main/java/com/openhis/web/outpatient/dto/OrderDTO.java @@ -0,0 +1,75 @@ +package com.openhis.web.outpatient.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * 门诊医嘱返回的 DTO + * + * 关键修复(Bug #561): + * 1. 之前返回的“总量单位”字段仅是字典表的主键 ID,前端直接展示导致出现 “null” 或者数字 ID。 + * 2. 新增 `totalUnitName` 字段用于返回字典中文名称,并在 JSON 序列化时保持向后兼容。 + * - 旧字段 `totalUnitId`(ID)仍保留,供老接口使用。 + * - 前端页面改为使用 `totalUnitName`,即可得到正确的中文单位显示。 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class OrderDTO { + + private Long id; + private String itemName; + private Double price; + + /** 原始的单位 ID(字典表主键),保留兼容老接口 */ + @JsonProperty("totalUnitId") + private Integer totalUnitId; + + /** 新增:总量单位的中文名称,前端展示使用 */ + @JsonProperty("totalUnitName") + private String totalUnitName; + + // 其它已有字段省略 ... + + // ------------------- Getter / Setter ------------------- + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getItemName() { + return itemName; + } + + public void setItemName(String itemName) { + this.itemName = itemName; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price; + } + + public Integer getTotalUnitId() { + return totalUnitId; + } + + public void setTotalUnitId(Integer totalUnitId) { + this.totalUnitId = totalUnitId; + } + + public String getTotalUnitName() { + return totalUnitName; + } + + public void setTotalUnitName(String totalUnitName) { + this.totalUnitName = totalUnitName; + } + + // 其它 getter / setter 省略 ... +} diff --git a/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java b/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java new file mode 100644 index 000000000..e495efb58 --- /dev/null +++ b/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java @@ -0,0 +1,47 @@ +package com.openhis.web.outpatient.mapper; + +import com.openhis.web.outpatient.dto.OrderDTO; +import org.apache.ibatis.annotations.*; + +import java.util.List; + +/** + * 门诊医嘱相关数据库操作 Mapper + * + * 关键修复(Bug #561): + * 1. 在查询医嘱列表时,联表查询字典表(his_dict)获取“总量单位”的中文名称。 + * 之前仅返回 total_unit_id,导致前端展示为 null 或者数字 ID。 + * 现在返回 total_unit_name,并映射到 DTO 的 totalUnitName 字段。 + */ +@Mapper +public interface OrderMapper { + + // 其它已有方法省略 ... + + /** + * 查询门诊医嘱列表(含总量单位中文名称)。 + * + * @param doctorId 医生 ID + * @return 包含总量单位中文名称的医嘱 DTO 列表 + */ + @Select({ + "" + }) + List selectOrderListByDoctor(@Param("doctorId") Long doctorId); + + // 其它已有方法保持不变 ... +} diff --git a/src/main/java/com/openhis/web/outpatient/service/OrderServiceImpl.java b/src/main/java/com/openhis/web/outpatient/service/OrderServiceImpl.java new file mode 100644 index 000000000..70d5890f2 --- /dev/null +++ b/src/main/java/com/openhis/web/outpatient/service/OrderServiceImpl.java @@ -0,0 +1,34 @@ +package com.openhis.web.outpatient.service; + +import com.openhis.web.outpatient.dto.OrderDTO; +import com.openhis.web.outpatient.mapper.OrderMapper; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 门诊医嘱服务实现 + * + * 关键修复(Bug #561): + * 1. 在业务层返回的 DTO 中已经包含 totalUnitName,前端直接使用即可。 + */ +@Service +public class OrderServiceImpl implements OrderService { + + private final OrderMapper orderMapper; + + public OrderServiceImpl(OrderMapper orderMapper) { + this.orderMapper = orderMapper; + } + + @Override + public List getOrdersByDoctor(Long doctorId) { + if (doctorId == null) { + throw new IllegalArgumentException("医生ID不能为空"); + } + // 直接返回 Mapper 已经填充好的 totalUnitName + return orderMapper.selectOrderListByDoctor(doctorId); + } + + // 其它业务方法保持不变 ... +} diff --git a/src/main/resources/static/js/views/outpatient/DoctorOrder.vue b/src/main/resources/static/js/views/outpatient/DoctorOrder.vue new file mode 100644 index 000000000..dc0c5fd4a --- /dev/null +++ b/src/main/resources/static/js/views/outpatient/DoctorOrder.vue @@ -0,0 +1,22 @@ + + +