From 9aa42e1cd8af0de557b3c422d53b557c5397f5d7 Mon Sep 17 00:00:00 2001
From: value <z1292839451@163.com>
Date: 星期三, 15 五月 2024 02:12:49 +0800
Subject: [PATCH] 标准库分页优化
---
inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java | 53 ++++++++++++++++++++++++++++++-----------------------
inspect-server/src/main/java/com/yuanchu/mom/service/StandardProductListService.java | 3 ++-
inspect-server/src/main/java/com/yuanchu/mom/controller/StandardTreeController.java | 4 ++--
3 files changed, 34 insertions(+), 26 deletions(-)
diff --git a/inspect-server/src/main/java/com/yuanchu/mom/controller/StandardTreeController.java b/inspect-server/src/main/java/com/yuanchu/mom/controller/StandardTreeController.java
index a62d352..d718001 100644
--- a/inspect-server/src/main/java/com/yuanchu/mom/controller/StandardTreeController.java
+++ b/inspect-server/src/main/java/com/yuanchu/mom/controller/StandardTreeController.java
@@ -92,8 +92,8 @@
@ApiOperation(value = "閫氳繃妫�楠屾爣鍑嗘煡璇㈡楠岄」鐩�")
@PostMapping("/selectStandardProductListByMethodId")
@ValueAuth
- public Result selectStandardProductListByMethodId(Integer id, String tree){
- return Result.success(standardProductListService.selectStandardProductListByMethodId(id, tree));
+ public Result selectStandardProductListByMethodId(Integer id, String tree, Integer page){
+ return Result.success(standardProductListService.selectStandardProductListByMethodId(id, tree, page));
}
@ApiOperation(value = "鑾峰彇鏍囧噯鏍戜笅鏍囧噯鏂规硶鏋氫妇")
diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/StandardProductListService.java b/inspect-server/src/main/java/com/yuanchu/mom/service/StandardProductListService.java
index 7e03502..5539cd5 100644
--- a/inspect-server/src/main/java/com/yuanchu/mom/service/StandardProductListService.java
+++ b/inspect-server/src/main/java/com/yuanchu/mom/service/StandardProductListService.java
@@ -6,6 +6,7 @@
import com.yuanchu.mom.pojo.StandardProductList;
import java.util.List;
+import java.util.Map;
/**
* @author Administrator
@@ -20,6 +21,6 @@
List<StandardProductList> selectStandardProductList(InsSample insSample);
- List<StandardProductList> selectStandardProductListByMethodId(Integer id, String tree);
+ Map<String, Object> selectStandardProductListByMethodId(Integer id, String tree, Integer page);
}
diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java
index d75719a..660938b 100644
--- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java
+++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java
@@ -16,9 +16,7 @@
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@@ -103,7 +101,7 @@
}
@Override
- public List<StandardProductList> selectStandardProductListByMethodId(Integer id, String tree) {
+ public Map<String, Object> selectStandardProductListByMethodId(Integer id, String tree, Integer page) {
String[] trees = tree.split(" - ");
List<StandardProductList> list = new ArrayList<>();
if (trees.length == 3) {
@@ -154,25 +152,34 @@
}
}
}
- Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
- CompletableFuture.supplyAsync(() -> {
- standardProductListMapper.delete(Wrappers.<StandardProductList>lambdaUpdate().eq(StandardProductList::getStandardMethodListId, id).like(StandardProductList::getTree, tree));
- standardProductListService2.saveBatch(list.stream().map(a->{
- a.setFactory(trees[0]);
- a.setLaboratory(trees[1]);
- a.setSampleType(trees[2]);
- a.setCreateUser(userId);
- a.setUpdateUser(userId);
- a.setStandardMethodListId(id);
- return a;
- }).collect(Collectors.toList()));
- return null;
- }).thenAccept(res -> {
- }).exceptionally(e -> {
- e.printStackTrace();
- return null;
- });
- return list;
+ if(page == 1){
+ Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
+ CompletableFuture.supplyAsync(() -> {
+ standardProductListMapper.delete(Wrappers.<StandardProductList>lambdaUpdate().eq(StandardProductList::getStandardMethodListId, id).like(StandardProductList::getTree, tree));
+ standardProductListService2.saveBatch(list.stream().map(a->{
+ a.setFactory(trees[0]);
+ a.setLaboratory(trees[1]);
+ a.setSampleType(trees[2]);
+ a.setCreateUser(userId);
+ a.setUpdateUser(userId);
+ a.setStandardMethodListId(id);
+ return a;
+ }).collect(Collectors.toList()));
+ return null;
+ }).thenAccept(res -> {
+ }).exceptionally(e -> {
+ e.printStackTrace();
+ return null;
+ });
+ }
+ Map<String, Object> map = new HashMap<>();
+ try {
+ map.put("productList", list.subList((page - 1)*50, page * 50));
+ }catch (IndexOutOfBoundsException e){
+ map.put("productList", list.subList((page - 1)*50, list.size()));
+ }
+ map.put("total", list.size());
+ return map;
}
}
--
Gitblit v1.9.3