diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationEmrAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationEmrAppServiceImpl.java index ec6527221..9647fb3fc 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationEmrAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationEmrAppServiceImpl.java @@ -220,18 +220,12 @@ public class DoctorStationEmrAppServiceImpl implements IDoctorStationEmrAppServi */ @Override public R getPendingEmrList(Long doctorId, Integer pageNo, Integer pageSize, String patientName) { - List> allRows = doctorStationEmrAppMapper.getPendingEmrList(doctorId, patientName); - int total = allRows.size(); + // 先查询总数 + Long total = doctorStationEmrAppMapper.getPendingEmrCount(doctorId, patientName); - // 分页截取 - int fromIndex = (pageNo - 1) * pageSize; - int toIndex = Math.min(fromIndex + pageSize, total); - List> pageRows; - if (fromIndex >= total) { - pageRows = new ArrayList<>(); - } else { - pageRows = allRows.subList(fromIndex, toIndex); - } + // 计算分页偏移量,再查询分页数据 + int offset = (pageNo - 1) * pageSize; + List> pageRows = doctorStationEmrAppMapper.getPendingEmrList(doctorId, patientName, pageSize, offset); // 计算年龄列 for (Map row : pageRows) { @@ -246,7 +240,7 @@ public class DoctorStationEmrAppServiceImpl implements IDoctorStationEmrAppServi Map result = new java.util.HashMap<>(); result.put("rows", pageRows); - result.put("total", total); + result.put("total", total != null ? total : 0L); return R.ok(result); } diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/mapper/DoctorStationEmrAppMapper.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/mapper/DoctorStationEmrAppMapper.java index 689a62b0b..7c375ffb0 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/mapper/DoctorStationEmrAppMapper.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/mapper/DoctorStationEmrAppMapper.java @@ -13,7 +13,9 @@ import java.util.Map; public interface DoctorStationEmrAppMapper { List> getPendingEmrList(@Param("doctorId") Long doctorId, - @Param("patientName") String patientName); + @Param("patientName") String patientName, + @Param("pageSize") Integer pageSize, + @Param("offset") Integer offset); Long getPendingEmrCount(@Param("doctorId") Long doctorId, @Param("patientName") String patientName); diff --git a/openhis-server-new/openhis-application/src/main/resources/mapper/doctorstation/DoctorStationEmrAppMapper.xml b/openhis-server-new/openhis-application/src/main/resources/mapper/doctorstation/DoctorStationEmrAppMapper.xml index d5bbe0619..b4a88763d 100755 --- a/openhis-server-new/openhis-application/src/main/resources/mapper/doctorstation/DoctorStationEmrAppMapper.xml +++ b/openhis-server-new/openhis-application/src/main/resources/mapper/doctorstation/DoctorStationEmrAppMapper.xml @@ -22,19 +22,19 @@ AND p.name LIKE CONCAT('%', #{patientName}, '%') ORDER BY e.create_time DESC + LIMIT #{pageSize} OFFSET #{offset}