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