This commit is contained in:
Lemon
2024-09-09 21:32:31 +08:00
parent 4500fd649d
commit 6f5fdc8a42
2 changed files with 185 additions and 4 deletions

View File

@@ -187,18 +187,18 @@ public class PileService {
}
// 查询充电桩下枪口信息
CompletableFuture<List<ConnectorInfoVO>> connectorInfoListFuture = CompletableFuture.supplyAsync(() -> pileConnectorInfoService.selectConnectorInfoList(pileSn));
CompletableFuture<List<ConnectorInfoVO>> connectorInfoListFuture = FutureUtil.supplyAsync(() -> pileConnectorInfoService.selectConnectorInfoList(pileSn));
log.info("查询充电枪口详情-supplyAsync-selectConnectorInfoList:{}", connectorInfoListFuture);
// 查计费模板信息
CompletableFuture<List<BillingPriceVO>> billingPriceFuture = CompletableFuture.supplyAsync(() -> pileBillingTemplateService.queryBillingPrice(pileInfoVO.getStationId()));
CompletableFuture<List<BillingPriceVO>> billingPriceFuture = FutureUtil.supplyAsync(() -> pileBillingTemplateService.queryBillingPrice(pileInfoVO.getStationId()));
log.info("查询充电枪口详情-supplyAsync-queryBillingPrice:{}", billingPriceFuture);
// 查询运营商信息
CompletableFuture<MerchantInfoVO> merchantInfoVOFuture = CompletableFuture.supplyAsync(() -> pileMerchantInfoService.getMerchantInfoVO(pileInfoVO.getMerchantId()));
CompletableFuture<MerchantInfoVO> merchantInfoVOFuture = FutureUtil.supplyAsync(() -> pileMerchantInfoService.getMerchantInfoVO(pileInfoVO.getMerchantId()));
log.info("查询充电枪口详情-supplyAsync-getMerchantInfoVO:{}", merchantInfoVOFuture);
CompletableFuture<Void> all = CompletableFuture.allOf(connectorInfoListFuture, merchantInfoVOFuture, billingPriceFuture);
CompletableFuture all = FutureUtil.allOf(connectorInfoListFuture, merchantInfoVOFuture, billingPriceFuture);
// .join()和.get()都会阻塞并获取线程的执行情况
// .join()会抛出未经检查的异常,不会强制开发者处理异常 .get()会抛出检查异常,需要开发者处理
all.join();