mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-19 06:39:50 +08:00
update
This commit is contained in:
@@ -5,6 +5,7 @@ import com.jsowell.pile.dto.amap.GetStationInfoDTO;
|
|||||||
import com.jsowell.thirdparty.amap.domain.AMapStationInfo;
|
import com.jsowell.thirdparty.amap.domain.AMapStationInfo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 高德地图Service
|
* 高德地图Service
|
||||||
@@ -19,7 +20,7 @@ public interface AMapService {
|
|||||||
* @param dto
|
* @param dto
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<AMapStationInfo> getStationInfos(GetStationInfoDTO dto);
|
List<AMapStationInfo> getStationInfos(GetStationInfoDTO dto) throws ExecutionException, InterruptedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商家推送充电设备动态数据
|
* 商家推送充电设备动态数据
|
||||||
|
|||||||
@@ -29,9 +29,7 @@ import java.text.NumberFormat;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,7 +71,7 @@ public class AMapServiceImpl implements AMapService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<AMapStationInfo> getStationInfos(GetStationInfoDTO dto) {
|
public List<AMapStationInfo> getStationInfos(GetStationInfoDTO dto) throws ExecutionException, InterruptedException {
|
||||||
StopWatch sw = new StopWatch();
|
StopWatch sw = new StopWatch();
|
||||||
// List<AMapStationInfo> resultList = new ArrayList<>();
|
// List<AMapStationInfo> resultList = new ArrayList<>();
|
||||||
|
|
||||||
@@ -92,21 +90,27 @@ public class AMapServiceImpl implements AMapService {
|
|||||||
}
|
}
|
||||||
// 拼装高德格式数据
|
// 拼装高德格式数据
|
||||||
sw.start("拼装高德格式数据");
|
sw.start("拼装高德格式数据");
|
||||||
// for (PileStationInfo stationInfo : stationInfos) {
|
|
||||||
//
|
// 使用自定义ForkJoinPool
|
||||||
// // AMapStationInfo aMapStationInfo = assembleAMapData(stationInfo);
|
List<AMapStationInfo> resultList = new ForkJoinPool(10).submit(() ->
|
||||||
// // resultList.add(aMapStationInfo);
|
stationInfos.parallelStream().map(x -> {
|
||||||
// }
|
try {
|
||||||
List<AMapStationInfo> collect = stationInfos.parallelStream().map(x -> {
|
return assembleAMapData(x);
|
||||||
try {
|
} catch (ExecutionException | InterruptedException e) {
|
||||||
return assembleAMapData(x);
|
throw new RuntimeException(e);
|
||||||
} catch (ExecutionException | InterruptedException e) {
|
}
|
||||||
throw new RuntimeException(e);
|
}).collect(Collectors.toList())
|
||||||
}
|
).fork().join();
|
||||||
}).collect(Collectors.toList());
|
// List<AMapStationInfo> collect = stationInfos.parallelStream().map(x -> {
|
||||||
|
// try {
|
||||||
|
// return assembleAMapData(x);
|
||||||
|
// } catch (ExecutionException | InterruptedException e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
// }).collect(Collectors.toList());
|
||||||
sw.stop();
|
sw.stop();
|
||||||
log.info("接口耗时:{}, 详情:{}", sw.getTotalTimeMillis(), sw.prettyPrint());
|
log.info("接口耗时:{}, 详情:{}", sw.getTotalTimeMillis(), sw.prettyPrint());
|
||||||
return collect;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user