mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
update 小程序站点列表首页按照距离排序
This commit is contained in:
@@ -11,11 +11,13 @@ import com.jsowell.pile.dto.QueryConnectorListDTO;
|
||||
import com.jsowell.pile.dto.QueryStationDTO;
|
||||
import com.jsowell.pile.service.IPileConnectorInfoService;
|
||||
import com.jsowell.pile.service.IPileStationInfoService;
|
||||
import com.jsowell.pile.vo.base.StationInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.PersonalPileInfoVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 充电桩相关接口
|
||||
@@ -51,6 +53,7 @@ public class PileController extends BaseController {
|
||||
// startPage();
|
||||
// List<PileStationVO> list = pileStationInfoService.uniAppQueryStationInfos(queryStationDTO);
|
||||
PageResponse pageResponse = pileStationInfoService.uniAppQueryStationInfoList(queryStationDTO);
|
||||
// List<StationInfoVO> list = pileStationInfoService.uniAppQueryStationInfoList(queryStationDTO);
|
||||
response = new RestApiResponse<>(pageResponse);
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("查询充电站信息列表warn", e);
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.pile.domain.PileStationInfo;
|
||||
import com.jsowell.pile.dto.FastCreateStationDTO;
|
||||
import com.jsowell.pile.dto.QueryStationDTO;
|
||||
import com.jsowell.pile.vo.base.StationInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileStationVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -7,10 +8,7 @@ import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.entity.SysDept;
|
||||
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.DistanceUtils;
|
||||
import com.jsowell.common.util.SecurityUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.*;
|
||||
import com.jsowell.common.util.ip.AddressUtils;
|
||||
import com.jsowell.pile.domain.PileStationInfo;
|
||||
import com.jsowell.pile.dto.FastCreateStationDTO;
|
||||
@@ -34,6 +32,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 充电站信息Service业务层处理
|
||||
@@ -251,31 +250,31 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService {
|
||||
*/
|
||||
@Override
|
||||
public PageResponse uniAppQueryStationInfoList(QueryStationDTO dto) {
|
||||
int pageNum = dto.getPageNum() == 0 ? 1 : dto.getPageNum();
|
||||
int pageSize = dto.getPageSize() == 0 ? 10 : dto.getPageSize();
|
||||
long pageNum = dto.getPageNum() == 0 ? 1L : dto.getPageNum();
|
||||
long pageSize = dto.getPageSize() == 0 ? 10L : dto.getPageSize();
|
||||
|
||||
// 小程序站点列表页只展示对外开放的站点
|
||||
dto.setPublicFlag(Constants.ONE);
|
||||
// 根据前台参数分页
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
// PageHelper.startPage(pageNum, pageSize);
|
||||
List<PileStationVO> list = pileStationInfoMapper.queryStationInfos(dto);
|
||||
PageInfo<PileStationVO> pageInfo = new PageInfo<>(list);
|
||||
if (CollectionUtils.isEmpty(pageInfo.getList())) {
|
||||
return PageResponse.builder()
|
||||
.pageNum(pageInfo.getPageNum())
|
||||
.pageSize(pageInfo.getPageSize())
|
||||
.list(Lists.newArrayList())
|
||||
.pages(pageInfo.getPages())
|
||||
.total(pageInfo.getTotal())
|
||||
.build();
|
||||
}
|
||||
// PageInfo<PileStationVO> pageInfo = new PageInfo<>(list);
|
||||
// if (CollectionUtils.isEmpty(pageInfo.getList())) {
|
||||
// return PageResponse.builder()
|
||||
// .pageNum(pageInfo.getPageNum())
|
||||
// .pageSize(pageInfo.getPageSize())
|
||||
// .list(Lists.newArrayList())
|
||||
// .pages(pageInfo.getPages())
|
||||
// .total(pageInfo.getTotal())
|
||||
// .build();
|
||||
// }
|
||||
|
||||
List<StationInfoVO> stationVOList = Lists.newArrayList();
|
||||
StationInfoVO stationVO = null;
|
||||
String stationLng = dto.getStationLng();
|
||||
String stationLat = dto.getStationLat();
|
||||
double distance = 0d;
|
||||
for (PileStationVO pileStationVO : pageInfo.getList()) {
|
||||
for (PileStationVO pileStationVO : list) {
|
||||
stationVO = new StationInfoVO();
|
||||
if (StringUtils.isNotEmpty(stationLng) && StringUtils.isNotEmpty(stationLat)) {
|
||||
try{
|
||||
@@ -343,14 +342,20 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService {
|
||||
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(pageInfo.getPageNum())
|
||||
.pageSize(pageInfo.getPageSize())
|
||||
.list(stationVOList)
|
||||
.pages(pageInfo.getPages())
|
||||
.total(pageInfo.getTotal())
|
||||
.pageNum(Integer.parseInt(String.valueOf(pageNum)))
|
||||
.pageSize(Integer.parseInt(String.valueOf(pageSize)))
|
||||
.list(collect)
|
||||
.pages(pages)
|
||||
.total(total)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user