| | |
| | | import com.dsh.other.util.GeodesyUtil; |
| | | import com.dsh.other.util.ResultUtil; |
| | | import com.dsh.other.util.ToolUtil; |
| | | import com.sun.javafx.binding.StringFormatter; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.DecimalFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | for (Store store : storeList) { |
| | | String storeLon = store.getLon(); |
| | | String storeLat = store.getLat(); |
| | | String result = storeLon + "," + storeLat; |
| | | String distanceTOKilometer = gdMapGeocodingUtil.getDistanceTOKilometer(current, result); |
| | | // String result = storeLon + "," + storeLat; |
| | | // String distanceTOKilometer = gdMapGeocodingUtil.getDistanceTOKilometer(current, result); |
| | | long l = 0; |
| | | // try { |
| | | // l = Long.parseLong(distanceTOKilometer); |
| | |
| | | info.setStoreId(store.getId()); |
| | | info.setStoreName(store.getName()); |
| | | info.setStoreImg(store.getCoverDrawing()); |
| | | info.setDistance((long) Double.parseDouble(distanceTOKilometer)); |
| | | // info.setDistance( Double.parseDouble(distanceTOKilometer)); |
| | | |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(list.getLongitude() + "," + list.getLatitude(), storeLon + "," + storeLat); |
| | | double wgs84 = new BigDecimal(distance.get("WGS84")).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | info.setDistance(wgs84); |
| | | |
| | | |
| | | String str = store.getAddress(); |
| | |
| | | |
| | | 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); |
| | | if(null != geocode){ |
| | | 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; |
| | | // } |
| | | 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; |
| | | // } |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(current, result); |
| | | 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.setStoreTime(store.getStartTime() + "-" + store.getEndTime()); |
| | | detailList.setStoreInfo(store.getIntroduce()); |
| | | detailList.setStoreDistance(Double.valueOf(distanceTOKilometer)); |
| | | detailList.setStoreDistance(null != distance ? Double.valueOf(String.format("%.2f", distance.get("WGS84") / 1000)) : 0D); |
| | | detailLists.add(detailList); |
| | | } |
| | | } |