This commit is contained in:
2023-06-25 11:25:24 +08:00
parent 195224382f
commit 020d9c10d5

View File

@@ -153,22 +153,18 @@ public class AMapServiceImpl implements AMapService {
stopWatch.start("拼装高德需要的格式数据-查询数据");
// 根据站点id查询计费模板
// List<AMapPriceChargingInfo> priceList = getPriceInfoByStationId(String.valueOf(stationInfoId));
CompletableFuture<List<AMapPriceChargingInfo>> future1 = CompletableFuture.supplyAsync(() -> getPriceInfoByStationId(String.valueOf(stationInfoId)));
// 根据站点id查询快、慢充设备数量
// Map<String, Integer> pileNumMap = pileConnectorInfoService.getPileTypeNum(stationInfoId);
CompletableFuture<Map<String, Integer>> future2 = CompletableFuture.supplyAsync(() -> pileConnectorInfoService.getPileTypeNum(stationInfoId));
// 根据站点查询站点下所有桩
// List<AMapEquipmentInfo> aMapEquipmentInfos = getPileListByStationId(String.valueOf(stationInfoId));
CompletableFuture<List<AMapEquipmentInfo>> future3 = CompletableFuture.supplyAsync(() -> getPileListByStationId(String.valueOf(stationInfoId)));
CompletableFuture<Void> all = CompletableFuture.allOf(future1, future2, future3);
// .join()和.get()都会阻塞并获取线程的执行情况
// .join()会抛出未经检查的异常,不会强制开发者处理异常 .get()会抛出检查异常,需要开发者处理
all.join();
// all.get();
aMapInfo.setPriceChargingInfo(future1.get());
Map<String, Integer> pileNumMap = future2.get();