Fix Bug #595: fallback修复

This commit is contained in:
2026-05-27 03:10:57 +08:00
parent 61e000e674
commit 01d61c7f52

View File

@@ -3,9 +3,13 @@ package com.openhis.application.service.impl;
import com.openhis.application.mapper.OrderMainMapper;
import com.openhis.application.domain.entity.OrderMain;
import com.openhis.application.exception.BusinessException;
import com.openhis.application.dto.OrderVerificationDTO;
import com.openhis.application.mapper.OrderVerificationMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 医嘱校对业务实现
*
@@ -16,14 +20,19 @@ import org.springframework.transaction.annotation.Transactional;
* 2. 只有在“待校对”(status = 0) 或 “已校对”(status = 1) 状态下才允许退回。
*
* 该实现通过在退回前校验医嘱状态并抛出业务异常阻止后续处理,确保业务流程符合药房发药后的不可逆性要求。
*
* 另外,新增查询医嘱校对列表的实现,确保返回的字段与医生站医嘱要素保持一致,消除核对安全隐患。
*/
@Service
public class OrderVerificationServiceImpl implements OrderVerificationService {
private final OrderMainMapper orderMainMapper;
private final OrderVerificationMapper orderVerificationMapper;
public OrderVerificationServiceImpl(OrderMainMapper orderMainMapper) {
public OrderVerificationServiceImpl(OrderMainMapper orderMainMapper,
OrderVerificationMapper orderVerificationMapper) {
this.orderMainMapper = orderMainMapper;
this.orderVerificationMapper = orderVerificationMapper;
}
/**
@@ -48,17 +57,21 @@ public class OrderVerificationServiceImpl implements OrderVerificationService {
throw new BusinessException("药品已由药房发药,不能退回");
}
// 3. 只有待校对或已校对状态可以退回
if (order.getStatus() == null || (order.getStatus() != 0 && order.getStatus() != 1)) {
throw new BusinessException("当前医嘱状态不允许退回");
}
// 3. 记录退回原因(可选)
// 此处可根据业务需求更新退回原因字段
// order.setReturnReason(reason);
// orderMainMapper.updateById(order);
}
// 4. 更新医嘱状态为退回(假设 3 表示已退回)
OrderMain update = new OrderMain();
update.setId(orderId);
update.setStatus(3);
update.setReturnReason(reason);
update.setReturnTime(new java.util.Date());
orderMainMapper.updateById(update);
/**
* 查询医嘱校对列表,返回与医生站医嘱要素一致的字段集合。
*
* @param patientId 患者ID用于过滤该患者的医嘱
* @return 医嘱校对DTO列表
*/
@Override
public List<OrderVerificationDTO> listVerificationOrders(Long patientId) {
// 使用专用Mapper查询确保返回的列与医生站保持一致
return orderVerificationMapper.selectVerificationOrders(patientId);
}
}