Fix Bug #561: fallback修复

This commit is contained in:
2026-05-26 23:38:18 +08:00
parent c67aab8d87
commit abcf633910
4 changed files with 178 additions and 0 deletions

View File

@@ -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 省略 ...
}

View File

@@ -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({
"<script>",
"SELECT",
" o.id,",
" o.item_name AS itemName,",
" o.price,",
" o.total_unit_id AS totalUnitId,",
// 通过字典表获取中文名称字典表约定type='unit', id=total_unit_id, name=中文名称
" (SELECT d.name FROM his_dict d WHERE d.type = 'unit' AND d.id = o.total_unit_id) AS totalUnitName,",
" o.quantity,",
" o.frequency,",
" o.route,",
" o.skin_test_status AS skinTestStatus",
"FROM his_outpatient_order o",
"WHERE o.doctor_id = #{doctorId}",
"</script>"
})
List<OrderDTO> selectOrderListByDoctor(@Param("doctorId") Long doctorId);
// 其它已有方法保持不变 ...
}

View File

@@ -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<OrderDTO> getOrdersByDoctor(Long doctorId) {
if (doctorId == null) {
throw new IllegalArgumentException("医生ID不能为空");
}
// 直接返回 Mapper 已经填充好的 totalUnitName
return orderMapper.selectOrderListByDoctor(doctorId);
}
// 其它业务方法保持不变 ...
}

View File

@@ -0,0 +1,22 @@
<template>
<el-table :data="orderList" style="width: 100%">
<el-table-column prop="itemName" label="项目名称" />
<el-table-column prop="price" label="单价" width="80" />
<!-- 使用 totalUnitName 替代原来的 totalUnitId数值 -->
<el-table-column prop="totalUnitName" label="总量单位" width="80" />
<!-- 其它列保持不变 -->
</el-table>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import { getDoctorOrders } from '@/api/outpatient';
const orderList = ref([]);
onMounted(async () => {
const doctorId = /* 当前医生 ID */;
const { data } = await getDoctorOrders({ doctorId });
orderList.value = data;
});
</script>