From a9564eae9f0169ca39329b2f14a8f13d13358a0a Mon Sep 17 00:00:00 2001 From: nickchange <126672920+nickchange@users.noreply.github.com> Date: 星期五, 17 十一月 2023 15:28:44 +0800 Subject: [PATCH] 11.7 --- cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java | 50 +++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 39 insertions(+), 11 deletions(-) diff --git a/cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java b/cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java index 4e1dabd..ebe6326 100644 --- a/cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java +++ b/cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java @@ -9,6 +9,7 @@ import com.dsh.other.model.dto.siteDto.StoreInfoDto; import com.dsh.other.service.*; import com.dsh.other.util.GDMapGeocodingUtil; +import com.dsh.other.util.GeodesyUtil; import com.dsh.other.util.ResultUtil; import com.dsh.other.util.ToolUtil; import io.swagger.annotations.ApiImplicitParam; @@ -17,6 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; import java.util.stream.Collectors; @@ -171,36 +174,54 @@ String current = distanceVo.getLongitude()+","+distanceVo.getLatitude(); Store store = storeService.getById(distanceVo.getStoreId()); String result = store.getLon()+","+store.getLat(); - return gdMapGeocodingUtil.getDistanceTOKilometer(current, result); + + + if(ToolUtil.isNotEmpty(distanceVo.getLongitude()) && ToolUtil.isNotEmpty(distanceVo.getLatitude())){ + Map<String, Double> distance = GeodesyUtil.getDistance(distanceVo.getLongitude() + "," + distanceVo.getLatitude(), store.getLon() + "," + store.getLat()); + double wgs84 = new BigDecimal(distance.get("WGS84")).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); +// packageResponse.setDistance(wgs84); + return wgs84+""; + } + return ""; + +// return gdMapGeocodingUtil.getDistanceTOKilometer(current, result); } @PostMapping("/base/protocol/storeDetail/citycodeLoLa") - public List<StoreDetailList> getQueryStoreList(@RequestBody StoreOfCitycodeResp citycodeResp){ + public List<StoreDetailList> getQueryStoreList(@RequestBody StoreOfCitycodeResp citycodeResp) throws Exception { List<StoreDetailList> detailLists = new ArrayList<>(); + + if (citycodeResp.getCityCode()==null){ + Map<String, String> geocode = gdMapGeocodingUtil.geocode(citycodeResp.getLongitude(), citycodeResp.getLatitude()); + String provinceCode = geocode.get("provinceCode"); + String cityCode = geocode.get("cityCode"); + citycodeResp.setCityCode(cityCode); + } + List<Store> list = storeService.list(new QueryWrapper<Store>() .eq("state",1 ) .eq("cityCode",citycodeResp.getCityCode())); if (list.size() > 0 ){ - if (ToolUtil.isEmpty(citycodeResp.getLongitude()) && ToolUtil.isEmpty(citycodeResp.getLatitude())){ - return detailLists; - } +// if (ToolUtil.isEmpty(citycodeResp.getLongitude()) && ToolUtil.isEmpty(citycodeResp.getLatitude())){ +// return detailLists; +// } for (Store store : list) { String current = citycodeResp.getLongitude() +","+citycodeResp.getLatitude(); String result = store.getLon()+","+store.getLat(); String distanceTOKilometer = gdMapGeocodingUtil.getDistanceTOKilometer(current, result); - long l = Long.parseLong(distanceTOKilometer); -// 取5公里范围内的门店 - if ( l > 5){ - continue; - } +// long l = Long.parseLong(distanceTOKilometer); +//// 取5公里范围内的门店 +// if ( l > 5){ +// continue; +// } StoreDetailList detailList = new StoreDetailList(); detailList.setStoreId(store.getId()); detailList.setStoreImg(store.getCoverDrawing()); detailList.setStoreName(store.getName()); detailList.setStoreAddress(store.getAddress()); detailList.setStorePhone(store.getPhone()); - detailList.setStoreDistance(l); +// detailList.setStoreDistance(l); detailList.setStoreTime(store.getStartTime() + "-" + store.getEndTime()); detailList.setStoreInfo(store.getIntroduce()); detailLists.add(detailList); @@ -401,6 +422,13 @@ if(list.size()>0){ tStoreOtherConfigTrues= tStoreOtherConfigTrueService.list(new LambdaQueryWrapper<TStoreOtherConfigTrue>().in(TStoreOtherConfigTrue::getPid, list.stream().map(TStoreOther::getId).collect(Collectors.toList())).eq(TStoreOtherConfigTrue::getState,1)); } + for (TStoreOtherConfigTrue tStoreOtherConfigTrue : tStoreOtherConfigTrues) { + for (TStoreOther tStoreOther : list) { + if (tStoreOtherConfigTrue.getPid()==tStoreOther.getId()){ + tStoreOtherConfigTrue.setSort(tStoreOther.getSort()); + } + } + } return ResultUtil.success(tStoreOtherConfigTrues); }catch (Exception e){ e.printStackTrace(); -- Gitblit v1.7.1