diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java index a68fc417a..efb87bc50 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java @@ -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 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 stationInfos = pileStationInfoService.getStationInfosByThirdParty(); + + PageInfo pageInfo = new PageInfo<>(stationInfos); sw.stop(); - if (CollectionUtils.isEmpty(stationInfos)) { + if (CollectionUtils.isEmpty(pageInfo.getList())) { return new ArrayList<>(); } // 拼装高德格式数据 sw.start("拼装高德格式数据"); // 使用自定义ForkJoinPool - List 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 collect = stationInfos.parallelStream().map(x -> { - // try { - // return assembleAMapData(x); - // } catch (ExecutionException | InterruptedException e) { - // throw new RuntimeException(e); - // } - // }).collect(Collectors.toList()); + // List 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 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;