mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 11:35:12 +08:00
优化查询充电站信息列表(主页)接口
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.jsowell.pile.service.impl;
|
||||
|
||||
import cn.hutool.core.util.PageUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
@@ -450,20 +452,22 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
|
||||
*/
|
||||
@Override
|
||||
public PageResponse uniAppQueryStationInfoList(QueryStationDTO dto) {
|
||||
long pageNum = dto.getPageNum() == 0 ? 1L : dto.getPageNum();
|
||||
long pageSize = dto.getPageSize() == 0 ? 10L : dto.getPageSize();
|
||||
int pageNum = dto.getPageNum() == 0 ? 1 : dto.getPageNum();
|
||||
int pageSize = dto.getPageSize() == 0 ? 10 : dto.getPageSize();
|
||||
|
||||
// 小程序站点列表页只展示对外开放的站点
|
||||
dto.setPublicFlag(Constants.ONE);
|
||||
// 根据前台参数分页
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<PileStationVO> list = pileStationInfoMapper.queryStationInfos(dto);
|
||||
PageInfo<PileStationVO> pageInfo = new PageInfo<>(list);
|
||||
|
||||
List<StationInfoVO> stationVOList = Lists.newArrayList();
|
||||
StationInfoVO stationVO = null;
|
||||
StationInfoVO stationVO;
|
||||
String stationLng = dto.getStationLng();
|
||||
String stationLat = dto.getStationLat();
|
||||
double distance = 0d;
|
||||
for (PileStationVO pileStationVO : list) {
|
||||
for (PileStationVO pileStationVO : pageInfo.getList()) {
|
||||
stationVO = new StationInfoVO();
|
||||
if (StringUtils.isNotEmpty(stationLng) && StringUtils.isNotEmpty(stationLat)) {
|
||||
try{
|
||||
@@ -491,11 +495,10 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
|
||||
stationVO.setStationImgList(Lists.newArrayList(pileStationVO.getPictures().split(",")));
|
||||
}
|
||||
|
||||
// 查询快慢充数量
|
||||
Map<String, Integer> map = pileConnectorInfoService.getPileTypeNum(Long.parseLong(pileStationVO.getId()));
|
||||
|
||||
Integer fastFree = map.get("fastFree");
|
||||
Integer slowFree = map.get("slowFree");
|
||||
|
||||
stationVO.setFastTotal(map.get("fastTotal"));
|
||||
stationVO.setFastFree(fastFree);
|
||||
stationVO.setSlowTotal(map.get("slowTotal"));
|
||||
@@ -526,21 +529,16 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
|
||||
return a.compareTo(b);
|
||||
});
|
||||
}
|
||||
List<StationInfoVO> collect = stationVOList.stream()
|
||||
.skip((pageNum - 1) * pageSize)
|
||||
.limit(pageSize)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int total = stationVOList.size();
|
||||
int pages = PageUtil.totalPage(total, dto.getPageSize());
|
||||
// 返回结果集
|
||||
return PageResponse.builder()
|
||||
.pageNum(Integer.parseInt(String.valueOf(pageNum)))
|
||||
.pageSize(Integer.parseInt(String.valueOf(pageSize)))
|
||||
.list(collect)
|
||||
.pages(pages)
|
||||
.total(total)
|
||||
PageResponse pageResponse = PageResponse.builder()
|
||||
.pageNum(pageInfo.getPageNum())
|
||||
.pageSize(pageInfo.getPageSize())
|
||||
.list(stationVOList)
|
||||
.pages(pageInfo.getPages())
|
||||
.total(pageInfo.getTotal())
|
||||
.build();
|
||||
return pageResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user