做公司网站 哪个程序用的多,单页网站产品,网站排名快速见效的方法,网站建设 职责接口想要提高查询速度#xff0c;需要减少查询数据库的次数#xff0c;需要把循环里面的查询提出来一次性查询完毕#xff0c;然后通过java代码来获取响应的值。如下所示#xff1a;
ListOrderInfoHtVO orderInfoList orderInfoService.getOrderInfoHtlist(query…接口想要提高查询速度需要减少查询数据库的次数需要把循环里面的查询提出来一次性查询完毕然后通过java代码来获取响应的值。如下所示
ListOrderInfoHtVO orderInfoList orderInfoService.getOrderInfoHtlist(query);if(CollectionUtils.isNotEmpty(orderInfoList)){ListInteger orderIdList orderInfoList.stream().map(OrderInfoHtVO::getOrderId)
.collect(Collectors.toList());ListString orderNoList orderInfoList.stream().map(OrderInfoHtVO::getOrderNumber)
.collect(Collectors.toList());ListInvoiceStatusVO invoiceStatusVOList applayInvoiceInfoService.
getInvoiceStatusByOrderList(orderIdList,orderNoList,orderInfoList);MapInteger,ListInvoiceStatusVO invoiceStatusVOMap invoiceStatusVOList.stream().
collect(Collectors.groupingBy(InvoiceStatusVO::getOrderId));ListApplayInvoiceHongChongCountVO applayInvoiceHongChongCountVOList applayInvoiceInfoService
.searchApplayInvoiceHongChongCountListByOrderNoList(orderNoList);MapString,ListApplayInvoiceHongChongCountVO applayInvoiceHongChongCountVOMap applayInvoiceHongChongCountVOList.stream()
.collect(Collectors.groupingBy(ApplayInvoiceHongChongCountVO::getOrderNo));ListPackageGoodsCountVO packageGoodsCountVOList orderInfoService
.searchPackageGoodsCountListByOrderIdList(orderIdList);MapInteger,ListPackageGoodsCountVO packageGoodsCountVOMap packageGoodsCountVOList.stream()
.collect(Collectors.groupingBy(PackageGoodsCountVO::getOrderId));for (OrderInfoHtVO orderInfoHtVO : orderInfoList) {if(CollectionUtils.isNotEmpty(invoiceStatusVOMap.get(orderInfoHtVO.getOrderId()))){orderInfoHtVO.setInvoiceStatus(invoiceStatusVOMap.get(orderInfoHtVO.getOrderId()).get(0).getInvoiceStatus());
}else{orderInfoHtVO.setInvoiceStatus(0);
}if(CollectionUtils.isNotEmpty(applayInvoiceHongChongCountVOMap.get(orderInfoHtVO.getOrderNumber()))){orderInfoHtVO.setIsHongChong(applayInvoiceHongChongCountVOMap.get(orderInfoHtVO.getOrderNumber()).get(0).getIsHongChong());
}else{orderInfoHtVO.setIsHongChong(0);
}if(CollectionUtils.isNotEmpty(packageGoodsCountVOMap.get(orderInfoHtVO.getOrderId()))){orderInfoHtVO.setIsPackage(packageGoodsCountVOMap.get(orderInfoHtVO.getOrderId()).get(0).getIsPackage());
}else{orderInfoHtVO.setIsPackage(0);
}}}