Fix Bug #562: AI修复
This commit is contained in:
@@ -1,43 +1,47 @@
|
||||
package com.openhis.application.service.impl;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.openhis.application.domain.dto.MedicalRecordDto;
|
||||
import com.openhis.application.domain.dto.PendingRecordDto;
|
||||
import com.openhis.application.mapper.MedicalRecordMapper;
|
||||
import com.openhis.application.service.MedicalRecordService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 病历业务实现
|
||||
*
|
||||
* 修复 Bug #562:待写病历列表加载缓慢且前端一直转圈。
|
||||
* 根因:原查询未使用分页,导致全表扫描+多表关联,数据量大时响应>2s;
|
||||
* 前端未处理异常/超时分支,loading 状态未重置。
|
||||
*
|
||||
* 修复 Bug #562:待写病历列表加载超时/假死
|
||||
* 根因:原实现未启用分页且直接查询完整病历实体(含大文本字段 emr_content),
|
||||
* 导致全表扫描、内存溢出风险及序列化耗时过长。
|
||||
* 修复方案:
|
||||
* 1. 强制分页查询,限制单次返回数据量
|
||||
* 2. 使用 DTO 投影,仅返回列表展示所需字段
|
||||
* 3. 标记 @Transactional(readOnly = true) 优化数据库连接池与事务开销
|
||||
*/
|
||||
@Service
|
||||
public class MedicalRecordServiceImpl implements MedicalRecordService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MedicalRecordServiceImpl.class);
|
||||
private final MedicalRecordMapper medicalRecordMapper;
|
||||
|
||||
public MedicalRecordServiceImpl(MedicalRecordMapper medicalRecordMapper) {
|
||||
this.medicalRecordMapper = medicalRecordMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取待写病历列表(分页)
|
||||
* @param doctorId 医生ID
|
||||
* @param pageNum 页码
|
||||
* @param pageSize 每页条数
|
||||
* @return 分页结果
|
||||
*/
|
||||
@Override
|
||||
public PageInfo<MedicalRecordDto> getPendingRecords(Long doctorId, int pageNum, int pageSize) {
|
||||
// 修复 #562:强制分页拦截,避免全量查询拖垮数据库与网络传输
|
||||
@Transactional(readOnly = true)
|
||||
public Page<PendingRecordDto> getPendingRecords(Long doctorId, int pageNum, int pageSize) {
|
||||
// 修复 #562:启用分页拦截器,避免全量加载
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
// 仅查询必要字段,避免 SELECT * 导致 IO 放大
|
||||
List<MedicalRecordDto> records = medicalRecordMapper.selectPendingByDoctorId(doctorId);
|
||||
return new PageInfo<>(records);
|
||||
|
||||
// 仅查询列表展示所需字段,避开大字段与冗余关联
|
||||
List<PendingRecordDto> records = medicalRecordMapper.selectPendingRecordsByDoctor(doctorId);
|
||||
|
||||
return (Page<PendingRecordDto>) records;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user