java for循环批次处理
for (int from = 0, to = 0, size = orderList.size(); from < size; from = to) { to = Math.min(from + query.getBatchSize(), size); List<Order> pageList = orderList.subList(from, to); for (Order order : pageList) { TradeBillSyncSpec tradeBillSyncSpec = setTradeBillSyncSpec.apply(partnerMap, order); tradeBillSyncSpecList.add(tradeBillSyncSpec); // 返回操作结果 DealToMiddleGroundUpgradeOrderVo upgradeDataVO = setDealToMiddleGroundUpgradeOrderVo(order); upgradeDataVOList.add(upgradeDataVO); } try { //事务内更新 transactionTemplate.executeWithoutResult(transactionStatus -> { tradeBillBatchSync(pageList, tradeBillSyncSpecList, needUpdate); }); } catch (Exception e) { log.error("commonDealToMiddleGround 异常:{}", e); } }