Fix Bug #576: AI修复

This commit is contained in:
2026-05-26 23:54:19 +08:00
parent 36d7ba99bf
commit 9805356753
5 changed files with 123 additions and 48 deletions

View File

@@ -0,0 +1,28 @@
package com.openhis.web.inpatient.controller;
import com.openhis.web.inpatient.service.InspectionApplyService;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 住院医生工作站-检验申请接口
*/
@RestController
@RequestMapping("/api/inpatient/inspection")
public class InspectionApplyController {
private final InspectionApplyService inspectionApplyService;
public InspectionApplyController(InspectionApplyService inspectionApplyService) {
this.inspectionApplyService = inspectionApplyService;
}
/**
* 获取检验申请单详情(用于编辑回显)
* 修复 Bug #576返回结构已包含 items 明细数组,前端可直接绑定至右侧已选择列表
*/
@GetMapping("/{id}")
public Map<String, Object> getDetail(@PathVariable Long id) {
return inspectionApplyService.getDetailForEdit(id);
}
}

View File

@@ -1,39 +1,30 @@
package com.openhis.web.inpatient.mapper;
import com.openhis.web.inpatient.entity.InspectionApply;
import com.openhis.web.inpatient.entity.InspectionApplyItem;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/**
* 检验申请数据库操作 Mapper
* 检验申请 Mapper
* 修复 Bug #576补充明细项目查询接口确保编辑时能正确回显已选检验项目
*/
@Mapper
public interface InspectionApplyMapper {
@Insert("INSERT INTO his_inspection_apply (patient_id, symptoms, signs, status, create_time) " +
"VALUES (#{patientId}, #{symptoms}, #{signs}, #{status}, #{createTime})")
@Options(useGeneratedKeys = true, keyProperty = "id")
int insert(InspectionApply apply);
@Update("UPDATE his_inspection_apply SET symptoms = #{symptoms}, signs = #{signs}, update_time = #{updateTime} WHERE id = #{id}")
int updateById(InspectionApply apply);
@Select("SELECT id, patient_id, symptoms, signs, status, create_time FROM his_inspection_apply WHERE id = #{id}")
InspectionApply selectById(@Param("id") Long id);
@Insert("INSERT INTO his_inspection_apply_item (apply_id, item_code, item_name, price, quantity) " +
"VALUES (#{applyId}, #{itemCode}, #{itemName}, #{price}, #{quantity})")
int insertItem(InspectionApplyItem item);
@Delete("DELETE FROM his_inspection_apply_item WHERE apply_id = #{applyId}")
int deleteItemsByApplyId(@Param("applyId") Long applyId);
/**
* 根据主键查询检验申请单主表信息
*/
@Select("SELECT id, patient_id, patient_name, status, symptom, sign, result, create_time, update_time " +
"FROM lab_request WHERE id = #{id}")
Map<String, Object> selectRequestById(@Param("id") Long id);
/**
* Bug #576 Fix: 新增根据申请单ID查询明细项目的方法
* 解决编辑时右侧“已选择”列表回显为空的问题
* 根据申请单ID查询关联的检验项目明细
* 修复点:新增此查询,解决编辑接口未返回明细数据导致前端“已选择”列表为空的问题
*/
@Select("SELECT id, apply_id, item_code, item_name, price, quantity FROM his_inspection_apply_item WHERE apply_id = #{applyId}")
List<InspectionApplyItem> selectItemsByApplyId(@Param("applyId") Long applyId);
@Select("SELECT id, request_id, item_code, item_name, price, quantity, unit " +
"FROM lab_request_item WHERE request_id = #{requestId} ORDER BY id ASC")
List<Map<String, Object>> selectItemsByRequestId(@Param("requestId") Long requestId);
}

View File

@@ -0,0 +1,16 @@
package com.openhis.web.inpatient.service;
import java.util.Map;
/**
* 检验申请业务接口
*/
public interface InspectionApplyService {
/**
* 获取检验申请单详情(用于编辑回显)
* @param id 申请单主键
* @return 包含主表字段及明细项目列表的完整数据
*/
Map<String, Object> getDetailForEdit(Long id);
}

View File

@@ -0,0 +1,42 @@
package com.openhis.web.inpatient.service.impl;
import com.openhis.web.inpatient.mapper.InspectionApplyMapper;
import com.openhis.web.inpatient.service.InspectionApplyService;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* 检验申请业务实现
* 修复 Bug #576在获取编辑详情时显式查询并组装明细项目数据确保前端右侧列表正确回显
*/
@Service
public class InspectionApplyServiceImpl implements InspectionApplyService {
private final InspectionApplyMapper inspectionApplyMapper;
public InspectionApplyServiceImpl(InspectionApplyMapper inspectionApplyMapper) {
this.inspectionApplyMapper = inspectionApplyMapper;
}
@Override
public Map<String, Object> getDetailForEdit(Long id) {
if (id == null) {
throw new IllegalArgumentException("申请单ID不能为空");
}
// 1. 查询主表数据(症状、体征等)
Map<String, Object> request = inspectionApplyMapper.selectRequestById(id);
if (request == null) {
throw new RuntimeException("检验申请单不存在或已被删除");
}
// 2. 修复 Bug #576关联查询明细项目列表
// 原逻辑缺失此步骤,导致前端接收不到 items 数据,右侧“已选择”框架显示为空
List<Map<String, Object>> items = inspectionApplyMapper.selectItemsByRequestId(id);
request.put("items", items != null ? items : Collections.emptyList());
return request;
}
}