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