This commit is contained in:
2023-06-25 10:19:27 +08:00
parent 8413ef8e6b
commit 59195d1d03
2 changed files with 22 additions and 2 deletions

View File

@@ -121,6 +121,8 @@ public class AMapServiceImpl implements AMapService {
* @return 高度需要的数据格式
*/
private AMapStationInfo assembleAMapData(PileStationInfo stationInfo) throws ExecutionException, InterruptedException {
StopWatch stopWatch = new StopWatch();
stopWatch.start("拼装高德需要的格式数据-设置参数");
AMapStationInfo aMapInfo = new AMapStationInfo();
Long stationInfoId = stationInfo.getId();
aMapInfo.setStationID(String.valueOf(stationInfoId));
@@ -146,7 +148,9 @@ public class AMapServiceImpl implements AMapService {
}
aMapInfo.setConstruction(Integer.parseInt(construction));
aMapInfo.setBusineHours(stationInfo.getBusinessHours());
stopWatch.stop();
stopWatch.start("拼装高德需要的格式数据-查询数据");
// 根据站点id查询计费模板
// List<AMapPriceChargingInfo> priceList = getPriceInfoByStationId(String.valueOf(stationInfoId));
CompletableFuture<List<AMapPriceChargingInfo>> future1 = CompletableFuture.supplyAsync(() -> getPriceInfoByStationId(String.valueOf(stationInfoId)));
@@ -163,13 +167,18 @@ public class AMapServiceImpl implements AMapService {
// .join()和.get()都会阻塞并获取线程的执行情况
// .join()会抛出未经检查的异常,不会强制开发者处理异常 .get()会抛出检查异常,需要开发者处理
all.join();
all.get();
// all.get();
aMapInfo.setPriceChargingInfo(future1.get());
Map<String, Integer> pileNumMap = future2.get();
aMapInfo.setFastEquipmentNum(pileNumMap.get("fastTotal"));
aMapInfo.setSlowEquipmentNum(pileNumMap.get("slowTotal"));
aMapInfo.setEquipmentInfos(future3.get());
stopWatch.stop();
log.info("高德查询-拼装高德数据耗时:{}, 详细:{}", stopWatch.getTotalTimeMillis(), stopWatch.prettyPrint());
return aMapInfo;
}
@@ -266,6 +275,8 @@ public class AMapServiceImpl implements AMapService {
* @return
*/
private List<AMapPriceChargingInfo> getPriceInfoByStationId(String StationId) {
StopWatch sw = new StopWatch();
sw.start("高德查询-根据站点id查询计费模板");
List<AMapPriceChargingInfo> priceList = new ArrayList<>();
// 查询计费模板
List<BillingPriceVO> billingPriceList = pileBillingTemplateService.queryBillingPrice(StationId);
@@ -277,6 +288,8 @@ public class AMapServiceImpl implements AMapService {
priceList.add(info);
}
sw.stop();
log.info(sw.prettyPrint());
return priceList;
}
@@ -287,6 +300,8 @@ public class AMapServiceImpl implements AMapService {
* @return
*/
private List<AMapEquipmentInfo> getPileListByStationId(String stationId) {
StopWatch sw = new StopWatch();
sw.start("高德查询-根据站点查询站点下所有桩");
List<AMapEquipmentInfo> pileList = new ArrayList<>();
// 根据站点查询站点下所有桩
List<PileBasicInfo> pileBasicInfoList = pileBasicInfoService.getPileListByStationId(String.valueOf(stationId));
@@ -311,6 +326,8 @@ public class AMapServiceImpl implements AMapService {
pileList.add(info);
}
sw.stop();
log.info(sw.prettyPrint());
return pileList;
}