mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
update
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.jsowell.thirdparty.amap.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.PageUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
@@ -75,39 +76,40 @@ public class AMapServiceImpl implements AMapService {
|
||||
StopWatch sw = new StopWatch();
|
||||
// List<AMapStationInfo> resultList = new ArrayList<>();
|
||||
|
||||
if (StringUtils.equals("page", dto.getType())) {
|
||||
int pageNo = dto.getCurrentPage() == null ? 1 : dto.getCurrentPage();
|
||||
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
|
||||
// 设置分页参数
|
||||
PageUtils.startPage(pageNo, pageSize);
|
||||
}
|
||||
int pageNo = dto.getCurrentPage() == null ? 1 : dto.getCurrentPage();
|
||||
int pageSize = dto.getPageSize() == null ? 20 : dto.getPageSize();
|
||||
// 设置分页参数
|
||||
PageUtils.startPage(pageNo, pageSize);
|
||||
// 查询站点信息
|
||||
sw.start("查询站点信息");
|
||||
List<PileStationInfo> stationInfos = pileStationInfoService.getStationInfosByThirdParty();
|
||||
|
||||
PageInfo<PileStationInfo> pageInfo = new PageInfo<>(stationInfos);
|
||||
sw.stop();
|
||||
if (CollectionUtils.isEmpty(stationInfos)) {
|
||||
if (CollectionUtils.isEmpty(pageInfo.getList())) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// 拼装高德格式数据
|
||||
sw.start("拼装高德格式数据");
|
||||
|
||||
// 使用自定义ForkJoinPool
|
||||
List<AMapStationInfo> resultList = new ForkJoinPool(10).submit(() ->
|
||||
stationInfos.parallelStream().map(x -> {
|
||||
try {
|
||||
return assembleAMapData(x);
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}).collect(Collectors.toList())
|
||||
).fork().join();
|
||||
// List<AMapStationInfo> collect = stationInfos.parallelStream().map(x -> {
|
||||
// try {
|
||||
// return assembleAMapData(x);
|
||||
// } catch (ExecutionException | InterruptedException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }).collect(Collectors.toList());
|
||||
// List<AMapStationInfo> resultList = new ForkJoinPool(10).submit(() ->
|
||||
// stationInfos.parallelStream().map(x -> {
|
||||
// try {
|
||||
// return assembleAMapData(x);
|
||||
// } catch (ExecutionException | InterruptedException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }).collect(Collectors.toList())
|
||||
// ).fork().join();
|
||||
|
||||
List<AMapStationInfo> resultList = pageInfo.getList().parallelStream().map(x -> {
|
||||
try {
|
||||
return assembleAMapData(x);
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
sw.stop();
|
||||
log.info("接口耗时:{}, 详情:{}", sw.getTotalTimeMillis(), sw.prettyPrint());
|
||||
return resultList;
|
||||
|
||||
Reference in New Issue
Block a user