Fix Bug #562: AI修复

This commit is contained in:
2026-05-27 02:44:11 +08:00
parent 0b6ad55b5a
commit a7639fa9b1
3 changed files with 172 additions and 1 deletions

View File

@@ -0,0 +1,58 @@
package com.openhis.web.outpatient.service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.openhis.web.outpatient.mapper.MedicalRecordMapper;
import com.openhis.web.outpatient.vo.MedicalRecordListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 门诊病历业务服务
*
* 修复 Bug #562
* 原 getPendingRecords 方法未使用分页且关联查询了完整的病历正文TEXT/CLOB字段
* 导致单次查询数据量过大、数据库响应超时前端加载超过2秒。
*
* 修复方案:
* 1. 引入 PageHelper 实现分页查询限制单次返回行数默认20条
* 2. 切换至轻量级 Mapper 方法 selectPendingList仅查询列表展示所需字段排除病历正文
* 3. 添加 @Transactional(readOnly = true) 优化只读事务性能,避免不必要的锁开销。
*/
@Service
public class MedicalRecordService {
@Autowired
private MedicalRecordMapper medicalRecordMapper;
/**
* 查询待写病历列表(分页优化版)
*
* @param doctorId 医生ID
* @param pageNum 页码
* @param pageSize 每页条数
* @return 分页结果
*/
@Transactional(readOnly = true)
public PageInfo<MedicalRecordListVO> getPendingRecords(Long doctorId, int pageNum, int pageSize) {
// 开启分页插件,拦截 SQL 自动追加 LIMIT/OFFSET
PageHelper.startPage(pageNum, pageSize);
// 执行轻量级查询,避免拉取大字段,利用 doctor_id + status 索引
List<MedicalRecordListVO> list = medicalRecordMapper.selectPendingList(doctorId);
return new PageInfo<>(list);
}
/**
* 获取单份病历详情(按需加载完整内容)
*
* @param recordId 病历ID
* @return 完整病历VO
*/
@Transactional(readOnly = true)
public MedicalRecordListVO getRecordDetail(Long recordId) {
return medicalRecordMapper.selectRecordDetail(recordId);
}
}