• Java批量操作及分页


     

    一、每次批量插入1000

    // 批量操作
    if (!CollectionUtils.isEmpty(watchOrderSubBOList)) {
    for (WatchOrderSubscribeBO watchOrderSubscribeBO : watchOrderSubBOList) {

    list.add(watchOrderSubscribeBO);
    if (list.size() == 1000) {
    watchOrderSubscribeService.batchInsert(list);
    list.clear();
    }
    }

    if (list.size() > 0) {
    watchOrderSubscribeService.batchInsert(list);
    }
    }

    二、利用subList分页

    // 总记录数
    int totalSize = listBO.size();
    // 每页N条
    int pageSize = page.getPageSize();
    // 第几页
    int pageNum = page.getStart() + 1;
    // 共N页
    int totalPage = totalSize % pageSize == 0 ? totalSize / pageSize : (totalSize / pageSize) + 1;
    // 起始条数
    int startNum = (pageNum - 1) * pageSize > totalSize ? 0 : (pageNum - 1) * pageSize;
    // 结束条数
    int endNum = pageNum * pageSize > totalSize ? (totalSize) : pageNum * pageSize;
    // 后端分页
    page.setDatas(listBO.subList(startNum, endNum));
    page.setTotalPage(totalPage);
    page.setTotal(totalSize);

     

    三、模拟Post请求,访问web

    Map<String, String> header = new HashMap<String, String>();
    header.put("Content-type", "application/json;charset=utf-8");
    header.put("appId", "1000");
    LOGGER.info("cmtoken订购鉴OTT权校验请求开始,请求地址={},请求头={},请求参数={}", authenurl, header, reqBody);
    String resp = HttpUtils.postUrlStringBody(authenurl, reqBody, header);

     

  • 相关阅读:
    在Ubuntu下安装TensorFlow-gpu版本
    ubuntu安装和卸载软件命令
    Window7通过Anaconda安装Tensorflow
    Kaggle Titanic Data Science Solutions
    CNN、RNN和DNN的区别
    卷积神经网络介绍
    大数据随想
    golang omitempty 总结
    LeetCode 856 递归思路详解
    安装Nginx的各种报错的解决
  • 原文地址:https://www.cnblogs.com/nanfengxiangbei/p/16310321.html
Copyright © 2020-2023  润新知