From d525a50f5223e43f0ef945ef435ac3981ece0f4b Mon Sep 17 00:00:00 2001 From: guanyu Date: Fri, 24 Apr 2026 08:37:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Bug=20#414=20=E6=A3=80=E9=AA=8C=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=88=97=E8=A1=A8=E5=8A=A0=E8=BD=BD=E7=BC=93=E6=85=A2?= =?UTF-8?q?=20-=20=E4=BC=98=E5=8C=96=E5=88=86=E9=A1=B5=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 限制分页大小默认20,最大50,防止一次性加载过多数据 - 修复pageSize参数验证逻辑错误(之前编辑导致语法错误) - 使用MyBatis-Plus优化COUNT查询(optimizeCountSql=true) - 规范化pageNo参数默认值为1 - 同步保留Bug #415价格非负校验 --- .../LabActivityDefinitionAppServiceImpl.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/lab/appservice/impl/LabActivityDefinitionAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/lab/appservice/impl/LabActivityDefinitionAppServiceImpl.java index 93b2b3a1..08b1c9b9 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/lab/appservice/impl/LabActivityDefinitionAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/lab/appservice/impl/LabActivityDefinitionAppServiceImpl.java @@ -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 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 page = labActivityDefinitionManageMapper - .getLabActivityDefinitionPage(new Page<>(pageNo, pageSize), queryWrapper); + // Bug #414: 使用optimizeCountSql=true优化COUNT查询性能 + Page page = new Page<>(pageNo, pageSize, true); + IPage 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);