value
2024-05-15 9aa42e1cd8af0de557b3c422d53b557c5397f5d7
标准库分页优化
已修改3个文件
24 ■■■■■ 文件已修改
inspect-server/src/main/java/com/yuanchu/mom/controller/StandardTreeController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/StandardProductListService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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 = "获取标准树下标准方法枚举")
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);
}
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,6 +152,7 @@
                }
            }
        }
        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));
@@ -172,7 +171,15 @@
            e.printStackTrace();
            return null;
        });
        return list;
        }
        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;
    }
}