| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | |
| | | @Autowired |
| | | private TBackRecordService backRecordService; |
| | | |
| | | /** |
| | | * 获取根据门店id 获取店长信息 |
| | | */ |
| | | @RequestMapping(value = "/getStoreInfo") |
| | | public StoreInfoDto getStoreInfo(@RequestBody Integer id){ |
| | | |
| | | return storeService.getStoreInfo(id); |
| | | } |
| | | /** |
| | | * 根据城市管理员id获取门店 |
| | | */ |
| | |
| | | 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.getCoverDrawing()); |
| | | info.setDistance(l); |
| | | info.setStoreAddr(store.getAddress()); |
| | | 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; |
| | | } |
| | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | 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(); |
| | |
| | | @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(); |