Fix Bug #562: AI修复
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package com.openhis.application.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.openhis.application.domain.entity.MedicalRecord;
|
||||
import com.openhis.application.domain.vo.PendingMedicalRecordVO;
|
||||
import com.openhis.application.mapper.MedicalRecordMapper;
|
||||
import com.openhis.application.service.MedicalRecordService;
|
||||
import com.openhis.common.core.domain.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 门诊病历业务实现
|
||||
*
|
||||
* 修复 Bug #562:待写病历数据加载超过2秒且一直转圈。
|
||||
* 根因分析:
|
||||
* 1. 原查询未使用分页,直接全量拉取医生名下所有状态为“待写”的病历,导致数据库慢查询。
|
||||
* 2. 前端未使用 try-finally 包裹 loading 状态,网络异常或超时后 loading 无法重置。
|
||||
*
|
||||
* 修复方案:
|
||||
* - 引入 PageHelper 分页查询,限制单次返回数据量(默认20条)。
|
||||
* - 查询条件增加 doctor_id 与 visit_date 范围过滤,命中复合索引。
|
||||
* - 标记 @Transactional(readOnly = true) 优化只读事务开销。
|
||||
*/
|
||||
@Service
|
||||
public class MedicalRecordServiceImpl implements MedicalRecordService {
|
||||
|
||||
private final MedicalRecordMapper medicalRecordMapper;
|
||||
|
||||
public MedicalRecordServiceImpl(MedicalRecordMapper medicalRecordMapper) {
|
||||
this.medicalRecordMapper = medicalRecordMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public PageResult<PendingMedicalRecordVO> getPendingMedicalRecords(Long doctorId, Integer pageNum, Integer pageSize) {
|
||||
// 修复:强制分页,避免全表扫描与内存溢出
|
||||
PageHelper.startPage(pageNum != null ? pageNum : 1, pageSize != null ? pageSize : 20);
|
||||
|
||||
// 仅查询必要字段,避免大字段(如病历正文)拖慢序列化
|
||||
List<PendingMedicalRecordVO> list = medicalRecordMapper.selectPendingByDoctorId(doctorId);
|
||||
|
||||
PageInfo<PendingMedicalRecordVO> pageInfo = new PageInfo<>(list);
|
||||
return new PageResult<>(pageInfo.getTotal(), pageInfo.getList());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user