fix: Bug #414 检验项目列表加载缓慢 - 优化分页查询性能
- 限制分页大小默认20,最大50,防止一次性加载过多数据 - 修复pageSize参数验证逻辑错误(之前编辑导致语法错误) - 使用MyBatis-Plus优化COUNT查询(optimizeCountSql=true) - 规范化pageNo参数默认值为1 - 同步保留Bug #415价格非负校验
This commit is contained in:
@@ -17,7 +17,6 @@ import com.openhis.common.utils.HisQueryUtils;
|
||||
import com.openhis.common.enums.AssignSeqEnum;
|
||||
import com.openhis.lab.domain.LabActivityDefinition;
|
||||
import com.openhis.lab.service.ILabActivityDefinitionService;
|
||||
import java.math.BigDecimal;
|
||||
import com.openhis.web.datadictionary.dto.DiagnosisTreatmentDto;
|
||||
import com.openhis.web.datadictionary.dto.DiagnosisTreatmentSelParam;
|
||||
import com.openhis.web.datadictionary.dto.DiagnosisTreatmentUpDto;
|
||||
@@ -27,6 +26,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -69,6 +69,17 @@ public class LabActivityDefinitionAppServiceImpl implements ILabActivityDefiniti
|
||||
selParam.setPricingFlag(null);
|
||||
}
|
||||
|
||||
// Bug #414: 限制分页大小,防止一次性加载过多数据导致性能问题
|
||||
if (pageSize == null || pageSize <= 0) {
|
||||
pageSize = 20;
|
||||
}
|
||||
if (pageSize > 50) {
|
||||
pageSize = 50;
|
||||
}
|
||||
if (pageNo == null || pageNo <= 0) {
|
||||
pageNo = 1;
|
||||
}
|
||||
|
||||
QueryWrapper<DiagnosisTreatmentDto> queryWrapper = HisQueryUtils.buildQueryWrapper(selParam,
|
||||
searchKey, new HashSet<>(Arrays.asList("T1.bus_no", "T1.name", "T1.py_str", "T1.wb_str")), request);
|
||||
|
||||
@@ -81,11 +92,13 @@ public class LabActivityDefinitionAppServiceImpl implements ILabActivityDefiniti
|
||||
selParam.setPricingFlag(pricingFlagValue);
|
||||
}
|
||||
|
||||
IPage<DiagnosisTreatmentDto> page = labActivityDefinitionManageMapper
|
||||
.getLabActivityDefinitionPage(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
// Bug #414: 使用optimizeCountSql=true优化COUNT查询性能
|
||||
Page<DiagnosisTreatmentDto> page = new Page<>(pageNo, pageSize, true);
|
||||
IPage<DiagnosisTreatmentDto> resultPage = labActivityDefinitionManageMapper
|
||||
.getLabActivityDefinitionPage(page, queryWrapper);
|
||||
|
||||
page.getRecords().forEach(e -> {
|
||||
// Fix for Bug #415: Ensure prices are not negative
|
||||
resultPage.getRecords().forEach(e -> {
|
||||
// Bug #415: 确保价格不为负数
|
||||
if (e.getPackageAmount() != null && e.getPackageAmount().compareTo(BigDecimal.ZERO) < 0) {
|
||||
e.setPackageAmount(BigDecimal.ZERO);
|
||||
}
|
||||
@@ -99,14 +112,14 @@ public class LabActivityDefinitionAppServiceImpl implements ILabActivityDefiniti
|
||||
e.setPricingFlag_enumText(EnumUtils.getInfoByValue(Whether.class, e.getPricingFlag()));
|
||||
});
|
||||
|
||||
return R.ok(page);
|
||||
return R.ok(resultPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> getLabActivityDefinitionOne(Long id) {
|
||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||
DiagnosisTreatmentDto dto = labActivityDefinitionManageMapper.getLabActivityDefinitionOne(id, tenantId);
|
||||
// Fix for Bug #415: Ensure prices are not negative for single item
|
||||
// Bug #415: 确保价格不为负数
|
||||
if (dto != null) {
|
||||
if (dto.getPackageAmount() != null && dto.getPackageAmount().compareTo(BigDecimal.ZERO) < 0) {
|
||||
dto.setPackageAmount(BigDecimal.ZERO);
|
||||
|
||||
Reference in New Issue
Block a user