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