From 5c6b1469792343d30781074c18880259498109b4 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期四, 09 一月 2025 18:11:37 +0800 Subject: [PATCH] 修改bug --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java index c483fe4..425f8b3 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java @@ -70,7 +70,18 @@ appUser = appUserClient.getAppUserById(userid); } - List<NearbyShopVO> nearbyShopVOS = shopMapper.selectNearbyShopList(longitude, longitude); + List<NearbyShopVO> nearbyShopVOS = shopMapper.selectNearbyShopList(); + for (NearbyShopVO nearbyShopVO : nearbyShopVOS) { + Double wgs84 = GeodesyUtil.getDistance(nearbyShopVO.getLongitude() + "," + nearbyShopVO.getLatitude(), longitude + "," + latitude).get("WGS84"); + nearbyShopVO.setDistance(wgs84); + } + nearbyShopVOS.sort(new Comparator<NearbyShopVO>() { + @Override + public int compare(NearbyShopVO o1, NearbyShopVO o2) { + return o1.getDistance().compareTo(o2.getDistance()); + } + }); + if(null != appUser && null != appUser.getShopId()){ AppUser finalAppUser = appUser; Optional<NearbyShopVO> first = nearbyShopVOS.stream().filter(s -> s.getId().equals(finalAppUser.getShopId().longValue())).findFirst(); @@ -89,7 +100,7 @@ vo.setAddress(shop.getAddress()); vo.setHomePicture(shop.getHomePicture()); Double wgs84 = GeodesyUtil.getDistance(longitude.toString() + "," + latitude.toString(), shop.getLongitude() + "," + shop.getLatitude()).get("WGS84"); - vo.setDistance(wgs84.toString()); + vo.setDistance(wgs84); nearbyShopVOS.add(0, vo); } } -- Gitblit v1.7.1