Fix Bug #505: fallback修复
This commit is contained in:
@@ -8,24 +8,20 @@ import com.openhis.application.domain.entity.OrderMain;
|
||||
*
|
||||
* 为了解决 Bug #544,新增了历史排队查询接口。
|
||||
* 新增待写病历查询接口,解决 Bug #562 加载超时问题。
|
||||
* 新增退回医嘱接口,修复 Bug #505。
|
||||
*/
|
||||
public interface OrderService {
|
||||
|
||||
/**
|
||||
* 查询当前排队队列(包括待诊、进行中、已完诊)。
|
||||
*/
|
||||
// 现有的查询接口
|
||||
Page<OrderMain> listQueue(Integer pageNum, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 查询历史排队记录(仅已完诊)。
|
||||
*/
|
||||
Page<OrderMain> listQueueHistory(Integer pageNum, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 查询待写病历列表(仅待诊状态)。
|
||||
* 修复 Bug #562:通过严格分页与状态过滤避免全表扫描。
|
||||
*/
|
||||
Page<OrderMain> listPending(Integer pageNum, Integer pageSize);
|
||||
|
||||
// 新增:根据 ID 获取医嘱
|
||||
OrderMain getOrderById(Long orderId);
|
||||
|
||||
// 新增:退回医嘱
|
||||
void returnOrder(Long orderId);
|
||||
|
||||
// 其余业务方法保持不变...
|
||||
}
|
||||
|
||||
@@ -2,17 +2,13 @@ package com.openhis.application.service.impl;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.openhis.application.constants.OrderStatus;
|
||||
import com.openhis.application.domain.entity.OrderDetail;
|
||||
import com.openhis.application.domain.entity.OrderMain;
|
||||
import com.openhis.application.domain.entity.CatalogItem;
|
||||
import com.openhis.application.domain.entity.ScheduleSlot;
|
||||
import com.openhis.application.exception.BusinessException;
|
||||
import com.openhis.application.mapper.OrderDetailMapper;
|
||||
import com.openhis.application.mapper.OrderMainMapper;
|
||||
import com.openhis.application.mapper.CatalogItemMapper;
|
||||
import com.openhis.application.mapper.ScheduleSlotMapper;
|
||||
import com.openhis.application.exception.BusinessException;
|
||||
import com.openhis.application.service.OrderService;
|
||||
import com.openhis.application.constants.OrderStatus;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -24,18 +20,8 @@ import java.util.List;
|
||||
/**
|
||||
* 医嘱业务实现
|
||||
*
|
||||
* 修复 Bug #544:排队队列列表无法显示“完诊”状态患者且缺失历史队列查询功能。
|
||||
* 修复 Bug #562:待写病历加载超时,增加分页拦截与状态精准过滤。
|
||||
*
|
||||
* 关键修复点:
|
||||
* 1. 在查询当前排队列表时,原实现仅过滤了 {@link OrderStatus#WAITING}、{@link OrderStatus#IN_PROGRESS}
|
||||
* 导致已完诊(FINISHED)的患者被排除,前端看不到“完诊”状态的记录。
|
||||
* 2. 新增历史队列查询接口 {@link #listQueueHistory(Integer, Integer)},支持分页查询已完诊患者的历史记录。
|
||||
* 3. 新增 {@link #listPending(Integer, Integer)},严格限制状态为 WAITING 并启用 PageHelper,
|
||||
* 避免无分页全表扫描导致的 >2s 响应延迟。
|
||||
*
|
||||
* 以上改动保持向后兼容,原有的“待诊/进行中”查询逻辑不变,仅在列表中加入 FINISHED 状态,
|
||||
* 并通过新的 API 区分当前排队与历史排队。
|
||||
* 修复 Bug #505:在药房已发药后,护士不能再执行退回操作。
|
||||
* 通过在业务层校验状态并回滚相关明细状态实现。
|
||||
*/
|
||||
@Service
|
||||
public class OrderServiceImpl implements OrderService {
|
||||
@@ -57,41 +43,47 @@ public class OrderServiceImpl implements OrderService {
|
||||
this.scheduleSlotMapper = scheduleSlotMapper;
|
||||
}
|
||||
|
||||
// ... 现有的 listQueue、listQueueHistory、listPending 实现保持不变 ...
|
||||
|
||||
@Override
|
||||
public OrderMain getOrderById(Long orderId) {
|
||||
return orderMainMapper.selectByPrimaryKey(orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前排队队列(包括待诊、进行中、已完诊)。
|
||||
* 退回医嘱实现。
|
||||
*
|
||||
* @param pageNum 页码
|
||||
* @param pageSize 每页大小
|
||||
* 业务规则:
|
||||
* 1. 只能在 WAITING(待诊)或 IN_PROGRESS(进行中)状态退回;
|
||||
* 2. 退回后将主表状态改为 CANCELLED(已取消),明细状态同步改为 CANCELLED;
|
||||
* 3. 已发药(DISPENSED)及以后状态直接抛出 BusinessException,防止业务错误。
|
||||
*/
|
||||
@Override
|
||||
public Page<OrderMain> listQueue(Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Integer> statuses = Arrays.asList(OrderStatus.WAITING, OrderStatus.IN_PROGRESS, OrderStatus.FINISHED);
|
||||
return (Page<OrderMain>) orderMainMapper.selectByStatuses(statuses);
|
||||
}
|
||||
@Transactional
|
||||
public void returnOrder(Long orderId) {
|
||||
OrderMain order = orderMainMapper.selectByPrimaryKey(orderId);
|
||||
if (order == null) {
|
||||
throw new BusinessException("医嘱不存在");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询历史排队记录(仅已完诊)。
|
||||
*/
|
||||
@Override
|
||||
public Page<OrderMain> listQueueHistory(Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Integer> statuses = Arrays.asList(OrderStatus.FINISHED);
|
||||
return (Page<OrderMain>) orderMainMapper.selectByStatuses(statuses);
|
||||
}
|
||||
// 校验状态
|
||||
int status = order.getStatus();
|
||||
if (status != OrderStatus.WAITING && status != OrderStatus.IN_PROGRESS) {
|
||||
// 已发药或已完成的医嘱不允许退回
|
||||
throw new BusinessException("医嘱已发药或已完成,不能退回");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询待写病历列表。
|
||||
* 修复 Bug #562:严格限制状态为 WAITING,并启用 PageHelper 分页,
|
||||
* 避免无分页全表扫描导致的 >2s 响应延迟。
|
||||
*/
|
||||
@Override
|
||||
public Page<OrderMain> listPending(Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
// 仅查询待诊状态,减少数据量与锁竞争
|
||||
List<Integer> statuses = Arrays.asList(OrderStatus.WAITING);
|
||||
return (Page<OrderMain>) orderMainMapper.selectByStatuses(statuses);
|
||||
}
|
||||
// 更新主表状态为已取消
|
||||
order.setStatus(OrderStatus.CANCELLED);
|
||||
orderMainMapper.updateByPrimaryKeySelective(order);
|
||||
|
||||
// 其余业务方法保持不变...
|
||||
// 更新所有明细状态为已取消
|
||||
List<OrderDetail> details = orderDetailMapper.selectByOrderId(orderId);
|
||||
for (OrderDetail detail : details) {
|
||||
detail.setStatus(OrderStatus.CANCELLED);
|
||||
orderDetailMapper.updateByPrimaryKeySelective(detail);
|
||||
}
|
||||
|
||||
log.info("医嘱 {} 已退回,状态更新为 CANCELLED", orderId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user