Fix Bug #562: AI修复
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package com.openhis.web.outpatient.mapper;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 门诊病历数据访问层
|
||||
*
|
||||
* 修复 Bug #562:待写病历列表加载缓慢(>2s)
|
||||
* 根因分析:
|
||||
* 原实现使用 `SELECT *` 查询病历表,导致包含大文本字段(如 `record_content`, `history`, `diagnosis_detail`)
|
||||
* 的全量数据被加载至内存并进行 JSON 序列化,造成网络 IO 与 CPU 耗时过长。
|
||||
* 修复方案:
|
||||
* 1. 显式指定列表视图所需字段,剔除大文本列,仅返回基础展示信息;
|
||||
* 2. 增加 `ORDER BY create_time DESC` 与 `LIMIT` 限制,避免全表扫描与过量数据返回;
|
||||
* 3. 建议 DBA 配合创建复合索引:`CREATE INDEX idx_medical_record_doctor_status_time ON medical_record(doctor_id, status, create_time DESC);`
|
||||
*/
|
||||
@Mapper
|
||||
public interface MedicalRecordMapper {
|
||||
|
||||
/**
|
||||
* 查询当前医生的待写病历列表
|
||||
*
|
||||
* @param doctorId 医生ID
|
||||
* @return 病历基础信息列表
|
||||
*/
|
||||
@Select("SELECT " +
|
||||
"id, " +
|
||||
"patient_id, " +
|
||||
"patient_name, " +
|
||||
"visit_no, " +
|
||||
"doctor_id, " +
|
||||
"status, " +
|
||||
"create_time, " +
|
||||
"update_time " +
|
||||
"FROM medical_record " +
|
||||
"WHERE doctor_id = #{doctorId} AND status = 'PENDING' " +
|
||||
"ORDER BY create_time DESC " +
|
||||
"LIMIT 50")
|
||||
List<Map<String, Object>> selectPendingRecordsByDoctorId(@Param("doctorId") Long doctorId);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.openhis.web.outpatient.service.impl;
|
||||
|
||||
import com.openhis.web.outpatient.mapper.MedicalRecordMapper;
|
||||
import com.openhis.web.outpatient.service.MedicalRecordService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 门诊病历业务实现
|
||||
*
|
||||
* 修复 Bug #562:对接优化后的 Mapper,确保待写病历接口响应时间 < 2s。
|
||||
*/
|
||||
@Service
|
||||
public class MedicalRecordServiceImpl implements MedicalRecordService {
|
||||
|
||||
@Autowired
|
||||
private MedicalRecordMapper medicalRecordMapper;
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getPendingRecords(Long doctorId) {
|
||||
return medicalRecordMapper.selectPendingRecordsByDoctorId(doctorId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user