From ae9bfd2d66f68a553786ac78b12f4390e65e4e09 Mon Sep 17 00:00:00 2001 From: 44323 <443237572@qq.com> Date: 星期五, 24 十一月 2023 18:30:18 +0800 Subject: [PATCH] 后台bug修改 --- cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java | 141 ++++++++++++++++++++++++++++++++++++---------- 1 files changed, 109 insertions(+), 32 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 a699e6d..3a55e2c 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 @@ -3,14 +3,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.dsh.other.entity.Store; -import com.dsh.other.entity.TBackRecord; -import com.dsh.other.entity.TStoreOther; -import com.dsh.other.entity.TStoreOtherConfigTrue; +import com.dsh.other.entity.*; import com.dsh.other.feignclient.model.*; import com.dsh.other.model.*; +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; @@ -19,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; @@ -39,7 +40,14 @@ @Autowired private TBackRecordService backRecordService; + /** + * 获取根据门店id 获取店长信息 + */ + @RequestMapping(value = "/getStoreInfo") + public StoreInfoDto getStoreInfo(@RequestBody Integer id){ + return storeService.getStoreInfo(id); + } /** * 根据城市管理员id获取门店 */ @@ -117,28 +125,41 @@ String result = storeLon+","+storeLat; String distanceTOKilometer = gdMapGeocodingUtil.getDistanceTOKilometer(current, result); long l = 0; - try { - l = Long.parseLong(distanceTOKilometer); - }catch (Exception e){ - l = 0; - } +// try { +// l = Long.parseLong(distanceTOKilometer); +// }catch (Exception e){ +// l = 0; +// } StoreInfo info = new StoreInfo(); info.setStoreId(store.getId()); info.setStoreName(store.getName()); - info.setStoreImg(store.getRealPicture()); - info.setDistance(l); - info.setStoreAddr(store.getAddress()); + info.setStoreImg(store.getCoverDrawing()); + info.setDistance((long) Double.parseDouble(distanceTOKilometer)); + + + String str = store.getAddress(); + str = str.substring(str.indexOf("省") + 1); + + // 去掉第一个“市”及之前的字符串 + str = str.substring(str.indexOf("市") + 1); + + // 去掉第一个“区”及之前的字符串 + str = str.substring(str.indexOf("区") + 1); + + info.setStoreAddr(str); info.setLatitude(storeLat); info.setLongitude(storeLon); + storeInfos.add(info); } - Comparator<StoreInfo> distanceComparator = new Comparator<StoreInfo>() { - @Override - public int compare(StoreInfo store1, StoreInfo store2) { - return Long.compare(store1.getDistance(), store2.getDistance()); - } - }; - Collections.sort(storeInfos, distanceComparator); +// Comparator<StoreInfo> distanceComparator = new Comparator<StoreInfo>() { +// @Override +// public int compare(StoreInfo store1, StoreInfo store2) { +// return Long.compare(store1.getDistance(), store2.getDistance()); +// } +// }; +// Collections.sort(storeInfos, distanceComparator); + storeInfos = storeInfos.stream().sorted(Comparator.comparing(StoreInfo::getDistance)).collect(Collectors.toList()); } return storeInfos; } @@ -153,38 +174,57 @@ 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()); + detailList.setStoreDistance(Double.valueOf(distanceTOKilometer)); detailLists.add(detailList); } } @@ -249,6 +289,14 @@ } } + @ResponseBody + @PostMapping("/store/querySiteIdById") + public List<Integer> querySiteIdById(@RequestBody List<Integer> storeIds){ + List<Site> list = siteService.list(new LambdaQueryWrapper<Site>().in(Site::getStoreId, storeIds)); + List<Integer> collect = list.stream().map(Site::getId).collect(Collectors.toList()); + return collect; + } + @ResponseBody @@ -304,6 +352,28 @@ } } + @ResponseBody + @PostMapping("/store/queryByStoreId") + public OperatorUser queryByStoreId(@RequestBody Integer id){ + try { + return storeService.queryByStoreId(id); + }catch (Exception e){ + e.printStackTrace(); + return null; + } + } + + + @Autowired + private ISiteService siteService; + @ResponseBody + @PostMapping("/store/querySiteId") + public List<Integer> querySiteId(@RequestBody Integer storeId){ + List<Site> list = siteService.list(new LambdaQueryWrapper<Site>().eq(Site::getStoreId, storeId).eq(Site::getSign, 1)); + List<Integer> collect = list.stream().map(Site::getId).collect(Collectors.toList()); + return collect; + } + @PostMapping("/store/addBackRecord") public void addBackRecord(@RequestBody String s){ @@ -352,6 +422,13 @@ List<TStoreOther> list = tStoreOtherService.list(new LambdaQueryWrapper<TStoreOther>().eq(TStoreOther::getStoreId, id).eq(TStoreOther::getState,1)); 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){ @@ -406,9 +483,9 @@ @ApiImplicitParams({ @ApiImplicitParam(value = "城市code", name = "cityCode", dataType = "string", required = true), }) - public ResultUtil<List<BaseVo>> queryStoreByCityCode(String cityCode){ + public ResultUtil<List<BaseVo>> queryStoreByCityCode(String provinceCode,String cityCode){ try { - List<BaseVo> list = storeService.queryStoreByCityCode(cityCode); + List<BaseVo> list = storeService.queryStoreByCityCode(provinceCode,cityCode); return ResultUtil.success(list); }catch (Exception e){ e.printStackTrace(); -- Gitblit v1.7.1