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

@@ -614,6 +614,8 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService {
* @return * @return
*/ */
public Map<String, Integer> getPileTypeNum(Long stationId) { public Map<String, Integer> getPileTypeNum(Long stationId) {
StopWatch sw = new StopWatch();
sw.start("高德查询-根据站点id查询快、慢充设备数量");
int fastTotal = 0; int fastTotal = 0;
int fastFree = 0; int fastFree = 0;
int slowTotal = 0; int slowTotal = 0;
@@ -639,7 +641,8 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService {
map.put("fastFree", fastFree); map.put("fastFree", fastFree);
map.put("slowTotal", slowTotal); map.put("slowTotal", slowTotal);
map.put("slowFree", slowFree); map.put("slowFree", slowFree);
sw.stop();
log.info(sw.prettyPrint());
return map; return map;
} }
} }

View File

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