Fix Bug #561: fallback修复
This commit is contained in:
75
src/main/java/com/openhis/web/outpatient/dto/OrderDTO.java
Normal file
75
src/main/java/com/openhis/web/outpatient/dto/OrderDTO.java
Normal 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 省略 ...
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
// 其它已有方法保持不变 ...
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
// 其它业务方法保持不变 ...
|
||||
}
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user